/* Games Lab shell — shared game styles. Same design language as the showcase
   (game-night dark, candy accents) but standalone: games load only this file.
   Mobile-first: big touch targets, portrait layout, one thumb. */

:root {
  --bg: #12141d;
  --surface: #1b1e2b;
  --surface-2: #232738;
  --line: #303549;
  --text: #f2f3f7;
  --muted: #9aa0b6;
  --accent: #ffb800;
  --good: #2e7d4f;
  --warn: #b28900;
  --bad: #a63b4e;
  --radius: 18px;
  --font: ui-rounded, "SF Pro Rounded", -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

.gl-app {
  max-width: 480px;
  min-height: 100%;
  margin: 0 auto;
  padding: 0 16px 32px;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */

.gl-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 0 10px;
}
.gl-topbar .gl-back {
  text-decoration: none; color: var(--muted); font-weight: 800; font-size: 1.1rem;
  padding: 4px 8px;
}
.gl-topbar h1 { font-size: 1.15rem; font-weight: 800; flex: 1; }
.gl-topbar .gl-title-accent { color: var(--accent); }
.gl-iconbtn {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; min-width: 38px; height: 38px; font-size: 1rem;
  font-family: var(--font); font-weight: 800; cursor: pointer;
}

/* ---------- screens ---------- */

.gl-screen { display: none; }
.gl-screen.active { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.gl-center { align-items: center; text-align: center; justify-content: center; }
.gl-spacer { flex: 1; }

/* ---------- buttons ---------- */

.gl-btn {
  display: block; width: 100%; border: none; cursor: pointer;
  padding: 15px; border-radius: 14px;
  background: var(--accent); color: #12141d;
  font-family: var(--font); font-weight: 800; font-size: 1rem;
  text-align: center; text-decoration: none;
}
.gl-btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.gl-btn:disabled { opacity: 0.4; cursor: default; }
.gl-btn-row { display: flex; gap: 10px; }
.gl-btn-row .gl-btn { flex: 1; }

/* ---------- pills & tiles ---------- */

.gl-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 0.85rem; font-weight: 700;
}
.gl-pill.accent { background: var(--accent); border-color: var(--accent); color: #12141d; }
.gl-pill-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.gl-tile-row { display: flex; gap: 7px; justify-content: center; }
.gl-tile {
  width: 52px; height: 52px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.5rem; text-transform: uppercase;
  background: var(--surface-2); border: 1px solid var(--line);
  cursor: pointer; user-select: none;
  font-family: var(--font); color: var(--text);
}
.gl-tile.good { background: var(--good); border-color: var(--good); }
.gl-tile.warn { background: var(--warn); border-color: var(--warn); }
.gl-tile.bad { background: var(--bad); border-color: var(--bad); }
.gl-tile.accent { background: var(--accent); border-color: var(--accent); color: #12141d; }
.gl-tile.dim { opacity: 0.45; }
.gl-tile.empty { background: transparent; border: 2px dashed var(--line); }
.gl-tile.selected { outline: 3px solid var(--accent); outline-offset: 1px; }

/* ---------- letter keyboard ---------- */

.gl-keys {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.gl-key {
  padding: 12px 0; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  font-family: var(--font); font-weight: 800; font-size: 1.05rem;
  text-align: center; text-transform: uppercase; cursor: pointer;
}
.gl-key:disabled { opacity: 0.3; }

/* ---------- number chips & operators (math games) ---------- */

.gl-num {
  min-width: 64px; height: 56px; padding: 0 14px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--line);
  font-family: var(--font); color: var(--text);
  font-weight: 800; font-size: 1.4rem; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.gl-num.selected { outline: 3px solid var(--accent); outline-offset: 1px; }
.gl-num.used { opacity: 0.25; pointer-events: none; }
.gl-num-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.gl-op {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); color: var(--accent);
  font-family: var(--font); font-weight: 800; font-size: 1.5rem; cursor: pointer;
}
.gl-op.selected { background: var(--accent); color: #12141d; border-color: var(--accent); }

/* ---------- result card & stats ---------- */

.gl-result {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; text-align: center;
}
.gl-result .gl-result-big { font-size: 2rem; font-weight: 800; }
.gl-result .gl-result-grid {
  margin: 10px auto; padding: 10px 18px; display: inline-block;
  background: var(--surface-2); border-radius: 12px;
  font-weight: 700; line-height: 1.6; white-space: pre-line;
}

.gl-stats-row { display: flex; gap: 10px; justify-content: center; }
.gl-stat {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 18px; border-radius: 12px; background: var(--surface-2);
  font-size: 0.75rem; font-weight: 700; color: var(--muted);
}
.gl-stat b { font-size: 1.2rem; color: var(--text); }

/* ---------- toast ---------- */

.gl-toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 16px);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px;
  font-weight: 800; font-size: 0.9rem; opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50; max-width: 90vw; text-align: center;
}
.gl-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- modal ---------- */

.gl-modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(6, 8, 14, 0.75);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.gl-modal-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  max-width: 420px; width: 100%; max-height: 85vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.gl-modal-card h2 { font-size: 1.3rem; font-weight: 800; }
.gl-modal-body { font-size: 0.95rem; }
.gl-modal-body ul { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

/* ---------- handoff overlay ---------- */

.gl-handoff {
  position: fixed; inset: 0; z-index: 45;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; text-align: center;
}
.gl-handoff-avatar { font-size: 3.5rem; }
.gl-handoff-line { color: var(--muted); font-weight: 700; }
.gl-handoff-who { font-size: 2rem; font-weight: 800; }
.gl-handoff .gl-btn { max-width: 320px; margin-top: 14px; }

/* ---------- confetti ---------- */

.gl-confetti-bit {
  position: fixed; top: -30px; z-index: 60; pointer-events: none;
  animation: gl-fall 2.2s ease-in forwards;
}
@keyframes gl-fall {
  to { transform: translateY(110vh) rotate(360deg); opacity: 0.7; }
}

/* ---------- misc ---------- */

.gl-h2 { font-size: 1.05rem; font-weight: 800; text-align: center; }
.gl-sub { color: var(--muted); font-size: 0.9rem; font-weight: 600; text-align: center; }
.gl-shake { animation: gl-shake 0.35s; }
@keyframes gl-shake {
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}

/* ---------- party roster (shell/party.js) ---------- */

.gl-roster { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.gl-roster-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 14px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-weight: 800; font-size: 0.95rem;
}
.gl-roster-x {
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  border-radius: 50%; width: 26px; height: 26px; cursor: pointer;
  font-family: var(--font); font-weight: 800; font-size: 0.8rem;
}
.gl-roster-add { display: flex; gap: 8px; margin-top: 12px; }
.gl-roster-input {
  flex: 1; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  font-family: var(--font); font-weight: 700; font-size: 1rem;
}
.gl-roster-input:focus { outline: 2px solid var(--accent); }
