/* games.css — the Puzzles hub (SPEC §18c). Prefix gm-: tiles, the game-screen header, the result and
   stats panels, the day-change note. Shared classes (.panel .btn .seg .num .pf .sub .pill .addlink .toast)
   come from app.css and are never restyled here. Phone breakpoints: 860 / 600 / 420. */

.gm-view { max-width: 1100px; margin: 0 auto; padding: 4px 0 40px; min-width: 0; }

/* ---------- hub ---------- */
.gm-hub-head { margin: 4px 0 14px; }
.gm-title { margin: 0; font-weight: 700; font-size: 30px; color: #f3e4c4; letter-spacing: .5px; text-shadow: 3px 3px 0 var(--shadow); }
.gm-sub { margin: 4px 0 0; color: var(--pale2); font-size: 15px; }

.gm-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: stretch; }
.gm-tile {
  display: block; width: 100%; text-align: left; cursor: pointer; padding: 16px 18px; min-width: 0;
  font: inherit; color: var(--ink); position: relative;
}
.gm-tile:hover { background: #f7ead0; }
.gm-tile:active { transform: translate(2px, 2px); box-shadow: inset 0 0 0 2px var(--line), 2px 2px 0 var(--shadow); }
.gm-tile:focus-visible { outline: 3px solid var(--star); outline-offset: 3px; }
.gm-tile-inner { display: flex; align-items: flex-start; gap: 16px; min-width: 0; }
.gm-tile-ico { width: 96px; height: 96px; flex: none; image-rendering: pixelated; image-rendering: crisp-edges; }
.gm-tile-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 auto; }
.gm-tile-name { font-size: 24px; font-weight: 600; line-height: 1.1; color: var(--ink); }
.gm-tile-blurb { font-size: 14px; line-height: 1.35; }
.gm-tile-status { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 14px; font-weight: 700; color: var(--muted); min-height: 22px; }
.gm-tile.is-won .gm-tile-status { color: var(--green-dk); }
.gm-tile.is-progress .gm-tile-status { color: var(--gold); }
.gm-tile.is-lost .gm-tile-status { color: var(--muted); }
.gm-tick { width: 22px; height: 22px; flex: none; }
.gm-pill { position: absolute; right: 14px; top: 12px; gap: 6px; }
.gm-pill-star, .gm-star { width: 22px; height: 22px; flex: none; }

/* ---------- game screen header ---------- */
.gm-game { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.gm-head { display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; min-height: 44px; }
.gm-back { color: var(--pale2); text-decoration: none; font-size: 19px; padding: 6px 4px; min-height: 40px; display: inline-flex; align-items: center; white-space: nowrap; }
.gm-back:hover { color: #f3e4c4; }
.gm-head-title { margin: 0 auto 0 0; font-weight: 700; font-size: 30px; color: #f3e4c4; letter-spacing: .5px; text-shadow: 3px 3px 0 var(--shadow); line-height: 1.1; min-width: 0; }
.gm-seg { flex: none; }
.gm-seg button { min-height: 40px; }
.gm-statsbtn { min-height: 40px; flex: none; }
.gm-statsbtn-ico { display: none; width: 22px; height: 22px; }

/* ---------- stats panel ---------- */
.gm-stats { padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.gm-stats-controls { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: center; }
.gm-stats-body { display: flex; flex-direction: column; gap: 12px; }
.gm-stats-empty { margin: 0; }
.gm-stats-rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px 14px; }
.gm-stat { display: flex; flex-direction: column; gap: 2px; background: var(--panel2); padding: 8px 12px; min-width: 0; }
.gm-stat-v { font-size: 24px; color: var(--gold); line-height: 1.1; white-space: nowrap; }
.gm-stat-k { font-size: 13px; color: var(--muted); font-weight: 700; }
.gm-bars { display: flex; flex-direction: column; gap: 5px; }
.gm-bar { display: grid; grid-template-columns: 32px 1fr 36px; gap: 8px; align-items: center; font-size: 12px; }
.gm-bar-k { color: var(--muted); text-align: right; }
.gm-bar-track { display: block; height: 16px; background: var(--panel2); border: 2px solid var(--edge); min-width: 0; }
.gm-bar-fill { display: block; height: 100%; background: var(--green); box-shadow: inset 0 -3px 0 var(--green-dk); min-width: 0; }
.gm-bar-fill.is-zero { background: transparent; box-shadow: none; }
.gm-bar-n { color: var(--ink); }

/* ---------- stage, status, note ---------- */
.gm-status { margin: 0; min-height: 0; }
/* the muted ink is for parchment: on the dark page, status and help lines use the pale ink */
.gm-status.sub, .gm-loading.sub, .gm-stage .sub { color: var(--pale2); }
.gm-status:empty { display: none; }
.gm-loading { padding: 14px 4px; color: var(--pale2); }
.gm-loading:empty { display: none; }
.gm-stage { min-width: 0; max-width: 100%; }
/* takes the focus back after a click on a tool button, so the keyboard reaches the game */
.gm-stage:focus { outline: none; }
/* .btn and .seg set their own display, which would otherwise beat the hidden attribute */
.gm-stage [hidden] { display: none !important; }
.gm-note-host:empty, .gm-stats-host:empty, .gm-below:empty { display: none; }
.gm-note { justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
.gm-note-text { flex: 1 1 240px; }
.gm-note-link { color: var(--accent); font-size: 18px; text-decoration: none; white-space: nowrap; min-height: 40px; display: inline-flex; align-items: center; padding: 0 4px; }
.gm-note-link:hover { text-decoration: underline; }

/* ---------- result panel ---------- */
.gm-result { padding: 16px 18px 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; animation: gm-result-in .35s ease-out; }
.gm-result:focus { outline: none; }
.gm-result:focus-visible { outline: 3px solid var(--star); outline-offset: 2px; }
.gm-strip-wrap { line-height: 0; }
.gm-strip { width: 192px; height: 80px; max-width: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
.gm-result-msg { margin: 0; font-size: 24px; font-weight: 600; color: var(--ink); line-height: 1.15; }
.gm-result-detail { margin: 0; color: var(--muted); font-size: 15px; font-weight: 700; }
.gm-result-bday { margin: 0; color: var(--accent); font-size: 20px; }
.gm-result-links { display: flex; gap: 10px 22px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.gm-result-links .addlink { margin-top: 0; font-size: 15px; }
@keyframes gm-result-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- phones ---------- */
@media (max-width: 860px) {
  .gm-view { padding-bottom: 30px; }
  .gm-title, .gm-head-title { font-size: 26px; }
  .gm-tiles { gap: 12px; }
  .gm-tile { padding: 14px 14px; }
  .gm-tile-ico { width: 72px; height: 72px; }
  .gm-tile-name { font-size: 21px; }
}
@media (max-width: 600px) {
  .gm-tiles { grid-template-columns: 1fr; }
  /* two rows: back + title + stats · mode seg (SPEC §18c), so the game's controls fit one screen */
  .gm-head { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "back title stats" "seg seg seg"; gap: 6px 8px; align-items: center; }
  .gm-back { grid-area: back; }
  .gm-statsbtn { grid-area: stats; justify-self: end; padding: 6px 10px 8px; min-height: 40px; }
  .gm-statsbtn-label { display: none; }
  .gm-statsbtn-ico { display: block; }
  .gm-head-title { grid-area: title; font-size: 22px; text-align: center; margin: 0; white-space: nowrap; }
  .gm-game { gap: 8px; }
  .gm-head .gm-seg { grid-area: seg; display: flex; width: 100%; }
  .gm-head .gm-seg button { flex: 1; }
  .gm-stats-controls .gm-seg { display: flex; flex: 1 1 100%; }
  .gm-stats-controls .gm-seg button { flex: 1; }
  .gm-result-msg { font-size: 21px; }
  /* while a game is open: one slim row of nav links; the countdown pill still shows when a tomato runs */
  .gm-playing .a-top { padding: 3px 6px; margin-bottom: 8px; justify-content: center; }
  .gm-playing .a-brand, .gm-playing .a-clock, .gm-playing .a-lang { display: none; }
  .gm-playing .a-right:not(:has(.a-countpill:not(.a-hidden))) { display: none; }
  .gm-playing .a-nav { flex-wrap: nowrap; gap: 0; }
  .gm-playing .a-nav a { padding: 6px 5px; font-size: 15px; white-space: nowrap; }
}
@media (max-width: 420px) {
  .gm-tile-inner { gap: 12px; }
  .gm-tile-ico { width: 64px; height: 64px; }
  .gm-pill { position: static; align-self: flex-start; margin-top: 8px; }
  .gm-tile-inner { flex-wrap: wrap; }
  .gm-stats-rows { grid-template-columns: 1fr 1fr; }
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  [class*="gm-"], [class*="gw-"], [class*="gp-"], [class*="gs-"], [class*="gc-"],
  [class*="gm-"]::before, [class*="gw-"]::before, [class*="gp-"]::before, [class*="gs-"]::before, [class*="gc-"]::before,
  [class*="gm-"]::after, [class*="gw-"]::after, [class*="gp-"]::after, [class*="gs-"]::after, [class*="gc-"]::after {
    animation: none !important; transition: none !important;
  }
}
