/* ============================================================
   apps/schulte.html · 方案 B「纸本实验」
   米白纸面 / 钢笔墨色 / 印章红批 / 蓝印 / 衬线印刷感
   字体通过 <link> 在 HTML 中加载，避免 @import 受 CSP 拦截
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body { min-height: 100%; }

:root {
  /* Paper */
  --paper:         #F1ECDD;
  --paper-shadow:  #E7DFC9;
  --paper-edge:    #DCD3BC;

  /* Ink */
  --ink:           #16202E;
  --ink-2:         #4A5566;
  --ink-mute:      #8B8675;
  --ink-line:      rgba(22, 32, 46, 0.18);
  --ink-line-soft: rgba(22, 32, 46, 0.08);

  /* Stamp */
  --stamp-red:     #B53821;
  --stamp-red-bg:  rgba(181, 56, 33, 0.08);
  --stamp-blue:    #2A4E68;
  --stamp-blue-bg: rgba(42, 78, 104, 0.08);
  --stamp-orange:  #C26A1F;

  /* Fonts */
  --font-display:  'Newsreader', 'Noto Serif SC', 'Songti SC', 'STSong', serif;
  --font-serif:    'Newsreader', 'Noto Serif SC', 'Songti SC', 'STSong', serif;
  --font-cn:       'Noto Serif SC', 'Songti SC', 'STSong', 'STZhongsong', serif;
  --font-mono:     'IBM Plex Mono', 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

body {
  background-color: var(--paper);
  background-image:
    /* 角落晕染：保留原有右上 / 左下两团 */
    radial-gradient(ellipse 40% 30% at 90% 10%, rgba(22, 32, 46, 0.045), transparent 60%),
    radial-gradient(ellipse 50% 35% at 8% 95%,  rgba(22, 32, 46, 0.035), transparent 60%),
    /* P2.1 · 整页边缘暗角，让纸有"实物感" */
    radial-gradient(ellipse 100% 80% at 50% 50%, transparent 55%, rgba(22, 32, 46, 0.10) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-cn);
  font-weight: 400;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* Paper grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0.09  0 0 0 0 0.13  0 0 0 0 0.18  0 0 0 0.10 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.7;
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: multiply;
}

/* Bottom-right watermark */
body::after {
  content: '';
  position: fixed;
  right: 4%;
  bottom: 4%;
  width: 360px;
  height: 360px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><text x='100' y='150' text-anchor='middle' font-family='Noto Serif SC, serif' font-size='200' fill='%2316202E' font-weight='700' opacity='0.06'>觅</text></svg>");
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
  z-index: 0;
}

/* P2.1 · 左下角墨渍：淡淡的咖啡渍 / 旧印迹 */
.paper-stain {
  position: fixed;
  left: 6%;
  bottom: 12%;
  width: 220px;
  height: 220px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'><filter id='s'><feTurbulence type='fractalNoise' baseFrequency='0.6' numOctaves='2' seed='7'/><feColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.30  0 0 0 0 0.15  0 0 0 0.18 0'/></filter><circle cx='100' cy='100' r='70' filter='url(%23s)'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: multiply;
  transform: rotate(-12deg);
}

main {
  flex: 1;
  padding: 40px 40px 60px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ============================================================
   Head
   ============================================================ */
.head {
  text-align: center;
  margin-bottom: 32px;
  position: relative;
}
.head h1 {
  font-family: var(--font-cn);
  font-size: 92px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.18em;
  line-height: 1.0;
  margin-bottom: 18px;
}
.head .title-rule {
  width: 64px;
  height: 2px;
  background: var(--ink);
  margin: 0 auto 16px;
}

/* ============================================================
   Difficulty List (numbered)
   ============================================================ */
.diff-list {
  display: flex;
  flex-direction: row;
  gap: 12px;
  max-width: 760px;
  margin: 0 auto 40px;
}
.diff-item {
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 14px;
  padding: 18px 22px 16px;
  background: transparent;
  border: 1px solid var(--ink-line);
  font-family: var(--font-cn);
  cursor: pointer;
  color: var(--ink-2);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  text-align: left;
  position: relative;
}
.diff-item .diff-no {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  font-weight: 400;
}
.diff-item .diff-name {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.1em;
}
.diff-item .diff-dim {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}
.diff-item:hover {
  background: var(--paper-shadow);
  color: var(--ink);
  border-color: var(--ink-line);
}
.diff-item.active {
  background: var(--paper-shadow);
  color: var(--ink);
  border-color: var(--ink);
}
.diff-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 4px;
  background: var(--stamp-blue);
}
.diff-item.active .diff-no {
  color: var(--stamp-blue);
  font-weight: 500;
}

/* ============================================================
   Game Area
   ============================================================ */
.game-area {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 40px;
  align-items: start;
}

/* Board card */
.board-wrap {
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: 36px 32px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow:
    0 1px 0 var(--ink-line-soft),
    0 6px 24px rgba(22, 32, 46, 0.06),
    0 30px 60px rgba(22, 32, 46, 0.05);
  position: relative;
}
.board-wrap::before {
  content: 'N° 04 · 训练用纸';
  position: absolute;
  top: -10px;
  left: 28px;
  background: var(--paper);
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ink-mute);
  text-transform: uppercase;
}

/* Next hint: blue stamp */
.next-hint {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-cn);
  font-size: 13px;
  color: var(--ink-2);
  letter-spacing: 0.18em;
}
.next-hint b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  background: var(--stamp-blue);
  color: var(--paper);
  border: 1px solid var(--stamp-blue);
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  font-feature-settings: "tnum";
  transform: rotate(-0.6deg);
}

/* Progress: ink line + dot */
.progress {
  width: 100%;
  height: 2px;
  background: var(--ink-line);
  position: relative;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--stamp-blue);
  transition: width 0.3s ease;
  position: relative;
}
.progress-bar::after {
  content: '';
  position: absolute;
  right: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  background: var(--stamp-blue);
  border: 1.5px solid var(--paper);
  border-radius: 50%;
  box-sizing: border-box;
}

/* Board */
.board {
  display: grid;
  gap: 6px;
  width: 480px;
  height: 480px;
  max-width: 100%;
  aspect-ratio: 1;
}
.board[data-n="5"] { width: 480px; height: 480px; }
.board[data-n="7"] { width: 540px; height: 540px; }
.board[data-n="9"] { width: 600px; height: 600px; }

/* Cell */
.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-feature-settings: "tnum";
  font-weight: 500;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  transition:
    transform 0.15s ease,
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease;
}
.cell[data-value] { font-size: 42px; }
.board[data-n="7"] .cell { font-size: 32px; }
.board[data-n="9"] .cell { font-size: 26px; }
.cell[data-value="1"] { font-weight: 700; }

/* Starting cell: red dot bookmark */
.cell[data-value="1"]::before {
  content: '';
  position: absolute;
  top: 7px;
  left: 7px;
  width: 6px;
  height: 6px;
  background: var(--stamp-red);
  border-radius: 50%;
}

/* Hover: slight paper depression */
.cell:hover {
  background: var(--paper-shadow);
  transform: translateY(1px);
}

/* Done: blue ink drop (P2.2 · 多层墨滴扩散) */
.cell.done {
  background: var(--paper) !important;
  color: var(--stamp-blue) !important;
  border-color: var(--stamp-blue) !important;
  cursor: default;
  font-weight: 600;
}
.cell.done::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%, transparent 22%, var(--stamp-blue) 24%, transparent 28%),
    radial-gradient(circle at 50% 50%, transparent 14%, var(--stamp-blue) 15%, transparent 17%);
  opacity: 0;
  animation: inkDrop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  filter: blur(0.3px);
}
.cell.done[data-value="1"]::before { opacity: 0; }
.cell.done:hover {
  transform: none;
  background: var(--paper);
}
@keyframes inkDrop {
  0%   { transform: scale(0.3); opacity: 0; }
  45%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 0.85; }
}

/* Error: red stamp + shake (P2.3) */
.cell.error {
  background: var(--stamp-red) !important;
  color: var(--paper) !important;
  border-color: var(--stamp-red) !important;
  /* stampDown 控色 / 透明度；shake 控位移；二者合成 0.55s */
  animation:
    stampDown 0.55s cubic-bezier(0.5, 0, 0.5, 1),
    cellShake 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97);
  transform: rotate(-2deg);
  z-index: 3;
  font-weight: 700;
}
.cell.error[data-value="1"]::before { opacity: 0; }
@keyframes stampDown {
  0%   { transform: rotate(-14deg) scale(1.45); opacity: 0.2; }
  35%  { transform: rotate(-3deg) scale(1.1); opacity: 1; }
  100% { transform: rotate(-2deg) scale(1); opacity: 1; }
}
/* P2.3 · 横向抖动（位移独立于 stampDown 的 rotate） */
@keyframes cellShake {
  0%, 100% { translate: 0 0; }
  10%      { translate: -4px 0; }
  20%      { translate:  5px 0; }
  30%      { translate: -4px 0; }
  40%      { translate:  4px 0; }
  50%      { translate: -2px 0; }
  60%      { translate:  2px 0; }
  70%      { translate: -1px 0; }
  80%      { translate:  1px 0; }
  90%      { translate:  0 0; }
}

/* ============================================================
   Stats Panel · 训练报告 Training Report
   ============================================================ */
.stats-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.report {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: 22px 24px 20px;
  box-shadow:
    0 1px 0 var(--ink-line-soft),
    0 6px 20px rgba(22, 32, 46, 0.05);
}
.report::before {
  content: 'TRAINING · N° 04';
  position: absolute;
  top: -10px;
  left: 24px;
  background: var(--paper);
  padding: 0 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--ink-mute);
}
.report-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ink-line);
  margin-bottom: 16px;
}
.report-title {
  font-family: var(--font-cn);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.12em;
  margin: 0;
}
.report-en {
  font-family: var(--font-serif);
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  text-transform: uppercase;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
}
.report-cell {
  padding: 14px 18px 16px;
  border-right: 1px solid var(--ink-line);
  border-bottom: 1px solid var(--ink-line);
  position: relative;
}
.report-cell:nth-child(3) {
  grid-column: 1 / -1;
  background: var(--stamp-blue-bg);
  border-bottom: 0;
}
.report-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ink-mute);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.report-value {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 500;
  color: var(--ink);
  font-feature-settings: "tnum";
  line-height: 1.05;
  letter-spacing: 0.02em;
}
.report-cell:nth-child(3) .report-value {
  color: var(--stamp-blue);
  font-size: 22px;
}
.report-value-err { color: var(--stamp-red); }
.report-value-best { color: var(--stamp-blue); }
.report-sep { color: var(--ink-mute); margin: 0 6px; font-weight: 400; }
.report-unit {
  font-family: var(--font-cn);
  font-size: 12px;
  color: var(--ink-mute);
  margin-left: 4px;
  font-weight: 400;
}

/* P2.4 · 历史走势 sparkline */
.report-trend {
  margin-top: 18px;
  padding: 14px 18px 10px;
  border-top: 1px solid var(--ink-line);
}
.trend-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.trend-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ink-mute);
  text-transform: uppercase;
}
.trend-meta {
  font-family: var(--font-serif);
  font-size: 11px;
  font-style: italic;
  color: var(--ink-2);
  letter-spacing: 0.06em;
}
.trend-svg {
  width: 100%;
  height: 48px;
  display: block;
  overflow: visible;
}
.trend-svg .trend-line {
  fill: none;
  stroke: var(--stamp-blue);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
}
.trend-svg .trend-baseline {
  stroke: var(--ink-line);
  stroke-width: 0.5;
  stroke-dasharray: 2 3;
}
.trend-svg .trend-dot {
  fill: var(--stamp-blue);
  stroke: var(--paper);
  stroke-width: 1;
}
.trend-svg .trend-dot.is-best {
  fill: var(--stamp-red);
}
.trend-svg .trend-label {
  font-family: var(--font-mono);
  font-size: 5px;
  fill: var(--ink-mute);
  letter-spacing: 0.05em;
}

/* timer pulse uses report-cell as container */
.report-cell.timer-pulse .report-value { animation: tick 0.22s ease; }
@keyframes tick {
  0%   { transform: translateX(-1px); opacity: 0.7; }
  100% { transform: translateX(0); opacity: 1; }
}

.btn-row { display: flex; gap: 10px; }
.btn {
  flex: 1;
  padding: 14px 16px;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.12em;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 1px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}
.btn::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid var(--ink-line);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.btn:hover::before { opacity: 1; }
.btn:hover {
  background: var(--ink);
  color: var(--paper);
}
.btn.primary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--ink);
}
.btn.primary:hover {
  background: var(--ink);
  color: var(--paper);
}

.hint {
  font-family: var(--font-cn);
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.9;
  padding: 16px 20px;
  background: var(--paper);
  border: 1px solid var(--ink-line);
  border-radius: 2px;
}
.hint b { color: var(--ink); font-weight: 600; }
.hint code {
  display: inline-block;
  padding: 0 7px;
  background: var(--stamp-blue-bg);
  color: var(--stamp-blue);
  border: 1px solid var(--stamp-blue);
  font-family: var(--font-serif);
  font-feature-settings: "tnum";
  font-size: 12px;
  border-radius: 1px;
}

.status-info {
  padding: 14px 18px;
  font-family: var(--font-cn);
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--ink-line);
  border-radius: 2px;
}
.status-info .guest { color: var(--stamp-orange); }

/* ============================================================
   Win Modal · Training Report
   ============================================================ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(241, 236, 221, 0.86);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.modal-mask.show {
  display: flex;
  opacity: 1;
  animation: maskIn 0.35s ease both;
}
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 2px;
  max-width: 480px;
  width: calc(100% - 40px);
  padding: 40px 40px 32px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(22, 32, 46, 0.18);
  animation: modalIn 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  overflow: hidden;
}
.modal::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--ink);
}
@keyframes modalIn {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Head */
.modal-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 18px;
}
.modal-head-en {
  font-family: var(--font-serif);
  font-size: 11px;
  letter-spacing: 0.32em;
  color: var(--ink-mute);
  text-transform: uppercase;
}
.modal-title {
  font-family: var(--font-cn);
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.16em;
  margin: 0;
  line-height: 1.1;
}
.modal-head-no {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--ink-mute);
  text-transform: uppercase;
  margin-top: 4px;
}

/* Grade line */
.modal-grade {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 18px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  margin-bottom: 18px;
}
.grade-label {
  font-family: var(--font-cn);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--ink-2);
}
.grade-value {
  font-family: var(--font-cn);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.16em;
}
.grade-en {
  font-family: var(--font-serif);
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0.2em;
  color: var(--ink-mute);
  text-transform: uppercase;
}

.modal-rule {
  height: 1px;
  background: var(--ink-line);
  margin-bottom: 20px;
}

/* Result columns */
.modal-result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--ink);
  margin-bottom: 24px;
}
.r-cell {
  padding: 16px 14px 14px;
  position: relative;
}
.r-cell + .r-cell {
  border-left: 1px solid var(--ink);
}
.r-cell-label {
  font-family: var(--font-cn);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.r-cell-value {
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 500;
  color: var(--ink);
  font-feature-settings: "tnum";
  line-height: 1;
  letter-spacing: 0.02em;
}
.r-cell-value-err { color: var(--stamp-red); }
.r-cell-unit {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--ink-mute);
  margin-top: 6px;
  text-transform: uppercase;
}

/* Stamps */
.modal-stamps {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
  min-height: 78px;
}
.stamp {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 78px;
  height: 78px;
  border: 2.5px solid currentColor;
  border-radius: 50%;
  transform: rotate(-6deg);
  position: relative;
  opacity: 0;
  animation: stampDrop 0.4s cubic-bezier(0.5, 0, 0.4, 1) 0.3s forwards;
}
.stamp:nth-child(2) { transform: rotate(4deg); animation-delay: 0.45s; }
.stamp:nth-child(3) { transform: rotate(-2deg); animation-delay: 0.6s; }
@keyframes stampDrop {
  0%   { transform: rotate(-22deg) scale(1.6); opacity: 0; }
  60%  { transform: rotate(-4deg)  scale(1.05); opacity: 1; }
  100% { transform: rotate(-6deg)  scale(1);    opacity: 1; }
}
.stamp-char {
  font-family: var(--font-cn);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}
.stamp-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  margin-top: 4px;
  text-transform: uppercase;
}
.stamp-pass  { color: var(--ink); }
.stamp-best  { color: var(--stamp-red); border-style: double; border-width: 4px; }
.stamp-best .stamp-label { color: var(--stamp-red); }
.stamp-guest { color: var(--stamp-orange); border-style: double; border-width: 4px; }
.stamp-guest .stamp-label { color: var(--stamp-orange); }
.stamp[hidden] { display: none; }

.modal-sub {
  font-family: var(--font-cn);
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 24px;
  letter-spacing: 0.1em;
  line-height: 1.7;
}
.modal-actions { display: flex; gap: 10px; justify-content: center; }

.modal .close {
  position: absolute;
  top: 14px; right: 16px;
  background: none;
  border: 0;
  font-size: 22px;
  color: var(--ink-mute);
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 2px;
  transition: background 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
}
.modal .close:hover {
  background: var(--paper-shadow);
  color: var(--ink);
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 24px;
  font-family: var(--font-cn);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.16em;
  border: 1px solid var(--ink);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error {
  background: var(--stamp-red);
  color: var(--paper);
  border-color: var(--stamp-red);
}

/* ============================================================
   Topbar meta chip (N° 04 · EST. 1962)
   ============================================================ */
.topbar-meta {
  position: fixed;
  top: 28px;
  right: 32px;
  z-index: 91;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 12px;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 1px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ink-mute);
  text-transform: uppercase;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(22, 32, 46, 0.06);
}
.topbar-meta .tm-no {
  color: var(--ink);
  font-weight: 500;
  letter-spacing: 0.18em;
}
.topbar-meta .tm-sep { opacity: 0.4; }
.topbar-meta .tm-year { letter-spacing: 0.24em; }

/* ============================================================
   Back link override (so it works on light bg)
   ============================================================ */
.back-link-wrapper {
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: 0 !important;
}
.back-link {
  color: var(--ink-2) !important;
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
}
.back-link:hover { color: var(--ink) !important; }

/* ============================================================
   Mobile
   ============================================================ */
@media (max-width: 960px) {
  main { padding: 40px 24px 48px; }
  .game-area { grid-template-columns: 1fr; gap: 28px; }
  .stats-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  .report-cell { padding: 12px 14px; }
  .report-value { font-size: 26px; }
  .report-cell:nth-child(3) .report-value { font-size: 18px; }

  .board[data-n="5"] { width: min(92vw, 480px); height: min(92vw, 480px); }
  .board[data-n="7"] { width: min(94vw, 540px); height: min(94vw, 540px); }
  .board[data-n="9"] { width: min(96vw, 600px); height: min(96vw, 600px); }

  .head h1 { font-size: 64px; }
}

@media (max-width: 640px) {
  main { padding: 28px 16px 36px; }
  .head { margin-bottom: 32px; }
  .head h1 { font-size: 48px; letter-spacing: 0.14em; }

  .diff-list {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 32px;
  }
  .diff-item { padding: 14px 16px; }
  .diff-item .diff-name { font-size: 16px; }
  .diff-item .diff-no { font-size: 12px; }

  .board-wrap { padding: 24px 18px 18px; }
  .board-wrap::before {
    left: 14px;
    font-size: 9px;
  }
  .next-hint { font-size: 11px; letter-spacing: 0.14em; }
  .next-hint b { min-width: 34px; height: 34px; font-size: 18px; }

  .report { padding: 18px 18px 14px; }
  .report-cell { padding: 10px 12px; }
  .report-value { font-size: 22px; }
  .report-cell:nth-child(3) .report-value { font-size: 16px; }
  .modal { padding: 32px 24px 24px; }
  .modal-title { font-size: 22px; }
  .r-cell-value { font-size: 26px; }

  .board,
  .board[data-n="5"],
  .board[data-n="7"],
  .board[data-n="9"] {
    width: calc(100vw - 60px);
    height: calc(100vw - 60px);
  }
  .board { gap: 4px; }
  .board[data-n="5"] .cell { font-size: 26px; }
  .board[data-n="7"] .cell { font-size: 20px; }
  .board[data-n="9"] .cell { font-size: 16px; }
  .cell { border-radius: 1px; }
  .cell[data-value="1"]::before { width: 5px; height: 5px; top: 5px; left: 5px; }
  .cell.done::after { inset: 5px; border-width: 1.5px; }

  .modal { padding: 32px 24px 24px; }
  .modal h2 { font-size: 22px; }
  .modal .result .r .v { font-size: 20px; }
}

@media (max-width: 380px) {
  .head h1 { font-size: 36px; }
  .diff-item .diff-name { font-size: 14px; }
  .board,
  .board[data-n="5"],
  .board[data-n="7"],
  .board[data-n="9"] {
    width: calc(100vw - 36px);
    height: calc(100vw - 36px);
  }
  body::after { width: 220px; height: 220px; right: 2%; bottom: 2%; }
}