/* Games: shared look. Builds on styles.css tokens (--ink, --paper, --cite, --hl, --faint, --wash, --quiet).
   Right letter, right place: footnote blue. Right letter, wrong place: the highlighter. Not in it: rail grey. */
:root {
  --gm-hit: var(--cite);
  --gm-near: var(--hl);
  --gm-miss: #8A8A86;
  --gm-tile: 58px;
}

.gm-page { padding: 8px 0 72px; }
.gm-page .wrap { max-width: 760px; }

.gm-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 24px; }
.gm-head .gm-kick { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.gm-head .gm-kick a { text-decoration: none; }
.gm-head .gm-kick a:hover { text-decoration: underline; }
.gm-head h1 { margin: 2px 0 0; font-size: clamp(30px, 6vw, 44px); line-height: 1; font-weight: 800; letter-spacing: -.02em; }
.gm-head .gm-sub { margin: 6px 0 0; color: var(--quiet); font-size: 15px; }
.gm-tools { display: flex; gap: 8px; }

.gm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--ink); color: var(--paper);
  font: 600 15px/1 var(--sans); text-decoration: none; cursor: pointer; }
.gm-btn:hover { background: #222; }
.gm-btn.ghost { background: var(--paper); color: var(--ink); }
.gm-btn.ghost:hover { background: var(--wash); }
.gm-btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.gm-btn[disabled] { opacity: .35; cursor: default; }
.gm-btn[hidden], .gm-page [hidden] { display: none !important; }

.gm-loading { padding: 64px 0; text-align: center; color: var(--quiet); }

/* Toast */
.gm-toast { position: fixed; left: 50%; top: 88px; transform: translate(-50%, -12px); z-index: 50; opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 6px; font-weight: 600; font-size: 15px;
  transition: opacity .2s var(--ease), transform .2s var(--ease); }
.gm-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Dialogs */
.gm-dlg { width: min(440px, calc(100vw - 32px)); border: 2px solid var(--ink); border-radius: 10px; padding: 28px 24px 20px;
  background: var(--paper); color: var(--ink); box-shadow: 0 18px 60px rgba(0,0,0,.25); }
.gm-dlg::backdrop { background: rgba(0,0,0,.45); }
.gm-dlg h2 { margin: 0 0 12px; font-size: 26px; line-height: 1.1; font-weight: 800; letter-spacing: -.01em; }
.gm-dlg p { margin: 0 0 12px; }
.gm-dlg-body { margin-bottom: 8px; }
.gm-dlg-body ul { padding-left: 20px; margin: 0 0 12px; }
.gm-dlg-body li { margin-bottom: 6px; }
.gm-x { position: absolute; top: 8px; right: 10px; width: 40px; height: 40px; border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--ink); }
.gm-dlg { position: fixed; }
.gm-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0; text-align: center; }
.gm-stats dd { margin: 0; font-size: 28px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.gm-stats dt { font-size: 12px; color: var(--quiet); order: 2; }
.gm-stats div { display: flex; flex-direction: column-reverse; }
.gm-hist { margin: 0 0 16px; font-size: 13px; }
.gm-hrow { display: grid; grid-template-columns: 4.5em 1fr; align-items: center; gap: 8px; margin-bottom: 3px; }
.gm-hrow span { text-align: right; color: var(--quiet); }
.gm-hrow i { font-style: normal; display: block; background: var(--ink); color: var(--paper); text-align: right; padding: 1px 6px; font-weight: 600; min-width: 1.6em; }
.gm-dlg-acts { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 8px; }
.gm-dlg-acts .gm-btn { flex: 1 1 140px; }
.gm-next { color: var(--quiet); font-size: 14px; margin: 8px 0 4px !important; }
.gm-next-t { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.gm-more { font-size: 14px; color: var(--quiet); margin: 8px 0 0 !important; border-top: 1px solid var(--rail); padding-top: 12px; }
.gm-gate p { font-size: 17px; }

/* Shared letter tile + keyboard (Typeset, Crosswire) */
.gm-tile { display: inline-flex; align-items: center; justify-content: center; width: var(--gm-tile); height: var(--gm-tile);
  border: 2px solid var(--faint); font: 800 30px/1 var(--sans); text-transform: uppercase; background: var(--paper); color: var(--ink); }
.gm-tile.filled { border-color: var(--ink); }
.gm-tile.hit { background: var(--gm-hit); border-color: var(--gm-hit); color: #fff; }
.gm-tile.near { background: var(--gm-near); border-color: var(--gm-near); color: var(--ink); }
.gm-tile.miss { background: var(--gm-miss); border-color: var(--gm-miss); color: #fff; }

.gm-kb { display: flex; flex-direction: column; gap: 8px; margin: 24px auto 0; max-width: 500px; user-select: none; touch-action: manipulation; }
.gm-kb div { display: flex; gap: 6px; justify-content: center; }
.gm-kb button { flex: 1 1 0; min-width: 0; height: 56px; border: 0; border-radius: 5px; background: var(--rail); color: var(--ink);
  font: 700 17px/1 var(--sans); text-transform: uppercase; cursor: pointer; }
.gm-kb button.wide { flex: 1.6 1 0; font-size: 13px; }
.gm-kb button:active { filter: brightness(.9); }
.gm-kb button.hit { background: var(--gm-hit); color: #fff; }
.gm-kb button.near { background: var(--gm-near); }
.gm-kb button.miss { background: var(--gm-miss); color: #fff; }

/* Hub */
.gm-hub-h { padding: 32px 0 8px; border-bottom: 2px solid var(--ink); margin-bottom: 28px; }
.gm-hub-h h1 { margin: 0; font-size: clamp(36px, 7vw, 64px); line-height: 1; font-weight: 800; letter-spacing: -.03em; }
.gm-hub-h p { margin: 10px 0 16px; font-size: 18px; max-width: 60ch; }
.gm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; margin-bottom: 48px; }
.gm-card { position: relative; display: flex; flex-direction: column; border: 2px solid var(--ink); border-radius: 10px; padding: 20px; text-decoration: none; min-height: 220px;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease); }
.gm-card:hover { transform: translateY(-2px); box-shadow: 4px 4px 0 var(--ink); }
.gm-card .ico { width: 64px; height: 64px; margin-bottom: 14px; }
.gm-card h2 { margin: 0 0 6px; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.gm-card p { margin: 0; color: #333; }
.gm-card .st { margin-top: auto; padding-top: 16px; font-size: 14px; font-weight: 600; display: flex; gap: 12px; align-items: center; }
.gm-card .st .done { background: var(--gm-hit); color: #fff; padding: 2px 8px; border-radius: 3px; }
.gm-card .st .new { background: var(--hl); padding: 2px 8px; border-radius: 3px; }
.gm-card .st .streak { color: var(--quiet); }
.gm-hub-note { color: var(--quiet); font-size: 15px; max-width: 62ch; margin-bottom: 64px; }

@media (max-width: 640px) {
  .gm-page .wrap, .gm-hub .wrap { padding: 0 16px; }
  :root { --gm-tile: 52px; }
  .gm-kb button { height: 52px; font-size: 15px; }
  .gm-kb div { gap: 4px; }
  .gm-head { margin-bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .gm-card, .gm-toast { transition: none; }
}

/* "How to play": always visible in each game's header, with a ? badge so it reads as help at a glance. */
.gm-tools { flex-shrink: 0; }
.gm-help-btn { gap: 7px; padding-left: 8px; }
.gm-help-btn .gm-q { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--ink); color: var(--paper); font: 800 14px/1 var(--sans); }
.gm-help-btn:hover .gm-q { background: #222; }
