:root {
  --bg: #040b08;
  --panel: rgba(6, 22, 14, 0.82);
  --line: #1f8f4e;
  --line-soft: #135c33;
  --neon: #39ff5a;
  --neon-dim: #22c247;
  --text: #e9fff0;
  --muted: #8fbfa0;
  --gold: #ffc21f;
  --pixel: 'Tiny5', 'Courier New', monospace;
  --ui: 'Chakra Petch', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--ui); }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
canvas#game.in-game { cursor: crosshair; }
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }

.screen { position: fixed; inset: 0; pointer-events: none; }
.screen > * { pointer-events: auto; }

.panel {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 0 14px rgba(57, 255, 90, 0.18), inset 0 0 18px rgba(57, 255, 90, 0.06);
  backdrop-filter: blur(3px);
}

kbd {
  display: inline-block; min-width: 22px; padding: 1px 6px; margin: 0 2px;
  border: 1.5px solid var(--line); border-radius: 5px; background: #07160e;
  font-family: var(--pixel); font-size: 13px; color: var(--neon); text-align: center;
}

.coin {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3b0 0 20%, var(--gold) 21% 70%, #c98a00 71%);
  box-shadow: 0 0 8px rgba(255, 194, 31, 0.7); vertical-align: -2px;
}

/* ---------- Lobby ---------- */
#lobby { display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(4, 11, 8, 0.2), rgba(4, 11, 8, 0.75) 75%); }
.lobby-top { position: absolute; top: 18px; right: 18px; }
.coins-pill { display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-family: var(--pixel); font-size: 20px; color: var(--gold); }
.coins-pill.small { padding: 4px 10px; font-size: 16px; border: 1.5px solid var(--line-soft); border-radius: 8px; margin-left: auto; margin-right: 12px; }

.lobby-card { width: min(420px, calc(100vw - 32px)); padding: 28px 28px 20px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.logo { display: flex; align-items: center; justify-content: center; gap: 12px; font-family: var(--pixel); font-weight: 700; font-size: clamp(34px, 9vw, 46px); color: var(--neon); letter-spacing: 2px; text-shadow: 0 0 12px rgba(57, 255, 90, 0.8), 0 0 28px rgba(57, 255, 90, 0.35); }
.logo em { font-style: normal; font-size: 0.55em; color: var(--text); text-shadow: none; opacity: 0.85; }
.logo-icon { width: 52px; height: 40px; color: var(--neon); filter: drop-shadow(0 0 6px rgba(57, 255, 90, 0.8)); }
.tagline { margin: -6px 0 4px; color: var(--muted); font-size: 14px; }

.skin-preview { position: relative; border: 1.5px dashed var(--line-soft); border-radius: 8px; padding: 6px 0 4px; cursor: pointer; }
.skin-preview canvas { width: 100%; max-width: 300px; height: auto; display: block; margin: 0 auto; }
.skin-name { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; }

#nickname {
  width: 100%; padding: 14px 16px; font-family: var(--pixel); font-size: 20px; text-align: center;
  color: var(--text); background: #030d07; border: 2px solid var(--line); border-radius: 8px; outline: none;
}
#nickname:focus { border-color: var(--neon); box-shadow: 0 0 12px rgba(57, 255, 90, 0.4); }
#nickname::placeholder { color: #4f7a5e; }

.btn { border-radius: 8px; border: 2px solid var(--line); padding: 12px 16px; font-size: 16px; font-weight: 700; color: var(--text); background: #07160e; transition: transform .08s, box-shadow .15s, background .15s; }
.btn:hover { box-shadow: 0 0 14px rgba(57, 255, 90, 0.35); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-play {
  font-family: var(--pixel); font-size: 28px; letter-spacing: 4px; padding: 14px; color: #03140a;
  background: linear-gradient(180deg, #6bff86, var(--neon) 45%, var(--neon-dim));
  border-color: #8dffa3; box-shadow: 0 0 22px rgba(57, 255, 90, 0.55);
}
.btn-play:hover { box-shadow: 0 0 32px rgba(57, 255, 90, 0.8); }
.btn-ghost { display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-ghost svg { width: 18px; height: 18px; color: var(--neon); }
.lobby-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lobby-stats { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding-top: 4px; }
.lobby-stats b { color: var(--gold); font-family: var(--pixel); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #777; margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--neon); box-shadow: 0 0 6px var(--neon); }
.lobby-hint { position: absolute; bottom: 20px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: 14px; pointer-events: none; padding: 0 16px; }

/* ---------- HUD ---------- */
.hud-tl { position: absolute; top: 14px; left: 14px; display: flex; gap: 12px; }
.player-card { display: flex; align-items: center; gap: 10px; padding: 8px 16px 8px 8px; min-width: 200px; }
.player-card canvas { width: 48px; height: 48px; border: 1.5px solid var(--line-soft); border-radius: 8px; background: #03100a; }
.pc-name { font-weight: 700; font-size: 18px; }
.pc-sub { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.score-card { display: flex; align-items: center; gap: 16px; padding: 8px 18px; }
.score-card label { display: block; font-size: 13px; color: var(--muted); }
.score-card b { font-family: var(--pixel); font-size: 26px; color: var(--neon); text-shadow: 0 0 8px rgba(57, 255, 90, 0.6); }
.score-card .sep { width: 1.5px; align-self: stretch; background: var(--line-soft); }

.hud-title { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; pointer-events: none !important;
  font-family: var(--pixel); font-weight: 700; font-size: 30px; color: var(--neon); letter-spacing: 2px; text-shadow: 0 0 10px rgba(57, 255, 90, 0.7); }
.hud-title .logo-icon { width: 40px; height: 30px; }

.hud-tr { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.hud-buttons { display: flex; gap: 8px; }
.ping { display: flex; align-items: center; gap: 8px; padding: 0 14px; height: 44px; font-family: var(--pixel); color: var(--neon); }
.ping svg { width: 16px; height: 16px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--neon); padding: 0; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:hover { box-shadow: 0 0 16px rgba(57, 255, 90, 0.45); }

.leaderboard { width: 270px; padding: 10px 10px 8px; }
.leaderboard h3 { margin: 2px 6px 8px; display: flex; align-items: center; gap: 10px; font-size: 21px; }
.crown, .crown-sm { display: inline-block; width: 24px; height: 16px; background: var(--gold);
  clip-path: polygon(0 100%, 0 20%, 25% 55%, 50% 0, 75% 55%, 100% 20%, 100% 100%); filter: drop-shadow(0 0 4px var(--gold)); }
.crown-sm { width: 16px; height: 11px; }
.leaderboard ol { list-style: none; margin: 0; padding: 0; }
.leaderboard li { display: grid; grid-template-columns: 30px 1fr auto; gap: 6px; padding: 4px 8px; font-size: 15.5px; font-weight: 600; border-radius: 5px; }
.leaderboard li .r { color: var(--text); }
.leaderboard li .sc { font-variant-numeric: tabular-nums; }
.leaderboard li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard li.me { background: linear-gradient(90deg, var(--neon), var(--neon-dim)); color: #03140a; box-shadow: 0 0 12px rgba(57, 255, 90, 0.5); }
.leaderboard li.me .r { color: #03140a; }
.leaderboard li.gap { padding: 0 8px; color: var(--muted); line-height: 0.8; }
.lb-foot { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1.5px solid var(--line-soft); color: var(--muted); font-size: 14px; }
.lb-foot svg { width: 18px; height: 18px; color: var(--neon); }

.minimap { position: fixed; right: 14px; bottom: 14px; padding: 6px; }
.minimap canvas { display: block; width: 180px; height: 180px; }
.mm-n { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--bg); padding: 0 6px; font-family: var(--pixel); color: var(--neon); font-size: 15px; }

.spectate-bar { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.spectate-bar .icon-btn { font-size: 30px; line-height: 1; padding-bottom: 4px; background: #07160e; border: 2px solid var(--line); border-radius: 8px; color: var(--neon); }
.spec-who { min-width: 150px; text-align: center; }
.spec-who label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; }
.spec-who b { font-size: 18px; }
.spectate-bar .btn { padding: 8px 16px; }
.btn-god small { font-weight: 500; color: var(--muted); font-size: 12px; }
.god-bar { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; align-items: center; gap: 14px; padding: 8px 12px; max-width: calc(100vw - 24px); }
.god-bar[hidden] { display: none; }
.god-zoom { font-family: var(--pixel); color: var(--gold); font-size: 18px; min-width: 56px; text-align: center; }
.god-help { font-size: 12px; color: var(--muted); line-height: 1.8; }
.god-bar .btn { padding: 8px 16px; }
canvas.god { cursor: grab; }
canvas.god:active { cursor: grabbing; }
.spectate-bar .btn-play { font-size: 20px; letter-spacing: 2px; }
.hud-hint { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 15px; transition: opacity 1s; pointer-events: none !important; }

/* ---------- Overlays / modals ---------- */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(1, 6, 3, 0.6); z-index: 10; padding: 16px; }
.death-card { width: min(380px, 100%); padding: 26px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.death-card h2 { margin: 0; font-family: var(--pixel); font-size: 40px; color: #ff4d5e; text-shadow: 0 0 14px rgba(255, 77, 94, 0.7); letter-spacing: 3px; }
.death-card p { margin: 0; color: var(--muted); }
.death-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0; }
.death-stats div { border: 1.5px solid var(--line-soft); border-radius: 8px; padding: 8px 4px; }
.death-stats label { display: block; font-size: 12px; color: var(--muted); }
.death-stats b { font-family: var(--pixel); font-size: 24px; color: var(--neon); }
.death-coins { color: var(--gold); font-weight: 600; }

.modal { width: min(440px, 100%); padding: 20px 22px 22px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal-wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-family: var(--pixel); color: var(--neon); font-size: 28px; flex: 1; }
.modal-wide .modal-head h2 { flex: 0 1 auto; }
.close { background: none; border: none; color: var(--muted); font-size: 32px; line-height: 1; padding: 0 4px; }
.close:hover { color: var(--text); }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.toggle input { display: none; }
.toggle i { flex: none; width: 46px; height: 24px; border-radius: 12px; background: #0b2316; border: 1.5px solid var(--line-soft); position: relative; transition: background .15s; }
.toggle i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.toggle input:checked + i { background: rgba(57, 255, 90, 0.25); border-color: var(--neon); }
.toggle input:checked + i::after { transform: translateX(22px); background: var(--neon); box-shadow: 0 0 8px var(--neon); }
.controls-box { margin-top: 14px; color: var(--muted); font-size: 14px; display: grid; gap: 8px; }
.controls-box h4 { margin: 0; color: var(--text); }
.controls-box b { color: var(--neon); }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.shop-item { border: 1.5px solid var(--line-soft); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; align-items: stretch; text-align: center; background: rgba(3, 13, 7, 0.6); }
.shop-item.equipped { border-color: var(--neon); box-shadow: 0 0 12px rgba(57, 255, 90, 0.35); }
.shop-item canvas { width: 100%; height: auto; }
.shop-item .nm { font-weight: 700; }
.shop-item .btn { padding: 8px; font-size: 14px; }
.shop-item .btn.buy { color: var(--gold); border-color: #8a6a10; }
.shop-item .btn.buy:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.shop-item .btn.equip-on { color: #03140a; background: var(--neon); border-color: var(--neon); }

.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); padding: 10px 18px; z-index: 20; font-weight: 600; }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .hud-title { display: none; }
  .score-card { padding: 6px 12px; }
  .score-card b { font-size: 20px; }
  .player-card { min-width: 0; padding-right: 10px; }
  .player-card canvas { width: 36px; height: 36px; }
  .pc-name { font-size: 15px; }
  .hud-tl { flex-direction: column; gap: 8px; }
  .leaderboard { width: 200px; }
  .leaderboard h3 { font-size: 16px; }
  .leaderboard li { font-size: 13px; padding: 2px 6px; grid-template-columns: 24px 1fr auto; }
  .minimap canvas { width: 120px; height: 120px; }
  .ping { display: none; }
}

.shop-section { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; margin-top: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line-soft); }
.shop-section b { font-family: var(--pixel); font-size: 20px; color: var(--neon); }
.shop-section span { font-size: 13px; color: var(--muted); }

/* ---------- Map picker ---------- */
.map-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.map-picker button { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left;
  padding: 8px 10px; border-radius: 8px; border: 2px solid var(--line-soft); background: #04110a; color: var(--text); }
.map-picker button.active { border-color: var(--neon); box-shadow: 0 0 12px rgba(57, 255, 90, 0.35); }
.mp-thumb { grid-row: 1 / 3; width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--line-soft); }
.mp-thumb.classic { background: #05110b; background-image: linear-gradient(rgba(57,255,90,.25) 1px, transparent 1px), linear-gradient(90deg, rgba(57,255,90,.25) 1px, transparent 1px); background-size: 7px 7px; }
.mp-thumb.jungle { background: radial-gradient(circle at 50% 50%, #ffa94d 0 6%, transparent 8%), linear-gradient(#2b2731, #2b2731) center / 44% 44% no-repeat, linear-gradient(#6a666c, #6a666c) center / 62% 62% no-repeat, radial-gradient(circle at 15% 85%, #2c7a2c 0 18%, transparent 20%), #0a1a0e; }
.mp-name { font-weight: 700; font-size: 14px; }
.mp-count { font-size: 12px; color: var(--muted); }

/* ---------- Static lobby backdrop (the live arena is not rendered behind the lobby) ---------- */
#lobby {
  background:
    radial-gradient(ellipse at 50% 45%, rgba(255, 150, 60, 0.10), transparent 55%),
    radial-gradient(ellipse at 20% 85%, rgba(20, 150, 160, 0.10), transparent 45%),
    linear-gradient(rgba(110, 72, 40, 0.16) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(110, 72, 40, 0.16) 1px, transparent 1px) 0 0 / 28px 28px,
    radial-gradient(ellipse at center, #1f150d 0%, #120c07 60%, #050302 100%);
}
.lobby-top { display: flex; gap: 10px; align-items: center; }

/* ---------- Account ---------- */
.account-pill { display: flex; align-items: center; gap: 8px; padding: 9px 14px; color: var(--text); font-weight: 700; font-size: 15px; }
.account-pill:hover { box-shadow: 0 0 16px rgba(57, 255, 90, 0.45); }
.acc-dot { width: 9px; height: 9px; border-radius: 50%; background: #6b6b6b; }
.account-pill.on .acc-dot { background: var(--neon); box-shadow: 0 0 6px var(--neon); }
.modal-account { width: min(400px, calc(100vw - 32px)); }
.modal-account form, #accSigned { display: flex; flex-direction: column; gap: 12px; }
.acc-note { margin: 0; color: var(--muted); font-size: 14px; }
.acc-note b { color: var(--text); }
.field { width: 100%; padding: 12px 14px; font-family: var(--ui); font-size: 16px; color: var(--text); background: #030d07; border: 2px solid var(--line); border-radius: 8px; outline: none; }
.field:focus { border-color: var(--neon); }
.acc-error, .priv-msg { margin: 0; color: #ff6b6b; font-size: 13px; }
.priv-msg.ok { color: var(--muted); }
.btn-acc { font-size: 18px; letter-spacing: 2px; padding: 10px; }

/* ---------- Private rooms ---------- */
.private-box { display: flex; flex-direction: column; gap: 6px; }
.private-row { display: grid; grid-template-columns: 1fr 86px auto; gap: 8px; }
.btn-sm { padding: 8px 10px; font-size: 13px; }
#privCode { min-width: 0; padding: 6px 8px; font-family: var(--pixel); font-size: 16px; text-align: center; text-transform: uppercase; color: var(--text); background: #030d07; border: 2px solid var(--line-soft); border-radius: 8px; outline: none; }
#privCode:focus { border-color: var(--neon); }
.private-banner { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1.5px dashed var(--gold); border-radius: 8px; font-size: 14px; }
.private-banner span { flex: 1; text-align: left; }
.private-banner b { font-family: var(--pixel); color: var(--gold); letter-spacing: 2px; }
.private-banner small { color: var(--muted); }

/* ---------- Event feed + chat ---------- */
.feed { position: absolute; left: 14px; bottom: 14px; width: min(380px, calc(100vw - 240px)); display: flex; flex-direction: column; gap: 6px; pointer-events: none !important; }
.feed ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.feed li { align-self: flex-start; max-width: 100%; padding: 3px 9px; border-radius: 6px; background: rgba(4, 12, 8, 0.62); font-size: 13.5px; line-height: 1.35;
  overflow-wrap: anywhere; transition: opacity 0.6s; text-shadow: 0 1px 2px #000; }
.feed li.fade { opacity: 0; }
.feed li .fn { font-weight: 700; color: #ffe0a8; }
.feed li .fn.me { color: var(--neon); }
.feed li.kill { color: #ffb3a1; }
.feed li.join, .feed li.leave { color: var(--muted); }
.feed li.escape { color: #8ff3f0; }
.feed li.chat { color: var(--text); background: rgba(4, 12, 8, 0.78); }
#chatInput { pointer-events: auto; width: 100%; padding: 7px 10px; font-family: var(--ui); font-size: 14px; color: var(--text);
  background: rgba(3, 13, 7, 0.55); border: 1.5px solid var(--line-soft); border-radius: 7px; outline: none; }
#chatInput:focus { background: rgba(3, 13, 7, 0.9); border-color: var(--neon); }
#chatInput::placeholder { color: #5f8a6e; }
@media (max-width: 700px) { .feed { width: calc(100vw - 28px); bottom: 210px; } }

/* ---------- Lobby layout: settings top-left, skin + shop bottom-left, server bottom-right ---------- */
.lobby-tl { position: absolute; top: 18px; left: 18px; }
.lobby-tl .icon-btn { width: 46px; height: 46px; }
.lobby-bl { position: absolute; left: 18px; bottom: 18px; width: 250px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.lobby-bl .skin-preview { padding: 4px 0 2px; }
.lobby-bl .btn { padding: 9px 12px; }
.lobby-br { position: absolute; right: 18px; bottom: 18px; display: flex; align-items: center; gap: 10px; padding: 9px 14px; color: var(--text); text-align: left; }
.lobby-br:hover { box-shadow: 0 0 16px rgba(57, 255, 90, 0.45); }
.lobby-br svg { width: 22px; height: 22px; color: var(--neon); }
.srv-text { display: flex; flex-direction: column; line-height: 1.15; }
.srv-text small { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.srv-text b { font-size: 15px; }
.srv-ping { font-family: var(--pixel); color: var(--neon); font-size: 14px; min-width: 52px; text-align: right; }
.acc-icon { width: 18px; height: 18px; color: var(--muted); }
.account-pill.on .acc-icon { color: var(--neon); filter: drop-shadow(0 0 4px rgba(57, 255, 90, 0.7)); }
@media (max-width: 900px) { .lobby-hint { display: none; } }
@media (max-width: 760px) {
  .lobby-bl { width: 180px; }
  .lobby-bl .skin-preview { display: none; }
}

/* Corner popups that stay clear of the centre lobby card. */
.overlay-tr, .overlay-br { background: rgba(1, 6, 3, 0.25); justify-content: flex-end; }
.overlay-tr { align-items: flex-start; padding: 78px 18px 16px; }
.overlay-br { align-items: flex-end; padding: 16px 18px 82px; }
.modal-account, .modal-server { width: min(340px, calc(100vw - 32px)); }
.server-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.server-list button { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; text-align: left;
  padding: 9px 12px; border-radius: 8px; border: 2px solid var(--line-soft); background: #04110a; color: var(--text); }
.server-list button.active { border-color: var(--neon); box-shadow: 0 0 12px rgba(57, 255, 90, 0.35); }
.server-list b { font-size: 15px; }
.server-list small { grid-column: 1; color: var(--muted); font-size: 12px; }
.server-list .ms { grid-row: 1 / 3; grid-column: 2; font-family: var(--pixel); color: var(--neon); }

/* ---------- Arena HUD: ping + fullscreen sit to the left of the leaderboard ---------- */
.hud-tr { flex-direction: row; align-items: flex-start; }
.feed { width: 300px; }
#chatInput { width: 260px; }

/* ---------- Game over buttons ---------- */
.death-actions { display: grid; grid-template-columns: 1fr 64px; gap: 10px; }
.icon-only { padding: 0; }
.icon-only svg { width: 26px; height: 26px; }

/* ---------- Settings tabs ---------- */
.tabs { display: flex; gap: 2px; margin-bottom: 6px; border-bottom: 1.5px solid var(--line-soft); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1; padding: 8px 4px; border: none; border-bottom: 2px solid transparent; margin-bottom: -1.5px; background: none;
  color: var(--muted); font-size: 14px; font-weight: 700; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--neon); border-bottom-color: var(--neon); }
.tab-panel { min-height: 196px; }
.slider { display: flex; flex-direction: column; gap: 8px; padding: 12px 2px; border-bottom: 1px solid var(--line-soft); }
.slider span { display: flex; justify-content: space-between; }
.slider b { font-family: var(--pixel); color: var(--neon); font-weight: 400; }
.slider input { width: 100%; accent-color: var(--neon); }
.controls-box { margin-top: 10px; }
.feed li.old { opacity: 0.6; }
.hud-hint.off { display: none !important; }

/* ---------- Lobby centre: title + selected snake above the play card ---------- */
.lobby-center { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.lobby-head { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.lobby-head .tagline { margin: 0; }
.lobby-head .skin-preview { margin-top: 4px; width: min(380px, calc(100vw - 32px)); background: rgba(3, 13, 7, 0.45); color: inherit; font: inherit; }
.lobby-head .skin-preview:hover { border-color: var(--line); }
.lobby-card { gap: 12px; padding: 20px 24px 16px; }
.lobby-bl { width: auto; padding: 0; background: none; border: none; box-shadow: none; }
.lobby-bl .btn { padding: 11px 18px; }

/* While any popup is open, the lobby gets out of the way (only its background stays). */
#lobby.modal-open > * { visibility: hidden; }

/* ---------- Settings: fixed size, tabs never resize it ---------- */
.modal-settings { width: min(460px, calc(100vw - 32px)); height: min(470px, calc(100vh - 32px)); display: flex; flex-direction: column; }
.modal-settings .tab-panel { flex: 1; min-height: 0; overflow-y: auto; }

/* ---------- Shop: big demo + arrows, thumbnail strip ---------- */
.modal-shop { width: min(620px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; }
.shop-stage { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 6px;
  border: 1.5px solid var(--line-soft); border-radius: 10px; background: radial-gradient(ellipse at center, #1f150d, #0a0704); padding: 8px 4px; }
.shop-stage canvas { width: 100%; height: auto; display: block; }
.shop-arrow { height: 64px; border-radius: 8px; border: 2px solid var(--line); background: #07160e; color: var(--neon); font-size: 34px; line-height: 1; padding-bottom: 6px; }
.shop-arrow:hover { box-shadow: 0 0 14px rgba(57, 255, 90, 0.4); }
.shop-info { display: flex; align-items: baseline; gap: 10px; }
.shop-cat { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; }
.shop-name { flex: 1; font-size: 22px; }
.shop-count { font-family: var(--pixel); color: var(--muted); font-size: 14px; }
.shop-action { padding: 12px; font-size: 17px; }
.shop-action.buy { color: var(--gold); border-color: #8a6a10; }
.shop-action.buy:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.shop-action.equip-on { color: #03140a; background: var(--neon); border-color: var(--neon); }
.shop-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--line-soft) transparent; }
.shop-thumb { flex: none; width: 92px; padding: 6px 4px 4px; border-radius: 8px; border: 2px solid var(--line-soft); background: #04110a; color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.shop-thumb canvas { width: 80px; height: 24px; }
.shop-thumb.sel { border-color: var(--neon); box-shadow: 0 0 10px rgba(57, 255, 90, 0.4); color: var(--text); }
.shop-thumb.equipped::after { content: '✓'; color: var(--neon); font-weight: 700; }
.shop-thumb .tp { color: var(--gold); }

/* ---------- Lobby v3: bigger logo, snake inside the play card ---------- */
.lobby-head .logo { font-size: clamp(44px, 11vw, 68px); gap: 16px; }
.lobby-head .logo-icon { width: 72px; height: 54px; }
.lobby-card .skin-preview { width: 100%; background: rgba(3, 13, 7, 0.45); color: inherit; font: inherit; }
.lobby-card .skin-preview:hover { border-color: var(--line); }

/* Popups take the play card's place: the card hides, everything else in the lobby stays (a bit darker). */
#lobby.modal-open > * { visibility: visible; }
#lobby.modal-open .lobby-card { visibility: hidden; }
#lobby.modal-open.modal-tall .lobby-head { visibility: hidden; }
.overlay.in-lobby { background: rgba(0, 0, 0, 0.38); align-items: flex-start; }

/* ---------- Shop v2: fewer boxes ---------- */
.modal-shop { gap: 6px; }
.modal-shop .coins-pill.small { border: none; background: none; box-shadow: none; padding: 0; }
.shop-stage { border: none; background: radial-gradient(ellipse at center, rgba(60, 40, 20, 0.55), transparent 70%); padding: 0; grid-template-columns: 36px 1fr 36px; }
.shop-arrow { height: auto; border: none; background: none; box-shadow: none; padding: 0 0 6px; font-size: 52px; color: var(--muted); }
.shop-arrow:hover { box-shadow: none; color: var(--neon); text-shadow: 0 0 12px rgba(57, 255, 90, 0.8); }
.shop-info { flex-direction: column; align-items: center; gap: 0; }
.shop-name { flex: none; font-size: 24px; }
.shop-action { width: min(260px, 100%); align-self: center; margin: 4px 0 2px; }
.shop-strip { gap: 2px; padding: 6px 2px 4px; border-top: 1px solid var(--line-soft); }
.shop-thumb { width: 84px; border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 4px 2px 3px; }
.shop-thumb:hover { color: var(--text); }
.shop-thumb.sel { border: none; border-bottom: 2px solid var(--neon); box-shadow: none; }

/* ---------- Lobby v4: logo + card (and popups that replace it) sit higher ---------- */
.lobby-center { transform: translateY(-11vh); }

/* Shop: no visible scrollbar on the skin strip (mouse wheel / arrows still scroll), more room under Buy */
.shop-strip { scrollbar-width: none; }
.shop-strip::-webkit-scrollbar { display: none; }
.shop-action { margin: 4px 0 16px; }
/* Game over card sits higher, matching the lobby layout */
#death .death-card { transform: translateY(-11vh); }

/* ---------- Admin panel ---------- */
.admin-pill .acc-icon { color: var(--gold); }
.admin-pill span { color: var(--gold); }
.modal-admin { width: min(680px, calc(100vw - 32px)); height: min(520px, calc(100vh - 32px)); display: flex; flex-direction: column; }
.modal-admin .tab-panel { flex: 1; min-height: 0; overflow-y: auto; }
.admin-bar { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.admin-bar .field { flex: 1; padding: 8px 12px; font-size: 14px; }
.admin-bar .acc-note { flex: 1; }
.admin-count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { position: sticky; top: 0; background: #06160d; text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); }
.admin-table td { padding: 7px 8px; border-bottom: 1px solid rgba(19, 92, 51, 0.5); }
.admin-table td.num { font-variant-numeric: tabular-nums; }
.admin-table .tag { font-size: 11px; color: var(--gold); margin-left: 6px; }
.admin-table .empty { color: var(--muted); text-align: center; padding: 18px; }
.admin-eye { width: 34px; height: 30px; display: grid; place-items: center; border-radius: 6px; border: 1.5px solid var(--line); background: #07160e; color: var(--neon); padding: 0; }
.admin-eye svg { width: 18px; height: 18px; }
.admin-eye:hover { box-shadow: 0 0 12px rgba(57, 255, 90, 0.45); }
.admin-watch-new { margin-top: 10px; }
.admin-empty { color: var(--muted); text-align: center; padding: 60px 20px; }

/* Sign-up captcha + guest prompts */
.captcha-box { min-height: 65px; display: flex; justify-content: center; }
.death-login { color: var(--muted); }
#chatInput:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Phones and tablets ----------
   body.touch   = touch screen as the main input (phones, tablets): minimap under the leaderboard.
   body.compact = small screen (width <= 760 or height <= 520, i.e. phones in either orientation): smaller HUD.
   Both classes are set by game.js. The PC layout above is unchanged. */
canvas#game { touch-action: none; }
body.touch .hud-tr, body.compact .hud-tr { flex-direction: column; align-items: flex-end; gap: 8px; }
body.touch .minimap, body.compact .minimap { position: relative; right: auto; bottom: auto; }
body.touch #chatInput { font-size: 16px; } /* 16px stops iOS zooming in when the field is tapped */

/* Tip text: above the bottom row instead of between the chat and the minimap. */
body.touch .hud-hint, body.compact .hud-hint {
  bottom: 24%; width: max-content; max-width: min(420px, calc(100vw - 40px)); text-align: center;
  padding: 6px 12px; border-radius: 8px; background: rgba(4, 12, 8, 0.65); font-size: 14px;
}
@media (max-width: 1100px) {
  .hud-hint { bottom: 24%; width: max-content; max-width: min(420px, calc(100vw - 40px)); text-align: center;
    padding: 6px 12px; border-radius: 8px; background: rgba(4, 12, 8, 0.65); }
}

/* Phones */
body.compact .hud-tl { top: 10px; left: 10px; gap: 6px; flex-direction: column; align-items: flex-start; }
body.compact .player-card { min-width: 0; padding: 4px 10px 4px 4px; gap: 8px; }
body.compact .player-card canvas { width: 30px; height: 30px; border-radius: 6px; }
body.compact .pc-name { font-size: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.compact .pc-sub { font-size: 12px; }
body.compact .score-card { padding: 4px 12px; gap: 10px; }
body.compact .score-card label { font-size: 11px; }
body.compact .score-card b { font-size: 18px; }
body.compact .hud-tr { top: 10px; right: 10px; gap: 6px; }
body.compact .ping { display: none; }
body.compact #hudFullscreen { width: 34px; height: 34px; }
body.compact #hudFullscreen svg { width: 18px; height: 18px; }
body.compact .leaderboard { width: 150px; padding: 6px 6px 4px; }
body.compact .leaderboard h3 { font-size: 14px; margin: 0 4px 4px; gap: 6px; }
body.compact .leaderboard .crown { width: 16px; height: 11px; }
body.compact .leaderboard li { font-size: 12px; padding: 1px 5px; gap: 4px; grid-template-columns: 20px 1fr auto; }
body.compact .lb-foot { display: none; }
body.compact .minimap { padding: 4px; }
body.compact .minimap canvas { width: 92px; height: 92px; }
body.compact .mm-n { font-size: 11px; top: -9px; }
body.compact .feed { left: 10px; bottom: 10px; width: min(260px, calc(100vw - 20px)); gap: 4px; }
body.compact .feed li { font-size: 12px; padding: 2px 7px; }
body.compact .feed li:nth-last-child(n+5) { display: none; } /* only the latest 4 lines */
body.compact #chatInput { width: 100%; padding: 5px 8px; }
body.compact .hud-hint { font-size: 13px; }
/* Spectate bar fits the width; the feed moves up above it. */
body.compact .spectate-bar { bottom: 10px; gap: 6px; padding: 6px; max-width: calc(100vw - 20px); }
body.compact .spectate-bar .icon-btn { width: 36px; height: 36px; font-size: 24px; }
body.compact .spec-who { min-width: 84px; }
body.compact .spec-who b { font-size: 14px; }
body.compact .spectate-bar .btn { padding: 6px 10px; font-size: 14px; }
body.compact .spectate-bar .btn-play { font-size: 16px; letter-spacing: 1px; }
body.compact #hud:has(#spectateBar:not([hidden])) .feed { bottom: 70px; }
/* Phone in landscape: the game over card must fit in ~390 px of height. */
@media (max-height: 520px) {
  #death .death-card { transform: none; padding: 14px 18px; gap: 8px; }
  .death-card h2 { font-size: 28px; }
  .death-stats { margin: 0; }
  .death-stats div { padding: 4px; }
  .death-stats b { font-size: 18px; }
  .death-card .btn-play { font-size: 20px; padding: 10px; }
  .death-card .btn { padding: 8px 12px; }
}

/* Lobby logo on phones: scale with the screen so "GRIDRUSH.FUN" never touches the edges. */
@media (max-width: 760px) {
  .lobby-head .logo { font-size: clamp(26px, 8.4vw, 44px); gap: 0.25em; letter-spacing: 1px; }
  .lobby-head .logo-icon { width: 1.1em; height: 0.83em; }
}
/* Phone in landscape: no room for the logo above the card, so everything gets more compact. */
@media (max-height: 520px) {
  .lobby-center { transform: none; gap: 8px; }
  .lobby-head .logo { font-size: 28px; gap: 8px; }
  .lobby-head .logo-icon { width: 30px; height: 23px; }
  .lobby-card { padding: 10px 16px 8px; gap: 8px; }
  .lobby-card .skin-preview { display: none; }
  #nickname { padding: 8px 12px; font-size: 18px; }
  .lobby-card .btn-play { padding: 8px; font-size: 22px; }
}
