/* Arcadia — base styles, layout chrome, modals, controls, toasts, footer */
:root {
  --bg: #0b0221; --bg2: #1c0b3f; --fg: #f6f0ff; --muted: #a596d8;
  --c0: #ff2bd6; --c1: #19f0ff; --c2: #ffe14d; --c3: #39ff88; --c4: #ff8a1f; --c5: #a274ff;
  --bg-rgb: 11,2,33; --bg2-rgb: 28,11,63; --fg-rgb: 246,240,255;
  --c0-rgb: 255,43,214; --c1-rgb: 25,240,255; --c2-rgb: 255,225,77; --c3-rgb: 57,255,136; --c4-rgb: 255,138,31; --c5-rgb: 162,116,255;
  --font: ui-monospace, "Cascadia Mono", "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.2,.8,.2,1);
  --radius: 14px;
  --top-h: 60px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; font-size: clamp(14px, 0.35vw + 12.5px, 19px); scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; color: var(--fg); font-family: var(--font); line-height: 1.55;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(var(--c5-rgb), .22), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(var(--c0-rgb), .10), transparent 60%),
    var(--bg);
  overflow-x: hidden;
  transition: background-color .4s;
}
body.modal-open { overflow: hidden; }
a { color: var(--c1); text-underline-offset: 3px; }
a:hover { color: var(--c2); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--c2); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.px-svg { display: block; height: 1.6em; width: auto; max-width: 100%; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--c2); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-weight: 700; text-decoration: none; transition: top .2s; }
.skip-link:focus { top: 12px; }
.noscript { position: fixed; inset: auto 0 0 0; padding: 16px; text-align: center; background: var(--c0); color: var(--bg); font-weight: 700; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font-weight: 700; font-size: .86rem; letter-spacing: .08em; text-transform: uppercase; line-height: 1;
  padding: .85em 1.25em; min-height: 44px; border: 0; border-radius: 8px; text-decoration: none;
  color: var(--fg); background: rgba(var(--fg-rgb), .06);
  box-shadow: inset 0 0 0 2px rgba(var(--fg-rgb), .32), 0 4px 0 rgba(0,0,0,.45);
  transition: transform .12s var(--ease), box-shadow .15s, background .2s, color .2s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:hover { background: rgba(var(--c1-rgb), .14); box-shadow: inset 0 0 0 2px var(--c1), 0 4px 0 rgba(0,0,0,.45), 0 0 20px rgba(var(--c1-rgb), .35); color: var(--fg); }
.btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--c1), 0 1px 0 rgba(0,0,0,.45); }
.btn-primary { background: var(--c0); color: var(--bg); box-shadow: 0 4px 0 rgba(0,0,0,.5), 0 0 26px rgba(var(--c0-rgb), .45); }
.btn-primary:hover { background: var(--c2); color: var(--bg); box-shadow: 0 4px 0 rgba(0,0,0,.5), 0 0 30px rgba(var(--c2-rgb), .55); }
.btn-primary:active { box-shadow: 0 1px 0 rgba(0,0,0,.5); }
.btn-ghost { background: transparent; box-shadow: inset 0 0 0 2px rgba(var(--fg-rgb), .18); color: var(--muted); }
.btn-danger { box-shadow: inset 0 0 0 2px rgba(var(--c4-rgb), .8), 0 4px 0 rgba(0,0,0,.45); color: var(--c4); }
.btn-danger:hover { background: rgba(var(--c4-rgb), .16); box-shadow: inset 0 0 0 2px var(--c4), 0 4px 0 rgba(0,0,0,.45); color: var(--fg); }
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border: 0; border-radius: 10px;
  background: rgba(var(--fg-rgb), .06); box-shadow: inset 0 0 0 2px rgba(var(--fg-rgb), .16); color: var(--fg);
  transition: background .2s, box-shadow .2s, transform .12s; -webkit-tap-highlight-color: transparent; flex: none;
}
.icon-btn:hover { background: rgba(var(--c1-rgb), .16); box-shadow: inset 0 0 0 2px var(--c1); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg, .nav-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg .fill { fill: currentColor; stroke: none; }
.icon-btn[aria-pressed="true"]:not(.btn-mute) { color: var(--c2); box-shadow: inset 0 0 0 2px var(--c2); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.btn-mute .i-off { display: none; }
.btn-mute[aria-pressed="true"] .i-on { display: none; }
.btn-mute[aria-pressed="true"] .i-off { display: block; }
.btn-mute[aria-pressed="true"] { color: var(--c4); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 12px;
  padding: 0 clamp(12px, 3vw, 40px); padding-top: env(safe-area-inset-top);
  background: rgba(var(--bg-rgb), .72); backdrop-filter: blur(12px) saturate(140%); -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid rgba(var(--fg-rgb), .08);
}
.logo { display: flex; align-items: center; color: var(--c0); text-decoration: none; margin-right: auto; padding: 6px 4px; }
.logo .logo-svg { height: 26px; filter: drop-shadow(0 0 6px rgba(var(--c0-rgb), .8)) drop-shadow(2px 2px 0 rgba(var(--c1-rgb), .7)); transition: transform .2s var(--ease); }
.logo:hover .logo-svg { transform: skewX(-6deg) scale(1.04); }
.logo-fallback { font-weight: 800; letter-spacing: .2em; }
.nav { display: flex; gap: 6px; align-items: center; }
.nav-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; min-height: 44px; border: 0; border-radius: 10px;
  background: transparent; color: var(--fg); font-size: .82rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; text-decoration: none;
  transition: background .2s, color .2s;
}
.nav-btn:hover { background: rgba(var(--c1-rgb), .12); color: var(--c1); }
.nav-toggle { display: none; }
@media (max-width: 860px) {
  .nav-toggle { display: inline-grid; order: 3; }
  .nav {
    position: absolute; top: calc(var(--top-h) + env(safe-area-inset-top)); right: 10px; left: 10px; flex-direction: column; align-items: stretch;
    padding: 10px; border-radius: 14px; background: rgba(var(--bg2-rgb), .97); box-shadow: 0 18px 50px rgba(0,0,0,.5), inset 0 0 0 2px rgba(var(--c1-rgb), .35);
    transform-origin: top right; transform: scale(.96) translateY(-8px); opacity: 0; visibility: hidden; transition: transform .2s var(--ease), opacity .2s, visibility .2s;
  }
  .nav.open { transform: none; opacity: 1; visibility: visible; }
  .nav-btn { justify-content: flex-start; font-size: .95rem; }
}

/* ---------- about & footer ---------- */
.about { padding: clamp(40px, 7vw, 90px) clamp(16px, 4vw, 48px); position: relative; }
.about-grid { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 1.5fr 1fr; gap: clamp(20px, 4vw, 48px); align-items: start; }
.px-title { margin: 0 0 18px; color: var(--c2); }
.px-title .px-svg { height: clamp(22px, 3.2vw, 34px); filter: drop-shadow(0 0 8px rgba(var(--c2-rgb), .5)); }
.px-title.small .px-svg { height: 20px; }
.about-copy p { color: rgba(var(--fg-rgb), .86); max-width: 62ch; }
.feature-list { list-style: none; padding: 0; margin: 18px 0; display: grid; gap: 10px; }
.feature-list li { padding: 12px 14px 12px 40px; position: relative; border-radius: 10px; background: rgba(var(--fg-rgb), .04); box-shadow: inset 0 0 0 1px rgba(var(--fg-rgb), .08); }
.feature-list li::before { content: ""; position: absolute; left: 14px; top: 18px; width: 12px; height: 12px; background: var(--c3); box-shadow: 0 0 10px var(--c3); }
.feature-list b { color: var(--c1); }
.hint { color: var(--muted); font-size: .85rem; }
.maker-card { padding: 24px; border-radius: var(--radius); background: linear-gradient(160deg, rgba(var(--c0-rgb), .14), rgba(var(--c1-rgb), .06)), rgba(var(--bg2-rgb), .7); box-shadow: inset 0 0 0 2px rgba(var(--c0-rgb), .45), 0 0 40px -10px rgba(var(--c0-rgb), .6); }
.maker-name { font-size: 1.5rem; font-weight: 800; margin: 0 0 6px; color: var(--fg); text-shadow: 0 0 14px rgba(var(--c0-rgb), .6); }
.maker-card p { color: rgba(var(--fg-rgb), .85); }
.maker-links, .credit-links { list-style: none; padding: 0; margin: 14px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.maker-links a, .credit-links a { display: inline-block; padding: 8px 14px; border-radius: 999px; text-decoration: none; font-weight: 700; font-size: .85rem; color: var(--fg); background: rgba(var(--fg-rgb), .06); box-shadow: inset 0 0 0 2px rgba(var(--c1-rgb), .45); transition: background .2s, color .2s, transform .15s; }
.maker-links a:hover, .credit-links a:hover { background: var(--c1); color: var(--bg); transform: translateY(-2px); }
.more-link { display: inline-block; font-weight: 800; color: var(--c2); text-decoration: none; margin-top: 4px; }
.more-link:hover { text-decoration: underline; }
.site-footer { padding: 40px clamp(16px, 4vw, 48px) calc(40px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(var(--fg-rgb), .08); background: rgba(0,0,0,.18); text-align: center; }
.footer-inner { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.credit { margin: 0; font-size: 1rem; }
.credit strong { color: var(--c0); }
.gratitude { margin: 12px 0 0; color: rgba(var(--fg-rgb), .7); font-size: .82rem; font-style: italic; max-width: 60ch; }
.fine { margin: 6px 0 0; color: var(--muted); font-size: .75rem; }
@media (max-width: 760px) { .about-grid { grid-template-columns: 1fr; } }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 14px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); opacity: 0; transition: opacity .25s; }
.modal-card {
  position: relative; width: min(600px, 100%); max-height: min(88vh, 900px); overflow: auto; overscroll-behavior: contain;
  border-radius: 16px; background: linear-gradient(180deg, rgba(var(--c1-rgb), .07), transparent 140px), var(--bg2);
  box-shadow: inset 0 0 0 2px rgba(var(--c1-rgb), .5), 0 30px 80px rgba(0,0,0,.6), 0 0 60px -18px var(--c1);
  transform: translateY(14px) scale(.97); opacity: 0; transition: transform .28s var(--ease), opacity .25s;
}
.modal-card.wide { width: min(880px, 100%); }
.modal.show .modal-backdrop { opacity: 1; }
.modal.show .modal-card { transform: none; opacity: 1; }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; background: rgba(var(--bg2-rgb), .96); border-bottom: 1px solid rgba(var(--fg-rgb), .08); }
.modal-head .px-title { margin: 0; }
.modal-close { font-size: 1.1rem; }
.modal-body { padding: 18px; display: grid; gap: 16px; }
.set-group { border: 0; margin: 0; padding: 14px; border-radius: 12px; background: rgba(var(--fg-rgb), .04); box-shadow: inset 0 0 0 1px rgba(var(--fg-rgb), .08); display: grid; gap: 10px; }
.set-group legend { float: left; width: 100%; padding: 0 0 6px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; font-size: .78rem; color: var(--c1); }
.set-note { margin: 0; color: var(--muted); font-size: .82rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 560px) { .theme-grid { grid-template-columns: repeat(2, 1fr); } }
.theme-card { position: relative; display: grid; gap: 6px; cursor: pointer; }
.theme-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tc-screen { display: grid; align-content: center; gap: 5px; height: 64px; padding: 10px; border-radius: 10px; background: var(--tb); box-shadow: inset 0 0 0 2px rgba(255,255,255,.12); transition: transform .15s, box-shadow .2s; }
.tc-screen i { display: block; height: 6px; border-radius: 3px; }
.tc-screen i:nth-child(1) { background: var(--t0); width: 80%; }
.tc-screen i:nth-child(2) { background: var(--t1); width: 55%; }
.tc-screen i:nth-child(3) { background: var(--t2); width: 68%; }
.tc-name { font-size: .78rem; font-weight: 700; text-align: center; color: rgba(var(--fg-rgb), .85); }
.theme-card:hover .tc-screen { transform: translateY(-2px); }
.theme-card input:checked + .tc-screen { box-shadow: inset 0 0 0 3px var(--tf), 0 0 18px -2px var(--t0); }
.theme-card input:focus-visible + .tc-screen { outline: 3px solid var(--c2); outline-offset: 3px; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 36px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sw { position: relative; flex: none; width: 46px; height: 26px; border-radius: 99px; background: rgba(var(--fg-rgb), .16); box-shadow: inset 0 0 0 2px rgba(var(--fg-rgb), .2); transition: background .2s; }
.sw::after { content: ""; position: absolute; top: 4px; left: 4px; width: 18px; height: 18px; border-radius: 4px; background: var(--fg); transition: transform .2s var(--ease), background .2s; }
.switch input:checked + .sw { background: var(--c3); }
.switch input:checked + .sw::after { transform: translateX(20px); background: var(--bg); }
.switch input:focus-visible + .sw { outline: 3px solid var(--c2); outline-offset: 3px; }
.sub-switches { display: grid; gap: 4px; padding-left: 14px; border-left: 2px solid rgba(var(--fg-rgb), .1); transition: opacity .2s; }
.sub-switches.disabled { opacity: .45; }
.range, .select { display: grid; gap: 6px; font-size: .88rem; }
.range input { width: 100%; accent-color: var(--c0); min-height: 28px; }
.select select { min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 0; background: var(--bg); color: var(--fg); box-shadow: inset 0 0 0 2px rgba(var(--fg-rgb), .2); }
.select select:focus-visible { outline: 3px solid var(--c2); }

/* ---------- score tables & achievements ---------- */
.score-table { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; counter-reset: none; }
.score-table li { display: grid; grid-template-columns: 2.4em 1fr auto auto; align-items: center; gap: 12px; padding: 7px 12px; border-radius: 8px; background: rgba(var(--fg-rgb), .04); font-variant-numeric: tabular-nums; }
.score-table li:nth-child(1) .rk { color: var(--c2); }
.score-table li:nth-child(2) .rk { color: var(--c1); }
.score-table li:nth-child(3) .rk { color: var(--c4); }
.score-table .rk { font-weight: 800; color: var(--muted); }
.score-table .nm { font-weight: 800; letter-spacing: .25em; color: var(--fg); }
.score-table .sc { font-weight: 800; color: var(--c3); text-align: right; }
.score-table .dt { color: var(--muted); font-size: .75rem; min-width: 4.5em; text-align: right; }
.score-table li.hl { background: rgba(var(--c0-rgb), .25); box-shadow: inset 0 0 0 2px var(--c0); animation: hl-blink 1s steps(2) 4; }
.score-table li.empty { display: block; text-align: center; padding: 22px 12px; color: var(--muted); background: transparent; border: 2px dashed rgba(var(--fg-rgb), .16); }
.score-table.big li { padding: 10px 14px; }
@keyframes hl-blink { 50% { background: rgba(var(--c0-rgb), .05); } }
.ach-count { margin: 0; font-weight: 700; color: var(--c2); }
.ach-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.ach { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; background: rgba(var(--fg-rgb), .04); box-shadow: inset 0 0 0 1px rgba(var(--fg-rgb), .08); opacity: .62; }
.ach.got { opacity: 1; background: linear-gradient(135deg, rgba(var(--c2-rgb), .14), transparent); box-shadow: inset 0 0 0 2px rgba(var(--c2-rgb), .55); }
.ach-ico { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; background: rgba(var(--fg-rgb), .08); color: var(--muted); }
.ach.got .ach-ico { background: var(--c2); color: var(--bg); box-shadow: 0 0 16px rgba(var(--c2-rgb), .55); }
.ach-ico .px-svg { height: 22px; }
.ach-txt { display: grid; gap: 2px; }
.ach-txt b { font-size: .92rem; }
.ach-txt small { color: rgba(var(--fg-rgb), .75); font-size: .78rem; }
.ach-txt em { color: var(--c3); font-style: normal; font-size: .72rem; }

/* ---------- toasts & fx ---------- */
.toasts { position: fixed; z-index: 80; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; width: min(460px, calc(100vw - 24px)); pointer-events: none; }
body.has-pad .toasts { bottom: auto; top: 70px; }
.toast { pointer-events: auto; padding: 12px 16px; border-radius: 12px; font-size: .86rem; font-weight: 700; color: var(--fg); background: rgba(var(--bg2-rgb), .96); box-shadow: inset 0 0 0 2px var(--c1), 0 12px 30px rgba(0,0,0,.5); animation: toast-in .35s var(--ease); }
.toast.ach { box-shadow: inset 0 0 0 2px var(--c2), 0 12px 30px rgba(0,0,0,.5), 0 0 24px -4px var(--c2); }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity .4s, transform .4s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.rain-coin { position: absolute; top: -40px; width: 24px; height: 24px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.75), transparent 35%), var(--c2); box-shadow: inset 0 0 0 3px rgba(0,0,0,.2), 0 0 12px var(--c2); animation: coin-rain 2s linear forwards; }
@keyframes coin-rain { to { transform: translateY(112vh) rotateY(900deg); } }
body.tilt #main { animation: tilt .6s steps(6); }
@keyframes tilt { 0%,100% { transform: none; } 20% { transform: translate(-10px, 3px) rotate(-1deg); } 40% { transform: translate(9px, -2px) rotate(1deg); } 60% { transform: translate(-6px, 1px); } 80% { transform: translate(4px, 0); } }

/* ---------- reduced motion ---------- */
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
.reduce-motion { scroll-behavior: auto; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
