/* Shared look and behaviour for every game page: same palette and fonts as the dashboard, a top bar with large
   buttons, no page scroll, no pinch zoom, no text selection. Each game adds its own game.css for the board. */
@font-face { font-family: "Cormorant Garamond"; font-weight: 300 700; font-display: swap; src: url("/fonts/cormorant-garamond-latin.woff2") format("woff2"); }
@font-face { font-family: "Inter Tight"; font-weight: 300 600; font-display: swap; src: url("/fonts/inter-tight-latin.woff2") format("woff2"); }

:root {
  --sea-deep: #162c33; --sea: #2f4f5a; --cream: #faf7f2; --sand: #f3ede4; --sand-deep: #e5dace;
  --coral: #b8926e; --ink: #171d24; --rule: #d4c9b8; --good: #3f7a5a; --bad: #a8473a;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Inter Tight", "Segoe UI", system-ui, sans-serif;
  --radius: 20px;
  --tap: 64px; /* smallest tap target */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
html { font-size: clamp(15px, min(1.2vw + 10px, 2.4vh + 4px), 22px); }
body.game {
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  font-family: var(--sans); font-weight: 300; color: var(--ink); background: var(--cream);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.1; margin: 0; }
button { font: inherit; color: inherit; }
img { -webkit-user-drag: none; }

/* ---------- top bar ---------- */
.game-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px clamp(12px, 2.5vw, 36px);
  background: var(--sea-deep); color: var(--cream);
}
.game-bar h1 { flex: 1; font-size: 1.9rem; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-status { font-size: 1.05rem; color: var(--sand); white-space: nowrap; }
.gbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: var(--tap); min-width: var(--tap); padding: 0 1.2em;
  border: 0; border-radius: 16px; cursor: pointer; text-decoration: none;
  font-size: 1.05rem; font-weight: 400; background: var(--sand-deep); color: var(--ink);
  touch-action: manipulation;
}
.gbtn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gbtn:active { transform: scale(0.96); }
.gbtn-primary { background: var(--coral); color: #fff; }
.gbtn-dark { background: var(--sea); color: var(--cream); }
.gbtn[aria-pressed="true"] { background: var(--coral); color: #fff; }
:focus-visible { outline: 4px solid var(--coral); outline-offset: 3px; }

/* ---------- play area ---------- */
.game-main {
  min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: clamp(10px, 2vh, 24px) clamp(12px, 2.5vw, 36px);
}
/* Segmented choice (players, difficulty, size): one row of large buttons, one pressed. */
.choice { display: inline-flex; gap: 6px; padding: 6px; border-radius: 20px; background: var(--sand); }
.choice button { min-height: 56px; padding: 0 1.2em; border: 0; border-radius: 14px; background: transparent; cursor: pointer; font-size: 1.05rem; touch-action: manipulation; }
.choice button[aria-pressed="true"] { background: var(--sea-deep); color: var(--cream); }
.game-message { min-height: 1.6em; font-size: 1.3rem; font-family: var(--serif); color: var(--sea-deep); text-align: center; }
.game-credit { position: fixed; right: 12px; bottom: 8px; font-size: 11px; color: #6b6f73; max-width: 60vw; text-align: right; pointer-events: none; }

/* ---------- win message ---------- */
.game-win { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(22,44,51,0.55); }
.game-win[hidden] { display: none; }
.game-win-box {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  min-width: min(90vw, 440px); max-width: min(92vw, 640px); padding: 36px 44px; border-radius: 28px;
  background: var(--cream); text-align: center; box-shadow: 0 24px 70px rgba(0,0,0,0.35);
  animation: win-in 0.35s cubic-bezier(.2,.9,.3,1.3);
}
.game-win-box h2 { font-size: 3rem; color: var(--sea-deep); }
.game-win-box p { margin: 0; font-size: 1.2rem; color: #4a5157; }
.game-win-actions { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
@keyframes win-in { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .game-win-box { animation: none; } }

/* ---------- high scores for this stay (inside the win message) ---------- */
.game-win-box.has-board { max-width: min(96vw, 900px); padding: 26px 32px; gap: 10px; }
.game-win-box.has-board h2 { font-size: 2.4rem; }
.game-board { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.game-board[hidden] { display: none; }
.gb-title { font-size: 1.6rem; color: var(--sea-deep); }
.gb-list { list-style: none; margin: 0; padding: 0; width: min(100%, 520px); display: grid; gap: 4px; }
.gb-list li { display: flex; align-items: center; gap: 12px; padding: 6px 14px; border-radius: 12px; background: var(--sand); font-size: 1.15rem; }
.gb-list li.is-you { background: var(--coral); color: #fff; }
.gb-rank { width: 1.6em; font-weight: 600; text-align: center; }
.gb-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gb-score { white-space: nowrap; }
.gb-name-box {
  min-width: min(100%, 420px); min-height: 64px; padding: 0 20px; border-radius: 14px; border: 3px solid var(--sea);
  display: flex; align-items: center; justify-content: center; background: #fff;
  font-family: var(--serif); font-size: 2.2rem; color: var(--sea-deep);
}
.gb-caret { width: 3px; height: 1.1em; margin-left: 3px; background: var(--coral); animation: gb-blink 1s steps(1) infinite; }
@keyframes gb-blink { 50% { opacity: 0; } }
.gb-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.gb-chip { min-height: 52px; background: var(--sand); }
.gb-keys { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; width: 100%; }
.gb-key {
  min-height: clamp(48px, 7vh, 64px); border: 0; border-radius: 12px; cursor: pointer; touch-action: manipulation;
  background: var(--sand-deep); font-size: 1.35rem; font-weight: 500;
}
.gb-key:active { transform: scale(0.94); background: var(--coral); color: #fff; }
.gb-wide { grid-column: span 2; font-size: 1.05rem; }
.gb-save { min-height: var(--tap); padding: 0 2em; font-size: 1.2rem; }
.gb-save:disabled { opacity: 0.45; }
@media (prefers-reduced-motion: reduce) { .gb-caret { animation: none; } }
