/* Layout: cockpit HUD in portrait. A rainy city sits behind a holographic visor;
   every panel is a chamfered cyan frame (SVG drawn by js/game.js, [data-frame]).
   Play screen = gauges + score on top, framed board in the middle, radar + tactical data below. */
@font-face { font-family: "Oxanium"; src: url("../fonts/oxanium.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Chakra Petch"; src: url("../fonts/chakra-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Chakra Petch"; src: url("../fonts/chakra-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Chakra Petch"; src: url("../fonts/chakra-700.woff2") format("woff2"); font-weight: 700 800; font-display: swap; }

:root {
  --bg: #040a11;
  --panel: rgba(8, 30, 46, .62);
  --holo: #36c9ff;
  --holo-dim: rgba(54, 201, 255, .16);
  --glow: rgba(54, 201, 255, .55);
  --ink: #d9f4ff;
  --muted: #6d9cb5;
  --green: #2bff8a;
  --red: #ff2d55;
  --gold: #ffc84a;
  --warn: #ff9a2e;
  --blue: #4da3ff;
  --violet: #b45cff;
  --cell: rgba(54, 201, 255, .045);
  --city: .38;

  --font-display: "Oxanium", "Eurostile", "Bank Gothic", "Arial Narrow", sans-serif;
  --font-ui: "Chakra Petch", "Arial Narrow", system-ui, sans-serif;
  color-scheme: dark;
}

/* In-game themes swap the same tokens. */
#app[data-skin="neon"]   { --bg:#090414; --panel:rgba(30,10,52,.62); --holo:#c45cff; --holo-dim:rgba(196,92,255,.16); --glow:rgba(196,92,255,.55); --ink:#f3e8ff; --muted:#a28cc4; --green:#39ff9f; --red:#ff2e88; --warn:#ffb13b; --cell:rgba(196,92,255,.05); }
#app[data-skin="craie"]  { --bg:#06100c; --panel:rgba(10,40,28,.62); --holo:#7dffb3; --holo-dim:rgba(125,255,179,.14); --glow:rgba(125,255,179,.5); --ink:#e6fff1; --muted:#7fb59a; --green:#e8ff5a; --red:#ff3d3d; --warn:#ffa53a; --cell:rgba(125,255,179,.045); }
#app[data-skin="lave"]   { --bg:#120604; --panel:rgba(48,14,8,.62); --holo:#ff7a3c; --holo-dim:rgba(255,122,60,.16); --glow:rgba(255,122,60,.55); --ink:#ffeee6; --muted:#c39282; --green:#b8f25c; --red:#ff2f4f; --warn:#ffd23c; --cell:rgba(255,122,60,.05); }
#app[data-skin="ocean"]  { --bg:#020d14; --panel:rgba(4,34,44,.62); --holo:#4ef0e0; --holo-dim:rgba(78,240,224,.15); --glow:rgba(78,240,224,.5); --ink:#e3fffb; --muted:#7fb1ae; --green:#7dff6a; --red:#ff5d73; --warn:#ffb347; --cell:rgba(78,240,224,.045); }
#app[data-skin="sakura"] { --bg:#12060c; --panel:rgba(52,12,32,.62); --holo:#ff8fc7; --holo-dim:rgba(255,143,199,.16); --glow:rgba(255,143,199,.55); --ink:#ffeef6; --muted:#c495ad; --green:#7dffb0; --red:#ff3b5c; --warn:#ffb347; --cell:rgba(255,143,199,.05); }
#app[data-skin="glace"]  { --bg:#04101a; --panel:rgba(10,36,56,.62); --holo:#a8e6ff; --holo-dim:rgba(168,230,255,.15); --glow:rgba(168,230,255,.5); --ink:#eefaff; --muted:#8fb3c6; --green:#6dffd8; --red:#ff5577; --warn:#ffc04d; --cell:rgba(168,230,255,.045); }
#app[data-skin="vapeur"] { --bg:#10041a; --panel:rgba(44,10,60,.62); --holo:#ff6ad5; --holo-dim:rgba(255,106,213,.16); --glow:rgba(255,106,213,.55); --ink:#fff0fb; --muted:#b98fc0; --green:#00f5d4; --red:#ff3366; --warn:#ffd23c; --cell:rgba(255,106,213,.05); }
#app[data-skin="or"]     { --bg:#0e0a02; --panel:rgba(44,32,6,.62); --holo:#ffd25a; --holo-dim:rgba(255,210,90,.16); --glow:rgba(255,210,90,.55); --ink:#fff8e6; --muted:#c4aa74; --green:#8dff6a; --red:#ff4040; --warn:#ff9a3c; --cell:rgba(255,210,90,.05); }
#app[data-skin="shadow"] { --bg:#08090a; --panel:rgba(30,32,36,.7); --holo:#e8edf2; --holo-dim:rgba(232,237,242,.12); --glow:rgba(232,237,242,.4); --ink:#ffffff; --muted:#9aa1a9; --green:#4be38a; --red:#f2424f; --warn:#ff9a2e; --cell:rgba(255,255,255,.04); --city: .22; }

[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

#app {
  position: relative;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  isolation: isolate;
}
/* City behind the visor, then rain (canvas), then scanlines + vignette on top of everything. */
#app::before {
  content: ""; position: absolute; inset: 0; z-index: -2;
  background: url("../assets/city.jpg") center 30% / cover no-repeat;
  opacity: var(--city);
  filter: saturate(1.1) blur(1px);
}
#rain { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.visor {
  position: absolute; inset: 0; z-index: 30; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(255,255,255,.035) 0 1px, transparent 1px 3px),
    radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0,0,0,.65) 100%);
  mix-blend-mode: normal;
}

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(14px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
  gap: 12px;
}
.screen.enter > * { animation: boot .5s cubic-bezier(.2,.8,.2,1) both; }
.screen.enter > *:nth-child(2) { animation-delay: .06s; }
.screen.enter > *:nth-child(3) { animation-delay: .12s; }
.screen.enter > *:nth-child(4) { animation-delay: .18s; }
.screen.enter > *:nth-child(5) { animation-delay: .24s; }
.screen.enter > *:nth-child(6) { animation-delay: .3s; }
@keyframes boot {
  0% { opacity: 0; transform: scaleY(.04); filter: brightness(3); }
  45% { opacity: 1; transform: scaleY(1.04); }
  60% { opacity: .5; }
  75% { opacity: 1; }
  100% { transform: none; filter: none; }
}

/* ---------- frames ---------- */
[data-frame] { position: relative; isolation: isolate; }
.frame-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: -1; }
.frame-svg .fill { fill: var(--panel); stroke: none; }
.frame-svg .line { fill: none; stroke: var(--holo); stroke-width: 1.5; filter: drop-shadow(0 0 4px var(--glow)); }
.frame-svg .tick { fill: none; stroke: var(--holo); stroke-width: 3.5; stroke-linecap: square; }
.frame-svg .line.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .7s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- shared bits ---------- */
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .2em; color: var(--holo); font-weight: 600; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.coins { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--gold); font-family: var(--font-display); }
.coin { width: 12px; height: 12px; background: var(--gold); clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); flex: none; box-shadow: 0 0 6px var(--gold); }

.btn {
  border: 0; background: var(--holo-dim);
  padding: 14px 16px;
  font-weight: 700; font-size: 15px; letter-spacing: .14em; text-transform: uppercase;
  cursor: pointer; transition: transform .08s, background .15s;
  color: var(--ink);
}
.btn:active { transform: scale(.97); background: rgba(54, 201, 255, .3); }
.btn-go {
  background: var(--green); color: #021a0c;
  font-family: var(--font-display); font-weight: 800; font-size: 26px; letter-spacing: .22em;
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 14px, 100% calc(100% - 14px), calc(100% - 14px) 100%, 14px 100%, 0 calc(100% - 14px), 0 14px);
  box-shadow: 0 0 24px var(--green);
  animation: breathe 2.4s ease-in-out infinite;
}
.btn-go:active { background: var(--green); filter: brightness(1.2); }
@keyframes breathe { 50% { filter: brightness(1.18); } }
.icon-btn { width: 42px; height: 42px; padding: 0; display: grid; place-items: center; background: transparent; border: 0; cursor: pointer; color: var(--holo); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: .2em; text-transform: uppercase; color: var(--holo); text-shadow: 0 0 10px var(--glow); }
.spacer { width: 42px; }

/* glitch text */
.glitch { position: relative; }
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; inset: 0; pointer-events: none;
}
.glitch::before { color: var(--holo); transform: translate(-2px, 0); clip-path: inset(0 0 60% 0); opacity: .7; animation: gl1 3.2s steps(1) infinite; }
.glitch::after  { color: var(--red);  transform: translate(2px, 0);  clip-path: inset(55% 0 0 0); opacity: .7; animation: gl2 2.7s steps(1) infinite; }
@keyframes gl1 { 0%, 92% { transform: translate(0); opacity: 0; } 93% { transform: translate(-4px, -1px); opacity: .8; } 96% { transform: translate(3px, 1px); } }
@keyframes gl2 { 0%, 88% { transform: translate(0); opacity: 0; } 89% { transform: translate(4px, 1px); opacity: .8; } 93% { transform: translate(-3px, 0); } }

/* ---------- menu ---------- */
.menu-top { display: flex; justify-content: space-between; align-items: center; }
.sys { font-size: 11px; letter-spacing: .2em; color: var(--muted); text-transform: uppercase; }
.sys b { color: var(--green); font-weight: 700; }
.menu-hero { flex: 1; min-height: 0; display: grid; place-items: center; padding: 18px 26px; }
.demo { width: 100%; height: 100%; max-height: 230px; display: grid; grid-template-columns: repeat(5, 1fr); grid-auto-rows: 1fr; gap: 6px; }
.demo i { background: var(--cell); clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px); transition: background .2s; }
.demo i.g { background: var(--green); box-shadow: 0 0 14px var(--green); animation: materialize .25s ease-out; }
.demo i.r { background: var(--red); animation: materialize .25s ease-out; }
.title {
  margin: 0; text-align: center;
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(30px, 9.6vw, 44px); line-height: 1; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink); text-shadow: 0 0 18px var(--glow);
}
.title .t-red { color: var(--red); text-shadow: 0 0 18px var(--red); display: inline-block; }
.title .tagline { display: block; margin-top: 6px; font-family: var(--font-ui); font-size: 14px; font-weight: 600; letter-spacing: .14em; color: var(--muted); text-shadow: none; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode {
  display: grid; gap: 1px; text-align: left; padding: 9px 12px; cursor: pointer;
  background: transparent; border: 0;
}
.mode:last-child:nth-child(odd) { grid-column: 1 / -1; }
.mode b { font-family: var(--font-display); font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.mode span { font-size: 13px; color: var(--muted); font-weight: 500; line-height: 1.2; }
.mode em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--holo); letter-spacing: .14em; text-transform: uppercase; }
.mode[aria-checked="true"] b { color: var(--green); text-shadow: 0 0 8px var(--green); }
.mode[aria-checked="true"] .frame-svg .line { stroke: var(--green); filter: drop-shadow(0 0 5px var(--green)); }
.mode[aria-checked="true"] .frame-svg .tick { stroke: var(--green); }
.menu-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-actions .btn-go { grid-column: 1 / -1; }

/* ---------- play ---------- */
#play { gap: 6px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
.hud { display: grid; grid-template-columns: 50px 1fr 50px; align-items: center; gap: 8px; height: 88px; }
.gauge { position: relative; height: 100%; display: grid; justify-items: center; }
.gauge svg { width: 30px; height: 62px; overflow: visible; }
.arc-track { fill: none; stroke: var(--holo-dim); stroke-width: 9; }
.arc-fill  { fill: none; stroke-width: 9; stroke-dasharray: 100; transition: stroke-dashoffset .3s ease-out; }
.gauge-energy .arc-fill { stroke: var(--green); filter: drop-shadow(0 0 6px var(--green)); }
.gauge-shield .arc-fill { stroke: var(--warn); filter: drop-shadow(0 0 6px var(--warn)); }
.gauge-energy .arc-fill.low { stroke: var(--red); filter: drop-shadow(0 0 6px var(--red)); animation: blink .5s steps(1) infinite; }
.g-label { font-size: 10px; letter-spacing: .14em; font-weight: 700; text-transform: uppercase; }
.gauge-energy .g-label { color: var(--green); }
.gauge-shield .g-label { color: var(--warn); }
.g-value { font-size: 15px; font-weight: 700; }
.score-frame { height: 100%; display: grid; place-content: center; text-align: center; }
.hud-score { font-size: 40px; font-weight: 800; line-height: 1; text-shadow: 0 0 16px var(--glow); }
.hud-score.bump { animation: bump .18s ease-out; }
@keyframes bump { 40% { transform: scale(1.14); color: var(--green); } }
.combo { color: var(--warn); font-weight: 700; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; min-height: 16px; }
@keyframes blink { 50% { opacity: .25; } }

.board-wrap { flex: 1; min-height: 0; display: flex; position: relative; container-type: size; }
/* Chaos: a square board (it spins), centred; transform set every frame by the game */
.board.chaos { flex: none; width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); margin: auto; will-change: transform; }
.board.chaos.verso .cell { background: color-mix(in srgb, var(--warn) 12%, transparent); }
.board.chaos.verso .frame-svg .line { stroke: var(--warn); }
/* Chaos events */
.board.chaos.fog { filter: blur(2.2px) brightness(.8); }
/* Chicken mini-game */
.mini { position: absolute; inset: 0; z-index: 11; display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: calc(14px + env(safe-area-inset-top, 0px)) 16px calc(18px + env(safe-area-inset-bottom, 0px)); background: rgba(2, 8, 14, .92); touch-action: none; user-select: none; -webkit-user-select: none; }
.mini-head { display: flex; justify-content: space-between; align-items: baseline; }
.mini-head b { font-family: var(--font-display); font-size: 34px; color: var(--warn); }
.mini canvas { flex: none; width: 100%; aspect-ratio: 4 / 3; max-height: 70%; border: 2px solid var(--holo); border-radius: 6px; box-shadow: 0 0 18px var(--glow); }
.mini-help { margin: 0; text-align: center; color: var(--muted); font-size: 13px; letter-spacing: .08em; }
.board {
  --cols: 4; --rows: 6; --ar: .6667;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  gap: 6px; padding: 10px;
  flex: 1; min-width: 0;
  touch-action: none;
}
.board.pulse .frame-svg .line { stroke-width: 2.6; filter: drop-shadow(0 0 10px var(--holo)); }
.cell { position: relative; background: var(--cell); clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }
.cell.grow { animation: materialize .4s ease-out both; }
.board.small .cell { clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px); }

.tile {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  animation: materialize .2s ease-out;
  transition: background .06s;
}
.tile::before { /* holographic scan sheen */
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.16) 0 1px, transparent 1px 4px);
  mix-blend-mode: overlay;
}
.tile::after { content: ""; width: 34%; aspect-ratio: 1; position: relative; }
.tile.green { background: linear-gradient(160deg, var(--green), color-mix(in srgb, var(--green) 55%, #000)); }
.tile.green::after { border: 3px solid rgba(0,0,0,.45); border-radius: 50%; }
.tile.gold  { background: linear-gradient(160deg, var(--gold), color-mix(in srgb, var(--gold) 55%, #000)); }
.tile.gold::after  { background: rgba(0,0,0,.45); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.tile.red   { background: linear-gradient(160deg, var(--red), color-mix(in srgb, var(--red) 55%, #000)); }
.tile.red::after { background: rgba(0,0,0,.5); clip-path: polygon(20% 0, 50% 30%, 80% 0, 100% 20%, 70% 50%, 100% 80%, 80% 100%, 50% 70%, 20% 100%, 0 80%, 30% 50%, 0 20%); width: 30%; }
.tile.flip { animation: flip .14s ease-out; }
.tile .timer { position: absolute; left: 12%; right: 12%; bottom: 9%; height: 3px; background: rgba(0,0,0,.45); transform-origin: left; z-index: 1; }
.tile.red .timer { display: none; }
.tile.hit { animation: hit .2s ease-in forwards; }
.tile.miss { animation: miss .3s steps(4) forwards; }

/* tile shapes */
#app[data-shape="cercle"]  .tile { clip-path: circle(48%); }
#app[data-shape="losange"] .tile { clip-path: polygon(50% 2%, 98% 50%, 50% 98%, 2% 50%); }
#app[data-shape="hexa"]    .tile { clip-path: polygon(25% 4%, 75% 4%, 98% 50%, 75% 96%, 25% 96%, 2% 50%); }
#app[data-shape="etoile"]  .tile { clip-path: polygon(50% 0, 63% 32%, 98% 35%, 71% 58%, 80% 94%, 50% 75%, 20% 94%, 29% 58%, 2% 35%, 37% 32%); }
#app[data-shape="triangle"] .tile { clip-path: polygon(50% 4%, 97% 94%, 3% 94%); }
#app[data-shape="octo"]     .tile { clip-path: polygon(30% 2%, 70% 2%, 98% 30%, 98% 70%, 70% 98%, 30% 98%, 2% 70%, 2% 30%); }
#app[data-shape="bouclier"] .tile { clip-path: polygon(50% 2%, 96% 16%, 92% 60%, 50% 98%, 8% 60%, 4% 16%); }
#app[data-shape="triangle"] .tile::after { width: 22%; }
#app[data-shape="triangle"] .tile .timer, #app[data-shape="octo"] .tile .timer, #app[data-shape="bouclier"] .tile .timer { bottom: 22%; left: 30%; right: 30%; }
#app[data-shape="etoile"]  .tile::after, #app[data-shape="losange"] .tile::after { width: 22%; }
#app[data-shape="etoile"]  .tile .timer, #app[data-shape="losange"] .tile .timer, #app[data-shape="hexa"] .tile .timer, #app[data-shape="cercle"] .tile .timer { bottom: 22%; left: 30%; right: 30%; }

@keyframes materialize {
  0% { transform: scaleY(.05) scaleX(1.2); opacity: 0; filter: brightness(3); }
  60% { transform: scaleY(1.08); opacity: 1; }
  100% { transform: none; filter: none; }
}
@keyframes flip { 0% { transform: scaleX(.2); filter: brightness(2.5); } 100% { transform: none; } }
@keyframes hit  { 0% { filter: brightness(2.5); } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes miss { 0% { opacity: 1; } 100% { opacity: 0; transform: translateX(3px) scaleY(.2); filter: grayscale(1); } }

.beatbar { height: 4px; background: var(--holo-dim); overflow: hidden; margin-inline: 14px; }
.beatbar i { display: block; height: 100%; width: 100%; background: var(--holo); box-shadow: 0 0 8px var(--holo); transform-origin: left; }

.bottom-hud { display: grid; grid-template-columns: 72px 1fr 42px; gap: 10px; align-items: center; height: 70px; }
.radar { height: 66px; display: grid; place-content: center; text-align: center; overflow: hidden; }
.radar-grid {
  position: absolute; inset: 6px;
  background:
    linear-gradient(var(--holo-dim) 1px, transparent 1px) 0 0 / 12px 12px,
    linear-gradient(90deg, var(--holo-dim) 1px, transparent 1px) 0 0 / 12px 12px;
}
.sweep {
  position: absolute; inset: -30%;
  background: conic-gradient(from 0deg, transparent 0 300deg, color-mix(in srgb, var(--holo) 45%, transparent) 360deg);
  animation: spin var(--bar, 2.4s) linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }
.radar .num, .radar small { position: relative; }
.radar .num { font-size: 24px; font-weight: 800; line-height: 1; text-shadow: 0 0 10px var(--glow); }
.radar small { font-size: 10px; letter-spacing: .2em; color: var(--holo); font-weight: 700; }
.tactical { margin: 0; display: grid; gap: 0; font-size: 12px; line-height: 1.25; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tactical dt { font-family: var(--font-display); font-size: 14px; color: var(--holo); letter-spacing: .14em; margin-bottom: 2px; text-shadow: 0 0 8px var(--glow); }
.tactical dd { margin: 0; display: flex; justify-content: space-between; gap: 8px; }
.tactical b { color: var(--ink); font-weight: 700; }

#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }
.flash { position: absolute; inset: 0; pointer-events: none; z-index: 21; background: var(--red); opacity: 0; mix-blend-mode: screen; }
.flash.on { animation: flash .5s ease-out; }
@keyframes flash { from { opacity: .5; } to { opacity: 0; } }
.glitching { animation: glitchShake .45s steps(2); }
.glitching .board, .glitching .hud { animation: rgb .45s steps(3); }
@keyframes glitchShake {
  0% { transform: translate(0); } 15% { transform: translate(-9px, 2px) skewX(4deg); } 30% { transform: translate(8px, -3px); }
  45% { transform: translate(-5px, 1px) skewX(-3deg); } 60% { transform: translate(4px, 0); } 100% { transform: none; }
}
@keyframes rgb { 0%, 100% { filter: none; } 33% { filter: drop-shadow(-5px 0 0 var(--red)) drop-shadow(5px 0 0 var(--holo)); } 66% { filter: hue-rotate(60deg) contrast(1.6); } }

.banner {
  position: absolute; left: -16px; right: -16px; top: 42%; z-index: 9; pointer-events: none;
  padding: 10px 0; text-align: center;
  font-family: var(--font-display); font-weight: 800; font-size: 28px; letter-spacing: .24em; text-transform: uppercase;
  color: var(--ink); text-shadow: 0 0 14px var(--glow);
  background: linear-gradient(90deg, transparent, var(--holo-dim) 20%, var(--holo-dim) 80%, transparent);
  border-block: 1px solid var(--holo);
  opacity: 0;
}
.banner small { display: block; font-family: var(--font-ui); font-size: 12px; letter-spacing: .3em; color: var(--holo); font-weight: 700; }
.banner.on { animation: banner 1.1s cubic-bezier(.2,.8,.2,1); }
.banner.warn { color: var(--red); border-color: var(--red); text-shadow: 0 0 14px var(--red); }
@keyframes banner {
  0% { opacity: 0; transform: translateX(-30%) scaleY(.2); }
  18% { opacity: 1; transform: none; }
  80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateX(30%) scaleY(.2); }
}

.pause-overlay, .countdown {
  position: absolute; inset: 0; z-index: 12; display: grid; place-items: center;
}
.pause-overlay { background: rgba(2, 8, 14, .86); }
.countdown { pointer-events: none; }
.countdown .ring {
  width: 160px; height: 160px; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: 84px; color: var(--ink); text-shadow: 0 0 20px var(--glow);
  animation: count .45s ease-out;
}
.countdown .ring svg { position: absolute; width: 160px; height: 160px; animation: spin 1.4s linear infinite; }
.countdown .ring polygon { fill: none; stroke: var(--holo); stroke-width: 2; stroke-dasharray: 30 12; filter: drop-shadow(0 0 6px var(--glow)); }
@keyframes count { 0% { transform: scale(1.6); opacity: 0; } 40% { opacity: 1; } 100% { transform: scale(1); } }
.pause-card { display: grid; gap: 10px; width: min(280px, 100%); text-align: center; padding: 22px; }
.pause-card h3 { margin: 0 0 6px; font-family: var(--font-display); font-weight: 800; font-size: 30px; letter-spacing: .24em; text-transform: uppercase; color: var(--holo); }

/* ---------- game over ---------- */
#over { justify-content: center; gap: 14px; }
.over-title { margin: 6px 0 0; font-family: var(--font-display); font-weight: 800; font-size: 40px; line-height: 1; letter-spacing: .08em; text-transform: uppercase; color: var(--red); text-shadow: 0 0 18px var(--red); }
.over-sub { margin: 6px 0 0; color: var(--muted); font-weight: 600; letter-spacing: .06em; }
.over-score { font-size: 96px; font-weight: 800; line-height: 1; margin-top: 4px; text-shadow: 0 0 24px var(--glow); }
.over-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 10px 12px; }
.stat .num { font-size: 24px; font-weight: 700; display: block; margin-top: 2px; }
.new-best { color: var(--gold); font-weight: 700; letter-spacing: .24em; text-transform: uppercase; font-size: 13px; text-shadow: 0 0 10px var(--gold); animation: blink .8s steps(1) 4; }
.name-row { display: flex; gap: 8px; }
.name-row input {
  flex: 1; min-width: 0; font: inherit; font-weight: 700; color: var(--ink); letter-spacing: .08em;
  background: var(--panel); border: 1px solid var(--holo); padding: 12px 14px;
  user-select: text; -webkit-user-select: text;
}
.over-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.over-actions .btn-go { grid-column: 1 / -1; }

/* ---------- shop & ranking ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--holo-dim); }
.tab { flex: 1 0 auto; border: 0; background: transparent; padding: 10px 8px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: 12px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab[aria-selected="true"] { color: var(--holo); border-bottom-color: var(--holo); text-shadow: 0 0 8px var(--glow); }
.shop-list { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; padding: 4px 2px 8px; }
.item { display: grid; gap: 8px; padding: 12px; text-align: left; background: transparent; border: 0; cursor: pointer; }
.item .name { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .08em; text-transform: uppercase; }
.item .state { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.item.equipped .state { color: var(--green); }
.item.equipped .frame-svg .line { stroke: var(--green); }
.item.locked.cant .state { color: var(--red); }
.preview { height: 58px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px; }
.preview span { clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px); }
.preview-shape { display: grid; place-items: center; grid-template-columns: 1fr; }
.preview-shape span { width: 42px; height: 42px; background: var(--green); }
.toast {
  position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 40;
  background: var(--panel); border: 1px solid var(--holo); color: var(--ink); font-weight: 700; letter-spacing: .08em;
  padding: 10px 16px; opacity: 0; transition: opacity .2s; pointer-events: none;
  width: max-content; max-width: calc(100% - 32px); text-align: center; line-height: 1.35;
  box-shadow: 0 0 16px var(--glow);
}
.toast.on { opacity: 1; }

.board-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; overflow-y: auto; flex: 1; min-height: 0; align-content: start; }
.board-list li { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 10px 14px; background: var(--panel); border-left: 2px solid var(--holo-dim); }
.board-list li.me { border-left-color: var(--green); }
.board-list .rank { font-family: var(--font-display); font-size: 20px; font-weight: 800; color: var(--muted); }
.board-list .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; letter-spacing: .04em; }
.board-list .who small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: .08em; }
.board-list .pts { font-family: var(--font-display); font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.board-list li.empty { display: block; background: none; border: 0; }
.empty { color: var(--muted); text-align: center; padding: 40px 10px; line-height: 1.5; }
.note { color: var(--muted); font-size: 12px; letter-spacing: .1em; margin: 0; text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; }
}

/* ================= v2.2: menu, specials, modes, new screens ================= */
.screen.scroll { overflow-y: auto; overscroll-behavior: contain; }
#menu { gap: 10px; overflow-y: auto; }
.menu-top { gap: 10px; }
.rank-badge { display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 8px; row-gap: 3px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; min-width: 0; flex: 1; }
.rank-badge b { font-family: var(--font-display); font-size: 15px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); text-shadow: 0 0 8px var(--gold); }
.rank-badge .xpbar { grid-column: 1 / -1; }
.xpbar { display: block; height: 4px; background: var(--holo-dim); overflow: hidden; }
.xpbar i { display: block; height: 100%; width: 0; background: var(--gold); box-shadow: 0 0 6px var(--gold); transition: width .6s ease-out; }
.menu-hero { flex: 1 1 120px; min-height: 90px; padding: 12px 26px; }
.demo { max-height: 150px; }
.title { font-size: clamp(26px, 8.4vw, 38px); }
.daily { display: grid; gap: 2px; text-align: left; padding: 9px 14px; background: transparent; border: 0; cursor: pointer; }
.daily .frame-svg .line, .daily .frame-svg .tick { stroke: var(--gold); }
.daily-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.daily .label { color: var(--gold); font-size: 13px; }
.daily b { font-family: var(--font-display); font-size: 14px; letter-spacing: .1em; text-transform: uppercase; }
.daily-state { font-size: 13px; color: var(--muted); }
.modes { gap: 6px; }
.mode { padding: 7px 10px; }
.mode b { font-size: 13px; }
.mode em { font-size: 10px; }
.mode-rule { margin: -2px 0 0; min-height: 18px; font-size: 13px; color: var(--muted); text-align: center; }
.menu-actions { grid-template-columns: 1fr 1fr; gap: 8px; }
.menu-actions .btn { padding-block: 11px; font-size: 13px; }
.menu-actions .btn-go { font-size: 24px; padding-block: 12px; }
.menu-actions.two .btn-go { grid-column: auto; }
.visitors { margin: -4px 0 0; text-align: center; font-size: 13px; letter-spacing: .08em; color: var(--muted); }
.visitors b { color: var(--ink); font-size: 15px; margin-right: 2px; }
.visitors i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; vertical-align: 1px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 2s ease-in-out infinite; }
.pill { display: inline-block; margin-left: 6px; padding: 1px 6px; font-size: 11px; color: var(--bg); background: var(--gold); letter-spacing: .04em; }

/* special tiles */
.tile.blue   { background: linear-gradient(160deg, var(--blue), color-mix(in srgb, var(--blue) 50%, #000)); }
.tile.violet { background: linear-gradient(160deg, var(--violet), color-mix(in srgb, var(--violet) 50%, #000)); }
.tile.blue::after { /* snowflake-ish */
  background: rgba(0,0,0,.45);
  clip-path: polygon(45% 0, 55% 0, 55% 40%, 90% 20%, 95% 29%, 60% 50%, 95% 71%, 90% 80%, 55% 60%, 55% 100%, 45% 100%, 45% 60%, 10% 80%, 5% 71%, 40% 50%, 5% 29%, 10% 20%, 45% 40%);
}
.tile.violet::after { border: 3px solid rgba(0,0,0,.45); border-radius: 0; transform: rotate(45deg); width: 28%; }
.tile.hold {
  --hold: 0;
  background:
    conic-gradient(var(--ink) calc(var(--hold) * 360deg), transparent 0) center / 70% 70% no-repeat,
    linear-gradient(160deg, #2b3440, #07090c);
  box-shadow: inset 0 0 0 2px var(--ink);
}
.tile.hold::after { width: 22%; border-radius: 50%; background: var(--ink); }
.tile.hold.holding { box-shadow: inset 0 0 0 3px var(--gold), 0 0 18px var(--gold); }

/* rhythm: an approach ring closes onto the tile on the beat */
.board.rhythm .timer { display: none; }
.tile .ring {
  position: absolute; inset: 6%; z-index: 2; pointer-events: none;
  border: 3px solid var(--ink); border-radius: 50%;
  box-shadow: 0 0 10px var(--glow);
}
.judge {
  position: absolute; z-index: 22; pointer-events: none; transform: translate(-50%, -50%);
  font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink); text-shadow: 0 0 10px var(--glow);
  animation: judge .7s ease-out forwards;
}
.judge.perfect { color: var(--gold); text-shadow: 0 0 12px var(--gold); font-size: 24px; }
.judge.meh { color: var(--muted); }
.judge.blue { color: var(--blue); }
.judge.violet { color: var(--violet); }
@keyframes judge { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -140%) scale(1); } }

/* board states */
.board.frozen .frame-svg .line, .board.frozen .frame-svg .tick { stroke: var(--blue); filter: drop-shadow(0 0 8px var(--blue)); }
.board.frozen .cell { background: color-mix(in srgb, var(--blue) 10%, transparent); }
.board.boss { animation: sway 2.4s ease-in-out infinite; }
.board.boss .frame-svg .line, .board.boss .frame-svg .tick { stroke: var(--red); filter: drop-shadow(0 0 8px var(--red)); }
@keyframes sway { 0%, 100% { transform: rotate(0) translateX(0); } 25% { transform: rotate(-1.2deg) translateX(-4px); } 75% { transform: rotate(1.2deg) translateX(4px); } }
.board.target-red .frame-svg .line, .board.target-red .frame-svg .tick { stroke: var(--red); }
.beatbar.boss i { background: var(--red); box-shadow: 0 0 8px var(--red); }

/* stronger colour-blind cues: dots on greens, stripes on reds */
#app[data-cb="1"] .tile.green { background-image: radial-gradient(rgba(0,0,0,.35) 18%, transparent 20%), linear-gradient(160deg, var(--green), color-mix(in srgb, var(--green) 55%, #000)); background-size: 12px 12px, auto; }
#app[data-cb="1"] .tile.red { background-image: repeating-linear-gradient(45deg, rgba(0,0,0,.4) 0 5px, transparent 5px 11px), linear-gradient(160deg, var(--red), color-mix(in srgb, var(--red) 55%, #000)); }
#app[data-cb="1"] .tile::after { transform: scale(1.25); }

/* game over additions */
.over-score-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.over-side { display: grid; gap: 6px; justify-items: end; text-align: right; padding-bottom: 12px; }
.tag { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--holo); border: 1px solid var(--holo); padding: 3px 8px; }
.over-sub { line-height: 1.4; max-width: 34em; }
.xp-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.xp-row b { color: var(--gold); }
.xp-gain { font-family: var(--font-display); color: var(--gold); font-weight: 700; font-size: 14px; }
.done-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.done-list li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--green); padding: 6px 10px; background: color-mix(in srgb, var(--green) 10%, transparent); border-left: 2px solid var(--green); }
.done-list b { color: var(--gold); font-family: var(--font-display); }
#over .over-score { font-size: 84px; }
#over .over-actions { grid-template-columns: 1fr 1fr; }

/* shop */
.shop-preview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; height: 56px; }
.shop-preview .cellp { position: relative; background: var(--cell); clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); }
.shop-preview .tile { animation: none; }
.item.previewing .frame-svg .line { stroke: var(--gold); }
.item.previewing .state { color: var(--gold); }

/* missions, rank */
.intro { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.mission-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.mission { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px 14px; }
.m-text { font-weight: 700; }
.m-reward { display: inline-flex; align-items: center; gap: 5px; color: var(--gold); font-family: var(--font-display); font-weight: 700; }
.mission .xpbar { grid-column: 1 / -1; }
.m-prog { grid-column: 1 / -1; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.mission.done .m-prog { color: var(--green); }
.mission.done .frame-svg .line { stroke: var(--green); }
.rank-card { display: grid; gap: 6px; padding: 14px; margin-top: 6px; }
.rank-big { font-family: var(--font-display); font-size: 32px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); text-shadow: 0 0 12px var(--gold); }

/* duel */
.duel-card { display: grid; gap: 10px; padding: 14px; }
.code { font-size: 46px; font-weight: 800; letter-spacing: .3em; text-align: center; color: var(--ink); text-shadow: 0 0 14px var(--glow); }
.code-input {
  font: inherit; font-family: var(--font-display); font-size: 32px; font-weight: 800; letter-spacing: .3em; text-align: center; text-transform: uppercase;
  color: var(--ink); background: var(--panel); border: 1px solid var(--holo); padding: 10px;
  user-select: text; -webkit-user-select: text; min-width: 0; width: 100%;
}

/* settings */
.set-group { display: grid; padding: 6px 14px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--holo-dim); }
.set-row:last-child { border-bottom: 0; }
.set-row > span:first-child { display: grid; font-weight: 600; letter-spacing: .04em; }
.set-row small { font-size: 12px; color: var(--muted); font-weight: 500; }
.set-row input[type="range"] { width: 46%; accent-color: var(--holo); }
.toggle { width: 52px; height: 28px; border: 1px solid var(--holo); background: transparent; position: relative; cursor: pointer; flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: var(--muted); transition: transform .15s, background .15s; }
.toggle[aria-pressed="true"] { background: var(--holo-dim); }
.toggle[aria-pressed="true"]::after { transform: translateX(24px); background: var(--green); box-shadow: 0 0 8px var(--green); }
.seg { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.seg button { border: 1px solid var(--holo-dim); background: transparent; padding: 6px 9px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { border-color: var(--holo); color: var(--ink); background: var(--holo-dim); }
.seg button:disabled { opacity: .35; cursor: not-allowed; }
.btn.small { padding: 8px 12px; font-size: 12px; flex: none; }
.srv-form { display: grid; gap: 8px; padding: 10px 0; }
.srv-form input { font: inherit; font-size: 13px; color: var(--ink); background: var(--panel); border: 1px solid var(--holo); padding: 8px 9px; min-width: 0; width: 100%; box-sizing: border-box; user-select: text; -webkit-user-select: text; }
.srv-help { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
/* Login screen (startup, no account yet) */
#login { gap: 14px; }
#login > :first-child { margin-top: auto; }
#login > :last-child { margin-bottom: auto; }
#login .note { text-transform: none; letter-spacing: .02em; line-height: 1.5; text-align: center; }
.login-title { margin: 0 0 4px; }
.login-card { gap: 10px; padding: 14px; }
.login-card .btn-go { font-size: 18px; }
.login-field { display: grid; gap: 4px; }
.login-field input { font: inherit; font-size: 15px; font-weight: 600; color: var(--ink); background: var(--panel); border: 1px solid var(--holo); padding: 10px; min-width: 0; width: 100%; box-sizing: border-box; user-select: text; -webkit-user-select: text; }
.btn.danger { color: var(--red); }

/* calibration */
.calib-pad { flex: 1; min-height: 200px; display: grid; place-items: center; background: transparent; border: 0; cursor: pointer; touch-action: none; }
.calib-count { position: relative; font-size: 40px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; text-shadow: 0 0 14px var(--glow); }
.calib-ring { position: absolute; width: 120px; height: 120px; border: 2px solid var(--holo); border-radius: 50%; opacity: 0; }
.calib-ring.on { animation: calibRing .4s ease-out; }
@keyframes calibRing { from { opacity: .9; transform: scale(.6); } to { opacity: 0; transform: scale(1.6); } }
.calib-result { margin: 0; min-height: 40px; text-align: center; color: var(--ink); line-height: 1.4; }

/* tutorial */
.tuto-text { margin: 0; min-height: 48px; font-size: 18px; font-weight: 600; line-height: 1.35; text-align: center; }
.tuto-board { --cols: 3; --rows: 3; flex: 1; min-height: 0; }
.tuto-feedback { margin: 0; min-height: 24px; text-align: center; font-weight: 700; letter-spacing: .06em; }
.tuto-feedback.ok { color: var(--green); }
.tuto-feedback.bad { color: var(--red); }

/* privacy */
.prose { display: grid; gap: 12px; line-height: 1.55; color: var(--ink); }
.prose p { margin: 0; }

/* share modal */
.modal { position: absolute; inset: 0; z-index: 35; display: grid; place-items: center; padding: 16px; background: rgba(2, 8, 14, .88); }
.modal-card { display: grid; gap: 10px; padding: 14px; width: min(360px, 100%); }
.modal-card img { width: 100%; height: auto; display: block; user-select: auto; -webkit-user-select: auto; -webkit-touch-callout: default; }
#tuto-step { white-space: nowrap; min-width: 52px; }
.note.credits { text-transform: none; letter-spacing: .02em; line-height: 1.5; }
@media (max-height: 700px) {
  #menu .menu-hero { display: none; }
  #menu { gap: 8px; }
  .hud { height: 76px; }
  .gauge svg { height: 52px; }
  .hud-score { font-size: 34px; }
  .bottom-hud { height: 62px; }
  .radar { height: 58px; }
  .tactical { font-size: 10.5px; line-height: 1.15; }
  .tactical dt { font-size: 12px; margin-bottom: 0; }
}

/* iPhone & installable web app */
html, body { touch-action: manipulation; }
#app { -webkit-touch-callout: none; -webkit-user-select: none; }
.install { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.35; color: var(--ink); background: var(--holo-dim); border-left: 2px solid var(--holo); }
.install span { flex: 1; min-width: 0; }
.install b { color: var(--holo); }
.icon-btn.small-x { width: 28px; height: 28px; font-size: 20px; line-height: 1; flex: none; }
.toggle:disabled { opacity: .35; cursor: not-allowed; }

/* world leaderboard */
.event-card { display: grid; gap: 5px; padding: 12px 14px; }
.event-card .frame-svg .line, .event-card .frame-svg .tick { stroke: var(--gold); }
.event-card .label { color: var(--gold); }
.event-main { font-family: var(--font-display); font-size: 20px; letter-spacing: .06em; text-transform: uppercase; }
.event-sub { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.board-list li.gap { display: block; background: none; border: 0; padding: 0 14px; color: var(--muted); text-align: center; }
.over-online { margin: 0; font-size: 14px; line-height: 1.4; color: var(--holo); }
.over-online.ok { color: var(--green); }
.over-online.bad { color: var(--warn); }
.name-set { display: flex; gap: 6px; align-items: center; }
.name-set input { width: 9.5em; font: inherit; font-weight: 700; color: var(--ink); background: var(--panel); border: 1px solid var(--holo); padding: 7px 9px; user-select: text; -webkit-user-select: text; }

/* home: chosen mode, opens the « Modes de jeu » page */
.mode-pick { display: grid; gap: 2px; text-align: left; padding: 9px 14px; background: transparent; border: 0; cursor: pointer; color: inherit; font: inherit; }
.mode-pick-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mode-pick-go { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--holo); }
.mode-pick b { font-family: var(--font-display); font-size: 17px; letter-spacing: .1em; text-transform: uppercase; color: var(--green); text-shadow: 0 0 8px var(--green); }
.mode-pick .mode-rule { margin: 0; min-height: 0; text-align: left; font-size: 12.5px; line-height: 1.3; }

/* « Modes de jeu » page */
.mode-list { display: grid; gap: 10px; }
.mode-list .mode { padding: 12px 14px; gap: 3px; }
.mode-list .mode b { font-size: 16px; }
.mode-list .mode span { font-size: 13px; }

/* one world leaderboard: a row per player, tap = profile */
.board-hint { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.board-list li.open { cursor: pointer; }
.board-list li.open:active { background: var(--holo-dim); }
.board-list li.open::after { content: "›"; grid-column: 4; color: var(--muted); font-size: 20px; }
.board-list li.open { grid-template-columns: 30px 1fr auto 10px; }

/* player profile */
.prof-head { display: grid; justify-items: center; gap: 2px; padding: 16px 14px; text-align: center; }
.prof-total { font-family: var(--font-display); font-size: 46px; font-weight: 800; color: var(--ink); text-shadow: 0 0 14px var(--glow); }
.prof-sub { font-size: 12.5px; color: var(--muted); }
.prof-modes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.prof-mode { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; padding: 10px 14px; }
.prof-mode .pm-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .1em; text-transform: uppercase; }
.prof-mode .pm-info { grid-row: 2; font-size: 12px; color: var(--muted); }
.prof-mode .pm-score { grid-row: 1 / 3; grid-column: 2; font-family: var(--font-display); font-size: 26px; font-weight: 800; }
.prof-mode.none { opacity: .45; }
.prof-modes li.empty { display: block; color: var(--muted); }

/* startup animation: logo flash + scan bar, gone in 0.9 s, never catches taps */
.splash { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; gap: 14px; background: var(--bg); pointer-events: none; animation: splash-out .25s ease-in .65s forwards; }
.splash-logo { font-family: var(--font-display); font-weight: 800; font-size: clamp(40px, 13vw, 64px); letter-spacing: .08em; text-transform: uppercase; color: var(--ink); text-shadow: 0 0 18px var(--glow); animation: splash-in .45s cubic-bezier(.2,.8,.2,1) both; }
.splash-logo .t-red { color: var(--red); text-shadow: 0 0 18px var(--red); }
.splash-bar { display: block; height: 3px; width: 0; margin: 0 auto; background: var(--holo); box-shadow: 0 0 10px var(--holo); animation: splash-bar .55s ease-out .1s forwards; }
@keyframes splash-in { 0% { opacity: 0; transform: scale(1.25); filter: blur(6px); letter-spacing: .4em; } 60% { opacity: 1; filter: blur(0); } 100% { opacity: 1; transform: none; letter-spacing: .08em; } }
@keyframes splash-bar { to { width: 70%; } }
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .splash { display: none; } }

/* shop: unlock conditions and music */
.item .cond { font-size: 11.5px; font-weight: 600; line-height: 1.3; color: var(--warn); }
.item .cond.ok { color: var(--green); }
.item.blocked .preview { opacity: .55; }
.preview-music { display: grid; grid-template-columns: 1fr; place-items: center; font-size: 30px; color: var(--holo); text-shadow: 0 0 10px var(--glow); }

/* update available */
.update-bar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 40; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--green); box-shadow: 0 0 16px color-mix(in srgb, var(--green) 40%, transparent); backdrop-filter: blur(6px); }
.update-bar span { flex: 1; font-size: 13.5px; line-height: 1.3; }
.update-bar b { color: var(--green); }

/* ---------- interface polish ---------- */
/* press feedback on every tappable card */
.mode, .mode-pick, .item, .daily, .board-list li.open, .rank-badge { transition: transform .12s ease, filter .12s ease; }
.mode:active, .mode-pick:active, .item:active, .daily:active, .rank-badge:active { transform: scale(.97); filter: brightness(1.25); }
.board-list li.open:active { transform: scale(.985); }
.btn { transition: transform .12s ease, background .12s ease, filter .12s ease; }
/* settings sections */
.set-title { margin: 6px 2px -4px; font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; color: var(--holo); opacity: .85; }
.set-row > span:first-child { min-width: 0; }
/* game over: centred hero score */
.over-head { text-align: center; }
.over-head .over-sub { margin-inline: auto; }
#over .over-score-row { flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; }
#over .over-score-row .label { display: block; }
#over .over-score { font-size: 104px; }
#over .over-side { justify-items: center; text-align: center; padding-bottom: 0; }
.over-online:not([hidden]) { padding: 10px 12px; background: var(--panel); border-left: 2px solid currentColor; }
/* world podium */
.board-list li.top1 { border-left-color: var(--gold); background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 16%, transparent), var(--panel) 60%); }
.board-list li.top2 { border-left-color: #d7dee8; background: linear-gradient(90deg, rgba(215,222,232,.12), var(--panel) 60%); }
.board-list li.top3 { border-left-color: #e09a5c; background: linear-gradient(90deg, rgba(224,154,92,.13), var(--panel) 60%); }
.board-list li.top1 .rank { color: var(--gold); text-shadow: 0 0 8px var(--gold); }
.board-list li.top2 .rank { color: #d7dee8; text-shadow: 0 0 8px rgba(215,222,232,.7); }
.board-list li.top3 .rank { color: #e09a5c; text-shadow: 0 0 8px rgba(224,154,92,.7); }
.board-list li.me .who { color: var(--green); }
@media (prefers-reduced-motion: reduce) { .mode:active, .mode-pick:active, .item:active, .daily:active, .rank-badge:active, .board-list li.open:active { transform: none; } }
.menu-actions .btn:not(.btn-go) { display: flex; align-items: center; justify-content: center; white-space: nowrap; padding-inline: 8px; }
/* home: demo board one third smaller, the rest of the menu stays centred */
#menu .menu-top { margin-bottom: auto; }
#menu .menu-actions { margin-bottom: auto; }
#menu .menu-hero { max-height: 240px; }
#menu .demo { max-height: 100px; }

/* ---------- more tile shapes (shop) ---------- */
#app[data-shape="pilule"]  .tile { clip-path: inset(8% round 40%); }
#app[data-shape="goutte"]  .tile { clip-path: polygon(50% 0, 72% 30%, 88% 55%, 85% 78%, 70% 93%, 50% 98%, 30% 93%, 15% 78%, 12% 55%, 28% 30%); }
#app[data-shape="diamant"] .tile { clip-path: polygon(20% 8%, 80% 8%, 98% 35%, 50% 96%, 2% 35%); }
#app[data-shape="coeur"]   .tile { clip-path: polygon(50% 95%, 8% 55%, 2% 35%, 6% 18%, 20% 6%, 35% 6%, 50% 20%, 65% 6%, 80% 6%, 94% 18%, 98% 35%, 92% 55%); }
#app[data-shape="fleche"]  .tile { clip-path: polygon(50% 2%, 96% 48%, 68% 48%, 68% 98%, 32% 98%, 32% 48%, 4% 48%); }
#app[data-shape="pixel"]   .tile { clip-path: polygon(0 20%, 20% 20%, 20% 0, 80% 0, 80% 20%, 100% 20%, 100% 80%, 80% 80%, 80% 100%, 20% 100%, 20% 80%, 0 80%); }
#app[data-shape="goutte"] .tile::after, #app[data-shape="diamant"] .tile::after, #app[data-shape="coeur"] .tile::after, #app[data-shape="fleche"] .tile::after { width: 22%; }
#app[data-shape="goutte"] .tile .timer, #app[data-shape="diamant"] .tile .timer, #app[data-shape="coeur"] .tile .timer, #app[data-shape="fleche"] .tile .timer, #app[data-shape="pilule"] .tile .timer, #app[data-shape="pixel"] .tile .timer { bottom: 22%; left: 30%; right: 30%; }

/* ---------- campaign ---------- */
.menu-actions .btn-levels { grid-column: 1 / -1; color: var(--gold); gap: 10px; }
.menu-actions .btn-levels .frame-svg .line, .menu-actions .btn-levels .frame-svg .tick { stroke: var(--gold); }
.lv-count { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--ink); opacity: .85; }
.lv-stars { font-family: var(--font-display); font-weight: 700; color: var(--gold); text-shadow: 0 0 8px var(--gold); font-size: 14px; }
.world-tabs { flex: none; }
.world-tabs .tab.locked { opacity: .45; }
.world-name { margin: 0; font-size: 13px; color: var(--muted); letter-spacing: .04em; }
.lv-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.lv-tile { aspect-ratio: 1; display: grid; place-items: center; align-content: center; gap: 2px; padding: 4px; cursor: pointer; color: var(--ink);
  background: color-mix(in srgb, var(--lv) 14%, var(--panel)); border: 1px solid var(--lv); box-shadow: inset 0 0 12px color-mix(in srgb, var(--lv) 30%, transparent);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px); transition: transform .12s ease, filter .12s ease; }
.lv-tile b { font-family: var(--font-display); font-size: 22px; font-weight: 800; color: var(--lv); text-shadow: 0 0 10px var(--lv); }
.lv-tile .lv-st { font-size: 11px; letter-spacing: .05em; color: var(--gold); }
.lv-tile.full { box-shadow: inset 0 0 18px color-mix(in srgb, var(--gold) 45%, transparent); }
.lv-tile.locked { filter: grayscale(.85) brightness(.6); }
.lv-tile.locked b { font-size: 16px; text-shadow: none; }
.lv-tile.locked .lv-st { color: var(--muted); }
.lv-tile:active { transform: scale(.94); }
.lvd-head { display: grid; justify-items: center; gap: 4px; padding: 18px 16px; text-align: center; }
.lvd-name { font-family: var(--font-display); font-size: 24px; letter-spacing: .08em; text-transform: uppercase; color: var(--holo); text-shadow: 0 0 12px var(--glow); }
.lvd-mode { font-size: 13px; color: var(--muted); line-height: 1.35; }
.lvd-stars { font-size: 18px; color: var(--gold); letter-spacing: .1em; text-shadow: 0 0 8px var(--gold); }
.lvd-quests { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lvd-quests li { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px; padding: 11px 14px; }
.lvd-quests .q-mark { color: var(--gold); font-size: 16px; }
.lvd-quests .q-text { font-size: 14px; line-height: 1.3; }
.lvd-quests .q-reward { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--gold); }
.lvd-quests li.done .q-mark, .lvd-quests li.done .q-reward { color: var(--green); }
.lvd-quests li.done .frame-svg .line { stroke: var(--green); }
.lvd-theme { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.4; text-align: center; }
#over-missions li.ok { color: var(--green); }
#over-missions li.ko { color: var(--muted); }

/* difficulty (modes page) */
.diff-box { display: grid; gap: 8px; padding: 12px 14px; }
.diff-seg { justify-content: flex-start; }
.diff-seg button { flex: 1 1 auto; }
.diff-seg button[data-diff="hardcore"][aria-pressed="true"] { border-color: var(--warn); color: var(--warn); }
.diff-seg button[data-diff="impossible"][aria-pressed="true"] { border-color: var(--red); color: var(--red); }
.diff-note { margin: 0; font-size: 12.5px; color: var(--muted); }

/* ---------- tidy menus ---------- */
/* home: Jouer, Niveaux, then one row of three */
#menu .menu-actions { grid-template-columns: repeat(3, 1fr); }
#menu .menu-actions .btn-go, #menu .menu-actions .btn-levels { grid-column: 1 / -1; }
#menu .menu-actions .btn:not(.btn-go):not(.btn-levels) { font-size: 12px; padding-inline: 4px; letter-spacing: .06em; }
#menu .menu-actions .pill { margin-left: 4px; }
#daily-pill { margin: 0 8px 0 0; vertical-align: 1px; }
/* modes page: duel card in the theme colour */
.duel-card .label { color: var(--holo); }
.duel-card .frame-svg .line, .duel-card .frame-svg .tick { stroke: var(--holo); }
#modes-screen .daily { width: 100%; }
/* shop: every tab visible on two rows, compact cards */
#shop-tabs { display: grid; grid-template-columns: repeat(3, 1fr); overflow: visible; gap: 0 2px; flex: none; }
#shop-tabs .tab { padding: 9px 4px; }
.shop-list .item { padding: 10px; gap: 5px; }
.shop-list .preview { height: 44px; padding: 6px; }
.shop-list .preview-shape span { width: 32px; height: 32px; }
.shop-list .item .name { font-size: 13.5px; }
.set-select { max-width: 55%; font: inherit; font-size: 13px; font-weight: 700; color: var(--ink); background: var(--panel); border: 1px solid var(--holo); padding: 7px 8px; }
.set-select option { background: var(--bg); color: var(--ink); }
