/* TypWiz - games (WizRace, WordBlaster, Falling Letters).
   Flat surfaces, design tokens from app.css, all classes prefixed .g- */

.game-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.game-head h1 { margin: 0; }

.game-stage { min-height: 440px; user-select: none; -webkit-user-select: none; }
.g-wrap { position: relative; height: 480px; display: flex; flex-direction: column; }

/* Hidden input that opens the mobile keyboard */
.g-input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; margin: 0; font-size: 16px; pointer-events: none; color: transparent; background: transparent; caret-color: transparent; }

/* HUD */
.g-hud { display: flex; gap: 22px; align-items: baseline; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--bg); flex-wrap: wrap; flex: none; }
.g-stat { display: flex; align-items: baseline; gap: 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.g-stat b { font-size: 1.25rem; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: 0; text-transform: none; }
.g-stat.hi b { color: var(--accent); }
.g-hud .g-spacer { flex: 1; }
.g-hud .btn-sm { padding: 5px 10px; }

.g-canvas-box { position: relative; flex: 1; min-height: 0; cursor: text; }
.g-canvas { display: block; width: 100%; height: 100%; }

/* Overlay screens (start / pause / result) */
.g-screen { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 12px; padding: 24px; text-align: center; background: var(--surface); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.g-screen > :first-child { margin-top: auto; }
.g-screen > :last-child { margin-bottom: auto; }
.g-screen[hidden] { display: none; }
.g-screen.g-dim { background: color-mix(in srgb, var(--surface) 88%, transparent); }
.g-title { font-size: 1.6rem; font-weight: 800; margin: 0; letter-spacing: -.02em; }
.g-how { color: var(--muted); margin: 0; max-width: 520px; font-size: .95rem; }
.g-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 4px 0 -4px; }
.g-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.g-hint { font-size: .8rem; color: var(--faint); margin: 0; }
.g-big { font-size: 3.2rem; font-weight: 800; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; }

.g-levels { display: grid; grid-template-columns: repeat(6, 40px); gap: 6px; }
.g-levels button { font: inherit; font-weight: 600; font-size: .9rem; height: 36px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: var(--radius-sm); cursor: pointer; font-variant-numeric: tabular-nums; }
.g-levels button:hover { border-color: var(--brand); }
.g-levels button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.g-results { display: grid; grid-template-columns: repeat(4, minmax(80px, 1fr)); gap: 10px; width: 100%; max-width: 520px; }
.g-results div { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; }
.g-results b { display: block; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.g-results span { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.g-results .hi b { color: var(--accent); }
.g-new-best { color: var(--brand); font-weight: 700; font-size: .9rem; margin: 0; }

/* ========== WizRace ========== */
.g-race { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.g-track { position: relative; background: var(--bg); border-bottom: 1px solid var(--border); padding: 6px 0; flex: none; }
.g-lane { position: relative; height: 40px; margin: 0 16px; border-bottom: 1px dashed var(--border); }
.g-lane:last-child { border-bottom: 0; }
.g-lane::after { content: ""; position: absolute; right: 0; top: 4px; bottom: 4px; width: 3px; background: var(--faint); border-radius: 2px; }
.g-lane-name { position: absolute; left: 0; top: 50%; transform: translateY(-50%); font-size: .7rem; color: var(--faint); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; pointer-events: none; }
.g-racer { position: absolute; top: 2px; left: 0; width: 56px; height: 36px; will-change: transform; }
.g-racer svg { width: 56px; height: 36px; display: block; }
.g-place { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: .75rem; font-weight: 700; color: var(--brand); }
.g-lane.me .g-lane-name { color: var(--brand); }

.g-passage-box { position: relative; flex: 1; min-height: 0; padding: 16px 18px; overflow-y: auto; cursor: text; }
.g-passage { font-family: var(--mono); font-size: 1.15rem; line-height: 1.85; color: var(--muted); word-wrap: break-word; }
.g-passage .ok { color: var(--text); }
.g-passage .bad { color: var(--error); background: var(--error-soft); border-radius: 2px; }
.g-passage .cur { background: var(--brand-soft); border-radius: 3px; }
.g-passage .caret { box-shadow: inset 2px 0 0 var(--brand); }
.g-passage .bad.caret { box-shadow: none; }
.g-typed { font-family: var(--mono); font-size: 1rem; margin-top: 10px; min-height: 1.6em; color: var(--text); border-top: 1px solid var(--border); padding-top: 8px; }
.g-typed .bad { color: var(--error); text-decoration: underline; }
.g-count { position: absolute; inset: 0; display: grid; place-items: center; font-size: 4rem; font-weight: 800; color: var(--brand); background: color-mix(in srgb, var(--surface) 80%, transparent); z-index: 4; }
.g-count[hidden] { display: none; }

/* Garage */
.g-garage { display: grid; grid-template-columns: repeat(6, minmax(70px, 1fr)); gap: 8px; width: 100%; max-width: 560px; }
.g-garage button { font: inherit; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: var(--radius-sm); cursor: pointer; }
.g-garage button:hover { border-color: var(--brand); }
.g-garage button.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.g-garage button.locked svg { opacity: .45; }
.g-garage svg { width: 50px; height: 32px; }
.g-garage small { font-size: .72rem; color: var(--muted); line-height: 1.2; }
.g-garage .price { color: var(--accent); font-weight: 700; }

/* ========== Falling Letters ========== */
.g-finger { font-size: .85rem; color: var(--muted); }
.g-finger b { color: var(--brand); }
.g-rows { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

/* ========== Dojo Blade Shop (Wiz Ninja) ========== */
.g-blades { display: grid; grid-template-columns: repeat(5, minmax(84px, 1fr)); gap: 8px; width: 100%; max-width: 560px; }
.g-blades button { font: inherit; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: var(--radius-sm); cursor: pointer; }
.g-blades button:hover { border-color: var(--brand); }
.g-blades button.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.g-blades button.locked { opacity: .75; }
.g-blades .swatch { width: 32px; height: 6px; border-radius: 99px; display: block; }
.g-blades small { font-size: .72rem; color: var(--muted); line-height: 1.2; }
.g-blades .price { color: var(--accent); font-weight: 700; }

/* ========== Wiz Adventure ========== */
.g-chapters { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)); gap: 8px; width: 100%; max-width: 640px; text-align: left; }
.g-chapters button { font: inherit; display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: var(--radius-sm); cursor: pointer; }
.g-chapters button:hover:not(:disabled) { border-color: var(--brand); }
.g-chapters button.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.g-chapters button:disabled { opacity: .5; cursor: not-allowed; }
.g-chapters strong { font-size: .88rem; }
.g-chapters small { font-size: .74rem; color: var(--muted); }

.g-adv-scene { height: 156px; background: var(--bg); border-bottom: 1px solid var(--border); flex: none; position: relative; }
.g-adv-story { font-size: .88rem; color: var(--muted); margin: 0 0 10px; font-style: italic; }

/* ========== Responsive Games ========== */
@media (max-width: 640px) {
  .game-stage { min-height: 400px; }
  .g-wrap { height: 420px; min-height: 400px; }
  .g-hud { gap: 10px 14px; padding: 8px 12px; }
  .g-stat { font-size: .72rem; gap: 5px; }
  .g-stat b { font-size: 1.02rem; }
  .g-screen { padding: 18px 14px; gap: 10px; }
  .g-title { font-size: 1.3rem; }
  .g-big { font-size: 2.5rem; }
  .g-results { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .g-levels { grid-template-columns: repeat(6, 36px); }
  .g-lane { height: 32px; margin: 0 10px; }
  .g-racer, .g-racer svg { width: 44px; height: 28px; }
  .g-passage-box { padding: 12px 14px; }
  .g-passage { font-size: .96rem; line-height: 1.65; }
  .g-garage { grid-template-columns: repeat(3, 1fr); }
  .g-blades { grid-template-columns: repeat(3, 1fr); }
  .g-chapters { grid-template-columns: repeat(2, 1fr); }
  .g-adv-scene { height: 120px; }
}
@media (max-width: 420px) {
  .g-levels { grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; max-width: 240px; }
  .g-garage { grid-template-columns: repeat(2, 1fr); }
  .g-blades { grid-template-columns: repeat(2, 1fr); }
  .g-chapters { grid-template-columns: 1fr; }
  .g-actions { width: 100%; }
  .g-actions .btn { flex: 1 1 auto; }
}


