/* Pryzmio Arcade — global stylesheet.
 *
 * Token layer ported from Digibeat / spell DESIGN_SYSTEM.md §1 (the anti-drift rule,
 * invariant 1: every colour, radius, and size comes from :root; components read tokens,
 * never literals). Chunk 0 carries the tokens and the shared chrome; pack skins, the
 * session shell, and the return layer add their own layers on top in later chunks.
 */

:root {
  /* Praise tiers — same meaning everywhere (gold=perfect, cyan=amazing, emerald=great,
     amethyst=good, slate=gentle try-again; never an error red). */
  --gold: #ffd23f;
  --cyan: #36f1cd;
  --emerald: #7ae582;
  --amethyst: #9d8df1;
  --slate: #6c7a89;
  /* Surfaces */
  --bg-0: #070a1c;
  --bg-1: #0e1430;
  --bg-2: #161d44;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(150, 180, 255, 0.18);
  --ink: #eaf0ff;
  --ink-dim: #9fb0d8;
  --accent: #7aa2ff;
  --danger: #ff9aa2;
  /* Sizing */
  --radius: 22px;
  --tap-min: 64px;
  /* Ambient animation period (the music bed's visual counterpart). Not a gameplay
     clock: nothing under 12 is timed, and no per-response deadline reads from this. */
  --beat: 833ms;
}

@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/fonts/atkinson-hyperlegible-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  src: url('/fonts/atkinson-hyperlegible-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 18px;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: 'Atkinson Hyperlegible', 'Quicksand', 'Segoe UI Rounded', 'Nunito',
    system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 800px at 50% -10%, #21306e 0%, transparent 60%),
    radial-gradient(900px 700px at 90% 110%, #2a1b54 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* Ambient glow that breathes slowly. Purely decorative; stilled entirely under
   prefers-reduced-motion. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(900px 600px at 50% 85%, var(--accent) 0%, transparent 60%);
  opacity: 0.05;
  animation: ambient-pulse calc(var(--beat) * 2) ease-in-out infinite;
  z-index: 0;
}

@keyframes ambient-pulse {
  0%, 100% { opacity: 0.04; }
  50% { opacity: 0.09; }
}

#app {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  margin: 0 0 12px;
}

/* ---------- shared components ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.btn {
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  border-radius: var(--radius);
  padding: 16px 26px;
  font-size: 1.2rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  cursor: pointer;
  transition: transform 0.1s ease;
}
.btn:active {
  transform: scale(0.96);
}
.btn.primary {
  background: linear-gradient(150deg, #5f7bff, #8a5cff);
  border-color: transparent;
  box-shadow: 0 10px 30px -8px #5f7bff88;
}
.btn.ghost {
  min-height: 52px;
  padding: 10px 22px;
  font-size: 1.05rem;
  opacity: 0.92;
}
.btn[disabled] {
  opacity: 0.4;
  pointer-events: none;
}

.seg {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.seg button {
  min-height: var(--tap-min);
  border-radius: 16px;
  font-weight: 800;
  font-size: 1.1rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--panel-border);
  cursor: pointer;
}
.seg button.on {
  background: linear-gradient(150deg, #5f7bff, #8a5cff);
  border-color: transparent;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%) translateY(20px);
  background: #11183c;
  border: 1px solid var(--panel-border);
  color: var(--ink);
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1.1rem;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Overlay anatomy (z-index ladder: 40 particles / 50 toast / 60 content overlays /
   100 pause / 120 brain break / 200 adult gate — reserve the same rungs). */
.gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 6, 20, 0.7);
  backdrop-filter: blur(6px);
}
.gate-box {
  width: min(440px, 100%);
  border-radius: 20px;
  padding: 22px;
  background: linear-gradient(160deg, #1a2350, #11183c);
  border: 1px solid var(--panel-border);
  box-shadow: 0 24px 60px -20px #000d;
}
.gate-err {
  color: var(--danger);
  min-height: 1.4em;
}

/* ---------- app chrome ---------- */

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 10px;
}
.app-header .header-title {
  font-weight: 700;
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-icon {
  min-width: 48px;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--ink);
  font-size: 1.5rem;
  cursor: pointer;
}
.app-header .header-right {
  margin-left: auto;
}

/* ---------- home ---------- */

.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  gap: 8px;
}
.home-title {
  font-size: clamp(2rem, 9vw, 3.2rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}
.home-tag {
  color: var(--ink-dim);
  font-size: 1.05rem;
  margin: 0 0 26px;
}
.home .btn.primary {
  min-height: 96px;
  font-size: 1.5rem;
  align-self: center;
  width: min(340px, 100%);
}

/* ---------- responsive ---------- */

@media (max-width: 480px) {
  #app {
    padding: 12px;
  }
}

@media (min-width: 1025px) and (pointer: fine) {
  #app {
    max-width: 900px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
