@font-face {
  font-family: Silkscreen;
  src: url("/fonts/silkscreen-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Silkscreen;
  src: url("/fonts/silkscreen-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
/* The neon accents are PopPop's own gem colours, so menus and balls belong together. */
:root {
  color-scheme: dark;
  --bg: #0a0618;
  --panel: rgba(12, 6, 28, .93);
  --edge: #3a2d6a;
  --dim: #a9a0cf;
  --ink: #f4eeff;
  --cy: #3df4ff;
  --hot: #ff4fd8;
  --yel: #ffe040;
  --grn: #7dff4a;
  --org: #ff9a3c;
  --red: #ff4f6a;
  --vio: #b18bff;
  --mono: "Cascadia Mono", Consolas, monospace;
  --arcade: Silkscreen, "Cascadia Mono", monospace;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { isolation: isolate; overflow-x: clip; margin: 0; min-height: 100svh; display: flex; flex-direction: column; background: var(--bg); color: var(--ink); }
a { color: var(--cy); }
button, input, select { font: inherit; }

/* ---- neon buttons ---------------------------------------------------------------- */
button {
  --c: var(--cy);
  color: var(--c); border: 2px solid var(--c); border-radius: 4px; background: #12072ad9;
  min-height: 44px; padding: .5rem .95rem; cursor: pointer;
  font: 400 .8rem/1.2 var(--arcade); letter-spacing: .06em; text-transform: uppercase;
  transition: background .12s, color .12s, box-shadow .12s, transform .06s;
}
button:hover:not(:disabled) { background: #26105a; color: #fff; box-shadow: 0 0 14px var(--c), inset 0 0 10px color-mix(in srgb, var(--c) 30%, transparent); }
button:active:not(:disabled) { transform: scale(.97); }
button:disabled { opacity: .38; cursor: default; }
button.shot { background: #fff !important; color: #120720 !important; box-shadow: 0 0 22px #fff !important; }
button.alt { --c: var(--hot); }
button.warm { --c: var(--yel); }
button.go { --c: var(--grn); }
button.ghost { --c: var(--dim); border-color: #4a3a90; }
button.primary { color: #120720; background: var(--c); box-shadow: 0 0 16px color-mix(in srgb, var(--c) 60%, transparent); }
button.primary:hover:not(:disabled) { color: #120720; background: #fff; }
:focus-visible { outline: 2px solid var(--yel); outline-offset: 3px; }
input, select {
  display: block; width: 100%; min-height: 44px; padding: .58rem .75rem; margin: 0 0 1rem;
  border: 2px solid #4a3a90; border-radius: 4px; background: #05010e; color: #fff;
}
input:focus, select:focus { border-color: var(--yel); box-shadow: 0 0 8px var(--yel); outline: none; }
h1, h2, p { margin: 0; }
h2 { font: 700 clamp(.95rem, 2.8vw, 1.42rem)/1.25 var(--arcade); text-wrap: balance; }

/* ---- layers: nebula, stars, glow, particles, flash, CRT ----------------------------- */
#backdrop, #stars, #ambient, #effects, #glow, #flash, #crt { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#backdrop { z-index: -3; image-rendering: pixelated; transition: opacity .45s ease; }
#stars { z-index: -2; image-rendering: pixelated; }
#ambient {
  z-index: -1; opacity: 0; background-color: #5547b4;
  mask-image: radial-gradient(ellipse 51% 65% at 50% 59%, #000 2%, #000b 41%, transparent 100%);
  mix-blend-mode: screen;
  transition: opacity .35s ease, background-color .72s ease;
}
body.in-game #backdrop { opacity: .93; }
body.in-game #ambient { opacity: .26; }
#effects { z-index: 3; image-rendering: pixelated; }
/* Under the pixel layer, so the gems flying to the score stay crisp on top of the glow. */
#glow { z-index: 2; mix-blend-mode: screen; }
#flash { z-index: 5; opacity: 0; background: #fff; mix-blend-mode: screen; }

/* Scanlines, a phosphor mask and edge falloff. CRT FX: 0 off, 1 low, 2 high. */
#crt {
  z-index: 4;
  background:
    radial-gradient(ellipse at center, transparent 49%, #05021128 83%, #05021164),
    repeating-linear-gradient(to bottom, transparent 0 2px, #08021231 2px 3px, #0904130f 3px 4px),
    repeating-linear-gradient(90deg, #ff64af09 0 1px, #7af9eb04 1px 2px, #8074ff09 2px 3px);
}
html[data-crt="0"] #crt { display: none; }
html[data-crt="2"] #crt {
  background:
    radial-gradient(ellipse at center, transparent 42%, #0502114a 78%, #050211a8),
    repeating-linear-gradient(to bottom, transparent 0 2px, #0802125c 2px 3px, #0904131c 3px 4px),
    repeating-linear-gradient(90deg, #ff64af14 0 1px, #7af9eb0a 1px 2px, #8074ff14 2px 3px);
  animation: crt-flicker 4.2s steps(1) infinite;
}
@keyframes crt-flicker { 0%, 100% { opacity: 1; } 37% { opacity: .9; } 38% { opacity: 1; } 71% { opacity: .94; } 72% { opacity: 1; } }
@media (prefers-contrast: more), (forced-colors: active) {
  #crt, #flash { display: none; }
}

/* ---- top bar ------------------------------------------------------------------------ */
.topbar, footer { width: min(100% - 3.5rem, 76rem); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: .65rem; }
.topbar { padding: 1rem 0; }
.brand {
  display: flex; gap: .65rem; align-items: center; text-decoration: none; text-transform: uppercase; color: var(--ink);
  font: 400 .79rem var(--arcade); letter-spacing: .025em;
}
.brand:hover, footer a:hover { color: var(--cy); }
.brand-mark {
  width: 15px; height: 15px; background: var(--cy); box-shadow: 0 0 16px var(--cy);
  clip-path: polygon(0 0, 53% 0, 53% 18%, 18% 18%, 18% 82%, 53% 82%, 53% 100%, 0 100%,
  0 0, 100% 0, 100% 38%, 82% 38%, 82% 18%, 63% 18%, 63% 0);
}
.toolbar { display: flex; gap: .5rem; }
.toolbar button { font-size: .74rem; white-space: nowrap; background: #0a0418cc; }
#account { --c: var(--hot); }
#sound { display: flex; align-items: center; gap: .48rem; --c: var(--dim); }
#sound[aria-pressed="true"] { --c: var(--cy); }
.sound-mark { position: relative; display: inline-block; width: 13px; height: 12px; background: currentColor;
  clip-path: polygon(0 33%, 28% 33%, 63% 0, 63% 100%, 28% 67%, 0 67%, 0 33%, 76% 10%, 98% 10%, 98% 90%, 76% 90%, 76% 10%); }
main { flex: 1; display: grid; width: min(100% - 3.5rem, 73rem); margin: 0 auto; align-items: center; }
footer { justify-content: center; padding: .8rem 0 1rem; font-size: .78rem; gap: 1rem; }
footer a { color: var(--dim); text-underline-offset: 3px; }

/* ---- title screen ------------------------------------------------------------------- */
.home { display: grid; justify-items: center; text-align: center; gap: 1.1rem; padding: clamp(0rem, 2vh, 2rem) 0 1rem; }
.title-block { position: relative; display: grid; justify-items: center; isolation: isolate; padding-top: clamp(.5rem, 4vh, 3rem); }
#hero-art {
  position: absolute; z-index: -1; left: 50%; top: 50%; transform: translate(-50%, -54%);
  width: min(42rem, 118vw); height: auto; image-rendering: pixelated; pointer-events: none; opacity: .78;
  mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 52%, transparent 74%);
}
#title {
  display: flex; align-items: center; font: 700 clamp(3.6rem, 12vw, 8.6rem)/.95 var(--arcade);
  letter-spacing: -.07em; padding: 0 .1em .12em 0; white-space: nowrap;
}
#title span {
  display: inline-block; color: #f6e6ff;
  background: linear-gradient(#fff7f2 20%, #ffdcf5 54%, #ff7fe3 57%, #b372ed 96%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #8d2d9e) drop-shadow(0 5px 0 #3a1460) drop-shadow(0 0 14px #ff4fd8a0) drop-shadow(0 0 32px #ff4fd855);
  padding: .05em .065em .14em .01em; margin-right: -.035em;
  animation: wave 2.4s ease-in-out infinite; animation-delay: calc(var(--i) * -.18s);
}
#title span:nth-child(1) { --i: 0; } #title span:nth-child(2) { --i: 1; } #title span:nth-child(3) { --i: 2; }
#title span:nth-child(4) { --i: 3; } #title span:nth-child(5) { --i: 4; } #title span:nth-child(6) { --i: 5; }
#title span:nth-child(n + 4) {
  background-image: linear-gradient(#ecfaff 20%, #c8f4ff 54%, #3df4ff 57%, #6b7cff 95%);
  filter: drop-shadow(0 3px 0 #2a5fae) drop-shadow(0 5px 0 #192a6b) drop-shadow(0 0 14px #3df4ffa0) drop-shadow(0 0 32px #3df4ff55);
}
@keyframes wave { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-.07em); } }
.tagline {
  color: var(--yel); font: 400 clamp(.72rem, 1.9vw, 1rem) var(--arcade); letter-spacing: .18em; text-transform: uppercase;
  text-shadow: 0 0 10px var(--hot), 2px 2px 0 #400040; margin-top: .2rem;
}
.menu { display: grid; gap: .8rem; width: min(100%, 46rem); }
.primary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.mode-button {
  display: grid; align-content: center; justify-items: center; gap: .32rem; min-height: 6.2rem; padding: .8rem .6rem;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 16%, #0b0420e0), #0b0420e6 70%);
  box-shadow: 0 0 14px color-mix(in srgb, var(--c) 45%, transparent), inset 0 0 22px color-mix(in srgb, var(--c) 14%, transparent);
}
.mode-button strong { font: 700 clamp(1.25rem, 3.2vw, 1.75rem)/1 var(--arcade); letter-spacing: .1em; text-shadow: 0 0 12px var(--c); }
.mode-button small { color: #d8d0f2; font: 500 .74rem/1.3 system-ui, sans-serif; letter-spacing: .02em; text-transform: none; }
.mode-button:hover:not(:disabled) { background: linear-gradient(180deg, color-mix(in srgb, var(--c) 30%, #12062a), #160a36 80%); transform: translateY(-2px); }
.mode-button.hot { --c: var(--hot); }
.mode-button.yel { --c: var(--yel); }
.mode-button.grn { --c: var(--grn); }
.secondary { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; }
.secondary button { --c: #9d8fe0; flex: 1 1 7rem; min-height: 40px; font-size: .72rem; background: #0a0418c4; }
.secondary #settings { --c: var(--cy); }
.marquee {
  width: min(100%, 46rem); display: grid; gap: .2rem; padding: .55rem .8rem;
  background: #05000cb0; border-block: 1px solid #ff4fd844;
  font: 400 .72rem/1.5 var(--arcade); letter-spacing: .08em; text-transform: uppercase;
}
#daily-line { color: var(--hot); text-shadow: 0 0 8px #ff4fd877; }
#best-line { color: #fff; }
.notice { color: var(--dim); font-size: .9rem; }
.home .notice:empty { display: none; }
.flash-note { color: #9f97c2; font-size: .74rem; max-width: 36rem; }
.reduced-effects .flash-note { display: none; }

/* ---- play screen -------------------------------------------------------------------- */
.play { --play-size: clamp(22rem, min(69svh, 50vw), 40rem); width: 100%; margin: 0 auto; }
.play-header {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); place-items: center;
  gap: .5rem; margin: 0 auto .85rem; width: min(100%, calc(var(--play-size) + 3.5rem));
}
.play-header h2 { text-align: center; color: var(--yel); letter-spacing: .14em; text-transform: uppercase; text-shadow: 0 0 10px var(--hot), 2px 2px 0 #400040; }
#menu { justify-self: start; display: flex; align-items: center; gap: .52rem; }
.menu-mark { width: 10px; height: 13px; border-left: 3px solid currentColor; border-right: 3px solid currentColor; }
#seed-copy { --c: var(--dim); justify-self: end; font: 700 .7rem var(--mono); white-space: nowrap; text-transform: none; letter-spacing: 0; }
.play-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, var(--play-size)) minmax(0, 1fr); align-items: center; gap: clamp(.65rem, 2.55vw, 2.4rem); will-change: transform; }
.center-stage { min-width: 0; }
.hud { min-width: 0; display: grid; gap: 1rem; padding-bottom: 1rem; }
.score-box span, .counters span, .next span {
  display: block; color: var(--cy); font: 400 .74rem var(--arcade); letter-spacing: .1em; text-transform: uppercase;
}
.score-box { min-width: 0; container-type: inline-size; }
.score-box span { margin-bottom: .23rem; }
.score-box strong {
  --score-size: clamp(1.9rem, 4.1vw, 4.4rem);
  --score-ems: 1;
  display: block; width: fit-content; max-width: 100%; white-space: nowrap; color: #fff;
  font: 700 min(var(--score-size), calc(100cqi / var(--score-ems)))/1.12 var(--arcade);
  letter-spacing: -.075em; font-variant-numeric: tabular-nums;
  --pulse: 0;
  text-shadow: 0 2px 0 #4b1a6e, 0 0 calc(14px + var(--pulse) * 18px) #ff4fd8aa, 0 0 calc(32px + var(--pulse) * 30px) #3df4ff55;
  color: color-mix(in srgb, var(--yel) calc(min(var(--pulse), 1) * 85%), #fff);
  transform: scale(calc(1 + var(--pulse) * .13));
  transform-origin: left 66%;
}
.counters { display: grid; gap: .5rem; max-width: 12.25rem; }
.counters > div {
  display: flex; min-height: 43px; align-items: center; justify-content: space-between; gap: .4rem; padding: .35rem .72rem;
  border: 2px solid #3df4ff55; border-radius: 4px; background: #0a0418c8; box-shadow: inset 0 0 12px #3df4ff14;
}
.counters span { overflow-wrap: anywhere; }
.counters strong { font: 700 1.14rem var(--arcade); font-variant-numeric: tabular-nums; white-space: nowrap; color: #fff; }
.counters > div.warn { border-color: var(--red); box-shadow: 0 0 14px #ff4f6a88; animation: warn .5s steps(2) infinite; }
.counters > div.warn span, .counters > div.warn strong { color: var(--red); }
@keyframes warn { 50% { box-shadow: 0 0 2px #ff4f6a44; } }

/* Rival boards: one for a duel, up to three in a party. Slot colours as in PewPew. */
#rivals { display: grid; gap: .5rem; }
#rivals[data-count="2"], #rivals[data-count="3"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rival {
  --c: var(--hot); position: relative; min-width: 0; width: min(100%, 10rem); padding: .4rem .45rem .45rem;
  border: 2px solid var(--c); border-radius: 4px; background: #0a0418d0; box-shadow: 0 0 10px color-mix(in srgb, var(--c) 40%, transparent);
}
.rival[data-slot="1"] { --c: var(--org); } .rival[data-slot="2"] { --c: var(--grn); }
.rival h3 { margin: 0; color: var(--c); font: 700 .72rem var(--arcade); overflow-wrap: anywhere; text-transform: uppercase; }
.rival p { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .1rem .4rem; margin: .1rem 0 .3rem;
  color: var(--dim); font: 400 .62rem var(--arcade); text-transform: uppercase; }
.rival p strong { color: #fff; font-variant-numeric: tabular-nums; }
.rival canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.rival .tag { position: absolute; top: -.62rem; right: .35rem; padding: 0 .3rem; background: var(--c); color: #120720;
  font: 700 .55rem/1.35 var(--arcade); letter-spacing: .06em; text-transform: uppercase; border-radius: 2px; }
.rival.out { opacity: .42; filter: grayscale(.8); }
.rival.hit { animation: hit .4s ease-out; }
@keyframes hit { 25% { transform: translateX(-3px); box-shadow: 0 0 22px var(--c); } 60% { transform: translateX(2px); } }

.next {
  width: min(100%, 27rem); min-height: 46px; margin: 0 auto .55rem;
  display: flex; justify-content: center; align-items: center; gap: clamp(.35rem, 1vw, .8rem);
  border: 2px solid #ff4fd866; border-radius: 4px; padding: .16rem .75rem .16rem .95rem;
  background: #0a0418cc; box-shadow: 0 0 12px #ff4fd833, inset 0 0 14px #ff4fd81a;
}
.next span { color: var(--hot); }
#next { display: block; image-rendering: pixelated; width: min(78%, 17rem); height: auto; }
.board { position: relative; width: 100%; aspect-ratio: 1; touch-action: none; filter: drop-shadow(0 12px 26px #060514a2); }
.board::before {
  content: ''; position: absolute; inset: 0; border-radius: 8.3%; pointer-events: none;
  box-shadow: 0 0 0 2px #3df4ff55, 0 0 22px #3df4ff40, 0 0 60px #ff4fd826;
}
#board, #board-post { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }
#board.composited { opacity: 0; }
#cells { position: absolute; inset: 3.125%; display: grid; grid-template: repeat(6, 1fr) / repeat(6, 1fr); touch-action: none; }
#cells button { min-height: 0; min-width: 0; padding: 0; border: none; border-radius: 50%; background: transparent; box-shadow: none; transform: none; touch-action: none; }
#cells button:hover:not(:disabled) { background: transparent; box-shadow: none; }
#cells button:focus-visible { outline-offset: -2px; }
#countdown {
  position: absolute; inset: 2.6%; display: grid; place-items: center; border-radius: 8%; background: #0a0418c4;
  color: var(--yel); font: 700 clamp(3rem, 14vw, 8rem) var(--arcade); text-shadow: 0 0 18px var(--hot), 0 0 40px var(--hot), 4px 4px 0 #400040;
  pointer-events: none;
}
#countdown.go { color: var(--grn); text-shadow: 0 0 18px var(--grn), 0 0 44px var(--grn), 4px 4px 0 #0b3a10; background: transparent; }
#countdown span { display: block; animation: count .9s ease-out both; }
@keyframes count { 0% { transform: scale(1.9); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 100% { transform: scale(.85); opacity: .9; } }

/* Big neon words over the board: NICE!, COMBO x3, LOCKED. */
#banner { position: absolute; inset: 0 0 auto; height: 46%; display: grid; place-items: end center; pointer-events: none; z-index: 2; }
.banner-item {
  grid-area: 1 / 1; display: grid; justify-items: center; gap: .15rem; text-align: center;
  animation: banner var(--banner-ms, 1100ms) cubic-bezier(.2, .9, .3, 1.2) both;
}
.banner-item strong {
  color: var(--banner); font: 700 calc(var(--banner-size, 1) * clamp(1.6rem, 6.4vw, 3.4rem))/1 var(--arcade); letter-spacing: .04em;
  white-space: nowrap; text-shadow: 3px 3px 0 #1a0530, -2px -2px 0 #1a0530, 0 0 14px var(--banner), 0 0 36px var(--banner);
}
.banner-item small { color: #fff; font: 400 clamp(.62rem, 1.8vw, .85rem) var(--arcade); letter-spacing: .12em; text-transform: uppercase; text-shadow: 2px 2px 0 #1a0530, 0 0 10px var(--banner); }
@keyframes banner {
  0% { transform: scale(2.2) rotate(-6deg); opacity: 0; }
  14% { transform: scale(.92) rotate(2deg); opacity: 1; }
  24% { transform: scale(1.04) rotate(-1deg); }
  32%, 74% { transform: scale(1) rotate(0); opacity: 1; }
  100% { transform: translateY(-28%) scale(.96); opacity: 0; }
}
.reduced-effects .banner-item { animation-name: banner-still; }
@keyframes banner-still { 0% { opacity: 0; } 12%, 78% { opacity: 1; } 100% { opacity: 0; } }

.action-rail { display: grid; align-content: center; gap: .72rem; min-width: 0; }
.controls { display: grid; gap: .55rem; }
.controls button { --c: var(--hot); display: flex; align-items: center; text-align: left; gap: .55rem; min-height: 50px; width: 100%; font-size: .78rem; }
.controls b { color: currentColor; font-size: 1.38rem; line-height: 1; font-family: system-ui; }
#replay-controls button { --c: var(--cy); }
#results { --c: var(--yel); }
kbd { margin-left: auto; font: 700 .73rem var(--mono); color: var(--dim); border: 1px solid #a47ab35e; border-radius: .28rem; padding: .08rem .27rem; }
.play .notice { min-height: 4.4em; }
.play .notice.has-preview { color: var(--yel); }

/* ---- panels (dialogs) --------------------------------------------------------------- */
.panel {
  color: var(--ink); background: var(--panel); border: 2px solid var(--cy); border-radius: 4px;
  box-shadow: 0 0 24px #3df4ff59, inset 0 0 40px #ff4fd814, 0 22px 60px #000c;
}
dialog { padding: clamp(.85rem, 3.2vw, 1.45rem); width: min(36rem, calc(100% - 1.5rem)); max-height: calc(100% - 1.5rem); }
dialog::backdrop { background: #04000ccc; backdrop-filter: blur(3px); }
.panel::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, #0802121c 2px 3px, transparent 3px 4px);
}
html[data-crt="0"] .panel::after { display: none; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; border-bottom: 1px solid #2a2060; padding-bottom: .65rem; margin-bottom: .9rem; }
.dialog-head h2 { color: var(--yel); letter-spacing: .16em; text-transform: uppercase; text-shadow: 0 0 10px var(--hot), 2px 2px 0 #400040; }
#close { --c: var(--dim); min-width: 44px; padding: .2rem; font: 700 1rem var(--arcade); }
#dialog-body > * + * { margin-top: .8rem; }
#dialog-body form label { display: block; color: var(--cy); margin: .6rem 0 .25rem; font: 400 .72rem var(--arcade); text-transform: uppercase; letter-spacing: .08em; }
#dialog-body h3 { margin: .2rem 0 .4rem; color: var(--cy); font: 700 .8rem var(--arcade); letter-spacing: .14em; text-transform: uppercase; border-bottom: 1px solid #2a2060; padding-bottom: .25rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.result-score { color: #fff; font: 700 2.5rem/1.16 var(--arcade); letter-spacing: -.045em; text-shadow: 0 0 14px var(--hot), 0 0 30px #3df4ff66; }
.inline-link { display: inline-flex; align-items: center; }

/* Short menus (game menu, attack choices): big icon buttons. */
.panel:has(.arcade-actions) { width: min(24rem, calc(100% - 2rem)); }
.arcade-actions { display: grid; gap: .65rem; padding-bottom: .2rem; }
.arcade-actions button { display: grid; grid-template-columns: 1rem minmax(0, 1fr); align-items: center; gap: .75rem; min-height: 50px; text-align: left; font-size: .86rem; }
.arcade-actions button::before { content: ''; width: 1rem; aspect-ratio: 1; background: currentColor; }
.arcade-actions [data-icon="leave"] { --c: var(--red); }
.arcade-actions [data-icon="settings"] { --c: var(--vio); }
[data-icon="play"]::before {
  clip-path: polygon(12.5% 6.25%, 31.25% 6.25%, 31.25% 18.75%, 50% 18.75%, 50% 31.25%, 68.75% 31.25%,
    68.75% 43.75%, 87.5% 43.75%, 87.5% 56.25%, 68.75% 56.25%, 68.75% 68.75%, 50% 68.75%,
    50% 81.25%, 31.25% 81.25%, 31.25% 93.75%, 12.5% 93.75%);
}
[data-icon="vision"]::before, [data-icon="settings"]::before {
  clip-path: polygon(evenodd, 25% 0, 75% 0, 75% 25%, 100% 25%, 100% 75%, 75% 75%, 75% 100%, 25% 100%,
    25% 75%, 0 75%, 0 25%, 25% 25%, 25% 0, 37.5% 37.5%, 37.5% 62.5%, 62.5% 62.5%, 62.5% 37.5%, 37.5% 37.5%);
}
[data-icon="leave"]::before {
  clip-path: polygon(37.5% 0, 100% 0, 100% 100%, 37.5% 100%, 37.5% 81.25%, 81.25% 81.25%, 81.25% 18.75%,
    37.5% 18.75%, 37.5% 31.25%, 56.25% 31.25%, 56.25% 43.75%, 0 43.75%, 0 56.25%, 56.25% 56.25%,
    56.25% 68.75%, 37.5% 68.75%, 37.5% 81.25%, 25% 81.25%, 25% 18.75%, 37.5% 18.75%);
}
[data-icon="find"]::before {
  clip-path: polygon(evenodd, 25% 0, 75% 0, 75% 12.5%, 87.5% 12.5%, 87.5% 25%, 100% 25%, 100% 75%,
    87.5% 75%, 87.5% 87.5%, 75% 87.5%, 75% 100%, 25% 100%, 25% 87.5%, 12.5% 87.5%, 12.5% 75%, 0 75%,
    0 25%, 12.5% 25%, 12.5% 12.5%, 25% 12.5%, 25% 0, 25% 25%, 25% 75%, 75% 75%, 75% 25%, 25% 25%);
}
[data-icon="friend"]::before {
  clip-path: polygon(12.5% 6.25%, 43.75% 6.25%, 43.75% 43.75%, 56.25% 43.75%, 56.25% 18.75%, 87.5% 18.75%,
    87.5% 50%, 100% 50%, 100% 81.25%, 62.5% 81.25%, 62.5% 93.75%, 0 93.75%, 0 56.25%, 12.5% 56.25%);
}
[data-icon="bot"]::before {
  clip-path: polygon(43.75% 0, 56.25% 0, 56.25% 25%, 87.5% 25%, 87.5% 37.5%, 100% 37.5%, 100% 75%,
    87.5% 75%, 87.5% 93.75%, 12.5% 93.75%, 12.5% 75%, 0 75%, 0 37.5%, 12.5% 37.5%, 12.5% 25%, 43.75% 25%);
}

/* Solo: one big row per mode, like PewPew's difficulty list. */
.panel:has(.mode-list), .panel:has(.mode-cards), .panel:has(.settings-list), .panel:has(.friend-lobby) { width: min(44rem, calc(100% - 1.5rem)); }
.mode-list { display: grid; gap: .55rem; }
.mode-list button {
  display: grid; grid-template-columns: minmax(7.5rem, auto) minmax(0, 1fr) auto; align-items: center; gap: .3rem 1rem;
  min-height: 4.2rem; text-align: left; padding: .6rem .9rem;
}
.mode-list strong { font: 700 1.05rem var(--arcade); letter-spacing: .1em; text-shadow: 0 0 10px var(--c); }
.mode-list span { color: #d8d0f2; font: 400 .66rem/1.5 var(--arcade); letter-spacing: .04em; }
.mode-list em { color: var(--dim); font: normal 400 .62rem var(--arcade); text-align: right; white-space: nowrap; }
.mode-list button:hover:not(:disabled) span, .mode-list button:hover:not(:disabled) em { color: #fff; }

/* Online: a card per mode. */
.mode-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.mode-card {
  --c: var(--cy); display: grid; align-content: start; gap: .45rem; padding: .75rem; border: 2px solid var(--c); border-radius: 4px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 12%, #08031a), #08031a 70%);
  box-shadow: 0 0 12px color-mix(in srgb, var(--c) 35%, transparent);
}
#dialog-body .mode-card h3 { margin: 0; padding: 0; border: 0; color: var(--c); font: 700 1.1rem var(--arcade); letter-spacing: .12em; text-transform: uppercase; text-shadow: 0 0 10px var(--c); }
.mode-card .chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.mode-card .chips span { color: #120720; background: var(--c); padding: .05rem .35rem; border-radius: 2px; font: 700 .56rem/1.5 var(--arcade); letter-spacing: .06em; text-transform: uppercase; }
.mode-card p { color: #d8d0f2; font-size: .82rem; line-height: 1.4; min-height: 2.8em; }
.mode-card .actions button { --c: inherit; flex: 1 1 auto; min-height: 40px; padding-inline: .55rem; font-size: .66rem; }
.mode-card .actions button:first-child { color: #120720; background: var(--c); border-color: var(--c); }
.mode-card .actions button:first-child:hover:not(:disabled) { background: #fff; color: #120720; }
.mode-card .actions button:not(:first-child) { color: var(--c); border-color: var(--c); }

/* Settings: one shootable row per setting, as in PewPew. */
.settings-list { display: grid; gap: .45rem; }
.settings-list button { display: flex; justify-content: space-between; align-items: center; gap: 1rem; min-height: 48px; text-align: left; }
.settings-list button b { color: #fff; font-weight: 400; }
.settings-list button[data-on="false"] b { color: var(--dim); }
.settings-list .hint { color: var(--dim); font-size: .78rem; }

/* Waiting for players. */
.queue { display: flex; justify-content: center; gap: .5rem; margin: .4rem 0; }
.queue i { width: 1.1rem; height: 1.1rem; border: 2px solid var(--grn); border-radius: 2px; }
.queue i.on { background: var(--grn); box-shadow: 0 0 10px var(--grn); }
.searching { color: var(--grn); font: 400 .8rem var(--arcade); letter-spacing: .1em; text-transform: uppercase; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.reduced-effects .searching { animation: none; }

/* Match results. */
.standings { list-style: none; padding: 0; display: grid; gap: 2px; }
.standings li { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) auto; align-items: center; gap: .6rem; padding: .45rem .65rem; background: #ffffff08; font: 400 .78rem var(--arcade); text-transform: uppercase; }
.standings li b { font-weight: 700; }
.standings li.p1 b { color: #ffd23a; } .standings li.p2 b { color: #d0d8e8; } .standings li.p3 b { color: #e0884a; }
.standings li.me { background: #3df4ff1c; box-shadow: inset 3px 0 var(--cy); }
.standings li.out { opacity: .5; }
.standings li strong { color: #fff; font-variant-numeric: tabular-nums; }

.friend-lobby { display: grid; gap: .8rem; }
.friend-modes { display: flex; flex-wrap: wrap; gap: .4rem; }
.friend-modes button { flex: 1; min-height: 40px; font-size: .7rem; --c: var(--dim); }
.friend-modes button[aria-pressed="true"] { --c: var(--grn); color: #120720; background: var(--grn); }
.friend-list { display: grid; gap: .35rem; max-height: 10rem; overflow-y: auto; list-style: none; margin: 0; padding: .25rem; }
.friend-list li {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .38rem .6rem;
  padding: .3rem .5rem; border: 1px solid #2a2060; border-radius: 2px; background: #0a0418;
}
.friend-list li > span { overflow-wrap: anywhere; font-weight: 650; }
.friend-list li small { color: var(--grn); font: 400 .62rem var(--arcade); text-transform: uppercase; margin-left: .4rem; }
.friend-list li.linked-invite { border-color: var(--hot); background: #2a0d3c; }
.friend-list button { font-size: .66rem; padding-inline: .55rem; min-height: 38px; }
.friend-links { display: flex; flex-wrap: wrap; gap: .4rem .85rem; font-size: .82rem; }
.palette-options { min-width: 0; padding: 0; border: 0; display: grid; gap: .45rem; }
.palette-options legend { padding: 0 0 .35rem; color: var(--dim); font-size: .83rem; }
.palette-option { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; padding: .6rem .65rem;
  border: 2px solid #2a2060; border-radius: 4px; background: #0a0418; cursor: pointer; }
.palette-option:has(input:checked) { border-color: var(--cy); box-shadow: 0 0 10px #3df4ff55; }
.palette-option input { width: 1rem; min-height: 0; margin: 0; accent-color: var(--cy); }
.palette-option > span:nth-child(2) { flex: 1; min-width: max-content; }
.swatches { display: flex; gap: .2rem; margin-left: auto; }
.swatches i { width: .73rem; height: .73rem; border-radius: 50%; border: 1px solid #fff4; }

/* Leaderboards: PewPew's tab bar. */
.board-categories, .board-dates { display: grid; gap: .38rem; }
.board-categories { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.board-dates { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.board-categories button, .board-dates button { --c: var(--dim); padding-inline: .3rem; font-size: .68rem; border-color: #4a3a90; }
.board-dates button { display: grid; justify-items: center; align-content: center; gap: .05rem; min-height: 48px; }
.board-dates button span, .board-date-label { color: var(--dim); font-size: .62rem; font-weight: 500; }
.board-date-label { margin-bottom: .4rem; font: 400 .66rem var(--arcade); text-transform: uppercase; }
.board-categories button[aria-pressed="true"], .board-dates button[aria-pressed="true"] {
  --c: var(--cy); color: #120720; background: var(--cy); box-shadow: 0 0 14px var(--cy);
}
.board-dates button[aria-pressed="true"] span { color: #120720; }
@media (max-width: 460px) {
  .board-dates { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.scores, .badges { list-style: none; padding: 0; }
.scores li, .badges li { display: flex; align-items: center; gap: .65rem; justify-content: space-between; padding: .55rem .5rem; border-bottom: 1px solid #1e1648; }
.scores li:nth-child(-n + 3) span:first-child { color: var(--yel); }
.scores li span:first-child { flex: 1; overflow-wrap: anywhere; }
.scores li strong, .badges strong { color: var(--yel); }
.scores li button { --c: var(--yel); min-height: 36px; padding: .2rem .7rem; font-size: .64rem; }
.badges li { border: 1px solid #2a2060; margin-bottom: .35rem; opacity: .55; }
.badges li:not(.locked) { opacity: 1; border-color: var(--yel); }
.badges small { color: var(--dim); display: block; }
.badges .locked strong { color: var(--dim); }

@media (max-width: 880px) {
  .play { --play-size: clamp(22rem, min(69svh, 53vw), 34rem); }
  .play-layout { column-gap: .7rem; }
  .controls button { padding-inline: .55rem; gap: .33rem; }
}
@media (max-width: 720px) {
  .topbar, footer, main { width: min(100% - 1.45rem, 34rem); }
  .topbar { padding: .6rem 0; }
  .home { gap: .85rem; }
  #title { font-size: clamp(3.1rem, 17vw, 5.75rem); }
  .primary { grid-template-columns: minmax(0, 1fr); }
  .mode-button { min-height: 4.2rem; grid-template-columns: auto minmax(0, 1fr); justify-items: start; text-align: left; column-gap: .9rem; }
  .mode-button strong { min-width: 5.5ch; }
  .mode-cards { grid-template-columns: minmax(0, 1fr); }
  .mode-list button { grid-template-columns: minmax(0, 1fr) auto; }
  .mode-list span { grid-column: 1 / -1; grid-row: 2; }
  .play { padding: .25rem 0 0; }
  .play-header { width: 100%; margin-bottom: .5rem; }
  .play-header button { padding-inline: .47rem; }
  .play-layout { grid-template-columns: minmax(0, 1fr); gap: .56rem; }
  .hud { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); align-items: center; gap: .6rem; padding: 0 .15rem; }
  .score-box strong { --score-size: clamp(1.45rem, 6.4vw, 2.7rem); }
  .score-box span, .counters span { font-size: clamp(.55rem, 2.1vw, .69rem); letter-spacing: .055em; }
  .counters { display: flex; justify-content: end; gap: .24rem; max-width: none; min-width: 0; }
  .counters > div { flex: 0 1 5.5rem; min-width: 0; justify-content: center; align-items: center; flex-direction: column; padding: .22rem .28rem; gap: .08rem; }
  .counters strong { font-size: clamp(.94rem, 4vw, 1.13rem); }
  #rivals { grid-column: 1 / -1; display: flex !important; gap: .35rem; justify-content: center; }
  #rivals[hidden] { display: none !important; }
  .rival { flex: 1 1 0; width: auto; max-width: 9rem; padding: .25rem .32rem; display: grid; grid-template-columns: minmax(0, 1fr) 2.6rem; column-gap: .3rem; align-items: center; }
  .rival h3 { font-size: .58rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; }
  .rival p { margin: 0; font-size: .54rem; }
  .rival canvas { grid-column: 2; grid-row: 1 / span 2; }
  .center-stage { width: min(100%, 29rem); margin: auto; }
  .next { margin-bottom: .28rem; min-height: 37px; }
  #next { width: min(100%, 13rem); }
  .action-rail { gap: .5rem; }
  .controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #replay-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .play .notice { min-height: 2.8em; text-align: center; }
}
@media (max-width: 460px) {
  .brand { font-size: .66rem; gap: .4rem; letter-spacing: 0; }
  .toolbar button { font-size: .64rem; padding-inline: .53rem; }
  .secondary button { flex-basis: 30%; font-size: .64rem; padding-inline: .3rem; }
  .board-categories { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 380px) {
  .brand { font-size: .60rem; letter-spacing: .015em; gap: .35rem; }
  .toolbar { gap: .24rem; }
  .toolbar button { font-size: .62rem; padding-inline: .43rem; }
  #seed-copy { font-size: .62rem; }
}
.reduced-effects #title span, .reduced-effects #countdown span, html.reduced-effects #crt { animation: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
