/* Hanging! Synthwave colors, arcade HUD, crime-scene touches. Board colors come from body[data-board]. */
:root {
  --bg: #0d0221;
  --ink: #f6eaff;
  --dim: #c9b8e6;
  --cyan: #3df5ff;
  --pink: #ff3ea5;
  --gold: #ffd23f;
  --good: #3dff9e;
  --bad: #ff4d6d;
  --sq-light: #2b1658;
  --sq-dark: #170a35;
  --wp: #e9fdff;
  --bp: #ff5fb8;
  --po: #12062b;
  --pixel: 'Press Start 2P', monospace;
  --board: min(calc(100vw - 24px), calc(100dvh - 320px - env(safe-area-inset-top) - env(safe-area-inset-bottom)), 560px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; }
body {
  font-family: Orbitron, system-ui, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }

/* Background: sun and a scrolling neon floor */
/* Background: a synthwave flight toward the sun. The floor scrolls toward you, the sun's stripes drift, stars twinkle. */
#sky { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; --horizon: 62%; }
#stars {
  position: absolute; left: 0; right: 0; top: 0; height: var(--horizon);
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff, transparent), radial-gradient(1px 1px at 28% 42%, #ffd6f3, transparent),
    radial-gradient(1.5px 1.5px at 47% 12%, #fff, transparent), radial-gradient(1px 1px at 63% 33%, #c9fbff, transparent),
    radial-gradient(1.5px 1.5px at 81% 22%, #fff, transparent), radial-gradient(1px 1px at 92% 48%, #ffd6f3, transparent),
    radial-gradient(1px 1px at 6% 55%, #c9fbff, transparent), radial-gradient(1.5px 1.5px at 37% 64%, #fff, transparent),
    radial-gradient(1px 1px at 73% 8%, #fff, transparent), radial-gradient(1px 1px at 55% 52%, #fff, transparent);
  animation: twinkle 3.2s ease-in-out infinite alternate; opacity: .7;
}
@keyframes twinkle { to { opacity: .25; } }
#sun {
  position: absolute; left: 50%; top: var(--horizon); width: min(78vw, 340px); aspect-ratio: 1; transform: translate(-50%, -62%); border-radius: 50%;
  background: linear-gradient(#ffe66b 0%, #ffb347 30%, #ff7a59 55%, #ff3ea5 85%);
  -webkit-mask: repeating-linear-gradient(to bottom, #000 0 16px, transparent 16px 22px);
  mask: repeating-linear-gradient(to bottom, #000 0 16px, transparent 16px 22px);
  -webkit-mask-size: 100% 22px; mask-size: 100% 22px;
  clip-path: inset(0 0 38% 0);
  animation: sunbands 2.2s linear infinite, sunglow 4s ease-in-out infinite alternate;
  opacity: .5;
}
@keyframes sunbands { to { -webkit-mask-position: 0 22px; mask-position: 0 22px; } }
@keyframes sunglow { from { filter: drop-shadow(0 0 18px rgba(255,62,165,.6)); } to { filter: drop-shadow(0 0 40px rgba(255,122,89,.9)); } }
#sky::after {
  content: ""; position: absolute; left: 0; right: 0; top: var(--horizon); height: 2px; margin-top: -1px;
  background: #ff3ea5; box-shadow: 0 0 18px 4px rgba(255,62,165,.8);
}
#floor {
  position: absolute; left: -60%; right: -60%; top: var(--horizon); bottom: -10%;
  background-color: #0d0221;
  background-image: linear-gradient(rgba(255,62,165,.85) 2px, transparent 2px), linear-gradient(90deg, rgba(255,62,165,.85) 2px, transparent 2px);
  background-size: 60px 60px;
  transform: perspective(300px) rotateX(68deg); transform-origin: top;
  -webkit-mask: linear-gradient(to bottom, transparent 0%, #000 22%); mask: linear-gradient(to bottom, transparent 0%, #000 22%);
  opacity: .7; animation: floor .8s linear infinite;
}
@keyframes floor { from { background-position: 0 0, 0 0; } to { background-position: 0 60px, 0 0; } }
body.playing #sky { opacity: .55; transition: opacity .4s; }
body.fast #floor { animation-duration: .4s; opacity: .85; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 30; pointer-events: none; }

#app {
  position: relative; z-index: 1; height: 100%;
  padding: calc(env(safe-area-inset-top) + 10px) 12px calc(env(safe-area-inset-bottom) + 14px);
  max-width: 600px; margin: 0 auto;
}
.screen { display: none; height: 100%; flex-direction: column; align-items: center; gap: 12px; }
.screen.on { display: flex; }
#menu { overflow-y: auto; padding-bottom: 20px; }

.topbar { width: 100%; display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 22px; border: 1px solid rgba(61,245,255,.45);
  background: rgba(13,2,33,.5); color: var(--cyan); display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.modelabel { font-family: var(--pixel); font-size: 10px; color: var(--dim); text-align: center; line-height: 1.7; }
.topright { display: flex; gap: 10px; }
.tb3 { display: grid; grid-template-columns: 1fr auto 1fr; }
.tb3 .topright { justify-self: end; }
#mark[aria-pressed="true"] { color: var(--gold); border-color: var(--gold); box-shadow: 0 0 12px rgba(255,210,63,.5); }
#mark[aria-pressed="true"] svg { fill: var(--gold); }
#mark.pop { animation: pop .35s; }
#saved-list { color: var(--ink); }
#saved-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 0; border-bottom: 1px solid rgba(201,184,230,.12); }
#saved-list li .sv-name { flex: 1 1 100%; }
#saved-list li .sv-name small { color: var(--dim); }
#saved-list a, #saved-list button { font-size: 12px; color: var(--cyan); background: none; border: 1px solid rgba(61,245,255,.4); border-radius: 8px; padding: 4px 10px; text-decoration: none; }
#saved-list button { color: var(--dim); border-color: rgba(201,184,230,.3); }

.logo {
  margin: 8px 0 0; font-family: Monoton, cursive; font-weight: 400; font-size: clamp(44px, 14vw, 72px); line-height: 1;
  color: var(--pink); text-shadow: 0 0 6px var(--pink), 0 0 24px var(--pink), 0 0 48px #b5179e;
  animation: flicker 6s infinite;
}
.logo.small { font-size: clamp(40px, 12vw, 60px); margin-top: 40px; }
@keyframes flicker { 0%, 92%, 100% { opacity: 1; } 93% { opacity: .55; } 94% { opacity: 1; } 96% { opacity: .7; } }
.tag { margin: 0 0 8px; color: var(--dim); font-size: 13px; text-align: center; line-height: 1.5; }

.modes { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.modes[hidden] { display: none; }
.lv-k { font-family: var(--pixel); font-size: 11px; color: var(--gold); text-align: center; margin: 2px 0 4px; }
.mode {
  width: 100%; padding: 16px 18px; border-radius: 18px; border: 2px solid var(--cyan); background: rgba(61,245,255,.08);
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; text-align: left; gap: 2px 10px;
  box-shadow: 0 0 16px rgba(61,245,255,.35), inset 0 0 14px rgba(61,245,255,.12);
  transition: transform .12s;
}
.mode:active { transform: scale(.97); }
.mode.level { border-color: var(--gold); background: rgba(255,210,63,.05); }
.mode[data-mode="daily"] { border-color: var(--gold); box-shadow: 0 0 16px rgba(255,210,63,.35), inset 0 0 14px rgba(255,210,63,.1); background: rgba(255,210,63,.07); }
.mode[data-mode="zen"] { border-color: var(--pink); box-shadow: 0 0 16px rgba(255,62,165,.35), inset 0 0 14px rgba(255,62,165,.1); background: rgba(255,62,165,.07); }
.m-name { font-family: var(--pixel); font-size: 18px; margin-bottom: 6px; }
.m-sub { grid-column: 1; font-size: 12px; color: var(--dim); }
.m-best { grid-row: 1 / 3; grid-column: 2; align-self: center; font-family: var(--pixel); font-size: 10px; color: var(--gold); text-align: right; }

details { width: 100%; border: 1px solid rgba(201,184,230,.25); border-radius: 14px; padding: 10px 14px; background: rgba(13,2,33,.55); }
summary { cursor: pointer; font-size: 13px; letter-spacing: 2px; color: var(--dim); min-height: 28px; display: flex; align-items: center; }
details p { font-family: system-ui, sans-serif; font-size: 14px; line-height: 1.5; color: var(--ink); margin: 8px 0; }
.log ol { list-style: none; margin: 8px 0; padding: 0; font-family: system-ui, sans-serif; font-size: 13px; color: var(--dim); display: flex; flex-direction: column; gap: 6px; }
.small { border: 1px solid var(--dim); background: none; border-radius: 10px; padding: 8px 12px; font-size: 12px; min-height: 36px; }

.hud { width: var(--board); display: flex; justify-content: space-between; align-items: flex-start; }
.hud > div, .resgrid > div { display: flex; flex-direction: column; gap: 6px; }
.hud .hr { align-items: flex-end; }
.resgrid > div { align-items: center; }
.k { font-family: var(--pixel); font-size: 9px; letter-spacing: 1px; color: var(--dim); }
.k.pink { color: var(--pink); }
.v { font-family: var(--pixel); font-size: 18px; color: var(--gold); text-shadow: 0 0 10px rgba(255,210,63,.6); }
.v.white { color: var(--ink); text-shadow: none; }
.v.bump, #combo.bump, #streak.bump { animation: bump .3s; }
@keyframes bump { 40% { transform: scale(1.25); } }
.hud2 { width: var(--board); display: flex; justify-content: space-between; font-family: var(--pixel); font-size: 10px; }
.cyan { color: var(--cyan); text-shadow: 0 0 6px var(--cyan); }
.pink { color: var(--pink); text-shadow: 0 0 6px var(--pink); }
.gold { color: var(--gold); text-shadow: 0 0 6px rgba(255,210,63,.6); }
.ticks { width: var(--board); display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; }
.ticks i { height: 10px; background: rgba(255,255,255,.1); }
.ticks i.on { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.ticks.low i.on { background: var(--bad); box-shadow: 0 0 8px var(--bad); animation: pulse .4s infinite alternate; }
.ticks.zen i { background: rgba(255,62,165,.35); }
@keyframes pulse { to { opacity: .5; } }

#boardwrap { position: relative; width: var(--board); height: var(--board); flex: none; }
#board {
  width: 100%; height: 100%; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  border: 2px solid var(--edge); box-shadow: 0 0 18px var(--edge-glow), inset 0 0 18px var(--edge-glow); background: var(--bg);
}
#board.enter { animation: enter .35s cubic-bezier(.2,1.4,.4,1); }
@keyframes enter { from { transform: scale(.85) rotate(-2deg); opacity: 0; } }
.sq { position: relative; background: var(--sq-dark); box-shadow: inset 0 0 0 .5px var(--grid); }
.sq.l { background: var(--sq-light); }
.sq .coord { position: absolute; font-size: 9px; color: rgba(201,184,230,.55); pointer-events: none; font-family: system-ui, sans-serif; }
.sq .coord.f { right: 2px; bottom: 1px; }
.sq .coord.r { left: 2px; top: 1px; }
.pc { position: absolute; inset: 4%; width: 92%; height: 92%; pointer-events: none; transition: transform .15s; }
.pc.w { filter: drop-shadow(0 0 3px var(--cyan)) drop-shadow(0 0 7px rgba(61,245,255,.6)); }
.pc.b { filter: drop-shadow(0 0 3px var(--pink)) drop-shadow(0 0 7px rgba(255,62,165,.6)); }
.sq.has { cursor: pointer; }
.sq.has:active .pc { transform: scale(.9); }
.sq.hit .pc { animation: pop .35s; }
@keyframes pop { 40% { transform: scale(1.3) rotate(-6deg); } }
.sq.nope .pc { animation: nope .3s; }
@keyframes nope { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.mark { position: absolute; inset: 3px; border-radius: 50%; pointer-events: none; }
.mark.good { border: 3px solid var(--good); box-shadow: 0 0 14px var(--good), inset 0 0 10px var(--good); animation: ring .3s ease-out; }
.mark.pick { border: 3px solid var(--cyan); box-shadow: 0 0 12px var(--cyan); animation: ring .25s ease-out; }
.mark.miss { inset: 1px; border: 3px dashed #ffffff; border-radius: 42% 50% 38% 47%; box-shadow: 0 0 14px var(--bad), inset 0 0 14px rgba(255,77,109,.55); animation: throb .8s infinite alternate; }
.mark.wrong { border-radius: 0; inset: 18%; }
.mark.wrong::before, .mark.wrong::after { content: ""; position: absolute; left: 50%; top: -10%; width: 4px; height: 120%; margin-left: -2px; background: var(--bad); box-shadow: 0 0 8px var(--bad); border-radius: 2px; transform: rotate(45deg); }
.mark.wrong::after { transform: rotate(-45deg); }
@keyframes ring { from { transform: scale(1.6); opacity: 0; } }
@keyframes throb { to { transform: scale(.88); } }

#arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#arrows line { stroke-linecap: round; }
#arrows .att { stroke: var(--bad); stroke-width: 9; opacity: .85; filter: drop-shadow(0 0 4px var(--bad)); }
#arrows .def { stroke: var(--good); stroke-width: 7; stroke-dasharray: 2 16; opacity: .9; }
#arrows .draw { animation: draw .45s ease-out both; }
@keyframes draw { from { stroke-dashoffset: 400; } }

#pop { position: absolute; inset: 0; pointer-events: none; display: flex; align-items: center; justify-content: center; }
.float { position: absolute; font-family: var(--pixel); font-size: 13px; color: var(--good); text-shadow: 0 0 8px var(--good); animation: float .9s ease-out forwards; white-space: nowrap; }
.float.bad { color: var(--bad); text-shadow: 0 0 8px var(--bad); }
@keyframes float { to { transform: translateY(-46px); opacity: 0; } }
.banner {
  position: absolute; font-family: var(--pixel); font-size: clamp(20px, 6.5vw, 32px); padding: 12px 14px; border: 4px solid currentColor;
  background: rgba(13,2,33,.65); box-shadow: 0 0 20px currentColor; color: var(--gold);
  text-shadow: 0 0 8px var(--gold), 0 0 30px #ff7a59; animation: banner .9s cubic-bezier(.2,1.6,.4,1) forwards; white-space: nowrap;
}
.banner.cyan { color: var(--cyan); text-shadow: 0 0 8px var(--cyan), 0 0 30px var(--cyan); }
@keyframes banner { 0% { transform: scale(2.4) rotate(-8deg); opacity: 0; } 22% { transform: scale(1) rotate(-8deg); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(1.05) rotate(-8deg); opacity: 0; } }

.source { margin: 0; font-family: system-ui, sans-serif; font-size: 12px; color: var(--dim); text-align: center; min-height: 16px; }
.source b { color: var(--gold); font-weight: 600; }
.actions { width: var(--board); margin-top: auto; display: flex; gap: 10px; }
.actions.col { flex-direction: column; width: 100%; }
.big {
  font-family: var(--pixel); font-size: 15px !important;
  width: 100%; height: 60px; border-radius: 30px; border: 2px solid var(--cyan); background: rgba(61,245,255,.14);
  color: #e9fdff; font-size: 18px; font-weight: 900; letter-spacing: 4px; box-shadow: 0 0 18px rgba(61,245,255,.55); transition: transform .1s;
}
.big:active { transform: scale(.96); }
.ghost { width: 100%; height: 52px; border-radius: 26px; border: 1px solid var(--dim); background: none; letter-spacing: 3px; }

.sheet {
  overflow-x: hidden;
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; max-width: 600px; margin: 0 auto;
  max-height: 46vh; overflow-y: auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px);
  background: rgba(16,4,40,.94); border-top: 2px solid var(--pink); border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 40px rgba(255,62,165,.35); animation: up .3s ease-out;
}
.sheet[hidden] { display: none; }
@keyframes up { from { transform: translateY(100%); } }
.tape {
  margin: -16px -16px 14px; height: 28px; background: var(--gold); color: #111; font-family: var(--pixel); font-size: 10px;
  display: flex; align-items: center; white-space: nowrap; overflow: hidden; border-radius: 20px 20px 0 0; padding-left: 12px;
  background-image: repeating-linear-gradient(-45deg, transparent 0 14px, rgba(0,0,0,.1) 14px 28px);
}
.sheet h2 { font-family: var(--pixel); margin: 0 0 12px; font-size: 14px; color: var(--pink); }
#review { display: flex; flex-direction: column; }
#review[hidden] { display: none; }
.rv-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.rv-head h2 { margin: 0 !important; }
#rv-toggle { flex: none; font-family: var(--pixel); font-size: 9px; letter-spacing: 1px; }
#review .show-t, #review.min .hide-t, #review.min #rv-list { display: none; }
#review.min .show-t { display: inline; }
#rv-next { flex: none; }
#review #rv-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#review { overflow-y: hidden; }
.sq.flash { animation: flash .9s; }
@keyframes flash { 0%, 50% { box-shadow: inset 0 0 0 4px var(--gold), 0 0 18px var(--gold); } 25%, 75% { box-shadow: inset 0 0 0 4px transparent; } }
#rv-list li[data-sq] { cursor: pointer; }
#rv-list { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 8px; font-family: system-ui, sans-serif; font-size: 14px; line-height: 1.45; }
#rv-list li { padding-left: 22px; position: relative; }
#rv-list li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 10px; height: 10px; border-radius: 50%; }
#rv-list li.miss::before { background: var(--bad); box-shadow: 0 0 6px var(--bad); }
#rv-list li.got::before { background: var(--good); box-shadow: 0 0 6px var(--good); }
#rv-list li.wrong::before { background: var(--dim); }

.newbest { font-family: var(--pixel); font-size: 12px; color: var(--gold); text-shadow: 0 0 10px var(--gold); animation: pulse .6s infinite alternate; }
.bigscore { font-family: var(--pixel); font-size: clamp(30px, 10vw, 48px); margin: 6px 0; color: var(--cyan); text-shadow: 0 0 14px var(--cyan), 0 0 40px var(--cyan); }
.resgrid { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 8px; margin: 10px 0; }
.resgrid .wide { grid-column: 1 / -1; }

#app.shake { animation: shake .35s; }
#app.shake2 { animation: shake2 .5s; }
@keyframes shake { 20% { transform: translate(-5px, 2px); } 40% { transform: translate(5px, -2px); } 60% { transform: translate(-3px, 1px); } 80% { transform: translate(3px, 0); } }
@keyframes shake2 { 15% { transform: translate(-9px, 4px) rotate(-1deg); } 30% { transform: translate(9px, -4px) rotate(1deg); } 50% { transform: translate(-6px, 2px); } 70% { transform: translate(5px, -1px); } 85% { transform: translate(-2px, 0); } }

@media (prefers-reduced-motion: reduce) {
  #floor, .logo, #sun, #stars { animation: none; }
  #app.shake, #app.shake2 { animation: none; }
}
@media (min-width: 700px) {
  :root { --board: min(calc(100dvh - 310px), 560px); }
}

/* Board colors: same neon look, different board. */
body { --edge: var(--pink); --edge-glow: rgba(255,62,165,.6); --grid: rgba(255,62,165,.22); }
body[data-board="midnight"] { --sq-light: #173a5c; --sq-dark: #0a1a30; --edge: var(--cyan); --edge-glow: rgba(61,245,255,.5); --grid: rgba(61,245,255,.2); }
body[data-board="ember"] { --sq-light: #5a2330; --sq-dark: #2a0f19; --edge: #ff7a59; --edge-glow: rgba(255,122,89,.55); --grid: rgba(255,122,89,.2); }
body[data-board="arcade"] { --sq-light: #1d3b1d; --sq-dark: #0b170b; --edge: #39ff14; --edge-glow: rgba(57,255,20,.45); --grid: rgba(57,255,20,.15); }
body[data-board="chalk"] { --sq-light: #3a3b40; --sq-dark: #222327; --edge: #f2f2f2; --edge-glow: rgba(255,255,255,.25); --grid: rgba(255,255,255,.08); }
.settings { width: 100%; border: 1px solid rgba(201,184,230,.25); border-radius: 14px; padding: 14px; background: rgba(13,2,33,.75); display: flex; flex-direction: column; gap: 12px; }
.settings[hidden] { display: none; }
.swatches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: none; padding: 0; font-family: var(--pixel); font-size: 7px; color: var(--dim); }
.swatch b { width: 48px; height: 48px; display: grid; grid-template-columns: 1fr 1fr; border: 2px solid rgba(255,255,255,.15); border-radius: 6px; overflow: hidden; }
.swatch[aria-pressed="true"] b { border-color: var(--gold); box-shadow: 0 0 10px var(--gold); }
.swatch[aria-pressed="true"] { color: var(--gold); }
/* Wide screens: the notes sit beside the board instead of under it */
@media (min-width: 1150px) {
  #review.sheet {
    left: calc(50% + var(--board) / 2 + 24px); right: auto; bottom: auto; top: 150px; margin: 0;
    width: min(380px, calc(50% - var(--board) / 2 - 48px)); max-height: calc(100dvh - 180px) !important;
    border: 2px solid var(--pink); border-radius: 22px; animation: none;
  }
}
