:root {
  --bg: #070707; --ink: #eafff7; --teal: #0c9793; --mint: #7ff9bc; --deep: #085f6c;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  position: fixed; inset: 0; background: var(--bg); color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}
canvas#game { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; touch-action: none; }
.hidden { display: none !important; }

#hud {
  position: fixed; top: 0; left: 0; right: 0; pointer-events: none;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) 0 calc(12px + var(--safe-l));
  text-shadow: 0 2px 6px rgba(0,0,0,.6);
}
.hud-left { font-weight: 800; letter-spacing: .08em; font-size: 14px; min-width: 96px; }
#hud-score { font-size: 13px; opacity: .8; margin-top: 2px; }
#hud-time {
  font-size: 40px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: .02em;
  background: rgba(7,7,7,.45); border: 1px solid rgba(127,249,188,.25); border-radius: 14px;
  padding: 2px 16px; min-width: 104px; text-align: center; line-height: 1.15;
}
#hud-time.low { color: #ff5a5a; border-color: rgba(255,90,90,.6); animation: pulse .5s ease-in-out infinite alternate; }
#hud-time.penalty { color: #ff5a5a; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }
.hud-right { display: flex; gap: 8px; pointer-events: auto; min-width: 96px; justify-content: flex-end; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid rgba(127,249,188,.35);
  background: rgba(7,7,7,.55); color: var(--ink); display: grid; place-items: center; padding: 0;
  cursor: pointer; touch-action: manipulation;
}
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.icon-btn:active { transform: scale(.94); }

#banner {
  position: fixed; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none;
  text-shadow: 0 4px 18px rgba(0,0,0,.8);
}
#banner-main { font-size: clamp(34px, 9vw, 72px); font-weight: 900; letter-spacing: .06em;
  background: linear-gradient(180deg, #ffffff, var(--mint)); -webkit-background-clip: text; background-clip: text; color: transparent; }
#banner-sub { font-size: clamp(15px, 3.6vw, 22px); font-weight: 700; opacity: .9; margin-top: 6px; }
#banner.pop { animation: pop .35s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#debug-badge { position: fixed; bottom: calc(8px + var(--safe-b)); left: 8px; font: 11px ui-monospace, monospace;
  background: #ff3b6b; color: #fff; padding: 3px 6px; border-radius: 6px; pointer-events: none; opacity: .85; }

.screen {
  position: fixed; inset: 0; display: grid; place-items: center; overflow-y: auto;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background: radial-gradient(ellipse at center, rgba(7,7,7,.35), rgba(7,7,7,.8));
  touch-action: pan-y;
}
.panel {
  width: min(400px, 100%); text-align: center; padding: 22px 20px;
  background: linear-gradient(180deg, rgba(11,18,32,.88), rgba(7,7,7,.92));
  border: 1px solid rgba(127,249,188,.22); border-radius: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.06);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.logo { width: 88px; height: 88px; filter: drop-shadow(0 6px 20px rgba(12,151,147,.45)); }
.game-name {
  margin: 0; font-size: clamp(44px, 13vw, 64px); font-weight: 900; letter-spacing: .08em; line-height: 1;
  background: linear-gradient(180deg, #ffffff 10%, var(--mint) 55%, var(--teal)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tag { margin: 0 0 6px; opacity: .75; font-weight: 600; }
h2 { margin: 0 0 4px; letter-spacing: .1em; font-size: 28px; color: var(--mint); }
.btn {
  width: 100%; max-width: 280px; padding: 14px 18px; font: inherit; font-weight: 800; letter-spacing: .12em; font-size: 16px;
  color: var(--ink); background: rgba(255,255,255,.06); border: 1px solid rgba(127,249,188,.3); border-radius: 14px; cursor: pointer;
  touch-action: manipulation;
}
.btn:hover { background: rgba(127,249,188,.12); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #17a07e, #0c7f80); border-color: transparent; color: #fff; box-shadow: 0 6px 20px rgba(23,160,126,.35); }
.btn.small { width: auto; padding: 10px 16px; }
.toggle { display: flex; align-items: center; gap: 8px; font-weight: 600; opacity: .9; cursor: pointer; padding: 6px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--teal); }
.hint { margin: 6px 0 0; font-size: 13px; line-height: 1.5; opacity: .7; }
.hint kbd { font: 12px ui-monospace, monospace; padding: 1px 5px; border: 1px solid rgba(255,255,255,.3); border-radius: 4px; }
.stats { margin: 0; line-height: 1.6; opacity: .9; }
.scores { list-style: none; margin: 4px 0; padding: 0; width: 100%; max-width: 300px; font-variant-numeric: tabular-nums; }
.scores li { display: grid; grid-template-columns: 28px 52px 1fr auto; gap: 6px; padding: 6px 8px; border-radius: 8px; font-size: 15px; text-align: left; }
.scores li:nth-child(odd) { background: rgba(255,255,255,.04); }
.scores li.me { background: rgba(127,249,188,.18); color: #fff; }
.scores li .rk { opacity: .6; } .scores li .nm { font-weight: 900; letter-spacing: .1em; } .scores li .ex { opacity: .7; font-size: 13px; }
.scores .empty { display: block; text-align: center; opacity: .6; }
#initials-form { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.initials-row { display: flex; gap: 8px; }
#initials {
  width: 120px; font-size: 28px; font-weight: 900; letter-spacing: .3em; text-align: center; text-transform: uppercase;
  padding: 8px; border-radius: 12px; border: 1px solid var(--mint); background: rgba(0,0,0,.4); color: #fff;
  -webkit-user-select: text; user-select: text;
}
@media (max-height: 500px) {
  .panel { padding: 12px 16px; gap: 6px; }
  .logo { width: 56px; height: 56px; }
  .game-name { font-size: 40px; }
  .btn { padding: 10px 14px; }
  #hud-time { font-size: 30px; }
}
