/* ============================================================
   Simon Says — Memory Arena · dark neon theme
   ============================================================ */
:root {
  --bg: #070a14;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-border: rgba(255, 255, 255, 0.09);
  --text: #e8ecf8;
  --muted: #9aa3bd;

  --green: #22c55e;   --green-hi: #4ade80;
  --red: #ef4444;     --red-hi: #f87171;
  --yellow: #eab308;  --yellow-hi: #fde047;
  --blue: #3b82f6;    --blue-hi: #93c5fd;

  --accent: #22d3ee;
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- ambient background ---------- */
.bg-fx { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.orb {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: .28;
  animation: drift 26s ease-in-out infinite alternate;
}
.orb-green  { width: 42vmax; height: 42vmax; background: var(--green);  top: -12%; left: -10%; }
.orb-yellow { width: 36vmax; height: 36vmax; background: var(--yellow); bottom: -18%; right: -8%; animation-delay: -6s; }
.orb-blue   { width: 40vmax; height: 40vmax; background: var(--blue);   top: 30%; right: 22%; animation-delay: -12s; opacity: .2; }
.orb-red    { width: 30vmax; height: 30vmax; background: var(--red);    bottom: 8%; left: 26%; animation-delay: -18s; opacity: .16; }

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(6vmax, -4vmax) scale(1.15); }
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(7, 10, 20, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--panel-border);
}
.logo {
  display: flex; align-items: center; gap: .55rem;
  background: none; border: 0; cursor: pointer;
  font-size: 1.05rem; font-weight: 800; letter-spacing: .14em; color: var(--text);
}
.logo span { background: linear-gradient(90deg, var(--green-hi), var(--yellow-hi) 35%, var(--red-hi) 65%, var(--blue-hi)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo-pads { display: grid; grid-template-columns: repeat(2, 9px); gap: 3px; }
.logo-pads i { width: 9px; height: 9px; border-radius: 50%; animation: logoPulse 2.4s infinite; }
.logo-pads i:nth-child(1) { background: var(--green); }
.logo-pads i:nth-child(2) { background: var(--yellow); animation-delay: .3s; }
.logo-pads i:nth-child(3) { background: var(--red);    animation-delay: .6s; }
.logo-pads i:nth-child(4) { background: var(--blue);   animation-delay: .9s; }
@keyframes logoPulse { 0%,100% { opacity:.35; transform:scale(.85);} 25% { opacity:1; transform:scale(1.15);} }

.topnav { display: flex; gap: .4rem; align-items: center; }
.topnav button, .topnav a {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: .92rem; padding: .45rem .8rem; border-radius: 10px; text-decoration: none;
  transition: color .15s, background .15s;
}
.topnav button:hover, .topnav a:hover { color: var(--text); background: rgba(255,255,255,.07); }
.topnav-reset { color: #fca5a5; }
.topnav-reset:hover { background: rgba(239, 68, 68, .14); color: #fecaca; }

/* ---------- views ---------- */
.view { display: none; padding: 2rem clamp(1rem, 4vw, 3rem) 4rem; max-width: 1080px; margin: 0 auto; }
.view.active { display: block; animation: viewIn .35s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- hero ---------- */
.hero { text-align: center; padding: clamp(2.5rem, 8vh, 5.5rem) 0 3rem; position: relative; }
.kicker {
  display: inline-block; font-size: .78rem; letter-spacing: .28em; text-transform: uppercase;
  color: var(--accent); border: 1px solid rgba(34, 211, 238, .35); background: rgba(34, 211, 238, .07);
  padding: .4rem 1rem; border-radius: 999px; margin-bottom: 1.4rem;
}
.hero-title {
  font-size: clamp(3rem, 11vw, 6.5rem); line-height: .95; font-weight: 900; letter-spacing: .02em;
  background: linear-gradient(92deg, var(--green-hi) 8%, var(--yellow-hi) 38%, var(--red-hi) 64%, var(--blue-hi) 95%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 26px rgba(74, 222, 128, .25));
}
.hero-title span { display: block; }
.hero-sub { margin: 1.2rem auto 2rem; max-width: 34rem; color: var(--muted); font-size: clamp(1rem, 2.4vw, 1.2rem); }

.hero-ctas { display: flex; gap: .9rem; justify-content: center; flex-wrap: wrap; margin-bottom: 2.6rem; }

/* decorative pulsing pads */
.hero-pads { display: flex; gap: clamp(.7rem, 3vw, 1.4rem); justify-content: center; }
.hp { width: clamp(44px, 9vw, 74px); aspect-ratio: 1; border-radius: 26%; animation: heroPad 3.2s infinite; }
.hp-green  { background: radial-gradient(circle at 35% 30%, var(--green-hi), var(--green));   box-shadow: 0 0 24px rgba(34,197,94,.5); }
.hp-yellow { background: radial-gradient(circle at 35% 30%, var(--yellow-hi), var(--yellow)); box-shadow: 0 0 24px rgba(234,179,8,.5); animation-delay: .8s; }
.hp-red    { background: radial-gradient(circle at 35% 30%, var(--red-hi), var(--red));       box-shadow: 0 0 24px rgba(239,68,68,.5);  animation-delay: 1.6s; }
.hp-blue   { background: radial-gradient(circle at 35% 30%, var(--blue-hi), var(--blue));     box-shadow: 0 0 24px rgba(59,130,246,.5); animation-delay: 2.4s; }
@keyframes heroPad {
  0%, 100% { transform: scale(.82); filter: brightness(.55); }
  12%      { transform: scale(1.06); filter: brightness(1.35); }
  24%      { transform: scale(.9); filter: brightness(.7); }
}

/* ---------- sections & cards ---------- */
.section-title { font-size: clamp(1.5rem, 4vw, 2.1rem); margin: 3.2rem 0 1.3rem; letter-spacing: .02em; }
.cards-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }

.card {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: var(--radius); padding: 1.3rem 1.4rem; backdrop-filter: blur(8px);
}
.step-card h3 { margin: .7rem 0 .5rem; font-size: 1.12rem; }
.step-card p { color: var(--muted); font-size: .93rem; line-height: 1.55; }
.step-num {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  font-weight: 800; font-size: 1.1rem; color: #06121a;
  background: linear-gradient(135deg, var(--accent), #818cf8);
}

.features-strip {
  display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.6rem;
}
.features-strip span {
  font-size: .85rem; color: var(--muted); padding: .45rem .9rem; border-radius: 999px;
  background: rgba(255,255,255,.05); border: 1px solid var(--panel-border);
}

/* ---------- buttons ---------- */
.btn {
  font: inherit; cursor: pointer; border-radius: 14px; padding: .8rem 1.6rem;
  font-weight: 700; letter-spacing: .02em; transition: transform .12s, box-shadow .2s, background .2s, opacity .2s;
  border: 1px solid transparent;
}
.btn:active { transform: scale(.96); }
.btn-primary {
  color: #04121a; background: linear-gradient(135deg, var(--green-hi), var(--accent));
  box-shadow: 0 8px 28px rgba(34, 211, 238, .28);
}
.btn-primary:hover { box-shadow: 0 10px 36px rgba(34, 211, 238, .5); transform: translateY(-2px); }
.btn-ghost { color: var(--text); background: rgba(255,255,255,.06); border-color: var(--panel-border); }
.btn-ghost:hover { background: rgba(255,255,255,.12); transform: translateY(-2px); }
.btn-danger { color: #fecaca; background: rgba(239, 68, 68, .14); border-color: rgba(239, 68, 68, .4); }
.btn-danger:hover { background: rgba(239, 68, 68, .28); }
.btn.big { font-size: 1.15rem; padding: 1rem 2.6rem; margin-top: 1.8rem; display: block; width: fit-content; margin-left: auto; margin-right: auto; }
.btn.small { padding: .5rem 1rem; font-size: .88rem; border-radius: 10px; }
.btn-row { display: flex; gap: .9rem; justify-content: center; margin-top: 2.2rem; flex-wrap: wrap; }

.back-btn {
  background: none; border: 0; color: var(--muted); font-size: .95rem; cursor: pointer;
  padding: .4rem 0; margin-bottom: 1rem; transition: color .15s;
}
.back-btn:hover { color: var(--text); }

.setup-title { font-size: clamp(1.7rem, 5vw, 2.4rem); margin-bottom: 1.6rem; }
.setup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.1rem; align-items: start; }

/* ---------- form fields ---------- */
.field { display: block; }
.field span, .opt-group legend, .inline-label {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); display: block; margin-bottom: .6rem;
}
.opt-group { border: 0; }
.field input[type="text"], .field input:not([type]), #players-list input, select {
  width: 100%; font: inherit; color: var(--text); background: rgba(0,0,0,.35);
  border: 1px solid var(--panel-border); border-radius: 12px; padding: .7rem .9rem; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, #players-list input:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 211, 238, .18);
}
select option { background: #0d1226; }

/* ---------- option cards (level / direction) ---------- */
.opt-row { display: grid; gap: .7rem; }
[data-opt="level"] .opt-row { grid-template-columns: repeat(3, 1fr); }
[data-opt="direction"] .opt-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.opt-card {
  font: inherit; text-align: left; cursor: pointer; color: var(--text);
  background: rgba(0,0,0,.3); border: 1px solid var(--panel-border); border-radius: 14px;
  padding: .85rem 1rem; transition: all .15s; display: flex; flex-direction: column; gap: .25rem;
}
.opt-card b { font-size: 1rem; }
.opt-card small { color: var(--muted); line-height: 1.4; }
.opt-card:hover { border-color: rgba(34, 211, 238, .5); transform: translateY(-2px); }
.opt-card.selected {
  border-color: var(--accent); background: rgba(34, 211, 238, .1);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .15), 0 6px 22px rgba(34, 211, 238, .18);
}

/* ---------- switch ---------- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; }
.switch-row > span { color: var(--muted); font-size: .92rem; line-height: 1.45; }
.switch-row input { display: none; }
.switch {
  flex: 0 0 auto; width: 52px; height: 30px; border-radius: 999px; background: rgba(255,255,255,.14);
  position: relative; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #cbd5e1; transition: transform .2s, background .2s;
}
.switch-row input:checked + .switch { background: linear-gradient(90deg, var(--green), var(--accent)); }
.switch-row input:checked + .switch::after { transform: translateX(22px); background: #fff; }

.ta-row { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.ta-row label { font-size: .9rem; color: var(--muted); white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- tone chips ---------- */
.tone-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.tone-chip {
  font: inherit; cursor: pointer; color: var(--text); text-align: left;
  background: rgba(0,0,0,.3); border: 1px solid var(--panel-border); border-radius: 14px;
  padding: .7rem .9rem; display: flex; align-items: center; gap: .6rem; transition: all .15s;
}
.tone-chip:hover { transform: translateY(-2px); border-color: rgba(34,211,238,.5); }
.tone-chip.selected { border-color: var(--accent); background: rgba(34, 211, 238, .1); box-shadow: 0 0 0 3px rgba(34,211,238,.15); }
.tone-emoji { font-size: 1.5rem; }
.tone-name { flex: 1; font-weight: 600; font-size: .95rem; }
.tone-preview {
  border: 0; background: rgba(255,255,255,.1); color: var(--text); width: 30px; height: 30px;
  border-radius: 50%; cursor: pointer; font-size: .8rem; transition: all .15s; flex: 0 0 auto;
}
.tone-preview:hover { background: var(--accent); color: #04121a; }

/* ---------- battle players ---------- */
.players-card { grid-column: span 1; }
.count-pill { font-size: .75rem; letter-spacing: 0; text-transform: none; color: var(--accent); background: rgba(34,211,238,.12); padding: .15rem .6rem; border-radius: 999px; margin-left: .4rem; }
#players-list { display: grid; gap: .55rem; margin-bottom: .9rem; }
.player-row { display: flex; gap: .55rem; align-items: center; }
.player-row input { flex: 1; }
.player-num { width: 26px; height: 26px; border-radius: 8px; background: rgba(34,211,238,.15); color: var(--accent); display: grid; place-items: center; font-size: .8rem; font-weight: 700; flex: 0 0 auto; }
.remove-player { border: 0; background: rgba(239,68,68,.15); color: #fca5a5; width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: .9rem; transition: all .15s; flex: 0 0 auto; }
.remove-player:hover:not(:disabled) { background: rgba(239,68,68,.4); color: #fff; }
.remove-player:disabled { opacity: .3; cursor: not-allowed; }
.hint { color: var(--muted); font-size: .85rem; margin-top: .7rem; line-height: 1.5; }

/* ---------- HUD ---------- */
#view-game { display: none; max-width: 900px; }
#view-game.active { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; padding-top: 1.4rem; }

.hud { width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; }
.hud-left { display: flex; gap: .5rem; flex-wrap: wrap; }
.pill { font-size: .8rem; padding: .35rem .8rem; border-radius: 999px; background: rgba(34,211,238,.12); color: var(--accent); border: 1px solid rgba(34,211,238,.3); font-weight: 600; }
.pill-dim { background: rgba(255,255,255,.06); color: var(--muted); border-color: var(--panel-border); }

.hud-center { text-align: center; min-width: 0; }
#status-msg { font-size: clamp(1.05rem, 3vw, 1.45rem); font-weight: 700; letter-spacing: .02em; transition: color .2s; }
#status-msg.good { color: var(--green-hi); }
#status-msg.bad { color: var(--red-hi); }

.timer-bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; margin-top: .5rem; max-width: 420px; margin-left: auto; margin-right: auto; }
.timer-bar i { display: block; height: 100%; width: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--green-hi), var(--yellow-hi) 60%, var(--red-hi)); }

.hud-right { display: flex; gap: 1.2rem; }
.stat label { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.stat b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
#hud-clock-wrap.low #hud-clock { color: var(--red-hi); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- battle strip ---------- */
.battle-strip { width: 100%; display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.b-chip {
  display: flex; align-items: center; gap: .5rem; padding: .4rem .85rem; border-radius: 999px;
  background: rgba(255,255,255,.06); border: 1px solid var(--panel-border); font-size: .88rem; transition: all .2s;
}
.b-chip b { font-variant-numeric: tabular-nums; color: var(--muted); }
.b-chip.active { border-color: var(--accent); background: rgba(34,211,238,.14); box-shadow: 0 0 16px rgba(34,211,238,.35); transform: scale(1.05); }
.b-chip.active b { color: var(--accent); }
.b-chip.out { opacity: .38; text-decoration: line-through; }

/* ---------- board ---------- */
/* Every direction mode shares the circular compass-rose geometry:
   round pads centered on a ring of radius ~32.5%, a faint dashed dial
   through their centers, and a hub in the middle. Each layout only
   activates its own positions (4 or 8). */
.board {
  position: relative;
  width: min(76vmin, 540px); aspect-ratio: 1; display: block;
  padding: 2%; border-radius: 34px;
  background: rgba(255,255,255,.035); border: 1px solid var(--panel-border);
  box-shadow: inset 0 0 60px rgba(0,0,0,.5), 0 24px 70px rgba(0,0,0,.5);
}

/* faint compass dial through the pad centers */
.board::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 65%; aspect-ratio: 1;
  transform: translate(-50%, -50%); border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, .10); pointer-events: none;
}

/* shared pad geometry — index 0 green, 1 red, 2 yellow, 3 blue */
.board .pad { position: absolute; width: 21%; aspect-ratio: 1; border-radius: 50%; }
/* four-pad layouts get slightly larger pads so the ring stays balanced */
.layout-cardinal .pad, .layout-diagonal .pad { width: 25%; }
.board .hub { position: absolute; left: 35%; top: 35%; width: 30%; margin: 0; }

/* cardinal — N · E · S · W on the ring */
.layout-cardinal .pad[data-pad="0"] { left: 39.5%; top: 7%;    } /* N */
.layout-cardinal .pad[data-pad="2"] { left: 72%;   top: 39.5%; } /* E */
.layout-cardinal .pad[data-pad="1"] { left: 39.5%; top: 72%;   } /* S */
.layout-cardinal .pad[data-pad="3"] { left: 7%;    top: 39.5%; } /* W */

/* diagonal — NW · NE · SW · SE on the ring */
.layout-diagonal .pad[data-pad="0"] { left: 16.6%; top: 16.6%; } /* NW */
.layout-diagonal .pad[data-pad="2"] { left: 62.4%; top: 16.6%; } /* NE */
.layout-diagonal .pad[data-pad="1"] { left: 16.6%; top: 62.4%; } /* SW */
.layout-diagonal .pad[data-pad="3"] { left: 62.4%; top: 62.4%; } /* SE */

/* octagon (all 8 directions) — full compass rose */
.layout-octagon .pad[data-pad="0"] { left: 39.5%; top: 7%;    } /* N   */
.layout-octagon .pad[data-pad="4"] { left: 62.4%; top: 16.6%; } /* NE  */
.layout-octagon .pad[data-pad="2"] { left: 72%;   top: 39.5%; } /* E   */
.layout-octagon .pad[data-pad="5"] { left: 62.4%; top: 62.4%; } /* SE  */
.layout-octagon .pad[data-pad="1"] { left: 39.5%; top: 72%;   } /* S   */
.layout-octagon .pad[data-pad="6"] { left: 16.6%; top: 62.4%; } /* SW  */
.layout-octagon .pad[data-pad="3"] { left: 7%;    top: 39.5%; } /* W   */
.layout-octagon .pad[data-pad="7"] { left: 16.6%; top: 16.6%; } /* NW  */

.pad {
  border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .09s, box-shadow .18s, background .18s, filter .18s;
  -webkit-tap-highlight-color: transparent; user-select: none; touch-action: manipulation;
}
.pad:active { transform: scale(.97); }

.pad-0 { --c: var(--green);  --ch: var(--green-hi);  background: rgba(34,197,94,.16);  border: 2px solid rgba(34,197,94,.4); }
.pad-1 { --c: var(--red);    --ch: var(--red-hi);    background: rgba(239,68,68,.16);  border: 2px solid rgba(239,68,68,.4); }
.pad-2 { --c: var(--yellow); --ch: var(--yellow-hi); background: rgba(234,179,8,.15);  border: 2px solid rgba(234,179,8,.4); }
.pad-3 { --c: var(--blue);   --ch: var(--blue-hi);   background: rgba(59,130,246,.16); border: 2px solid rgba(59,130,246,.4); }
.pad-4 { --c: #ec4899;       --ch: #f9a8d4;          background: rgba(236,72,153,.16); border: 2px solid rgba(236,72,153,.4); } /* NE pink */
.pad-5 { --c: #f97316;       --ch: #fdba74;          background: rgba(249,115,22,.16); border: 2px solid rgba(249,115,22,.4); } /* SE orange */
.pad-6 { --c: #a855f7;       --ch: #d8b4fe;          background: rgba(168,85,247,.16); border: 2px solid rgba(168,85,247,.4); } /* SW purple */
.pad-7 { --c: #22d3ee;       --ch: #67e8f9;          background: rgba(34,211,238,.16); border: 2px solid rgba(34,211,238,.4); } /* NW cyan */

/* pads 4–7 only exist in octagon (all-8) mode */
.pad[data-pad="4"], .pad[data-pad="5"], .pad[data-pad="6"], .pad[data-pad="7"] { display: none; }
.layout-octagon .pad[data-pad="4"], .layout-octagon .pad[data-pad="5"],
.layout-octagon .pad[data-pad="6"], .layout-octagon .pad[data-pad="7"] { display: flex; }

.pad.lit {
  background: radial-gradient(circle at 38% 32%, var(--ch), var(--c) 75%);
  box-shadow: 0 0 34px var(--c), 0 0 90px color-mix(in srgb, var(--c) 55%, transparent);
  transform: scale(1.035); border-color: transparent;
}
.pad-label { font-weight: 800; font-size: clamp(1rem, 4vmin, 1.7rem); color: rgba(255,255,255,.65); letter-spacing: .06em; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.pad.lit .pad-label { color: #fff; }
.pad-key {
  position: absolute; bottom: 9%; font-size: clamp(.55rem, 1.8vmin, .72rem); font-family: inherit;
  background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.2); color: rgba(255,255,255,.75);
  padding: .1rem .45rem; border-radius: 6px; letter-spacing: .08em;
}

.hub {
  aspect-ratio: 1; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.14), rgba(255,255,255,.04) 70%);
  border: 1px solid var(--panel-border); box-shadow: inset 0 0 30px rgba(0,0,0,.6);
}
.hub b { font-size: clamp(1.4rem, 6vmin, 2.4rem); }
.hub small { color: var(--muted); letter-spacing: .2em; font-size: clamp(.5rem, 1.8vmin, .7rem); text-transform: uppercase; }
.board.showing .hub { animation: hubPulse .9s ease-in-out infinite; border-color: rgba(34,211,238,.6); }
@keyframes hubPulse { 50% { box-shadow: inset 0 0 30px rgba(0,0,0,.6), 0 0 30px rgba(34,211,238,.4); } }

.board.shake { animation: shake .4s; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); }
}

.game-controls { display: flex; gap: .8rem; }

/* ---------- results ---------- */
#view-results { text-align: center; position: relative; }
.results-banner { margin: 1.5rem auto 2rem; max-width: 40rem; }
.results-banner h2 { font-size: clamp(2rem, 7vw, 3.4rem); line-height: 1.1; }
.results-banner p { color: var(--muted); margin-top: .8rem; font-size: 1.05rem; }
.results-banner .trophy { font-size: clamp(3rem, 9vw, 4.6rem); display: block; margin-bottom: .6rem; animation: trophyBounce 1.2s ease infinite alternate; }
@keyframes trophyBounce { to { transform: translateY(-10px) rotate(4deg); } }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .9rem; max-width: 640px; margin: 0 auto 2.4rem; }
.stat-card { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; padding: 1rem; }
.stat-card label { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin-bottom: .35rem; }
.stat-card b { font-size: 1.5rem; }

.lb-heading { margin: 2.4rem 0 1rem; font-size: 1.3rem; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; }

/* ---------- leaderboard tables ---------- */
.lb-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.1rem; }
.lb-card h3 { margin-bottom: .8rem; font-size: 1.05rem; }
.lb-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.lb-table th { text-align: left; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; padding: .45rem .6rem; border-bottom: 1px solid var(--panel-border); }
.lb-table td { padding: .55rem .6rem; border-bottom: 1px solid rgba(255,255,255,.05); font-variant-numeric: tabular-nums; }
.lb-table tr:last-child td { border-bottom: 0; }
.lb-table .rank { width: 2.4rem; font-weight: 800; color: var(--muted); }
.lb-table tr.me td { background: rgba(34, 211, 238, .12); }
.lb-table .score-cell { font-weight: 800; color: var(--accent); }
.lb-table .empty-row td { text-align: center; color: var(--muted); padding: 1.4rem; }
.lb-table.big { max-width: 640px; margin: 0 auto; width: 100%; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); overflow: hidden; }

/* ---------- footer ---------- */
.foot { text-align: center; color: var(--muted); font-size: .82rem; padding: 2rem 1rem 3rem; opacity: .7; }

kbd { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.22); border-bottom-width: 2px; border-radius: 6px; padding: .08rem .4rem; font-size: .8em; font-family: inherit; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .hud { grid-template-columns: 1fr; justify-items: center; gap: .6rem; }
  .hud-right { order: -1; }
  [data-opt="level"] .opt-row { grid-template-columns: 1fr; }
  #view-game.active { padding-top: .8rem; }
}


