/* ===== Wisp Arena — design system ===== */
:root {
  --bg: #0a0c14;
  --bg2: #0f1320;
  --panel: rgba(18, 22, 36, 0.72);
  --panel-solid: #141828;
  --stroke: rgba(255, 255, 255, 0.10);
  --stroke-strong: rgba(124, 139, 255, 0.55);
  --accent: #7c8bff;
  --accent2: #c9a3ff;
  --gold: #ffce5c;
  --danger: #ff5a3c;
  --good: #6affb0;
  --text: #eef1fb;
  --muted: #9aa3bd;
  --r: 14px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: radial-gradient(120% 120% at 50% 0%, #131830 0%, var(--bg) 70%);
  font-family: var(--font); color: var(--text); user-select: none; touch-action: none;
  -webkit-font-smoothing: antialiased;
}
#game { display: block; width: 100vw; height: 100vh; }

/* glass panel helper */
.glass {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--r);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

/* ===== HUD ===== */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud-top { position: absolute; top: clamp(8px, 1.4vw, 14px); left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start; padding: 0 clamp(8px, 1.6vw, 16px); gap: 10px; }

.pill {
  background: var(--panel); border: 1px solid var(--stroke); border-radius: 999px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  padding: 8px 18px; font-weight: 800; font-size: clamp(14px, 1.6vw, 18px); letter-spacing: .3px;
  box-shadow: var(--shadow); font-variant-numeric: tabular-nums;
}

.leaderboard {
  background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--r);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  padding: 8px 10px; font-size: 13px; min-width: 178px; box-shadow: var(--shadow);
}
.lb-title { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted);
  padding: 2px 4px 6px; border-bottom: 1px solid var(--stroke); margin-bottom: 4px; font-weight: 800; }
.lb-row { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 8px; }
.lb-row .lb-rank { text-align: center; font-size: 13px; color: var(--muted); font-weight: 800; }
.lb-row .lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.lb-row .lb-score { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 800; }
.lb-row.me { background: rgba(124, 139, 255, 0.16); }
.lb-row.me .lb-score { color: var(--text); }

/* magnifier / zoom control (left edge) */
.zoom { position: absolute; left: clamp(8px, 1.4vw, 14px); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 8px; pointer-events: auto; }
.zoom button { width: 40px; height: 40px; border-radius: 50%; font-size: 22px; font-weight: 800; line-height: 1;
  background: var(--panel); border: 1px solid var(--stroke); color: #cdd3e6; cursor: pointer;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: var(--shadow); }
.zoom button:hover { border-color: var(--stroke-strong); }
.zoom button:active { transform: scale(.92); }
@media (max-width: 480px) { .zoom button { width: 34px; height: 34px; font-size: 18px; } }

/* ===== coach / suggestions ===== */
.coach {
  position: absolute; top: clamp(56px, 8vw, 66px); left: 50%; transform: translate(-50%, -8px);
  background: var(--panel); border: 1px solid var(--stroke-strong); border-radius: 999px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  padding: 8px 18px; font-size: clamp(12px, 1.5vw, 14px); font-weight: 700; color: #eaf0ff;
  white-space: nowrap; box-shadow: var(--shadow); opacity: 0;
  transition: opacity .25s, transform .25s; pointer-events: none; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
.coach.show { opacity: 1; transform: translate(-50%, 0); }
.coach.warn { border-color: rgba(255, 120, 120, 0.7); color: #ffd9d9; }

/* ===== bomb-barrage alarm ===== */
.bomb-alert {
  position: absolute; top: clamp(100px, 14vw, 116px); left: 50%; transform: translateX(-50%);
  background: rgba(60, 8, 8, 0.92); border: 2px solid var(--danger); border-radius: 12px;
  padding: 10px 22px; font-size: clamp(15px, 2.4vw, 20px); font-weight: 900; letter-spacing: 1px;
  color: #ffd9c2; text-shadow: 0 0 12px rgba(255, 90, 60, 0.8); box-shadow: 0 0 30px rgba(255, 60, 30, 0.5);
  pointer-events: none; animation: bombFlash .5s steps(1) infinite; white-space: nowrap; max-width: 94vw;
}
@keyframes bombFlash { 0% { opacity: 1; } 50% { opacity: .4; } 100% { opacity: 1; } }

/* ===== bottom HUD: dust + abilities ===== */
.hud-bottom { position: absolute; left: 0; right: 0; bottom: clamp(10px, 1.8vw, 16px);
  display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; }
.dust { display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--stroke); border-radius: 999px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  padding: 6px 14px; font-size: 13px; box-shadow: var(--shadow); }
.dust-label { color: #cbd2ff; font-weight: 800; }
.dust-bar { width: clamp(90px, 18vw, 140px); height: 8px; background: #1b2030; border-radius: 999px; overflow: hidden; }
.dust-bar i { display: block; height: 100%; width: 30%;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .12s ease; }
#dustNum { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 16px; text-align: right; }

.abilities { display: flex; gap: 8px; pointer-events: auto; flex-wrap: wrap; justify-content: center; max-width: 96vw; }
.ab {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: clamp(58px, 11vw, 78px);
  background: linear-gradient(180deg, rgba(30,36,58,.9), rgba(18,22,34,.9));
  border: 1px solid var(--stroke); border-radius: 12px; padding: 8px 6px;
  color: #8b93ad; cursor: pointer; transition: transform .08s, border-color .12s, color .12s, box-shadow .12s;
}
.ab.ready { color: var(--text); border-color: var(--stroke-strong); box-shadow: 0 0 0 1px rgba(124,139,255,.18), var(--shadow); }
.ab.ready:hover { transform: translateY(-2px); }
.ab.ready:active { transform: scale(.95); }
.ab-key { font-size: 10px; opacity: .65; background: rgba(255,255,255,.08); border-radius: 5px; padding: 0 5px; }
.ab-name { font-size: clamp(11px, 1.4vw, 13px); font-weight: 800; }
.ab-cost { font-size: 11px; color: var(--accent2); font-weight: 700; }

/* ===== persistent controls reference ===== */
.controls-hint { position: absolute; left: clamp(8px, 1.4vw, 12px); bottom: clamp(10px, 1.8vw, 14px);
  display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); pointer-events: none; max-width: 46vw; }
.controls-hint b { color: #cdd3e6; }
.controls-hint span { background: rgba(0, 0, 0, 0.32); border-radius: 7px; padding: 3px 9px; width: fit-content; }

/* ===== corner buttons (help / audio / emote) ===== */
.help-btn { position: absolute; bottom: clamp(10px, 1.8vw, 14px); width: 40px; height: 40px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--stroke); color: #cdd3e6; font-size: 18px; font-weight: 900;
  cursor: pointer; pointer-events: auto; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; transition: transform .08s, border-color .12s; }
.help-btn:hover { border-color: var(--stroke-strong); }
.help-btn:active { transform: scale(.92); }
#helpBtn { right: clamp(8px, 1.4vw, 14px); }
.sfx-btn   { right: calc(clamp(8px, 1.4vw, 14px) + 46px); font-size: 16px; }
.music-btn { right: calc(clamp(8px, 1.4vw, 14px) + 92px); font-size: 16px; }
.emote-btn { right: calc(clamp(8px, 1.4vw, 14px) + 138px); font-size: 16px; }
.voice-btn { right: calc(clamp(8px, 1.4vw, 14px) + 184px); font-size: 16px; touch-action: none; }
.voice-btn.talking { border-color: var(--good); color: var(--good);
  box-shadow: 0 0 0 3px rgba(106,255,176,.35), var(--shadow); animation: micPulse .7s ease-in-out infinite; }
@keyframes micPulse { 0%,100% { box-shadow: 0 0 0 3px rgba(106,255,176,.30), var(--shadow); }
  50% { box-shadow: 0 0 0 7px rgba(106,255,176,0), var(--shadow); } }
.help-btn.off { opacity: .45; }
.help-btn.off::after { content: ""; position: absolute; left: 8px; right: 8px; top: 50%; height: 2px;
  background: var(--danger); transform: rotate(-20deg); border-radius: 2px; }

/* ===== emote / speak wheel ===== */
.emote-wheel {
  position: absolute; right: clamp(8px, 1.4vw, 14px); bottom: 64px; width: 196px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 10px;
  background: var(--panel-solid); border: 1px solid var(--stroke); border-radius: var(--r);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  pointer-events: auto; box-shadow: var(--shadow); z-index: 30;
}
.emote-wheel button { background: rgba(40, 48, 72, 0.6); border: 1px solid var(--stroke); border-radius: 10px;
  font-size: 22px; padding: 9px 0; cursor: pointer; line-height: 1; transition: transform .08s, background .12s; }
.emote-wheel button:hover { background: rgba(60, 70, 104, 0.8); }
.emote-wheel button:active { transform: scale(.9); }

/* ===== ability cast feedback ===== */
@keyframes castPulse { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(124,139,255,.6); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(124,139,255,0); } 100% { transform: scale(1); } }
.ab.cast { animation: castPulse .35s ease; border-color: var(--accent2); }
@keyframes castDenied { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.ab.denied { animation: castDenied .25s ease; }

/* ===== overlays ===== */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; padding: 24px; overflow-y: auto;
  background: radial-gradient(circle at 50% 32%, rgba(28, 34, 58, 0.95), rgba(7, 9, 16, 0.98)); }

/* start screen: let the live arena play behind it (attract mode), dimmed for readability */
#start.overlay {
  background:
    radial-gradient(120% 90% at 50% 38%, rgba(10,13,22,0.35), rgba(7,9,16,0.82));
  -webkit-backdrop-filter: blur(2px) saturate(1.1); backdrop-filter: blur(2px) saturate(1.1);
}
/* a soft glow behind the start content so text/buttons stay legible over motion */
#start::before {
  content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(680px, 94vw); height: min(600px, 88vh);
  background: radial-gradient(ellipse at center, rgba(9,11,20,0.72) 0%, rgba(9,11,20,0.34) 46%, transparent 72%);
  filter: blur(8px); z-index: -1; pointer-events: none;
}
.logo { margin: 0; font-size: clamp(38px, 9vw, 54px); font-weight: 900; letter-spacing: 3px; line-height: 1;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 22px rgba(124, 139, 255, 0.35)); }
.logo span { -webkit-text-fill-color: var(--text); color: var(--text); font-size: clamp(18px, 4vw, 22px); opacity: .85; letter-spacing: 6px; }
.tag { margin: 0 0 6px; color: #aeb6d4; font-size: clamp(13px, 2vw, 15px); text-align: center; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; text-align: center; max-width: 440px; line-height: 1.5; }
.conn { color: #e0b07a; font-size: 12px; height: 16px; }
#nameInput { background: #11141c; border: 1px solid #2a3040; color: var(--text); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; width: min(280px, 80vw); text-align: center; outline: none; transition: border-color .12s; }
#nameInput:focus { border-color: var(--accent); }

/* form picker */
.forms { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: 480px; }
.form { width: clamp(120px, 40vw, 144px); background: rgba(18, 22, 34, 0.8); border: 2px solid #2a3040; border-radius: var(--r);
  padding: 12px 10px; color: #cdd3e6; cursor: pointer; text-align: center; transition: border-color .12s, transform .08s, background .12s; }
.form:hover { border-color: var(--stroke-strong); }
.form:active { transform: scale(.97); }
.form.sel { border-color: var(--accent); background: rgba(44, 52, 88, 0.9); box-shadow: 0 0 0 1px rgba(124,139,255,.25); }
.form-icon { font-size: 30px; line-height: 1; }
.form-name { font-weight: 800; margin-top: 4px; }
.form-desc { font-size: 11px; color: var(--muted); margin-top: 4px; min-height: 28px; }

/* buttons */
.btn { border: none; border-radius: 12px; padding: 14px 22px; font-size: 16px; font-weight: 800; cursor: pointer;
  width: min(300px, 84vw); transition: transform .08s, filter .12s, box-shadow .12s; }
.btn.primary { background: linear-gradient(90deg, var(--accent), #9a7bff); color: #fff; box-shadow: 0 8px 24px rgba(124, 139, 255, 0.4); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border: 1px solid #2a3040; color: var(--text); }
.btn.ghost:hover { border-color: var(--stroke-strong); }
.btn.reward { background: linear-gradient(90deg, #d7a33a, #f0cf73); color: #1a1300; box-shadow: 0 8px 24px rgba(220, 170, 60, 0.35); }
.btn:active { transform: scale(.97); }
.death-score { font-size: clamp(18px, 3vw, 22px); font-weight: 800; color: #d8def2; }
.best-tag { font-size: 15px; font-weight: 800; color: var(--gold); }
.best-dim { font-size: 14px; font-weight: 700; color: var(--muted); }

/* account / login on the start screen */
.account { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 24px; }
.acct-label { font-size: 12px; color: var(--muted); }
.acct-guest { font-size: 13px; color: #cdd3e6; }
.acct-dim { color: var(--muted); font-weight: 400; }
.acct-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.acct-btn { background: rgba(18,22,34,.85); border: 1px solid #2a3040; color: #eef1fb; border-radius: 10px;
  padding: 8px 14px; font-size: 13px; font-weight: 700; cursor: pointer; transition: border-color .12s, transform .08s; }
.acct-btn:hover { border-color: var(--stroke-strong); }
.acct-btn:active { transform: scale(.96); }
.acct-status { font-size: 12px; color: #e0b07a; min-height: 14px; }
.gbtn { display: flex; align-items: center; min-height: 36px; color-scheme: light; }
.link-dialog { margin-top: 6px; font-size: 13px; color: #cdd3e6; background: rgba(18,22,34,.9);
  border: 1px solid var(--stroke); border-radius: 12px; padding: 10px 14px; max-width: 360px; }
.link-actions { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.acct-chip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: rgba(124,139,255,.12); border: 1px solid var(--stroke); border-radius: 999px; padding: 7px 14px; font-size: 13px; }
.acct-chip .acct-best { color: var(--gold); font-weight: 800; }
.acct-link { background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 12px; }
#death h2 { font-size: clamp(22px, 5vw, 30px); margin: 0; }

/* help overlay */
.help-overlay { gap: 16px; }
.help-overlay h2 { margin: 0; font-size: clamp(22px, 5vw, 28px); }
.help-overlay h3 { margin: 14px 0 6px; font-size: 15px; color: var(--accent); }
.help-grid { display: flex; gap: clamp(20px, 5vw, 40px); flex-wrap: wrap; justify-content: center; max-width: 800px; }
.help-col { min-width: 260px; max-width: 360px; }
.help-col ul { margin: 0; padding-left: 18px; }
.help-col li { font-size: 13px; color: #c2c8db; margin: 5px 0; line-height: 1.45; }
.help-col b { color: var(--text); }

/* dev ad overlay */
.ad-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.9); z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.ad-overlay .ad-box { width: min(300px, 86vw); height: min(250px, 50vh); background: #1b1b1b; border: 2px dashed #555;
  display: flex; align-items: center; justify-content: center; color: #666; font-size: 22px; letter-spacing: 4px; }

/* ===== responsive ===== */
@media (max-width: 720px) {
  .leaderboard { min-width: 140px; font-size: 12px; }
  .controls-hint { max-width: 60vw; }
  .ab { padding: 6px 4px; }
}
@media (max-width: 480px) {
  .controls-hint { display: none; }          /* the help overlay covers controls on tiny screens */
  .leaderboard { min-width: 118px; padding: 6px 7px; }
  .lb-title { font-size: 10px; }
  .dust-label { display: none; }
  .help-btn { width: 36px; height: 36px; }
  .abilities { gap: 6px; }
}
@media (max-height: 520px) {
  .hud-bottom { gap: 6px; bottom: 6px; }
  .ab { padding: 5px 5px; }
}
