/* ═══════════════════════════════════════════════════════════════════════════
   diep.io — black and green chrome.

   The arena is the interface, so the chrome around it is deliberately quiet:
   one accent green, everything else greys, and the only saturated colours on
   screen belong to the game itself (team red and blue, shape blues and greens).
   The in-game HUD floats over a full-bleed canvas, so every panel here is a
   translucent surface rather than an opaque card.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --font-display: 'Bebas Neue', 'DM Sans', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --bg: #000000;
  --surface: #0b0b0b;
  --surface2: #131313;
  --surface3: #1c1c1c;
  --border: #232323;
  --border2: #2f2f2f;

  --text: #f5f5f5;
  --muted: #8a8a8a;

  --green: #1db954;
  --green-bright: #1ed760;
  --green-dim: #0f5c2a;
  --red: #e91429;
  --blue: #2d7ff9;

  /* The arena's own palette, so the canvas and the CSS agree on what a team is. */
  --team-red: #e2504c;
  --team-blue: #4b8fe2;
  --shape-square: #ffe869;
  --shape-triangle: #fc7677;
  --shape-pentagon: #768cfc;
  --shape-alpha: #b47ff9;
  --shape-crasher: #7ad17a;
}

html[data-theme='light'] {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface2: #f0f3f0;
  --surface3: #e6eae6;
  --border: #d8ded8;
  --border2: #c6cec6;
  --text: #101410;
  --muted: #5c665c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.shell { max-width: 1080px; margin: 0 auto; padding: 14px 16px 44px; }

/* ── Header ─────────────────────────────────────────────────────────────── */

.header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}

.home-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; color: var(--muted);
  border: 1px solid var(--border); text-decoration: none;
  transition: color .16s ease, border-color .16s ease;
}
.home-btn:hover { color: var(--green-bright); border-color: var(--green-dim); }
.home-btn svg { width: 18px; height: 18px; }

.brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); }
.brand-mark {
  width: 14px; height: 14px; border-radius: 3px; background: var(--green);
  box-shadow: 0 0 14px rgba(29, 185, 84, .6);
}
.brand-text { font-size: 22px; letter-spacing: .5px; }
.brand-accent { color: var(--green); }
.header-right { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--green-bright); border-color: var(--green-dim); }
.icon-btn svg { width: 18px; height: 18px; }

.link-btn { color: var(--muted); font-size: 13px; }

/* ── Screens, panels, buttons ───────────────────────────────────────────── */

.screen { display: none; }
.screen.active { display: block; }

/* `hidden` must actually hide. A `display: flex` in a class rule beats the user
   agent's own `[hidden] { display: none }` at equal specificity, so an overlay
   carrying the attribute stayed LAID OUT — invisible, and quietly swallowing
   every click aimed at the upgrade bar underneath it. Any rule here that sets a
   display value on something toggled with `hidden` has to say so explicitly. */
.overlay[hidden],
.class-picker[hidden],
.team-score[hidden] { display: none; }

.menu-hero { padding: 26px 0 8px; }
.hero-title {
  font-family: var(--font-display); font-size: 46px; letter-spacing: 1px;
  margin: 0 0 6px; line-height: 1;
}
.hero-sub { color: var(--muted); margin: 0; max-width: 620px; line-height: 1.6; }
.hero-sub strong { color: var(--green-bright); }

.menu-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 20px 0 14px;
}

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; margin-bottom: 14px;
}
.panel.slim { padding: 10px 12px; margin-bottom: 10px; }
.panel-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); margin: 0 0 12px; font-weight: 600;
}
.count {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--surface3); color: var(--text); font-size: 11px;
}

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 11px 12px; border-radius: 10px; font-size: 15px;
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text);
  font-family: var(--font-body);
}
.field input:focus { outline: none; border-color: var(--green); }
#join-code { text-transform: uppercase; letter-spacing: .28em; font-family: var(--font-mono); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  padding: 11px 16px; border-radius: 10px; cursor: pointer; font-size: 14px;
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text);
  font-family: var(--font-body); transition: background .16s ease, border-color .16s ease;
}
.btn:hover { border-color: var(--green-dim); }
.btn.primary { background: var(--green); border-color: var(--green); color: #04120a; font-weight: 700; }
.btn.primary:hover { background: var(--green-bright); border-color: var(--green-bright); }
.btn.tiny { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 10px 0 0; }
.hint.err { color: var(--red); }

.lobby-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lobby-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 10px; background: var(--surface2);
  border: 1px solid var(--border);
}
.lobby-row .code { font-family: var(--font-mono); letter-spacing: .16em; font-size: 15px; }
.lobby-row .mode { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.mode.ffa { color: var(--green-bright); }
.mode.tdm { color: var(--blue); }
.lobby-row .meta { color: var(--muted); font-size: 12px; }

/* ── The game screen is full-bleed ──────────────────────────────────────── */

.screen.game {
  position: fixed; inset: 0; display: none;
  background: #050505;
}
.screen.game.active { display: block; }
#canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

.hud { position: absolute; inset: 0; pointer-events: none; }
.hud-left { position: absolute; left: 14px; top: 14px; width: min(300px, 42vw); }
.hud-right { position: absolute; right: 14px; top: 14px; width: min(230px, 34vw); }
.hud-right .panel {
  background: rgba(11, 11, 11, .72); backdrop-filter: blur(6px);
}
html[data-theme='light'] .hud-right .panel { background: rgba(255, 255, 255, .78); }

.bar {
  position: relative; height: 22px; border-radius: 6px; overflow: hidden;
  background: rgba(0, 0, 0, .6); border: 1px solid var(--border2); margin-bottom: 6px;
}
.bar-fill { height: 100%; width: 0%; transition: width .12s linear; }
.bar.health .bar-fill { background: linear-gradient(90deg, #1db954, #1ed760); }
.bar.xp .bar-fill { background: linear-gradient(90deg, #f5c518, #ffe066); }
.bar-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-family: var(--font-mono); text-shadow: 0 1px 2px rgba(0,0,0,.8);
}
.hud-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.stat-chip {
  background: rgba(11, 11, 11, .72); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px; font-size: 12px;
}
#hud-points { color: #04120a; background: var(--green-bright); border-color: var(--green-bright); font-weight: 700; }
.team-score { display: flex; gap: 6px; margin-top: 6px; }
.team { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.team.red { background: rgba(226, 80, 76, .18); color: var(--team-red); }
.team.blue { background: rgba(75, 143, 226, .18); color: var(--team-blue); }

.board, .kills { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.board li, .kills li {
  display: flex; align-items: center; gap: 6px; padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.board li:last-child, .kills li:last-child { border-bottom: none; }
.board .rank { color: var(--muted); font-family: var(--font-mono); width: 16px; }
.board .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .who.mine { color: var(--green-bright); font-weight: 600; }
.board .score { font-family: var(--font-mono); color: var(--muted); }
.kills li { color: var(--muted); }
.kills .victim { color: var(--text); }
.kills .killer { color: var(--red); }

/* ── Upgrade bar ───────────────────────────────────────────────────────── */

.upgrades {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  width: min(760px, calc(100vw - 28px));
  background: rgba(11, 11, 11, .82); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px;
}
html[data-theme='light'] .upgrades { background: rgba(255,255,255,.86); }
.upgrade-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.upgrade-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
}
.upgrade-points {
  background: var(--green-bright); color: #04120a; font-weight: 700;
  border-radius: 999px; padding: 1px 9px; font-size: 12px;
}
.upgrade-head .btn { margin-left: auto; }
.upgrade-rows { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat-row {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
}
.stat-row .name { font-size: 11px; color: var(--muted); flex: 1; white-space: nowrap; }
.stat-row .pips { display: flex; gap: 2px; }
.stat-row .pip { width: 6px; height: 10px; border-radius: 2px; background: var(--surface3); }
.stat-row .pip.on { background: var(--green); }
.stat-row .plus {
  width: 22px; height: 22px; border-radius: 6px; cursor: pointer; font-size: 14px;
  background: var(--surface3); border: 1px solid var(--border2); color: var(--text);
  line-height: 1;
}
.stat-row .plus:disabled { opacity: .35; cursor: not-allowed; }

/* ── Class picker and death overlay ────────────────────────────────────── */

.class-picker, .overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .72); z-index: 6; padding: 16px;
}
.class-card, .overlay-card {
  background: var(--surface); border: 1px solid var(--border2); border-radius: 16px;
  padding: 20px; width: min(560px, 100%); text-align: center;
}
.class-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 14px 0; }
.class-option {
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 12px;
  padding: 12px; cursor: pointer; color: var(--text); font-family: var(--font-body);
}
.class-option:hover { border-color: var(--green); }
.class-option .cls-name { display: block; font-size: 14px; margin-bottom: 4px; }
.class-option .cls-why { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.overlay-title { font-family: var(--font-display); font-size: 34px; margin: 0 0 6px; letter-spacing: .5px; }
.overlay-sub { color: var(--muted); margin: 0 0 16px; }
.overlay-actions { display: flex; gap: 10px; justify-content: center; }

/* ── Touch controls ───────────────────────────────────────────────────── */

.touch { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.touch .stick {
  position: absolute; left: 22px; bottom: 118px; width: 120px; height: 120px;
  border-radius: 50%; background: rgba(255,255,255,.06); border: 1px solid var(--border2);
  pointer-events: auto; touch-action: none;
}
.stick-knob {
  position: absolute; left: 40px; top: 40px; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(29, 185, 84, .55);
}
.touch .fire {
  position: absolute; right: 22px; bottom: 130px; width: 96px; height: 96px;
  border-radius: 50%; pointer-events: auto; font-weight: 700; letter-spacing: .1em;
}

/* ── Settings dropdown ────────────────────────────────────────────────── */

.settings-dropdown {
  position: fixed; right: 16px; top: 64px; width: 250px; z-index: 20;
  background: var(--surface); border: 1px solid var(--border2); border-radius: 14px;
  padding: 14px; box-shadow: 0 18px 40px rgba(0,0,0,.55);
}
.settings-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 8px; cursor: pointer; }
.check input { accent-color: var(--green); }
.theme-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }

@media (max-width: 760px) {
  .menu-grid { grid-template-columns: 1fr; }
  .hero-title { font-size: 36px; }
  .hud-right { display: none; }
  .upgrade-rows { grid-template-columns: repeat(2, 1fr); }
}
