/* Layer One Academy brand tokens and the app shell. Scene-specific styles live
   in their own files. */

:root {
  /* Brand: use exactly these four. */
  --navy: #1B2A4A;
  --copper: #B87333;
  --paper: #F5F1E8;
  --slate: #5C6672;

  --bg: var(--paper);
  --surface: #FFFDF8;
  --surface-2: #EAE4D6;
  --fg: var(--navy);
  --muted: var(--slate);
  --accent: var(--copper);
  --on-accent: var(--navy);
  --line: rgba(27, 42, 74, 0.16);
  --badge-edge: transparent;
  --pass: #1F8A5B;
  --fail: #C2412D;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 12px;
  --tap: 48px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121C33;
    --surface: var(--navy);
    --surface-2: #24365C;
    --fg: var(--paper);
    --muted: #A7AFBA;
    --line: rgba(245, 241, 232, 0.16);
    --badge-edge: rgba(245, 241, 232, 0.35);
    --pass: #4CC38A;
    --fail: #FF7A66;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121C33;
  --surface: var(--navy);
  --surface-2: #24365C;
  --fg: var(--paper);
  --muted: #A7AFBA;
  --line: rgba(245, 241, 232, 0.16);
  --badge-edge: rgba(245, 241, 232, 0.35);
  --pass: #4CC38A;
  --fail: #FF7A66;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 var(--font);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
.app-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.badge { display: block; flex: none; line-height: 0; border-radius: 10px; }
.badge-bg { fill: var(--navy); stroke: var(--badge-edge); stroke-width: 2; }
.badge-l { fill: var(--paper); }
.badge-1 { fill: var(--copper); }
.header-title {
  flex: 1;
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  flex: none;
  width: var(--tap);
  height: var(--tap);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

/* ---------- scene container ---------- */
.scene {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

/* ---------- shared controls ---------- */
.btn {
  min-height: 52px;
  padding: 0 20px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-small { min-height: 40px; padding: 0 14px; }

.chip {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.chip-go { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stars { display: inline-flex; gap: 2px; letter-spacing: 0; }
.star { color: var(--line); }
.star.on { color: var(--accent); }

.segmented { display: inline-flex; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg {
  min-width: 56px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}
.seg[aria-pressed="true"] { background: var(--fg); color: var(--bg); }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 24px);
  padding: 10px 12px 10px 16px;
  border-radius: var(--radius);
  background: var(--fg);
  color: var(--bg);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}
.toast .btn { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- menu ---------- */
.menu { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; padding: 12px 4px 24px; }
.menu-hero h2 { font-size: clamp(1.8rem, 7vw, 2.6rem); line-height: 1.1; letter-spacing: -0.01em; margin: 6px 0; }
.tagline { color: var(--muted); font-size: 1.05rem; }
.menu-games { display: flex; flex-direction: column; gap: 10px; }
.game-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 84px;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
}
button.game-card { cursor: pointer; border-color: var(--accent); }
button.game-card:active { transform: translateY(1px); }
.game-card.is-locked { background: transparent; border-style: dashed; color: var(--muted); }
.game-card-text { flex: 1; min-width: 0; }
.game-card h3 { font-size: 1.1rem; }
.game-card p { color: var(--muted); font-size: 0.92rem; }
.menu-settings { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

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