/* Four in a Row. The top part is the shared paper-and-ink look of the other sections (copied from
   ../hangman/styles.css: header, intro, tabs, buttons, article, footer); the grid is at the bottom. */
:root {
  --paper: #faf8f2;
  --ink: #292d28;
  --muted: #697064;
  --line: #dfdfd3;
  --accent: #bd5f3e;
  --teal: #24878b;
  --pad: #fffdf8;
  --dot: #d5d3c4;
  --ink-mark: #bd5f3e;
  --display: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Arial Rounded MT Bold", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1d1a; --ink: #ecebe3; --muted: #a3a898; --line: #3a3d36;
    --accent: #e27f5a; --teal: #58b9bd; --pad: #232621; --dot: #3d4138; --ink-mark: #e27f5a;
  }
}
:root[data-theme="dark"] {
  --paper: #1b1d1a; --ink: #ecebe3; --muted: #a3a898; --line: #3a3d36;
  --accent: #e27f5a; --teal: #58b9bd; --pad: #232621; --dot: #3d4138; --ink-mark: #e27f5a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--teal); outline-offset: 4px; }
.wrap { width: min(1120px, calc(100% - 48px)); margin: 0 auto; }

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; gap: 20px;
  padding: 20px 0; border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.crumbs { flex: 1; color: var(--muted); font-size: 15px; min-width: 0; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { margin: 0 8px; color: var(--line); }
.crumbs [aria-current] { color: var(--ink); }
.theme-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; display: grid; place-items: center; cursor: pointer;
}
.theme-btn:hover { border-color: var(--ink); }
.theme-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.langs { display: flex; gap: 2px; }
.langs a { padding: 5px 8px; border-radius: 999px; font-size: 13px; font-weight: 700; letter-spacing: .03em; color: var(--muted); text-decoration: none; }
.langs a:hover { color: var(--ink); }
.langs a[aria-current] { color: var(--ink); background: var(--line); }

/* ---------- intro ---------- */
.intro { padding: 34px 0 22px; }
.intro h1 {
  margin: 0; font-family: var(--display); font-weight: 800;
  font-size: clamp(40px, 6.4vw, 68px); line-height: 1.02; letter-spacing: -0.02em;
}
.lede { margin: 12px 0 0; font-size: 18px; color: var(--muted); max-width: 58ch; }

.durations { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.durations a {
  padding: 7px 16px; border: 1.5px solid var(--line); border-radius: 999px;
  text-decoration: none; font-size: 15px; color: var(--muted);
}
.durations a:hover { border-color: var(--ink); color: var(--ink); }
.durations a[aria-current] { background: var(--ink); border-color: var(--ink); color: var(--paper); font-weight: 600; }

.mode-switch { display: inline-flex; margin: 0 0 18px; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.mode-switch button { border: 0; background: transparent; padding: 8px 18px; cursor: pointer; font-weight: 600; }
.mode-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.stop-row { margin: 14px 0 0; min-height: 0; }
.stop-row:has([hidden]) { margin: 0; }

.challenge {
  margin: 0 0 20px; padding: 12px 16px; border-left: 4px solid var(--accent);
  background: var(--pad); font-weight: 600;
}

.actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 22px; }
.btn {
  padding: 11px 22px; border-radius: 999px; border: 1.5px solid var(--ink);
  background: transparent; cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
/* ---------- article ---------- */
.prose { max-width: 70ch; margin: 56px 0 0; font-size: 17px; line-height: 1.7; }
.prose h2 { font-family: var(--display); font-weight: 800; font-size: 28px; line-height: 1.2; margin: 44px 0 10px; letter-spacing: -0.01em; }
.prose h3 { font-size: 19px; margin: 26px 0 6px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 14px; }
.prose li { margin-bottom: 6px; }
.prose a { color: var(--accent); }
.prose table { width: 100%; border-collapse: collapse; font-size: 16px; margin: 0 0 16px; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 9px 12px 9px 0; text-align: left; vertical-align: top; }
.prose th { border-bottom: 2px solid var(--ink); font-weight: 700; }
.prose td:first-child { font-weight: 700; white-space: nowrap; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq-answer { padding: 8px 0 0; color: var(--muted); }

/* ---------- footer ---------- */
.site-footer { margin-top: 64px; padding: 22px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.site-footer a { text-decoration: none; color: var(--ink); }
.site-footer a:hover { color: var(--accent); }
.site-footer a[aria-current] { color: var(--muted); }
.site-footer .footer-site { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.site-footer p { margin: 10px 0 0; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 18px 0 0; }
.toolbar .label { color: var(--muted); font-size: 15px; }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; font-weight: 600; font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }


/* ---------- small screens (shared) ---------- */
@media (max-width: 760px) {
  .wrap { width: calc(100% - 32px); }
  .site-header { gap: 12px; padding: 14px 0; }
  .crumbs { display: none; }
  .brand { flex: 1; }
  .intro { padding: 24px 0 16px; }
  .lede { font-size: 16px; }
  .durations { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px 6px; scrollbar-width: none; }
  .durations::-webkit-scrollbar { display: none; }
  .durations a { white-space: nowrap; flex: none; }
  .prose { font-size: 16px; margin-top: 40px; }
  .prose h2 { font-size: 23px; }
  .prose table { display: block; overflow-x: auto; }
}

/* ---------- four in a row ---------- */
.btn[disabled] { opacity: .45; cursor: default; }
.btn[disabled]:hover { border-color: var(--ink); color: inherit; }
.fr-game { --board: #2f5aa8; --board-edge: #23467f; --hole: var(--paper); --red: #d9483b; --yellow: #f2c230; max-width: 620px; }
:root[data-theme="dark"] .fr-game { --board: #23457f; --board-edge: #17305a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fr-game { --board: #23457f; --board-edge: #17305a; } }
.fr-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0;
  padding: clamp(6px, 1.4vw, 12px); background: var(--board); border: 2px solid var(--board-edge); border-radius: 18px;
  box-shadow: 0 8px 20px rgba(20, 40, 80, .25); user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.fr-col {
  display: flex; flex-direction: column; gap: 0; padding: 0; border: 0; background: transparent; border-radius: 12px;
  cursor: pointer; overflow: hidden;
}
.fr-col:disabled { cursor: default; }
@media (hover: hover) { .fr-col:not(:disabled):hover { background: rgba(255, 255, 255, .12); } }
.fr-col:not(:disabled):focus-visible { background: rgba(255, 255, 255, .12); }
.fr-col.is-hint { background: rgba(255, 255, 255, .22); box-shadow: inset 0 0 0 3px #7fe0d5; }
.fr-cell { position: relative; display: block; aspect-ratio: 1; padding: 9%; }
.fr-cell i {
  display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--hole);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, .28);
}
.fr-cell.is-red i { background: radial-gradient(circle at 35% 30%, #f07a6c, var(--red) 55%, #a8322a); box-shadow: inset 0 -3px 5px rgba(0, 0, 0, .25); }
.fr-cell.is-yellow i { background: radial-gradient(circle at 35% 30%, #fde58f, var(--yellow) 55%, #c79414); box-shadow: inset 0 -3px 5px rgba(0, 0, 0, .2); }
.fr-cell.is-drop i { animation: fall calc(.07s * var(--fall, 6) + .1s) cubic-bezier(.45, 0, 1, 1); }
@keyframes fall { from { transform: translateY(calc(var(--fall, 6) * -100%)); } to { transform: translateY(0); } }
.fr-cell.is-last::after { content: ""; position: absolute; left: 50%; top: 50%; width: 16%; aspect-ratio: 1; margin: -8% 0 0 -8%; border-radius: 50%; background: rgba(255, 255, 255, .85); }
.fr-cell.is-win i { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); animation: winpulse 1s ease-in-out infinite alternate; }
@keyframes winpulse { to { transform: scale(.9); } }
.fr-grid.is-over .fr-cell:not(.is-win) i { opacity: .55; }
.fr-status { margin: 14px 0 0; min-height: 1.6em; font-weight: 600; }
.fr-grid[data-turn="yellow"] ~ .fr-status::before, .fr-grid[data-turn="red"] ~ .fr-status::before {
  content: ""; display: inline-block; width: .8em; height: .8em; border-radius: 50%; margin-right: 8px; vertical-align: -1px; background: var(--red);
}
.fr-grid[data-turn="yellow"] ~ .fr-status::before { background: var(--yellow); }
.fr-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 0; }
.fr-result { margin: 18px 0 0; padding: 16px 18px; border-left: 4px solid var(--ink); background: var(--pad); }
.fr-result.is-win { border-left-color: var(--teal); }
.fr-result-head { margin: 0; font: 800 26px/1.2 var(--display); }
.fr-result-sub { margin: 6px 0 12px; color: var(--muted); }
.fr-result-sub:empty { margin: 6px 0 0; }
.fr-bar { margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.fr-group { display: inline-flex; align-items: center; gap: 10px; }
.fr-note { margin: 12px 0 0; color: var(--muted); font-size: 15px; }
@media (max-width: 760px) {
  .fr-grid { border-radius: 14px; }
  .fr-bar { gap: 8px 10px; }
  .fr-bar .label { font-size: 13px; }
  .fr-bar .seg button { padding: 5px 10px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { .fr-cell.is-drop i, .fr-cell.is-win i { animation: none; } }
