/* "Play a round": the three card games, in one phone.
   This file is self-contained on purpose. It defines every colour it uses, so a visitor
   holding an older cached copy of styles.css still gets a readable game. */

:root {
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gold: #8a5a00;
  --gold-soft: rgba(240, 178, 75, 0.22);
  --warn: #b4462f;
  --warn-soft: rgba(180, 70, 47, 0.1);
  --pencil: #c4331a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --gold: #f0b24b;
    --gold-soft: rgba(240, 178, 75, 0.16);
    --warn: #f0907a;
    --warn-soft: rgba(240, 144, 122, 0.12);
    --pencil: #ff7a5c;
  }
}

/* ---------- layout ---------- */
.demo-grid { display: grid; gap: 2.5rem; align-items: center; }
.demo-grid > * { min-width: 0; }
@media (min-width: 900px) { .demo-grid { grid-template-columns: 1fr 380px; gap: 4rem; } }
.demo-copy .lead { max-width: 34rem; }
.demo-slot { display: flex; flex-direction: column; align-items: center; min-height: 690px; width: 100%; }
.demo-note { color: var(--muted); font-size: 0.85rem; text-align: center; margin: 1rem auto 0; max-width: 34ch; }
.demo-fallback { color: var(--muted); max-width: 30ch; text-align: center; padding-top: 3rem; }

/* game picker */
.gtabs { display: grid; gap: 0.6rem; margin-top: 1.5rem; }
.gtab {
  text-align: left; font: inherit; color: var(--text); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.9rem 1.1rem; display: grid; gap: 0.2rem; transition: border-color 0.15s, background 0.15s;
}
.gtab strong { font-size: 1.02rem; }
.gtab span { color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.gtab:hover { border-color: var(--accent); }
.gtab[aria-selected="true"] { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- phone ---------- */
.phone {
  width: 340px; max-width: 100%; height: 690px; border-radius: 46px; padding: 11px;
  background: linear-gradient(155deg, #2b3b34, #0a1410 62%);
  box-shadow: 0 40px 80px -30px rgba(6, 16, 12, 0.6), 0 14px 34px -14px rgba(6, 16, 12, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.phone-screen {
  position: relative; height: 100%; border-radius: 36px; overflow: hidden; background: var(--surface);
  display: flex; flex-direction: column; color: var(--text); font-size: 14px; line-height: 1.5;
}

/* ---------- card games ---------- */
.g-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 16px 18px 8px; }
.g-head strong { font-size: 15px; letter-spacing: -0.01em; }
.g-count { font: 600 11px var(--mono); color: var(--muted); }
.g-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.g-gate { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 26px; text-align: center; }
.g-gate h4 { font-size: 26px; line-height: 1.1; letter-spacing: -0.03em; margin: 0; }
.g-gate p { color: var(--muted); font-size: 13.5px; margin: 0; max-width: 27ch; }
.g-btn { border: 0; cursor: pointer; border-radius: 999px; padding: 14px 34px; background: var(--accent); color: var(--accent-ink); font: 700 15px var(--font); }
.g-btn.g-quiet { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 600; padding: 12px 26px; }
.g-sum { flex: 1; overflow-y: auto; padding: 8px 18px 18px; display: flex; flex-direction: column; gap: 14px; }
.g-sum .big { font: 700 11px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.g-sum h4 { font-size: 25px; line-height: 1.1; letter-spacing: -0.03em; margin: 0; }
.g-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.g-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.g-list li em { font: 500 11.5px var(--mono); color: var(--muted); font-style: normal; white-space: nowrap; }
.g-list li em.d-ok { color: var(--accent); }
.g-list li em.d-slow { color: var(--gold); }
.g-sum .g-note { color: var(--muted); font-size: 12.5px; margin: 0; }

/* fill the gap */
.fg-tick { display: flex; gap: 4px; padding: 0 18px; }
.fg-tick i { flex: 1; height: 3px; border-radius: 2px; background: var(--line); transition: background 0.3s; }
.fg-tick i.d-done { background: var(--accent); }
.fg-stage { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.fg-stack { position: relative; height: 238px; margin-bottom: 20px; }
.fg-peek { position: absolute; left: 12px; right: 12px; top: 12px; bottom: -12px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 24px -16px rgba(0, 0, 0, 0.5); }
.fg-peek.p2 { left: 24px; right: 24px; top: 24px; bottom: -24px; opacity: 0.6; }
.fg-face {
  position: absolute; inset: 0; border-radius: 20px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 16px 36px -22px rgba(0, 0, 0, 0.55); padding: 22px; display: flex; flex-direction: column; justify-content: center; gap: 14px;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
}
.fg-face.d-gone { transform: translateY(-26px) rotate(-3deg) scale(0.94); opacity: 0; }
.fg-face.d-enter { animation: fg-rise 0.34s cubic-bezier(0.2, 0.8, 0.3, 1); }
@keyframes fg-rise { from { transform: translateY(16px) scale(0.96); opacity: 0; } }
.fg-hint { font: 600 10px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.fg-sentence { margin: 0; font: 19px/1.65 ui-serif, Georgia, "Times New Roman", serif; }
.fg-gap { display: inline-block; min-width: 92px; padding: 0 4px; border-bottom: 2px solid var(--muted); text-align: center; }
.fg-gap b { font: 700 17px var(--font); color: var(--accent); }
.fg-gap.d-ok { border-color: var(--accent); background: var(--accent-soft); border-radius: 5px; }
.fg-gap.d-shown { border-color: var(--text); background: var(--gold-soft); border-radius: 5px; padding: 1px 6px; }
.fg-gap.d-shown b { color: var(--text); }
.fg-note { font: 500 12px var(--mono); color: var(--muted); }
.fg-note[hidden] { display: none; }
.fg-tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 92px; align-content: flex-start; }
.fg-tile { font: 600 15px var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 10px 13px; cursor: pointer; box-shadow: 0 1px 0 var(--line); transition: transform 0.12s, opacity 0.2s, background 0.2s; }
.fg-tile:hover { background: var(--accent-soft); border-color: var(--accent); }
.fg-tile.d-used { opacity: 0; pointer-events: none; transform: scale(0.9); }
.fg-undo { align-self: center; background: none; border: 0; padding: 4px; font: 600 11px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.fg-undo[hidden] { display: none; }

/* sounds right: follows the page theme, like the other games */
.sr-clock { padding: 18px 18px 0; }
.sr-clockrow { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.sr-clockrow .t { font: 800 26px/1 var(--font); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.sr-clockrow .s { font: 600 10.5px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.sr-drain { height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.sr-drain i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; }
.sr-arena { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 18px; text-align: center; }
.sr-pair { font: 700 30px/1.15 var(--font); letter-spacing: -0.03em; }
.sr-pair.d-ok { animation: sr-ok 0.3s; }
.sr-pair.d-miss { color: var(--muted); }
@keyframes sr-ok { 40% { color: var(--accent); } }
.sr-fix { font: 500 13px var(--mono); color: var(--gold); min-height: 1.3em; }
.sr-streak { display: flex; gap: 5px; min-height: 7px; }
.sr-streak i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.sr-streak i.d-on { background: var(--accent); }
.sr-judge { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 0 14px 16px; }
.sr-judge button { padding: 18px 8px; border-radius: 14px; border: 1px solid var(--line); cursor: pointer; background: var(--bg-alt); color: var(--text); font: 600 14px/1.25 var(--font); transition: border-color 0.14s, background 0.14s; }
.sr-judge button:hover { border-color: var(--accent); background: var(--accent-soft); }
.sr-judge small { display: block; font: 500 10px var(--mono); color: var(--muted); margin-top: 5px; }
.g-grp { font: 600 10px var(--mono); letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); margin: 0; }

/* wrong word (proof sheet) */
.ww-body { flex: 1; min-height: 0; padding: 0 14px 14px; display: flex; flex-direction: column; }
.ww-sheet { flex: 1; min-height: 0; display: grid; grid-template-columns: 32px 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: 0 14px 30px -22px rgba(0, 0, 0, 0.5); }
.ww-margin { border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 26px 0; gap: 13px; }
.ww-mark { font: 700 14px var(--mono); line-height: 1; color: var(--muted); opacity: 0.4; }
.ww-mark.d-on { color: var(--pencil); opacity: 1; transform: rotate(-9deg); transition: transform 0.3s cubic-bezier(0.2, 1.4, 0.4, 1); }
.ww-copy { padding: 22px 16px; overflow-y: auto; display: flex; flex-direction: column; }
.ww-src { font: 700 10px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--pencil); border: 1px solid var(--pencil); border-radius: 3px; padding: 3px 7px; align-self: flex-start; margin-bottom: 14px; }
.ww-line { margin: 0; font: 19px/1.75 ui-serif, Georgia, "Times New Roman", serif; }
.ww-word { font: inherit; color: inherit; background: none; border: 0; padding: 1px 0; margin: 0; cursor: pointer; border-radius: 3px; position: relative; }
.ww-word:hover { background: var(--warn-soft); }
.ww-word.d-dead { cursor: default; }
.ww-word.d-dead:hover { background: none; }
.ww-word.d-circle::before { content: ""; position: absolute; inset: -5px -7px; border: 1.5px solid var(--pencil); border-radius: 48% 52% 46% 54%; animation: ww-circle 0.75s ease forwards; }
@keyframes ww-circle { 0% { opacity: 0; transform: scale(0.85) rotate(-3deg); } 25% { opacity: 0.9; } 100% { opacity: 0; } }
.ww-word.d-struck { color: var(--muted); }
.ww-word.d-struck::after { content: ""; position: absolute; left: -3%; right: -3%; top: 54%; height: 1.6px; background: var(--pencil); border-radius: 2px; transform: rotate(-1.4deg); transform-origin: left; animation: ww-strike 0.3s ease; }
@keyframes ww-strike { from { transform: rotate(-1.4deg) scaleX(0); } }
.ww-fix { color: var(--pencil); font-weight: 700; display: inline-block; margin-left: 5px; transform: rotate(-1.2deg); animation: ww-write 0.34s cubic-bezier(0.2, 0.9, 0.3, 1) 0.2s both; }
@keyframes ww-write { from { opacity: 0; transform: translateY(4px) rotate(-4deg); } }
.ww-foot { padding: 12px 2px 0; display: grid; gap: 10px; }
.ww-hint { font: 500 11px var(--mono); color: var(--muted); text-align: center; min-height: 1.2em; }
.ww-note { font: 500 12px/1.55 var(--mono); border-left: 2px solid var(--pencil); padding-left: 10px; opacity: 0; transition: opacity 0.3s; min-height: 3.1em; }
.ww-note.d-on { opacity: 1; }
.ww-note b { color: var(--pencil); }
.ww-next { width: 100%; padding: 13px; border-radius: 6px; border: 1px solid var(--text); background: var(--text); color: var(--surface); cursor: pointer; font: 700 12px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.ww-next.d-on { opacity: 1; pointer-events: auto; }
.ww-next.d-quiet { background: transparent; color: var(--muted); border-color: var(--line); }
.ww-tally { display: flex; flex-direction: column; justify-content: center; gap: 14px; flex: 1; }
.ww-tally h4 { font-size: 25px; line-height: 1.15; letter-spacing: -0.02em; margin: 0; }

@media (max-width: 380px) {
  .d-promise article { padding: 10px 7px; }
  .d-promise h5 { font-size: 12px; }
  .d-promise p { font-size: 10.5px; }
  .d-h { font-size: 29px; }
}

@media (prefers-reduced-motion: reduce) {
  .fg-face.d-enter, .ww-fix, .ww-word.d-struck::after, .ww-word.d-circle::before, .sr-pair.d-ok { animation: none; }
  .fg-face, .fg-tile { transition: none; }
}
