/* =========================================================
   HANPAN — 한판
   Warm paper, hard rules, one accent. No gradients, no glass.
   ========================================================= */

:root {
  --bg: #f2eee3;
  --panel: #faf7ef;
  --panel-2: #eae3d3;
  --shade: #e3dbc8;
  --ink: #17140f;
  --ink-2: #3f3a2f;
  --mute: #7d7565;
  --line: #d8cfbc;
  --line-strong: #b5aa93;
  --accent: #d74325;
  --accent-deep: #a92f18;
  --green: #2e5c4f;
  --serif: "Gowun Batang", "Noto Serif KR", "Nanum Myeongjo", Georgia, serif;
  --sans: "IBM Plex Sans KR", Pretendard, -apple-system, BlinkMacSystemFont, "Malgun Gothic", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --max: 1220px;
  --gutter: 44px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

::selection { background: var(--accent); color: var(--bg); }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4, p, dl, dd, dt, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.wrap {
  width: 100%;
  max-width: calc(var(--max) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  font: 500 12px var(--mono);
}
.skip-link:focus { left: 12px; top: 12px; }

.grain {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--bg);
  border-bottom: 1px solid var(--ink);
}

.header-inner {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  line-height: 1;
}

.brand-mark {
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  color: var(--ink);
  transition: transform .35s ease;
}
.brand:hover .brand-mark { transform: rotate(90deg); }

.brand-word {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -.045em;
  padding-top: 2px;
}

.brand-sub {
  font: 500 9px var(--mono);
  letter-spacing: .22em;
  color: var(--mute);
  margin-left: 1px;
  padding-top: 3px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 30px;
}

.nav-link {
  font: 500 11px var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid transparent;
  transition: border-color .15s, color .15s;
}
.nav-link:hover { border-color: var(--ink); }
.nav-count { font-size: 9px; color: var(--accent); }

.sound-toggle {
  appearance: none;
  background: none;
  border: 0;
  padding: 8px 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font: 500 11px var(--mono);
  letter-spacing: .08em;
  color: var(--mute);
  transition: color .15s;
}
.sound-toggle:hover { color: var(--ink); }
.sound-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(215, 67, 37, .12);
  transition: background .15s, box-shadow .15s;
}
.sound-toggle[aria-pressed="false"] .sound-dot {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--mute);
}

/* ---------- ticker ---------- */

.ticker {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.ticker-inner {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  font: 400 9px var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--mute);
}
.ticker-items {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
.ticker-items i { font-style: normal; color: var(--line-strong); }
.ticker-right { white-space: nowrap; }
.ticker-right span { color: var(--ink); }

/* ---------- home hero ---------- */

.home-hero {
  padding: clamp(54px, 7vw, 92px) 0 clamp(44px, 5.5vw, 68px);
  border-bottom: 1px solid var(--ink);
}
.home-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .62fr);
  gap: clamp(40px, 6vw, 96px);
  align-items: end;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 500 10px var(--mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--mute);
}
.eyebrow::before {
  content: "";
  width: 30px;
  height: 1px;
  background: var(--ink);
  flex: 0 0 auto;
}

.hero-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(72px, 9.4vw, 132px);
  line-height: 1.08;
  letter-spacing: -.05em;
  margin: 22px 0 30px;
}
.hero-title span { display: block; }
.hero-title .accent { color: var(--accent); }

.hero-lede {
  max-width: 42ch;
  font-size: 16.5px;
  line-height: 1.75;
  color: var(--ink-2);
  word-break: keep-all;
}
.hero-lede strong { font-weight: 600; color: var(--ink); }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px 26px;
  margin-top: 34px;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 40px;
  padding: 11px 16px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 500 10.5px var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .35; cursor: default; pointer-events: none; }

.btn--primary {
  background: var(--ink);
  color: var(--bg);
  padding: 14px 20px;
  min-height: 46px;
}
.btn--primary:hover { background: var(--accent); border-color: var(--accent); color: #fff8f0; }

.btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff8f0;
}
.btn--accent:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.btn--ghost { border-color: var(--line-strong); }
.btn--sm { min-height: 32px; padding: 7px 11px; font-size: 9.5px; }

.arrow { font-family: var(--mono); font-size: 13px; line-height: 1; transform: translateY(-1px); }

.text-link {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  font: 500 11px var(--mono);
  letter-spacing: .04em;
  color: var(--mute);
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 3px;
  transition: color .15s, border-color .15s;
}
.text-link b { font-weight: 500; color: var(--ink); }
.text-link:hover { color: var(--accent); border-color: var(--accent); }
.text-link:hover b { color: var(--accent); }

/* hero side panel */

.hero-side { padding-bottom: 4px; }

.ledger-panel {
  border-top: 1px solid var(--ink);
  padding-top: 14px;
}
.ledger-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font: 500 9px var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--mute);
  padding-bottom: 10px;
}
.ledger-head .live { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); }
.ledger-head .live::before {
  content: "";
  width: 5px; height: 5px; background: var(--accent); border-radius: 50%;
}
.ledger-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.ledger-row dt {
  font-size: 12px;
  color: var(--mute);
  word-break: keep-all;
}
.ledger-row dd {
  font: 500 15px var(--mono);
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.ledger-row dd small { font-size: 10px; color: var(--mute); }

.resume-link {
  margin-top: 14px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 10px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: none;
  font: 500 11px var(--mono);
  letter-spacing: .04em;
  text-align: left;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.resume-link:hover { color: var(--accent); border-color: var(--accent); }
.resume-link span:last-child { font-size: 15px; }

.stamp {
  margin-top: 18px;
  width: fit-content;
  margin-left: auto;
  border: 1px solid var(--accent);
  color: var(--accent);
  font: 500 8.5px var(--mono);
  letter-spacing: .22em;
  text-transform: uppercase;
  padding: 7px 10px 6px;
  transform: rotate(-3deg);
  opacity: .85;
  user-select: none;
}
.hero-note {
  margin-top: 16px;
  font: 400 9.5px var(--mono);
  letter-spacing: .06em;
  color: var(--mute);
  text-align: right;
}

/* ---------- games section ---------- */

.games-section { padding: clamp(48px, 6vw, 76px) 0 clamp(64px, 8vw, 100px); }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.section-title {
  display: flex;
  align-items: baseline;
  gap: 16px;
}
.section-title h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(30px, 3.6vw, 44px);
  letter-spacing: -.04em;
  line-height: 1;
}
.section-count {
  font: 500 10px var(--mono);
  letter-spacing: .12em;
  color: var(--mute);
  padding-bottom: 4px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  align-items: center;
}
.filter-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 5px 0;
  cursor: pointer;
  font: 500 10px var(--mono);
  letter-spacing: .1em;
  color: var(--mute);
  border-bottom: 1px solid transparent;
  transition: color .15s, border-color .15s;
}
.filter-btn:hover { color: var(--ink); }
.filter-btn[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); }
.filter-btn sup { font-size: 8px; color: var(--line-strong); margin-left: 3px; }
.filter-btn[aria-pressed="true"] sup { color: var(--accent); }

.game-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 252px;
  padding: 20px 22px 18px;
  background: var(--bg);
  color: var(--ink);
  text-align: left;
  border: 0;
  cursor: pointer;
  overflow: hidden;
  transition: background .18s ease, color .18s ease;
  -webkit-tap-highlight-color: transparent;
}
.game-card::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: 16px;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width .28s cubic-bezier(.2,.7,.3,1);
}
.game-card:hover,
.game-card:focus-visible {
  background: var(--ink);
  color: var(--bg);
  outline: none;
}
.game-card:hover::after,
.game-card:focus-visible::after { width: 28px; }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font: 500 9px var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
}
.card-no { color: var(--mute); }
.card-cat { color: var(--mute); }
.game-card:hover .card-no,
.game-card:hover .card-cat { color: #a99f8d; }
.game-card:hover .card-cat { color: var(--accent); }

.card-main { margin: auto 0; padding: 26px 0 24px; }

.card-icon {
  display: block;
  width: 36px;
  height: 36px;
  color: var(--ink);
  margin-bottom: 18px;
  transition: color .18s ease, transform .25s ease;
}
.game-card:hover .card-icon { color: var(--accent); transform: translateY(-2px); }
.card-icon svg { width: 100%; height: 100%; }

.card-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 27px;
  letter-spacing: -.035em;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.card-title .card-sub {
  font: 500 8.5px var(--mono);
  letter-spacing: .14em;
  color: var(--mute);
  text-transform: uppercase;
}
.game-card:hover .card-sub { color: #a99f8d; }

.card-desc {
  margin-top: 7px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--mute);
  word-break: keep-all;
  transition: color .18s ease;
  max-width: 30ch;
}
.game-card:hover .card-desc { color: #bdb3a0; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font: 400 9px var(--mono);
  letter-spacing: .05em;
  color: var(--mute);
  transition: border-color .18s ease, color .18s ease;
}
.game-card:hover .card-foot { border-color: #3a352c; color: #a99f8d; }
.card-best { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.game-card:hover .card-best { color: var(--bg); }

.game-card.is-featured {
  grid-column: span 2;
  min-height: 300px;
  padding: 24px 30px 22px;
}
.game-card.is-featured .card-main {
  padding: 34px 0 28px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "title icon" "desc icon";
  align-items: end;
  gap: 4px 20px;
}
.game-card.is-featured .card-icon { grid-area: icon; width: 72px; height: 72px; margin: 0; align-self: center; }
.game-card.is-featured .card-title { grid-area: title; font-size: clamp(38px, 4.4vw, 56px); align-self: end; }
.game-card.is-featured .card-desc { grid-area: desc; margin-top: 4px; font-size: 14px; max-width: 38ch; }

.game-card.is-random {
  background: var(--accent);
  color: #fff8f0;
}
.game-card.is-random .card-no,
.game-card.is-random .card-cat,
.game-card.is-random .card-desc,
.game-card.is-random .card-sub,
.game-card.is-random .card-foot { color: rgba(255, 248, 240, .72); }
.game-card.is-random .card-foot { border-color: rgba(255, 248, 240, .28); }
.game-card.is-random .card-icon { color: #fff8f0; }
.game-card.is-random::after { background: #fff8f0; }
.game-card.is-random:hover,
.game-card.is-random:focus-visible { background: var(--ink); color: var(--bg); }
.game-card.is-random:hover .card-cat { color: var(--accent); }
.game-card.is-random:hover .card-desc,
.game-card.is-random:hover .card-no,
.game-card.is-random:hover .card-sub,
.game-card.is-random:hover .card-foot { color: #a99f8d; }
.game-card.is-random:hover .card-best { color: var(--bg); }

.game-card[hidden] { display: none; }
.game-grid.is-filtering .game-card.is-featured { grid-column: span 1; min-height: 252px; padding: 20px 22px 18px; }
.game-grid.is-filtering .game-card.is-featured .card-main { display: block; padding: 26px 0 24px; }
.game-grid.is-filtering .game-card.is-featured .card-icon { width: 36px; height: 36px; margin-bottom: 18px; }
.game-grid.is-filtering .game-card.is-featured .card-title { font-size: 27px; }

/* ---------- game page ---------- */

.game-page { padding-top: 34px; }

.game-crumb {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  font: 500 9.5px var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--mute);
}
.game-crumb a { border-bottom: 1px solid transparent; padding-bottom: 2px; transition: color .15s, border-color .15s; }
.game-crumb a:hover { color: var(--ink); border-color: var(--ink); }
.game-crumb .crumb-cat { color: var(--accent); }

.game-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  align-items: end;
  padding: 26px 0 30px;
  border-bottom: 1px solid var(--ink);
}
.game-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(48px, 6.6vw, 84px);
  letter-spacing: -.055em;
  line-height: .95;
  margin: 12px 0 12px;
}
.game-desc {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--mute);
  max-width: 52ch;
  word-break: keep-all;
}
.game-head-side { display: flex; gap: 44px; padding-bottom: 4px; }
.head-stat { display: flex; flex-direction: column; gap: 5px; }
.head-stat span {
  font: 500 8.5px var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--mute);
}
.head-stat strong {
  font: 500 16px var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  white-space: nowrap;
}

.game-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
  gap: 44px;
  align-items: start;
  padding: 34px 0 54px;
}

.stage {
  background: var(--panel);
  border: 1px solid var(--ink);
  min-width: 0;
}
.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 34px;
  padding: 0 13px;
  border-bottom: 1px solid var(--line);
  font: 500 8.5px var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--mute);
}
.stage-status { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); }
.stage-status i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--mute);
  transition: background .2s;
}
.stage-status.is-live i { background: var(--accent); animation: pulse 1.8s infinite; }
.stage-status.is-paused i { background: transparent; box-shadow: inset 0 0 0 1px var(--accent); }
.stage-id { color: var(--mute); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(215,67,37,.0); }
  50% { box-shadow: 0 0 0 4px rgba(215,67,37,.13); }
}

.stage-inner {
  padding: clamp(16px, 3.2vw, 34px);
  min-height: clamp(400px, 56vh, 620px);
  display: grid;
  justify-items: center;
  align-items: start;
}

.game-aside { padding-top: 2px; }
.aside-block {
  border-top: 1px solid var(--ink);
  padding: 14px 0 20px;
}
.aside-block h2 {
  font: 500 8.5px var(--mono);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 12px;
}
.aside-block p {
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-2);
  word-break: keep-all;
}
.control-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 0;
  font-size: 11.5px;
  color: var(--mute);
}
.control-list .keys { display: inline-flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 23px;
  height: 22px;
  padding: 0 5px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-bottom-color: var(--ink-2);
  font: 500 9.5px var(--mono);
  color: var(--ink);
  white-space: nowrap;
}

.best-list .best-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 0;
  font-size: 11.5px;
  color: var(--mute);
}
.best-row strong {
  font: 500 12.5px var(--mono);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.best-row .empty { color: var(--line-strong); }

.game-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0 64px;
  border-top: 1px solid var(--line);
  font: 500 10px var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.game-nav a { color: var(--mute); transition: color .15s; }
.game-nav a:hover { color: var(--accent); }
.game-nav .next { text-align: right; }

/* ---------- shared game chrome ---------- */

.game-shell {
  width: 100%;
  max-width: var(--gw, 560px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hud {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 20px;
  flex-wrap: wrap;
  width: 100%;
}
.hud-stats { display: flex; align-items: flex-end; gap: clamp(16px, 3vw, 30px); }
.stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat-label {
  font: 500 8px var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--mute);
  white-space: nowrap;
}
.stat-value {
  font: 500 21px var(--mono);
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat-value small { font-size: 10px; color: var(--mute); letter-spacing: 0; margin-left: 2px; }
.stat-value.is-accent { color: var(--accent); }

.hud-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  padding: 2px;
  gap: 2px;
  background: var(--bg);
}
.seg button {
  appearance: none;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 6px 10px;
  font: 500 9px var(--mono);
  letter-spacing: .06em;
  color: var(--mute);
  transition: background .12s, color .12s;
  min-height: 28px;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

.board-frame {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}
.board-surface {
  background: var(--panel);
  border: 1px solid var(--ink);
  box-shadow: 6px 6px 0 var(--shade);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(242, 238, 227, .95);
  text-align: center;
  animation: overlay-in .18s ease both;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.overlay-card { max-width: 320px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.overlay-kicker {
  font: 500 8.5px var(--mono);
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
}
.overlay-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.1;
  letter-spacing: -.04em;
  word-break: keep-all;
}
.overlay-text { font-size: 12.5px; line-height: 1.6; color: var(--mute); word-break: keep-all; }
.overlay-score {
  font: 500 26px var(--mono);
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  margin: 2px 0;
}
.overlay-score small { font-size: 10px; color: var(--mute); letter-spacing: .08em; margin-left: 4px; }
.overlay .btn { margin-top: 8px; }

.board-frame .overlay { inset: 0; }

.touch {
  display: none;
  width: 100%;
  justify-content: center;
}
.touch-inner { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.touch-pad {
  display: grid;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(2, 46px);
  gap: 5px;
}
.touch-pad button,
.touch button {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  font: 500 15px var(--mono);
  cursor: pointer;
  min-height: 44px;
  padding: 0 12px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.touch-pad button:active,
.touch button:active { background: var(--ink); color: var(--bg); }
.touch-pad .up { grid-column: 2; grid-row: 1; }
.touch-pad .left { grid-column: 1; grid-row: 2; }
.touch-pad .down { grid-column: 2; grid-row: 2; }
.touch-pad .right { grid-column: 3; grid-row: 2; }
.touch-row { display: flex; gap: 5px; }

.game-note {
  font: 400 9.5px var(--mono);
  letter-spacing: .03em;
  color: var(--mute);
  text-align: center;
  line-height: 1.6;
}
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 2048 ---------- */

.g2048 { --gap: 10px; width: 100%; max-width: 430px; }
.g2048-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: var(--gap);
  background: #e7dfcc;
  border: 1px solid var(--line-strong);
  box-shadow: 6px 6px 0 var(--shade);
  touch-action: none;
  user-select: none;
}
.g2048-cells {
  position: absolute;
  inset: var(--gap);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: var(--gap);
}
.g2048-cell { background: rgba(255, 255, 255, .34); }
.g2048-tiles { position: absolute; inset: var(--gap); }
.g2048-tile {
  position: absolute;
  top: 0; left: 0;
  width: calc((100% - var(--gap) * 3) / 4);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font: 600 clamp(19px, 5.4vw, 32px) var(--mono);
  letter-spacing: -.05em;
  color: var(--ink);
  background: #ece5d3;
  transition: transform .12s cubic-bezier(.2,.75,.3,1), background .15s, color .15s;
  will-change: transform;
  z-index: 1;
}
.g2048-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(23, 20, 15, .05);
  pointer-events: none;
}
.g2048-tile.is-new { animation: tile-in .16s ease both; }
.g2048-tile.is-merged { animation: tile-pop .18s ease both; z-index: 2; }
@keyframes tile-in { from { opacity: 0; scale: .6; } }
@keyframes tile-pop { 0% { filter: brightness(1.15); } 100% { filter: none; } }

.t2 { background: #ece5d3; }
.t4 { background: #e5d9bd; }
.t8 { background: #e1bd87; }
.t16 { background: #d99a5f; color: #fff8f0; }
.t32 { background: #cf7444; color: #fff8f0; }
.t64 { background: #c14e2c; color: #fff8f0; }
.t128 { background: #a63a21; color: #fff8f0; font-size: clamp(16px, 4.6vw, 27px); }
.t256 { background: #862d1a; color: #fff8f0; font-size: clamp(16px, 4.6vw, 27px); }
.t512 { background: #662415; color: #fff8f0; font-size: clamp(16px, 4.6vw, 27px); }
.t1024 { background: #41201a; color: #fff8f0; font-size: clamp(12px, 3.6vw, 21px); }
.t2048 { background: var(--accent); color: #fff8f0; font-size: clamp(12px, 3.6vw, 21px); }
.tbig { background: var(--ink); color: var(--bg); font-size: clamp(11px, 3.2vw, 19px); }

/* ---------- minesweeper ---------- */

.ms { width: 100%; max-width: 620px; }
.ms-board {
  width: 100%;
  display: grid;
  gap: 2px;
  background: var(--line-strong);
  border: 1px solid var(--ink);
  padding: 2px;
  box-shadow: 6px 6px 0 var(--shade);
  user-select: none;
  touch-action: manipulation;
}
.ms-cell {
  appearance: none;
  border: 0;
  padding: 0;
  min-width: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: #e9e2d1;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--mono);
  font-weight: 600;
  font-size: var(--cell-font, 13px);
  transition: background .1s;
  position: relative;
}
.ms-cell:hover { background: #ded5c0; }
.ms-cell.is-open { background: #f5f1e6; cursor: default; }
.ms-cell.is-open:hover { background: #f5f1e6; }
.ms-cell.is-mine { background: var(--accent); color: #fff8f0; }
.ms-cell.is-flag svg { width: 52%; height: 52%; color: var(--accent-deep); }
.ms-cell.is-mine svg { width: 55%; height: 55%; }
.ms-cell.is-wrong { background: #e2c5bb; }
.ms-cell.is-wrong::after {
  content: "";
  position: absolute;
  inset: 24%;
  background:
    linear-gradient(45deg, transparent 44%, var(--accent-deep) 44%, var(--accent-deep) 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, var(--accent-deep) 44%, var(--accent-deep) 56%, transparent 56%);
}
.ms-cell .n1 { color: #244f70; }
.ms-cell .n2 { color: var(--green); }
.ms-cell .n3 { color: var(--accent-deep); }
.ms-cell .n4 { color: #4b3f86; }
.ms-cell .n5 { color: #7a3325; }
.ms-cell .n6 { color: #2c6e83; }
.ms-cell .n7 { color: var(--ink); }
.ms-cell .n8 { color: var(--mute); }

/* ---------- tetris ---------- */

.tetris { width: 100%; max-width: 500px; }
.tetris-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(10px, 2vw, 20px);
}
.tetris-main {
  position: relative;
  flex: 1 1 260px;
  max-width: 300px;
}
.tetris-main canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--ink);
  background: #f7f3e9;
  box-shadow: 6px 6px 0 var(--shade);
}
.tetris-side {
  flex: 0 0 98px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tetris-side-label {
  font: 500 8px var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 5px;
}
.tetris-next {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  padding: 4px;
}
.tetris-next canvas { display: block; width: 100%; height: auto; }
.tetris-mini-stats { display: flex; flex-direction: column; gap: 7px; }
.tetris-mini-stats div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font: 400 8.5px var(--mono);
  letter-spacing: .06em;
  color: var(--mute);
}
.tetris-mini-stats strong { font-weight: 500; font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; }
.tetris-keys { display: flex; flex-direction: column; gap: 5px; }
.tetris-keys .btn { width: 100%; font-size: 8.5px; padding: 7px 4px; min-height: 30px; }
.tetris-wrap .overlay { inset: 0; }

/* ---------- snake / breakout canvases ---------- */

.canvas-game { width: 100%; }
.canvas-frame {
  position: relative;
  width: 100%;
  border: 1px solid var(--ink);
  box-shadow: 6px 6px 0 var(--shade);
  background: var(--panel);
  overflow: hidden;
}
.canvas-frame canvas { display: block; width: 100%; height: auto; }
.canvas-frame .overlay { inset: 0; }

/* ---------- gomoku ---------- */

.gomoku { width: 100%; max-width: 580px; }
.gomoku-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--ink);
  box-shadow: 6px 6px 0 var(--shade);
  background: #e7dcc3;
  touch-action: manipulation;
}
.gomoku-board canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }
.turn-badge { display: inline-flex; align-items: center; gap: 7px; }
.turn-stone { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.turn-stone.white { background: var(--panel); box-shadow: inset 0 0 0 1px var(--ink); }

/* ---------- memory ---------- */

.memory { width: 100%; max-width: 560px; }
.mem-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--ink);
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--shade);
}
.mem-card {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  aspect-ratio: 1;
  cursor: pointer;
  perspective: 700px;
  -webkit-tap-highlight-color: transparent;
}
.mem-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .34s cubic-bezier(.2,.75,.3,1);
}
.mem-card.is-open .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
}
.mem-back { background: var(--ink); color: var(--paper); }
.mem-back svg { width: 28%; height: 28%; opacity: .6; }
.mem-front {
  transform: rotateY(180deg);
  background: #f6f1e4;
  color: var(--ink);
  transition: background .2s, border-color .2s;
}
.mem-front svg { width: 42%; height: 42%; }
.mem-card.is-matched .mem-front { background: #f3e2d9; border-color: var(--accent); color: var(--accent-deep); }
.mem-card.is-matched { cursor: default; }
.mem-card:not(.is-open):not(.is-matched):hover .mem-back { background: #2c2820; }

/* ---------- 1 to 50 ---------- */

.one50 { width: 100%; max-width: 680px; }
.one-grid {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--ink);
  box-shadow: 6px 6px 0 var(--shade);
  user-select: none;
}
.one-cell {
  appearance: none;
  border: 1px solid var(--line);
  background: #f6f2e7;
  color: var(--ink);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  font: 500 clamp(12px, 2.1vw, 18px) var(--mono);
  transition: background .12s, color .12s, border-color .12s, transform .12s;
  -webkit-tap-highlight-color: transparent;
}
.one-cell:hover { border-color: var(--ink); }
.one-cell.is-done {
  background: var(--ink);
  border-color: var(--ink);
  color: transparent;
  pointer-events: none;
  transform: scale(.96);
}
.one-cell.is-wrong { animation: wrong-flash .3s ease; }
@keyframes wrong-flash {
  0%, 100% { background: #f6f2e7; }
  40% { background: var(--accent); color: #fff8f0; }
}
.one-next { color: var(--accent); font-size: 26px; }

/* ---------- sudoku ---------- */

.sudoku { width: 100%; max-width: 560px; }
.sudoku-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--shade);
  user-select: none;
}
.sudoku-board .s-cell {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0;
  min-width: 0;
  display: grid;
  place-items: center;
  font: 500 clamp(14px, 3vw, 24px) var(--mono);
  cursor: pointer;
  position: relative;
  transition: background .1s;
}
.sudoku-board .s-cell.given { font-weight: 600; }
.sudoku-board .s-cell.user { color: var(--green); }
.sudoku-board .s-cell.peer { background: #f1ecdf; }
.sudoku-board .s-cell.same { background: #ede2cd; }
.sudoku-board .s-cell.selected { background: #e4d5b7; box-shadow: inset 0 0 0 1px var(--accent); z-index: 2; }
.sudoku-board .s-cell.conflict { background: #f0d3c9; color: var(--accent-deep); }
.sudoku-board .s-cell.selected.conflict { background: #ecc4b7; }
.sudoku-board .s-cell.hinted { color: var(--accent-deep); }
.sudoku-board .s-cell:nth-child(3n) { border-right: 2px solid var(--ink); }
.sudoku-board .s-cell:nth-child(9n) { border-right: 0; }
.sudoku-board .s-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-board .s-cell:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid var(--ink); }
.sudoku-board .s-cell:nth-child(n+73) { border-bottom: 0; }
.sudoku-pad {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 5px;
  width: 100%;
}
.sudoku-pad button {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  aspect-ratio: 1;
  min-width: 0;
  cursor: pointer;
  font: 500 clamp(12px, 2.4vw, 16px) var(--mono);
  transition: background .12s, color .12s;
}
.sudoku-pad button:hover { background: var(--ink); color: var(--bg); }
.sudoku-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.sudoku-tools .btn { flex: 1; }

/* ---------- reaction ---------- */

.reaction { width: 100%; max-width: 620px; }
.reaction-panel {
  position: relative;
  width: 100%;
  min-height: clamp(300px, 48vh, 420px);
  border: 1px solid var(--ink);
  box-shadow: 6px 6px 0 var(--shade);
  background: #ece5d4;
  display: grid;
  place-items: center;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
.reaction-panel.is-wait { background: #e4dcc9; }
.reaction-panel.is-ready { background: var(--accent); color: #fff8f0; }
.reaction-panel.is-early { background: var(--ink); color: var(--bg); }
.reaction-panel.is-result { cursor: default; }
.reaction-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 480px;
  width: 100%;
}
.reaction-kicker {
  font: 500 8.5px var(--mono);
  letter-spacing: .2em;
  text-transform: uppercase;
  opacity: .65;
}
.reaction-big {
  font-family: var(--serif);
  word-break: keep-all;
  font-weight: 700;
  font-size: clamp(40px, 8vw, 72px);
  line-height: 1;
  letter-spacing: -.05em;
}
.reaction-big.mono { font: 500 clamp(44px, 9vw, 82px) var(--mono); letter-spacing: -.06em; }
.reaction-text { font-size: 13px; line-height: 1.6; opacity: .8; word-break: keep-all; max-width: 380px; }
.reaction-rounds { display: flex; gap: 5px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }
.reaction-rounds span {
  min-width: 54px;
  padding: 5px 7px;
  border: 1px solid rgba(23,20,15,.22);
  font: 500 10px var(--mono);
  color: inherit;
}
.reaction-panel.is-ready .reaction-rounds span,
.reaction-panel.is-early .reaction-rounds span { border-color: rgba(255,248,240,.35); }
.reaction-rounds span.empty { opacity: .4; }

/* ---------- footer / toast ---------- */

.site-footer {
  border-top: 1px solid var(--ink);
  margin-top: 20px;
}
.footer-inner {
  min-height: 118px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding-top: 24px;
  padding-bottom: 24px;
}
.footer-brand { display: flex; align-items: baseline; gap: 14px; }
.footer-word { font-family: var(--serif); font-weight: 700; font-size: 22px; letter-spacing: -.04em; }
.footer-copy { font: 400 9px var(--mono); letter-spacing: .1em; color: var(--mute); text-transform: uppercase; }
.footer-note { font-size: 11px; color: var(--mute); }
.footer-key { font: 400 9.5px var(--mono); letter-spacing: .04em; color: var(--mute); display: inline-flex; align-items: center; gap: 4px; }
.footer-key .kbd { min-width: 18px; height: 18px; font-size: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 150;
  transform: translate(-50%, 14px);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 18px;
  font: 500 10px var(--mono);
  letter-spacing: .08em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast .accent { color: var(--accent); }

.noscript { padding: 24px; text-align: center; }

/* ---------- responsive ---------- */

@media (max-width: 1040px) {
  :root { --gutter: 32px; }
  .home-hero-grid { grid-template-columns: minmax(0, 1.35fr) minmax(270px, .65fr); gap: 48px; }
  .game-body { grid-template-columns: minmax(0, 1fr) 236px; gap: 30px; }
  .game-head-side { gap: 28px; }
}

@media (max-width: 860px) {
  .home-hero-grid { grid-template-columns: 1fr; gap: 42px; align-items: start; }
  .hero-title { font-size: clamp(64px, 13vw, 110px); }
  .hero-side { max-width: 420px; }
  .stamp { margin-left: 0; }
  .hero-note { text-align: left; }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-card.is-featured { grid-column: span 2; }
  .game-card.is-random { min-height: 220px; }
  .game-body { grid-template-columns: 1fr; }
  .game-aside {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 28px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 24px;
  }
  .stage-inner { min-height: 360px; }
}

@media (max-width: 640px) {
  :root { --gutter: 18px; }
  .header-inner { height: 62px; }
  .brand-word { font-size: 21px; }
  .brand-sub { display: none; }
  .site-nav { gap: 18px; }
  .nav-link { font-size: 10px; }
  .sound-toggle { font-size: 10px; }
  .ticker-items span:nth-of-type(3),
  .ticker-items i:nth-of-type(3) { display: none; }
  .ticker-right { display: none; }
  .home-hero { padding-top: 42px; }
  .hero-title { margin: 16px 0 24px; letter-spacing: -.06em; }
  .hero-lede { font-size: 15px; }
  .hero-actions { gap: 14px 20px; margin-top: 28px; }
  .btn--primary { width: 100%; }
  .hero-actions .text-link { margin-left: 2px; }
  .section-head { align-items: flex-start; }
  .filters { gap: 2px 14px; }
  .game-grid { grid-template-columns: 1fr; }
  .game-card,
  .game-card.is-featured,
  .game-card.is-random,
  .game-grid.is-filtering .game-card.is-featured {
    grid-column: span 1;
    min-height: 220px;
    padding: 18px;
  }
  .game-card.is-featured .card-main,
  .game-grid.is-filtering .game-card.is-featured .card-main { display: block; padding: 24px 0 20px; }
  .game-card.is-featured .card-icon { width: 44px; height: 44px; margin-bottom: 18px; }
  .game-card.is-featured .card-title { font-size: 32px; }
  .game-card.is-random { min-height: 200px; }
  .game-page { padding-top: 22px; }
  .game-head { grid-template-columns: 1fr; gap: 20px; }
  .game-head-side { gap: 32px; padding: 0; }
  .game-title { font-size: clamp(44px, 14vw, 64px); }
  .game-body { padding-top: 22px; gap: 26px; }
  .stage-inner { padding: 14px; min-height: 0; }
  .stage-bar { height: 30px; font-size: 8px; }
  .game-aside { grid-template-columns: 1fr; }
  .aside-block:nth-child(2) { grid-column: auto; }
  .game-nav { padding-bottom: 44px; font-size: 9px; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 14px; }
  .footer-key { display: none; }
  .hud { align-items: flex-start; }
  .hud-stats { gap: 18px; }
  .stat-value { font-size: 18px; }
  .seg button { padding: 6px 8px; font-size: 8.5px; }
  .sudoku-pad { grid-template-columns: repeat(5, 1fr); }
  .sudoku-tools { width: 100%; }
  .one-grid { gap: 4px; padding: 5px; }
  .one-grid[data-size="large"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .one-cell { font-size: clamp(11px, 3.4vw, 16px); }
  .mem-board { gap: 5px; padding: 5px; }
  .gomoku-board,
  .g2048-board,
  .canvas-frame { box-shadow: 4px 4px 0 var(--shade); }
  .g2048 { --gap: 8px; }
  .tetris-side { flex-basis: 78px; }
  .tetris-side .btn { font-size: 8px; }
  .game-card::after { display: none; }
}

@media (hover: none) {
  .touch { display: flex; }
}

@media (max-width: 720px) {
  .touch { display: flex; }
}

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