/* 夜ふかし書房のナンプレ — 色はCSS変数（盤は「古い本の紙」なので明暗どちらでも紙色） */
:root {
  --bg: #f2eadb; --surface: #fffaf1; --surface-2: #ece0c9; --text: #2b2118; --text-sub: #75665a; --line: #dccbae;
  --accent: #a4501c; --accent-ink: #ffffff; --accent-soft: #f5e0cb;
  --paper: #efe2c6; --ink: #2b2118; --ink-line: rgba(70, 48, 28, .28); --ink-box: #3d2a1b;
  --cell-user: #2c4c8a; --cell-hint: #1f7650; --cell-wrong: #c42f2f;
  --hl-peer: rgba(164, 80, 28, .10); --hl-same: rgba(164, 80, 28, .30); --hl-sel: rgba(240, 168, 90, .62); --hl-bad: rgba(220, 60, 60, .20);
  --desk-op: .16;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16110d; --surface: #211913; --surface-2: #2e241b; --text: #f1e7d6; --text-sub: #b9a88f; --line: #3d3024;
    --accent: #f0a868; --accent-ink: #1a120b; --accent-soft: #3a2818; --desk-op: .12;
  }
}
:root[data-theme="dark"] {
  --bg: #16110d; --surface: #211913; --surface-2: #2e241b; --text: #f1e7d6; --text-sub: #b9a88f; --line: #3d3024;
  --accent: #f0a868; --accent-ink: #1a120b; --accent-soft: #3a2818; --desk-op: .12;
}
/* 画面の背景に古書店の机をうっすら */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: url(assets/desk.webp) center / cover no-repeat; opacity: var(--desk-op); }

/* タイトル */
.yf-hero { position: relative; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: linear-gradient(160deg, #3b2717, #1b130d); box-shadow: var(--shadow); }
.yf-hero img, .yf-hero video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.yf-start .mn-title { font-family: var(--font-serif); }
.yf-start .mn-daily-num { white-space: nowrap; flex: none; }
.yf-pages { display: flex; justify-content: space-between; align-items: baseline; }
.yf-free { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.yf-free .mn-btn { padding: 10px 6px; }
.yf-reread { display: grid; gap: 6px; margin-top: 8px; }
.yf-reread .mn-btn { justify-content: flex-start; min-height: 42px; font-weight: 600; font-size: 14px; }

/* プレイ */
.yf-play { display: flex; flex-direction: column; gap: 10px; }
.yf-top { display: flex; align-items: flex-end; gap: 8px; }
.yf-top-l { flex: 1; min-width: 0; }
.yf-stage { margin: 0; font-weight: 800; font-family: var(--font-serif); font-size: 16px; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.yf-goal { margin: 0; font-size: 12px; color: var(--text-sub); line-height: 1.4; }
.yf-stats { display: flex; gap: 8px; font-size: 12px; color: var(--text-sub); flex: none; }
.yf-stats b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }

.yf-board { width: 100%; max-width: 468px; margin: 0 auto; aspect-ratio: 1; display: grid; grid-template-rows: repeat(9, 1fr);
  background-color: var(--paper); background-image: url(assets/paper.webp); background-size: cover; background-position: center;
  border: 3px solid var(--ink-box); border-radius: 6px; overflow: hidden; color: var(--ink); box-shadow: 0 6px 18px rgba(40, 24, 10, .22); }
.yf-row { display: grid; grid-template-columns: repeat(9, 1fr); min-height: 0; }
.yf-cell { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; padding: 0; margin: 0;
  border: 0; border-right: 1px solid var(--ink-line); border-bottom: 1px solid var(--ink-line); background: transparent; color: var(--ink);
  font-family: var(--font-serif); font-size: clamp(19px, 6.2vw, 30px); font-weight: 600; line-height: 1; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.yf-row > .yf-cell:last-child { border-right: 0; }
.yf-row:last-child > .yf-cell { border-bottom: 0; }
.yf-cell.br { border-right: 2px solid var(--ink-box); }
.yf-cell.bb { border-bottom: 2px solid var(--ink-box); }
.yf-cell.is-given { font-weight: 900; }
.yf-cell.is-user { color: var(--cell-user); font-family: var(--font); font-weight: 700; }
.yf-cell.is-hint { color: var(--cell-hint); font-family: var(--font); font-weight: 700; }
.yf-cell.is-hint::after { content: ""; position: absolute; right: 3px; bottom: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--cell-hint); }
.yf-cell.is-peer { background: var(--hl-peer); }
.yf-cell.is-same { background: var(--hl-same); }
.yf-cell.is-conflict { background: var(--hl-bad); }
.yf-cell.is-sel { background: var(--hl-sel); }
.yf-cell.is-wrong { color: var(--cell-wrong); }
.yf-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.yf-notes { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); width: 100%; height: 100%; padding: 1px; }
.yf-notes i { font-style: normal; font-family: var(--font); font-size: clamp(8px, 2.3vw, 12px); font-weight: 600; color: #6a5845; display: flex; align-items: center; justify-content: center; line-height: 1; }
.yf-notes i.on { color: #fff; background: var(--accent); border-radius: 3px; }
.yf-board.is-solved { animation: yf-glow 1.2s ease-out; }
@keyframes yf-glow { 0% { box-shadow: 0 0 0 0 rgba(240, 168, 90, .9); } 100% { box-shadow: 0 0 0 22px rgba(240, 168, 90, 0); } }

.yf-pad { width: 100%; max-width: 468px; margin: 0 auto; display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; }
.yf-key { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 56px; min-width: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--accent); font-family: var(--font-serif); font-size: 25px; font-weight: 800; line-height: 1; cursor: pointer; touch-action: manipulation; box-shadow: var(--shadow); }
.yf-key small { font-family: var(--font); font-size: 10px; font-weight: 600; color: var(--text-sub); height: 12px; margin-top: 3px; }
.yf-key:active { transform: scale(.94); }
.yf-key.is-full { opacity: .28; box-shadow: none; }
.yf-tools { width: 100%; max-width: 468px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.yf-tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 52px; padding: 4px 2px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 12px; font-weight: 700; cursor: pointer; touch-action: manipulation; position: relative; }
.yf-tool .yf-ic { font-size: 18px; line-height: 1.1; color: var(--accent); }
.yf-tool em { position: absolute; top: 3px; right: 5px; font-style: normal; font-size: 9px; font-weight: 800; color: var(--text-sub); }
.yf-tool.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.yf-tool.on .yf-ic, .yf-tool.on em { color: var(--accent-ink); }
.yf-foot { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.yf-foot .mn-btn { min-height: 40px; font-size: 13px; padding: 6px 12px; border-color: transparent; color: var(--text-sub); }

/* 物語 */
.machi-text p.yf-diary { font-family: var(--font-serif); background: var(--paper) url(assets/paper.webp) center / cover; color: var(--ink); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 4px 10px 10px 4px; font-size: 16px; }
.yf-page-back { display: inline-block; margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 12px; }

/* 結果 */
.yf-final .mn-big { font-variant-numeric: tabular-nums; }

@media (max-width: 380px) {
  .yf-stats { gap: 6px; }
  .yf-key { height: 52px; font-size: 22px; }
}
@media (min-width: 900px) {
  .yf-key { height: 60px; }
}
