:root {
  --ink: #171716;
  --paper: #f4f1e9;
  --paper-deep: #e9e4d8;
  --accent: #ff5f56;
  --accent-dark: #d83d38;
  --muted: #6f6b63;
  --line: rgba(23, 23, 22, 0.16);
  --shadow: 0 18px 52px rgba(36, 30, 23, 0.13);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--paper); }
button { color: inherit; font: inherit; }
a { color: inherit; }
.hidden { display: none !important; }

.site-shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  min-height: 76px; padding: 12px 4vw;
  background: rgba(244, 241, 233, 0.92); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; width: fit-content; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; color: var(--accent); background: var(--ink); font: 800 25px/1 Georgia, serif; transform: rotate(-3deg); }
.brand strong { display: block; font: 800 19px/1.1 Georgia, serif; letter-spacing: .08em; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: .68rem; letter-spacing: .08em; }
.dataset-count { margin: 0; color: var(--muted); font-size: .78rem; }
.dataset-count b { color: var(--ink); font: 700 1.05rem/1 Georgia, serif; }

main { width: min(1180px, 92vw); margin: 0 auto; }
.eyebrow { margin: 0 0 10px; color: var(--accent-dark); font: 800 .78rem/1.2 Georgia, serif; letter-spacing: .16em; }
h1 { margin: 0; font: 700 clamp(2.25rem, 5vw, 4.7rem)/.98 Georgia, "Yu Mincho", serif; letter-spacing: -.045em; }
.game-intro { min-height: 76vh; display: grid; align-content: center; justify-items: center; padding: 50px 0 70px; text-align: center; }
.game-intro > p:not(.eyebrow) { max-width: 610px; margin: 24px auto 0; color: var(--muted); font-size: 1rem; line-height: 1.9; }
.game-stat { display: flex; align-items: baseline; gap: 10px; margin: 44px 0 22px; }
.game-stat strong { font: 700 3.5rem/1 Georgia, serif; }
.game-stat span { color: var(--muted); font-size: .86rem; }
.primary-button { min-width: 180px; min-height: 52px; border: 1px solid var(--ink); padding: 12px 22px; color: white; background: var(--ink); font-weight: 800; cursor: pointer; transition: background .16s, color .16s, transform .16s; }
.primary-button:hover:not(:disabled) { color: var(--ink); background: var(--accent); transform: translateY(-2px); }
.primary-button:disabled { opacity: .35; cursor: not-allowed; }
.accent-button { color: var(--ink); background: var(--accent); border-color: var(--accent); }
.accent-button:hover:not(:disabled) { color: white; background: var(--ink); border-color: var(--ink); }
.text-button { border: 0; border-bottom: 1px solid currentColor; padding: 5px 0; background: transparent; font-size: .88rem; font-weight: 700; cursor: pointer; }
.text-button:disabled { opacity: .35; cursor: not-allowed; }

.game-panel { padding: 52px 0 82px; }
.game-header { display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.game-header h1 { font-size: clamp(2rem, 5vw, 4.2rem); }
.game-status { color: var(--muted); font: 700 .86rem/1.4 Georgia, serif; letter-spacing: .08em; }
.progress-track { height: 5px; margin: 32px 0 20px; background: var(--paper-deep); overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .25s ease; }
.game-instruction { margin: 0 0 20px; color: var(--muted); font-size: .92rem; }
.game-grid { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 9px; }
.game-card { position: relative; border: 0; padding: 0; background: white; box-shadow: 0 8px 26px rgba(36,30,23,.1); cursor: pointer; text-align: left; overflow: hidden; }
.game-card img { width: 100%; aspect-ratio: 1 / 1.06; object-fit: cover; display: block; background: #ddd9cf; filter: saturate(.9); }
.game-card-name { display: block; min-height: 48px; padding: 9px 8px 10px; font: 700 .78rem/1.35 Georgia, "Yu Mincho", serif; }
.check { position: absolute; right: 7px; top: 7px; display: grid; width: 26px; height: 26px; place-items: center; border-radius: 50%; color: transparent; background: rgba(255,255,255,.9); box-shadow: 0 3px 12px rgba(0,0,0,.13); font-size: .72rem; }
.game-card[aria-pressed="true"] { outline: 4px solid var(--accent); outline-offset: -4px; }
.game-card[aria-pressed="true"] .check { color: white; background: var(--accent); }
.game-grid.pair { grid-template-columns: repeat(2, minmax(0, 430px)); justify-content: center; }
.game-grid.pair .game-card img { aspect-ratio: 1 / 1.12; }
.game-grid.pair .game-card-name { min-height: 0; padding: 14px 16px 16px; font-size: 1.05rem; }
.game-grid.pair .check { right: 12px; top: 12px; width: 34px; height: 34px; font-size: 1rem; }
.game-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 28px; }

.result-panel { padding: 58px 0 72px; text-align: center; }
.result-note { color: var(--muted); font-size: 1rem; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 900px; margin: 38px auto 32px; padding: 10px; background: white; box-shadow: var(--shadow); }
.result-card { position: relative; overflow: hidden; background: #e1ddd4; }
.result-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.result-card strong { position: absolute; inset: auto 0 0; padding: 28px 10px 10px; color: white; background: linear-gradient(transparent, rgba(0,0,0,.8)); font: 700 .96rem/1.3 Georgia, "Yu Mincho", serif; text-align: left; }
.result-actions { display: flex; justify-content: center; align-items: center; gap: 28px; flex-wrap: wrap; }

.loading-view { min-height: 75vh; display: grid; place-items: center; align-content: center; gap: 18px; color: var(--muted); }
.loader { width: 34px; height: 34px; border: 3px solid var(--paper-deep); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
footer { width: min(1180px, 92vw); margin: 0 auto; padding: 26px 0 42px; border-top: 1px solid var(--line); color: var(--muted); font-size: .74rem; line-height: 1.7; }
footer p { margin: 3px 0; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 24px; translate: -50% 20px; padding: 11px 16px; color: white; background: var(--ink); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s ease; font-size: .84rem; }
.toast.show { opacity: 1; translate: -50% 0; }

@media (max-width: 860px) {
  .game-grid { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 620px) {
  .topbar { min-height: 68px; }
  .brand small { display: none; }
  .game-intro { min-height: 72vh; }
  .game-panel { padding-top: 36px; }
  .game-header { align-items: start; }
  .game-grid { grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .game-grid.pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-card-name { min-height: 46px; font-size: .76rem; }
  .result-grid { gap: 5px; padding: 5px; }
  .result-card strong { font-size: .74rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
