:root {
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #f8f7f3;
  --text: #1a1a18;
  --muted: #5b5850;
  --line: #e2ded4;
  --line-strong: #cfcabd;
  --accent: #0b6e4f;
  --accent-hover: #095c42;
  --accent-soft: #e3f1ea;
  --accent-ink: #ffffff;
  --found: #e3172d;
  --hint: #b86e00;
  --miss: #555;
  --shadow: 0 1px 2px rgba(20, 20, 15, .06), 0 6px 24px rgba(20, 20, 15, .07);
  --radius: 18px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1211;
  --surface: #181c1a;
  --surface-2: #1f2421;
  --text: #f1efe9;
  --muted: #b3b0a7;
  --line: #2b312e;
  --line-strong: #3b433f;
  --accent: #3ec99a;
  --accent-hover: #5ad6ab;
  --accent-soft: #173229;
  --accent-ink: #08201a;
  --found: #ff4d5e;
  --hint: #ffb23e;
  --miss: #ddd;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1211;
    --surface: #181c1a;
    --surface-2: #1f2421;
    --text: #f1efe9;
    --muted: #b3b0a7;
    --line: #2b312e;
    --line-strong: #3b433f;
    --accent: #3ec99a;
    --accent-hover: #5ad6ab;
    --accent-soft: #173229;
    --accent-ink: #08201a;
    --found: #ff4d5e;
    --hint: #ffb23e;
    --miss: #ddd;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body > main { flex: 1 0 auto; width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.2; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* header */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 4px; min-height: 60px; }
.logo {
  display: inline-flex; align-items: center; gap: 10px; margin-right: auto;
  font-weight: 800; font-size: 22px; letter-spacing: -0.03em; color: var(--text); text-decoration: none;
}
.logo:hover { color: var(--text); }
.logo svg { width: 34px; height: 34px; flex: none; border-radius: 9px; }
.logo b { color: var(--accent); }
.icon-btn {
  min-width: 48px; min-height: 48px; border: 0; background: none; color: var(--text);
  font-size: 22px; border-radius: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .15s;
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--surface-2); color: var(--text); }

/* game header */
.game-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 14px; }
.game-head h1 { font-size: 24px; margin: 0; font-weight: 800; }
.game-head h1 span { color: var(--accent); }
.game-head .date { color: var(--muted); font-size: 15px; margin-top: 2px; }
.tabs {
  display: inline-flex; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px; box-shadow: var(--shadow);
}
.tabs a {
  min-width: 96px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 700; transition: background-color .15s, color .15s;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }

/* game card */
#game {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px;
}

/* status bar */
.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 2px 12px; min-height: 36px; }
.dots { display: flex; gap: 6px; }
.dots i {
  width: 22px; height: 22px; border-radius: 50%; display: block; position: relative;
  border: 2px solid var(--line-strong); background: var(--surface-2); transition: background-color .2s, border-color .2s;
}
.dots i.on { background: var(--found); border-color: var(--found); }
.dots i.on::after {
  content: ""; position: absolute; left: 6px; top: 2.5px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.count { font-weight: 700; font-size: 15px; }
.bar .chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  font-size: 15px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums;
}
.bar .chip:empty { display: none; }
.timer { margin-left: auto; min-width: 74px; }

.btn {
  min-height: 48px; padding: 0 20px; border-radius: 14px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  transition: background-color .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .5; cursor: default; }
.btn[hidden] { display: none; }

/* board */
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 760px) and (orientation: portrait) { .board { grid-template-columns: 1fr; gap: 8px; } }
.panel {
  position: relative; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden;
  background-color: var(--line); background-repeat: no-repeat; background-size: 200% 100%;
  touch-action: manipulation; cursor: crosshair; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.panel.a { background-position: 0 0; }
.panel.b { background-position: 100% 0; }
.panel svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.panel .lbl {
  position: absolute; left: 10px; top: 10px; font-size: 12px; font-weight: 800; letter-spacing: .06em;
  background: rgba(0,0,0,.6); color: #fff; padding: 4px 10px; border-radius: 999px; pointer-events: none;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.panel.b .lbl { background: rgba(227,23,45,.88); }
.ring { fill: none; stroke: var(--found); stroke-width: 5; }
.ring-hint { fill: none; stroke: var(--hint); stroke-width: 5; stroke-dasharray: 12 8; }
.miss { stroke: var(--miss); stroke-width: 5; stroke-linecap: round; }
@media (prefers-reduced-motion: no-preference) {
  .ring { animation: pop .25s ease-out; transform-box: fill-box; transform-origin: center; }
  .ring-hint { animation: pulse 1s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
  @keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
  @keyframes pulse { 50% { transform: scale(1.12); } }
}

.below { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 14px 0 0; }
.below .btn { flex: 1 1 auto; }
@media (min-width: 761px) { .below .btn { flex: 0 0 auto; } }
.note { color: var(--muted); font-size: 15px; }
.pnav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 14px 2px 0; font-weight: 600; }
.pnav a, .pnav span { flex: 1 1 0; padding: 10px 0; }
.pnav a:nth-child(2) { text-align: center; }
.pnav .next { text-align: right; }
.tip { display: flex; gap: 10px; align-items: flex-start; margin: 14px 2px 0; }
.tip svg { flex: none; margin-top: 2px; color: var(--accent); }
.tip p { margin: 0; }
.locked { padding: 40px 16px; text-align: center; }
.locked h2 { margin-top: 0; }

/* ad slots: reserved space above/below the board only */
.ad-slot { display: none; margin: 14px auto; text-align: center; }
.ad-slot.on { display: block; min-height: 100px; }

/* dialog */
dialog {
  border: 1px solid var(--line); border-radius: 22px; padding: 0; width: min(440px, calc(100% - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
dialog::backdrop { background: rgba(10,12,11,.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dlg { padding: 26px 22px 22px; }
.dlg h2 { margin: 0 44px 6px 0; font-size: 26px; }
dialog .x { position: absolute; right: 8px; top: 8px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin: 16px 0; }
.stats > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 4px 10px; }
.stats b { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stats span { display: block; font-size: 12px; line-height: 1.3; margin-top: 4px; color: var(--muted); font-weight: 600; }
.result { font-size: 18px; margin: 8px 0; }
.dlg .row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.dlg .row .btn { flex: 1; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 12px 20px; border-radius: 999px; font-weight: 700; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 10;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; }

/* content pages */
.page { max-width: 760px; margin: 0 auto; padding: 24px 16px 40px; }
.page > h1 { font-size: 32px; margin: 4px 0 16px; font-weight: 800; }
.page .card, .page.prose {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.page.prose { padding: 8px 28px 28px; margin: 24px auto 0; width: calc(100% - 32px); }
@media (max-width: 600px) { .page.prose { padding: 4px 18px 22px; margin-top: 12px; width: calc(100% - 20px); } }
.prose h1 { font-size: 30px; margin: 24px 0 12px; font-weight: 800; }
.prose h2 { font-size: 21px; margin: 30px 0 8px; }
.prose ul { padding-left: 1.2em; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--accent); }
.prose .btn { margin-top: 8px; }
.archive-month h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 28px 4px 10px; }
.arch {
  list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.arch li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.arch li:first-child { border-top: 0; }
.arch .d { flex: 1; font-weight: 600; }
.arch .d small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.arch a.m {
  min-width: 84px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid var(--line-strong); border-radius: 12px; text-decoration: none; color: var(--text); font-weight: 700;
  transition: background-color .15s;
}
.arch a.m:hover { background: var(--surface-2); }
.arch a.m.done { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* footer */
.foot { border-top: 1px solid var(--line); margin-top: 40px; padding: 28px 0 32px; color: var(--muted); font-size: 15px; background: var(--surface); }
.foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px 32px; }
.foot .brand { max-width: 340px; }
.foot .brand .logo { font-size: 19px; }
.foot .brand .logo svg { width: 28px; height: 28px; border-radius: 7px; }
.foot .brand p { margin: 8px 0 0; }
.foot nav { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 0 4px; margin: 0 -10px; }
.foot nav a { color: var(--muted); text-decoration: none; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; padding: 0 10px; border-radius: 10px; }
.foot nav a:hover { color: var(--text); background: var(--surface-2); }
.foot small { flex-basis: 100%; font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* phones: keep the photos as large as possible and the board high on screen */
@media (max-width: 600px) {
  .game-head { margin: 14px 0 10px; gap: 8px; }
  .game-head h1 { font-size: 20px; }
  .game-head .date { font-size: 14px; }
  .tabs a { min-width: 76px; }
  #game { margin: 0 -8px; padding: 8px; border-radius: 16px; }
  .bar { margin: 2px 4px 8px; gap: 8px; }
  .dots { gap: 4px; }
  .dots i { width: 20px; height: 20px; }
  .dots i.on::after { left: 5.5px; top: 2px; }
  .panel { border-radius: 10px; }
  .below { margin-top: 10px; }
  .tip { margin: 10px 4px 4px; }
  .foot nav a { padding: 0 8px; }
}
