/* DailyGameClub — game boards. Uses only the page's theme tokens:
   --bg --surface --surface-2 --text --muted --line --accent --accent-ink --ok --near --miss --danger --radius --font --mono
   Local sizing variables are prefixed --g-. Every class is prefixed g-. */

.g-game {
  box-sizing: border-box;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-family: var(--font);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.g-game *, .g-game *::before, .g-game *::after { box-sizing: border-box; }
.g-game :focus { outline: none; }
.g-game :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.g-game [hidden] { display: none !important; }
.g-game p { margin: 0; }
.g-sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- shared controls ---------- */
.g-btn {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 600 15px/1.1 var(--font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;
}
.g-btn:hover:not(:disabled) { background: var(--surface-2); }
.g-btn:active:not(:disabled) { transform: translateY(1px); }
.g-btn:disabled { opacity: .45; cursor: default; }
.g-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.g-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.g-btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.g-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }
.g-tools-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-tool { min-width: 0; padding: 0 6px; gap: 5px; white-space: nowrap; }
@media (max-width: 380px) { .g-tool { font-size: 14px; } .g-tool-state { padding: 2px 4px; font-size: 11px; } }
.g-tool-i { font-size: 18px; line-height: 1; }
.g-tool-state { font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.g-btn[aria-pressed="true"] .g-tool-state { background: var(--accent-ink); color: var(--accent); }

/* ---------- result line ---------- */
.g-result-slot { width: 100%; }
.g-result-slot:empty { display: none; }
.g-result {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  animation: g-rise .35s ease both;
}
.g-result-icon {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  font: 800 18px/1 var(--font);
  color: #fff;
  background: color-mix(in srgb, var(--ok) 86%, #000);
}
.g-result-lose .g-result-icon { background: color-mix(in srgb, var(--miss) 80%, #000); }
.g-result-error .g-result-icon { background: var(--danger); }
.g-result-error { border-color: var(--danger); }
.g-result-body { flex: 1; min-width: 0; }
.g-result-title { font-weight: 700; font-size: 16px; line-height: 1.3; }
.g-result-stats { color: var(--muted); font-size: 14px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.g-result-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.g-result-pending { color: var(--muted); text-align: center; font-size: 14px; padding: 8px; }

/* =========================================================================================
   Daily Word
   ========================================================================================= */
.g-word {
  --g-tile: clamp(40px, min(calc((100vw - 64px) / 5), calc((100vh - 370px) / 6.5)), 62px);
  gap: 14px;
}
.g-word-stage { position: relative; display: flex; justify-content: center; width: 100%; }
.g-word-board { display: grid; gap: 6px; padding: 2px; border-radius: var(--radius); }
.g-word-row { display: grid; grid-template-columns: repeat(5, var(--g-tile)); gap: 6px; }
.g-tile {
  position: relative;
  width: var(--g-tile); height: var(--g-tile);
  display: grid; place-items: center;
  border: 2px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font: 800 calc(var(--g-tile) * .5)/1 var(--font);
  text-transform: uppercase;
  user-select: none;
}
.g-word-row.g-current .g-tile { border-color: color-mix(in srgb, var(--line) 60%, var(--muted)); }
.g-tile.g-filled { border-color: var(--muted); }
.g-tile-m {
  position: absolute; top: 2px; right: 4px;
  font-size: calc(var(--g-tile) * .24); font-weight: 800; line-height: 1;
}
.g-tile.g-c, .g-key.g-c { background: color-mix(in srgb, var(--ok) 78%, #000); border-color: transparent; color: #fff; }
.g-tile.g-p, .g-key.g-p {
  background-color: var(--near);
  background-image: repeating-linear-gradient(135deg, transparent 0 7px, rgba(255, 255, 255, .2) 7px 10px);
  border-color: transparent;
  color: color-mix(in srgb, var(--near) 15%, #000);
}
.g-tile.g-a, .g-key.g-a { background: color-mix(in srgb, var(--miss) 80%, #000); border-color: transparent; color: #fff; }

.g-msg {
  position: absolute; left: 50%; top: 18%;
  transform: translate(-50%, -6px);
  z-index: 2;
  max-width: 90%;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--text); color: var(--bg);
  font-weight: 700; font-size: 15px; text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}
.g-msg.g-show { opacity: 1; transform: translate(-50%, 0); }

.g-kb { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 500px; user-select: none; }
.g-kb-row { display: flex; justify-content: center; gap: 5px; }
.g-key {
  position: relative;
  flex: 1 1 0; min-width: 0; max-width: 46px;
  height: clamp(46px, 7.4vh, 56px);
  padding: 0;
  border: 0; border-radius: 6px;
  background: var(--surface-2); color: var(--text);
  font: 700 16px/1 var(--font);
  cursor: pointer;
  touch-action: manipulation;
}
.g-key:hover:not(:disabled) { filter: brightness(.96); }
.g-key:active:not(:disabled) { transform: translateY(1px); }
.g-key-wide { flex: 1.55 1 0; max-width: 72px; font-size: 13px; letter-spacing: .02em; }
.g-key-wide span { font-size: 20px; }
.g-key-m { position: absolute; top: 3px; right: 4px; font-size: 10px; line-height: 1; }
.g-key.g-a .g-key-l { text-decoration: line-through; text-decoration-thickness: 2px; }
.g-done .g-key:disabled { cursor: default; }

@keyframes g-flip { from { transform: rotateX(90deg); } to { transform: rotateX(0); } }
@keyframes g-pop { 0% { transform: scale(1); } 45% { transform: scale(1.09); } 100% { transform: scale(1); } }
@keyframes g-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes g-bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-10px); } 70% { transform: translateY(2px); } }
@keyframes g-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.g-tile.g-flip { animation: g-flip .36s ease-out both; }
.g-tile.g-pop { animation: g-pop .12s ease-out; }
.g-word-row.g-shake { animation: g-shake .32s ease; }
.g-tile.g-win { animation: g-bounce .5s ease both; }
.g-tile.g-d1 { animation-delay: .11s; }
.g-tile.g-d2 { animation-delay: .22s; }
.g-tile.g-d3 { animation-delay: .33s; }
.g-tile.g-d4 { animation-delay: .44s; }
.g-tile.g-pop.g-d1, .g-tile.g-pop.g-d2, .g-tile.g-pop.g-d3, .g-tile.g-pop.g-d4 { animation-delay: 0s; }

/* =========================================================================================
   Daily Sudoku
   ========================================================================================= */
.g-sudoku { --g-board: min(100%, 468px, max(300px, calc(100vh - 320px))); gap: 12px; }
.g-sdk {
  width: var(--g-board);
  aspect-ratio: 1;
  display: flex; flex-direction: column;
  border: 2px solid var(--text);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  user-select: none;
}
.g-sdk-row { flex: 1; display: grid; grid-template-columns: repeat(9, 1fr); min-height: 0; }
.g-sdk-cell {
  position: relative;
  display: grid; place-items: center;
  min-width: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font: 500 clamp(17px, 5.4vw, 27px)/1 var(--font);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  cursor: pointer;
  touch-action: manipulation;
}
.g-sdk-cell:last-child { border-right: 0; }
.g-sdk-row:last-child .g-sdk-cell { border-bottom: 0; }
.g-sdk-cell.g-br { border-right: 2px solid color-mix(in srgb, var(--text) 75%, var(--surface)); }
.g-sdk-cell.g-bb { border-bottom: 2px solid color-mix(in srgb, var(--text) 75%, var(--surface)); }
.g-sdk-cell.g-given { color: var(--text); font-weight: 700; }
.g-sdk-cell.g-peer { background: var(--surface-2); }
.g-sdk-cell.g-same { background: color-mix(in srgb, var(--accent) 11%, var(--surface)); }
.g-sdk-cell.g-same .g-sdk-v { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.g-sdk-cell.g-sel { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); box-shadow: inset 0 0 0 2px var(--accent); }
.g-sdk-cell:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }
.g-sdk-cell.g-conflict { color: var(--danger); }
.g-sdk-cell.g-conflict .g-sdk-v { text-decoration: underline wavy var(--danger); text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.g-sdk-flag { display: none; }
.g-sdk-cell.g-conflict .g-sdk-flag {
  display: block; position: absolute; top: 1px; left: 3px;
  font: 800 10px/1 var(--font); color: var(--danger);
}
.g-sdk-notes { display: none; }
.g-sdk-cell.g-has-notes .g-sdk-notes {
  position: absolute; inset: 1px 2px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  place-items: center;
  font: 600 clamp(8px, 2.3vw, 12px)/1 var(--font);
  color: var(--muted);
}
.g-sdk-cell.g-has-notes .g-sdk-v { display: none; }
.g-done .g-sdk-cell { cursor: default; }
.g-done .g-sdk-cell.g-sel { box-shadow: none; }

.g-sdk-controls { width: var(--g-board); display: flex; flex-direction: column; gap: 8px; }
.g-sdk-pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.g-padkey {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 0; height: 54px; padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  cursor: pointer; touch-action: manipulation;
}
.g-padkey:hover:not(:disabled) { background: var(--surface-2); }
.g-padkey:active:not(:disabled) { transform: translateY(1px); }
.g-padkey:disabled { opacity: .45; cursor: default; }
.g-padkey-d { font: 600 22px/1 var(--font); }
.g-padkey-n { font: 600 10px/1 var(--font); color: var(--muted); }
.g-padkey.g-complete .g-padkey-d { color: var(--muted); }
.g-pencil .g-padkey { border-style: dashed; border-color: var(--accent); }
.g-pencil .g-padkey-d { font-size: 16px; color: var(--accent); }

/* =========================================================================================
   Number Target
   ========================================================================================= */
.g-target { gap: 12px; max-width: 520px; }
.g-tgt-target {
  display: flex; flex-direction: column; align-items: center;
  width: 100%;
  padding: 10px 12px 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
}
.g-tgt-label { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.g-tgt-value { font: 800 clamp(40px, 13vw, 58px)/1.05 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.g-tgt-expr { min-height: 22px; font: 600 16px/22px var(--mono); color: var(--muted); text-align: center; }
.g-tgt-expr.g-error { color: var(--danger); }
.g-tgt-expr.g-error::before { content: "⚠ "; }
.g-tgt-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
@media (min-width: 560px) { .g-tgt-nums { grid-template-columns: repeat(6, 1fr); } }
.g-num {
  position: relative;
  height: 64px; min-width: 0;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: 700 26px/1 var(--mono); font-variant-numeric: tabular-nums;
  cursor: pointer; touch-action: manipulation;
  transition: transform .12s ease;
}
.g-num:hover:not(:disabled) { border-color: var(--muted); }
.g-num.g-fresh { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.g-num-m { position: absolute; top: 4px; right: 6px; font-size: 11px; color: var(--accent); }
.g-num.g-selected { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); transform: translateY(-2px); box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 50%, #000); }
.g-num.g-selected .g-num-m { color: var(--accent-ink); }
.g-num.g-used {
  background: transparent;
  border-style: dashed;
  cursor: default;
}
.g-num.g-hit { background: color-mix(in srgb, var(--ok) 78%, #000); border-color: transparent; color: #fff; }
.g-num:disabled:not(.g-used) { cursor: default; }
.g-tgt-ops { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.g-op {
  height: 54px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text);
  font: 700 26px/1 var(--font);
  cursor: pointer; touch-action: manipulation;
}
.g-op:hover:not(:disabled) { border-color: var(--muted); }
.g-op.g-selected { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--accent) 50%, #000); }
.g-op:disabled { opacity: .45; cursor: default; }
.g-tgt-steps {
  width: 100%; margin: 0; padding: 0;
  list-style: none; counter-reset: g-step;
  display: flex; flex-direction: column; gap: 4px;
}
.g-tgt-steps li {
  counter-increment: g-step;
  display: flex; align-items: baseline; gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font: 500 16px/1.3 var(--mono);
}
.g-tgt-steps li::before { content: counter(g-step) "."; color: var(--muted); min-width: 1.6em; }
.g-tgt-steps li.g-hit { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); }
.g-hit-mark { font-family: var(--font); font-weight: 700; color: var(--text); }
.g-tgt-type { width: 100%; border-top: 1px solid var(--line); padding-top: 8px; }
.g-tgt-type summary {
  cursor: pointer; min-height: 44px; display: flex; align-items: center;
  color: var(--accent); font-weight: 600; font-size: 15px;
}
.g-tgt-form { display: flex; flex-direction: column; gap: 6px; padding-bottom: 4px; }
.g-tgt-form label { font-size: 14px; color: var(--muted); }
.g-form-row { display: flex; gap: 8px; }
.g-input {
  flex: 1; min-width: 0; min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: 500 16px var(--mono);
}
.g-form-msg { font-size: 14px; color: var(--muted); min-height: 1.2em; }

/* =========================================================================================
   Picture Cross
   ========================================================================================= */
.g-nonogram { gap: 12px; }
.g-ngm-scroll { max-width: 100%; overflow-x: auto; padding: 2px; }
.g-ngm {
  --g-cell: clamp(24px, calc((100vw - 120px) / 10), 44px);
  border-collapse: collapse;
  margin: 0 auto;
  user-select: none;
  touch-action: none;
}
.g-ngm.g-n5 { --g-cell: clamp(44px, calc((100vw - 110px) / 5), 64px); }
.g-ngm.g-n15 { --g-cell: clamp(20px, calc((100vw - 140px) / 15), 32px); }
.g-ngm-corner { border: 0; padding: 0; }
.g-ngm th { font: 600 13px/1.1 var(--mono); color: var(--text); padding: 0; }
.g-n5 th { font-size: 15px; }
.g-ngm-ch { vertical-align: bottom; padding: 0 0 5px !important; border-radius: 4px 4px 0 0; }
.g-clue-v { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.g-ngm-rh { text-align: right; padding: 0 7px 0 4px !important; white-space: nowrap; border-radius: 4px 0 0 4px; }
.g-clue-h { display: inline-flex; gap: 6px; justify-content: flex-end; }
.g-ngm th.g-cur { background: var(--surface-2); }
.g-ngm th.g-ok { color: var(--muted); }
.g-ngm th.g-ok [aria-hidden] span { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.g-ngm-cell {
  width: var(--g-cell); height: var(--g-cell);
  min-width: var(--g-cell);
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: center; vertical-align: middle;
  font: 700 calc(var(--g-cell) * .62)/1 var(--font);
  color: var(--muted);
  cursor: pointer;
}
.g-ngm tbody tr:first-child .g-ngm-cell { border-top: 2px solid var(--text); }
.g-ngm tbody tr:last-child .g-ngm-cell { border-bottom: 2px solid var(--text); }
.g-ngm tbody tr .g-ngm-rh + .g-ngm-cell { border-left: 2px solid var(--text); }
.g-ngm tbody tr .g-ngm-cell:last-child { border-right: 2px solid var(--text); }
.g-ngm-cell.g-br { border-right: 2px solid color-mix(in srgb, var(--text) 60%, var(--surface)); }
.g-ngm tr.g-bb .g-ngm-cell { border-bottom: 2px solid color-mix(in srgb, var(--text) 60%, var(--surface)); }
.g-ngm-cell.g-fill { background: var(--text); }
.g-ngm-cell.g-mark { background: var(--surface); }
.g-ngm-cell.g-sel { box-shadow: inset 0 0 0 2px var(--accent); }
.g-ngm-cell.g-fill.g-sel { box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 0 4px var(--surface); }
.g-ngm-cell:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.g-done .g-ngm-cell { cursor: default; }
.g-done .g-ngm-cell:focus-visible { outline-color: var(--text); }
.g-done .g-ngm-cell.g-fill { background: var(--accent); transition: background-color .4s ease; }

.g-ngm-controls { display: flex; gap: 8px; width: 100%; max-width: 420px; }
.g-ngm-controls .g-btn { flex: 0 0 auto; padding: 0 14px; }
.g-seg { flex: 1; display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.g-seg-b {
  flex: 1; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; background: transparent; color: var(--text);
  font: 600 15px/1 var(--font);
  cursor: pointer; touch-action: manipulation;
}
.g-seg-b + .g-seg-b { border-left: 1px solid var(--line); }
.g-seg-b[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.g-seg-b:disabled { opacity: .45; cursor: default; }
.g-seg-b:focus-visible { outline-offset: -3px; }
.g-seg-i { font-size: 20px; line-height: 1; }
.g-seg-fill { width: 14px; height: 14px; border-radius: 2px; background: currentColor; }

/* ---------- finished (read-only) boards: controls go away, the board and result stay ---------- */
.g-done .g-kb,
.g-done .g-sdk-controls,
.g-done .g-tgt-ops,
.g-done .g-tgt-expr,
.g-done .g-tgt-type,
.g-done .g-tools,
.g-done .g-ngm-controls { display: none; }
.g-done .g-tgt-nums { display: none; }
.g-num.g-hit .g-num-m { display: none; }
.g-done .g-ngm th.g-ok [aria-hidden] span { text-decoration: none; }

/* ---------- motion ---------- */
.g-game.g-reduced, .g-game.g-reduced *, .g-game.g-reduced *::before, .g-game.g-reduced *::after {
  animation: none !important;
  transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
  .g-game *, .g-game *::before, .g-game *::after, .g-game {
    animation: none !important;
    transition: none !important;
  }
}
