/* テーマ: A ウォルナット (既定) / B 北欧ペーパー / C ダーク・アトリエ
 * 配色はすべて CSS 変数経由。テーマ切替は <html data-theme="..."> で行う。
 * Canvas 側 (木目・マット・箱の色) は app.js の THEMES が同じパレットを持つ。 */
:root, :root[data-theme="walnut"] {
  --accent: #33523f;          /* 深緑: 主ボタン */
  --accent-dark: #27402f;
  --accent-ink: #f5efe4;
  --brass: #c9a227;           /* 真鍮: アクセント */
  --mat: #33523f;             /* マット色: 選択中カードの反転に使う (app.js THEMES と一致) */
  --mat-ink: #f5efe4;
  --paper: #f7f2e7;           /* スタート画面の紙面: 生成り */
  --paper-ink: #3a2a18;
  --paper-dim: #857258;
  --ink: #2e2118;
  --muted: #857258;
  --line: #d9cbb0;
  --panel: #f5efe4;           /* 生成りの紙 */
  --screen-bg: #e9dfc9;
  --screen-ink: #3a2a18;
  --glass: rgba(245,239,228,.9);
  --glass-ink: #2e2118;
  --desk-grad-1: #7a5636; --desk-grad-2: #5d3f27; --desk-grad-3: #4a3018;
  --grain-dark: rgba(46,29,12,.10); --grain-light: rgba(255,240,210,.06);
  --desk-vig: rgba(30,17,4,.20);
  --on-desk: #f7f1e3; --on-desk-dim: rgba(245,239,228,.78); --on-desk-shadow: rgba(43,26,8,.5);
  --shadow: rgba(43,28,12,.30); --shadow-soft: rgba(43,28,12,.15);
  --warn-bg: #f7ecd2; --warn-line: #d9be7f; --warn-ink: #5a4517;
  --danger: #8c3b34; --danger-line: #d8a49e;
  --praise-bg: #f3e5bd; --praise-ink: #7a5c14;
  --badge-bg: #eadfc6;
  --desk-fallback: #6b4a2a;
}
:root[data-theme="nordic"] {
  --accent: #cf6f4f;          /* テラコッタ */
  --accent-dark: #b5573a;
  --accent-ink: #fff8f0;
  --brass: #c99b3f;
  --mat: #9db89a;             /* セージ (app.js THEMES と一致) */
  --mat-ink: #2f4030;
  --paper: #fdfcf9;           /* スタート画面の紙面: 白 */
  --paper-ink: #3d3830;
  --paper-dim: #978b74;
  --ink: #3d3830;
  --muted: #978b74;
  --line: #e0d7bf;
  --panel: #fbfaf7;
  --screen-bg: #f2ecdd;
  --screen-ink: #4c4132;
  --glass: rgba(251,250,247,.92);
  --glass-ink: #3d3830;
  --desk-grad-1: #e8cf9f; --desk-grad-2: #d9b98c; --desk-grad-3: #c9a76f;
  --grain-dark: rgba(120,86,40,.08); --grain-light: rgba(255,255,255,.12);
  --desk-vig: rgba(120,84,32,.10);
  --on-desk: #4c4132; --on-desk-dim: rgba(76,65,50,.78); --on-desk-shadow: rgba(255,255,255,.4);
  --shadow: rgba(110,84,40,.28); --shadow-soft: rgba(110,84,40,.14);
  --warn-bg: #fdf3d8; --warn-line: #e5cf8a; --warn-ink: #6b5518;
  --danger: #b3543f; --danger-line: #e3b3a4;
  --praise-bg: #f7e8c8; --praise-ink: #7a5c14;
  --badge-bg: #f0ead8;
  --desk-fallback: #d9b98c;
}
:root[data-theme="atelier"] {
  --accent: #b08d4f;          /* アンティーク金 */
  --accent-dark: #97743c;
  --accent-ink: #2e2118;
  --brass: #b08d4f;
  --mat: #5e2f35;             /* ボルドー (app.js THEMES と一致) */
  --mat-ink: #f0e6d2;
  --paper: #2b211a;           /* スタート画面の紙面: 暗めの紙 */
  --paper-ink: #ece1c9;
  --paper-dim: #b3a284;
  --ink: #33291f;
  --muted: #8d7c66;
  --line: #c9b48c;
  --panel: #e8ddc8;           /* 生成り (暗い机に明るい紙) */
  --screen-bg: #221812;
  --screen-ink: #ece1c9;
  --glass: rgba(232,221,200,.93);
  --glass-ink: #33291f;
  --desk-grad-1: #46352a; --desk-grad-2: #3a2c22; --desk-grad-3: #291d16;
  --grain-dark: rgba(0,0,0,.20); --grain-light: rgba(232,221,200,.05);
  --desk-vig: rgba(0,0,0,.38);
  --on-desk: #ece1c9; --on-desk-dim: rgba(232,221,200,.72); --on-desk-shadow: rgba(0,0,0,.55);
  --shadow: rgba(0,0,0,.45); --shadow-soft: rgba(0,0,0,.30);
  --warn-bg: #57451f; --warn-line: #8a6f35; --warn-ink: #f3e5bb;
  --danger: #9c4438; --danger-line: #c08a80;
  --praise-bg: #57451f; --praise-ink: #e9cf8f;
  --badge-bg: #dccdaa;
  --desk-fallback: #3a2c22;
}
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--screen-bg);
  color: var(--ink);
  overscroll-behavior: none;
  letter-spacing: .01em;
}
button { font: inherit; cursor: pointer; }
.btn {
  min-height: 44px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px var(--shadow-soft), 0 4px 10px var(--shadow-soft), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active { transform: translateY(1px); box-shadow: 0 1px 2px var(--shadow-soft), inset 0 1px 0 rgba(255,255,255,.25); }
/* 主アクションはピル型ボタンにせず、真鍮の下線テキストに寄せる (案2の調子) */
.btn-underline {
  background: transparent; border-color: transparent; box-shadow: none;
  font-weight: 800; color: var(--ink); border-radius: 0;
  text-decoration: underline; text-decoration-color: var(--brass);
  text-decoration-thickness: 2.5px; text-underline-offset: 5px;
}
.btn-underline:active { transform: none; box-shadow: none; opacity: .65; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn[disabled]:active { transform: none; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- スタート画面 (案2: 紙 + タイポグラフィ、枠少なめ) ---------- */
#startView {
  position: fixed; inset: 0; overflow-y: auto;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255,255,255,.20), transparent 55%),
    repeating-linear-gradient(0deg, transparent 0 27px, var(--grain-light) 27px 28px),
    var(--paper);
  color: var(--paper-ink);
}
#startView[hidden] { display: none; }
.start-inner {
  min-height: 100%; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center;
  padding: 26px 20px 20px; gap: 16px; max-width: 640px; margin: 0 auto;
}
/* 罫線はこの1本だけ (ヘッダーの区切り) */
.start-head {
  width: 100%; text-align: left;
  border-bottom: 1px solid var(--line); padding-bottom: 16px;
  display: flex; flex-direction: column; gap: 7px;
}
.start-kicker {
  margin: 0; font-size: 11px; font-weight: 700;
  letter-spacing: .34em; color: var(--brass);
}
.start-title-text {
  margin: 0; font-size: 30px; font-weight: 800; letter-spacing: .08em; line-height: 1.25;
  color: var(--paper-ink);
}
.start-meta {
  margin: 0; font-size: 14px; color: var(--paper-ink);
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
}
#themeDateLabel { font-weight: 700; letter-spacing: .03em; }
.start-meta-sep { color: var(--paper-dim); }
.streak { color: var(--paper-dim); font-size: 13px; }
.streak #streakNum { color: var(--paper-ink); font-weight: 700; }
.start-creditline { margin: 0; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; min-height: 15px; }
.credit { color: var(--paper-dim); font-size: 11.5px; }
.credit a { color: var(--paper-dim); }
.fallback-note { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: 2px 8px; font-size: 12px; color: var(--warn-ink); }

/* 箱: ボタンではなく「机/紙面の上のモノ」。箱本体は静止して置かれている状態にし、
 * ふよふよ浮く上下の揺れは廃止。タップ可能性の示唆は「箱をタップ」の
 * プレーンテキスト + 静かに出る波紋リング + 押下時の沈みで担保する。
 * 影は SVG 内の接地影 (底面フットプリント沿い) で表現するので、
 * CSS の drop-shadow (浮いて見える) は付けない。 */
#giftBox {
  position: relative;
  width: min(84%, 430px); cursor: pointer; -webkit-tap-highlight-color: transparent; margin-top: 10px;
  transition: transform .12s ease;
}
#giftBox svg {
  position: relative; z-index: 1;
  width: 100%; height: auto; display: block;
}
/* 波紋リング: 箱 (svg は z-index: 1) より手前に出すため z-index: 2。
 * #giftBox (position: relative) の子として svg とは独立したオーバーレイであり、
 * 両者とも position + z-index を持つので、この大小関係で描画順が担保される。 */
#giftBox::after {
  content: ''; position: absolute; z-index: 2; left: 50%; top: 46%;
  width: 118px; height: 118px; border: 2px solid var(--brass); border-radius: 50%;
  opacity: 0; pointer-events: none;
  animation: giftRing 2.8s ease-out infinite;
}
@keyframes giftRing {
  0% { transform: translate(-50%,-50%) scale(.55); opacity: .5; }
  55% { opacity: 0; }
  100% { transform: translate(-50%,-50%) scale(1.05); opacity: 0; }
}
#giftBox:active { transform: scale(.97) translateY(3px); } /* 押した瞬間に少し沈む */
#giftBox:focus-visible { outline: 2px solid var(--brass); outline-offset: 4px; border-radius: 8px; }
/* 開封: 蓋 (上面+前縁+右縁のグループ) は回転させず、箱と平行なまま
 * 真上へ持ち上がりながら薄れる (translateY + opacity)。 */
#giftBox.opening { pointer-events: none; } /* 連打防止 (JS の state.opening と二重化) */
#giftBox.opening .gift-lid { animation: giftLidLift .42s cubic-bezier(.3, .7, .4, 1) both; }
@keyframes giftLidLift {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-52px); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #giftBox.opening .gift-lid { animation-duration: .01s; }
}
.start-hint {
  margin: 0; color: var(--paper-dim); font-size: 12.5px; font-weight: 600;
  letter-spacing: .26em;
}

/* 進捗サマリーは小さなテキスト、「つづきから遊ぶ」は下線テキスト (行全体がタップ可能) */
#resumePanel { display: flex; flex-direction: column; align-items: stretch; gap: 4px; margin-top: 4px; width: 100%; max-width: 430px; }
#resumePanel[hidden] { display: none; }
.resume-info {
  margin: 0; text-align: center; color: var(--paper-dim); font-size: 12.5px; letter-spacing: .04em;
}
.resume-link {
  background: none; border: 0; width: 100%; min-height: 48px; padding: 10px 6px;
  font-size: 17px; font-weight: 800; letter-spacing: .06em; color: var(--paper-ink);
  text-decoration: underline; text-decoration-color: var(--brass);
  text-decoration-thickness: 2.5px; text-underline-offset: 7px;
  -webkit-tap-highlight-color: transparent;
}
.resume-link:active { opacity: .6; }
.resume-arrow { color: var(--brass); text-decoration: none; }
/* 「はじめから」は誤タップを誘わないよう、つづきからより控えめな小さな下線リンク */
.fresh-link {
  background: none; border: 0; width: 100%; min-height: 44px; padding: 8px 6px;
  font-size: 13.5px; font-weight: 700; letter-spacing: .08em; color: var(--paper-dim);
  text-decoration: underline; text-decoration-color: var(--line);
  text-decoration-thickness: 1.5px; text-underline-offset: 6px;
  -webkit-tap-highlight-color: transparent;
}
.fresh-link:active { opacity: .6; }

.start-difficulty { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 8px; width: 100%; }
.start-difficulty-label { color: var(--paper-dim); font-weight: 700; font-size: 11px; letter-spacing: .3em; }
/* 案D: 重なったカード。重なりは負マージン、傾きは --tilt (JS が決定的に付与)。
 * 選択中は最前面 (z-index は JS) + せり上がり + テーマのマット色で反転。 */
.diff-fan {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start;
  padding: 12px 16px 4px; max-width: 560px;
}
.diff-card {
  position: relative;
  min-width: 60px; min-height: 66px; margin-left: -13px;
  padding: 9px 11px 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px;
  box-shadow: 0 1px 2px var(--shadow-soft), 0 5px 12px var(--shadow-soft), inset 0 1px 0 rgba(255,255,255,.35);
  transform: rotate(var(--tilt, 0deg));
  transition: transform .13s ease, box-shadow .13s ease;
  -webkit-tap-highlight-color: transparent;
}
.diff-card:first-child { margin-left: 0; }
.diff-card .diff-num { font-size: 16.5px; font-weight: 800; letter-spacing: .02em; line-height: 1.15; }
.diff-card .diff-sub { font-size: 9.5px; font-weight: 600; letter-spacing: .12em; opacity: .75; }
.diff-card.active {
  background: var(--mat); color: var(--mat-ink); border-color: transparent;
  transform: rotate(var(--tilt, 0deg)) translateY(-8px);
  box-shadow: 0 3px 6px var(--shadow-soft), 0 14px 24px var(--shadow), inset 0 1px 0 rgba(255,255,255,.22);
}
.diff-time { margin: 0; color: var(--paper-dim); font-size: 12px; letter-spacing: .08em; min-height: 16px; }

/* 導線はテキストリンク調に (日付移動は廃止したのでコレクションのみ) */
.start-links { width: 100%; display: flex; justify-content: flex-end; margin-top: 2px; }
.text-link {
  background: none; border: 0; min-height: 44px; padding: 10px 6px;
  color: var(--paper-ink); font-size: 13.5px; font-weight: 600; letter-spacing: .05em;
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 5px;
  -webkit-tap-highlight-color: transparent;
}
.text-link:active { opacity: .6; }

/* スタート画面のテーマ切替: 設定シートと同じ選択肢を、紙面に馴染む控えめな
 * 文字 + 色見本で置く。active の同期は app.js の applyTheme が
 * [data-theme-opt] 全体に対して行うので、設定シート側と常に一致する。 */
.start-theme {
  width: 100%; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 2px;
}
.start-theme-label {
  color: var(--paper-dim); font-size: 11px; font-weight: 700; letter-spacing: .3em; margin-right: 4px;
}
.theme-opt {
  background: none; border: 0; min-height: 36px; padding: 6px 8px;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--paper-dim); font-size: 12.5px; font-weight: 600; letter-spacing: .04em;
  -webkit-tap-highlight-color: transparent;
}
.theme-opt:active { opacity: .6; }
.theme-swatch {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 1px solid rgba(0,0,0,.20); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
.sw-walnut { background: linear-gradient(135deg, #7a5636, #5d3f27); }
.sw-nordic { background: linear-gradient(135deg, #e8cf9f, #d9b98c); }
.sw-atelier { background: linear-gradient(135deg, #46352a, #291d16); }
.theme-opt.active {
  color: var(--paper-ink);
  text-decoration: underline; text-decoration-color: var(--brass);
  text-decoration-thickness: 2px; text-underline-offset: 5px;
}
.theme-opt.active .theme-swatch { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--brass); }

.start-footer {
  margin-top: auto; width: 100%; display: flex; justify-content: space-between; gap: 10px;
  color: var(--paper-dim); font-size: 11px; flex-wrap: wrap;
}
.start-footer a { color: var(--paper-dim); }

/* ---------- プレイ画面 (全面の机 + floating 最小UI) ---------- */
#playView { position: fixed; inset: 0; }
#playView[hidden] { display: none; }
#stageWrap { position: absolute; inset: 0; overflow: hidden; background: var(--desk-fallback); }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

#surfaceLabel {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  background: rgba(24,17,10,.48); color: #fff; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; padding: 3px 14px;
  font-size: 12px; font-weight: 700; letter-spacing: .06em; pointer-events: none; z-index: 4;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
/* 範囲選択モードに入ったことを示すチップ (長押し成立〜矩形を離すまで) */
#selectChip {
  position: absolute; left: 50%; top: 42px; transform: translateX(-50%);
  background: rgba(24,17,10,.55); color: #fff; border: 1.5px solid var(--brass); border-radius: 999px; padding: 3px 14px;
  font-size: 12px; font-weight: 700; letter-spacing: .1em; pointer-events: none; z-index: 6;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
#selectChip[hidden] { display: none; }
#hud {
  position: absolute; left: 10px; top: 10px; z-index: 4; pointer-events: none;
  display: flex; gap: 10px; align-items: baseline;
  background: rgba(24,17,10,.48); color: #fff; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; padding: 4px 14px;
  font-size: 12px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
#hud #timerText { font-size: 12px; opacity: .9; }

.fab {
  position: absolute; z-index: 5;
  min-width: 44px; min-height: 44px; border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass); color: var(--glass-ink);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 6px var(--shadow-soft), 0 10px 22px var(--shadow-soft);
  font-size: 19px; line-height: 1; padding: 0 10px;
  transition: transform .08s ease;
}
.fab:active { transform: translateY(1px); }
#settingsBtn { right: 10px; top: 10px; }
.fab-surface {
  right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
  font-size: 14px; font-weight: 700; letter-spacing: .03em; padding: 0 18px;
  background: var(--accent); border-color: var(--accent-dark); color: var(--accent-ink);
}
.fab-surface:active { background: var(--accent-dark); }

#zoomCtl {
  position: absolute; left: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 5;
  display: flex; align-items: center; gap: 2px;
  background: rgba(24,17,10,.48); border: 1px solid rgba(255,255,255,.16); border-radius: 999px; padding: 3px 6px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.zoom-btn {
  min-width: 38px; min-height: 38px; border: 0; border-radius: 999px;
  background: transparent; color: #fff; font-size: 17px; line-height: 1;
}
.zoom-btn:active { background: rgba(255,255,255,.25); }
#zoomLabel { color: #fff; font-size: 12px; min-width: 40px; text-align: center; }

/* ミニマップ: 机でカメラ移動中だけ HUD の下にフェードインする (操作対象ではない) */
#minimap {
  position: absolute; left: 10px; top: 54px; z-index: 5;
  width: 132px; height: 118px; border-radius: 10px;
  background: rgba(24,17,10,.55); border: 1px solid rgba(255,255,255,.22);
  opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s ease;
  pointer-events: none;
}
#minimap.on { opacity: 1; visibility: visible; }

#dropZone {
  position: absolute; left: 8px; right: 8px; top: 8px; min-height: 52px;
  border: 3px dashed var(--accent); border-radius: 12px; background: var(--glass);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent-dark);
  pointer-events: none; z-index: 6;
}
#dropZone[hidden] { display: none; }
#dropZone.hot { background: var(--accent); color: var(--accent-ink); }
#resumeBanner {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(64px + env(safe-area-inset-bottom));
  background: rgba(24,17,10,.85); color: #fff; border-radius: 999px; padding: 6px 8px 6px 16px; font-size: 13px;
  display: flex; align-items: center; gap: 8px; z-index: 6;
}
#resumeBanner[hidden] { display: none; }
#resumeBanner button {
  background: transparent; color: #fff; border: 0; min-width: 28px; min-height: 28px; font-size: 15px;
}
#loadingOverlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--glass); color: var(--ink); font-weight: 700; z-index: 7;
}

#fadeVeil {
  position: fixed; inset: 0; background: #101014; opacity: 0;
  pointer-events: none; transition: opacity .26s ease; z-index: 80;
}
#fadeVeil.on { opacity: 1; }

/* ---------- コレクション ---------- */
#collectionView {
  position: fixed; inset: 0; overflow-y: auto; background: var(--screen-bg);
  padding: 12px; box-sizing: border-box;
}
#collectionView[hidden] { display: none; }
#collectionView > * { max-width: 960px; margin-left: auto; margin-right: auto; }
.collection-header { display: flex; align-items: center; gap: 12px; }
.collection-header h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: .05em; color: var(--screen-ink); }
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px auto; }
.stats .stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px;
  box-shadow: 0 1px 2px var(--shadow-soft), 0 4px 10px var(--shadow-soft);
}
.stats .stat b { font-size: 16px; }
.empty { color: var(--screen-ink); opacity: .6; padding: 24px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  text-align: left; padding: 0; width: 100%;
  box-shadow: 0 1px 2px var(--shadow-soft), 0 6px 16px var(--shadow-soft);
}
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--line); }
.card .card-body { padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 3px; }
.card .card-date { font-weight: 700; font-size: 13px; }
.badge {
  display: inline-block; background: var(--badge-bg); border: 1px solid var(--line); border-radius: 999px;
  padding: 1px 8px; font-size: 11px;
}
.badge.praise { background: var(--praise-bg); border-color: var(--brass); color: var(--praise-ink); font-weight: 700; }

/* ---------- モーダル / 設定シート ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20,14,8,.55); }
.modal-body {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
  max-width: min(92vw, 560px); max-height: 88vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  align-items: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.35), 0 4px 14px var(--shadow);
}
.modal-body img { max-width: 100%; max-height: 62vh; border-radius: 10px; }
.modal-close { align-self: center; }
.result-body { text-align: center; min-width: min(88vw, 340px); }
.result-body h2 { margin: 4px 0; font-weight: 800; letter-spacing: .05em; }
.praise { background: var(--praise-bg); border: 1px solid var(--brass); color: var(--praise-ink); border-radius: 10px; padding: 8px 12px; font-weight: 700; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
#detailText { font-size: 14px; line-height: 1.7; text-align: left; width: 100%; }
#detailCanvas { width: 100%; max-width: 528px; height: auto; aspect-ratio: 1; display: block; border-radius: 10px; }

.settings-body { min-width: min(88vw, 320px); align-items: stretch; }
.settings-body h2 { margin: 4px 0 2px; font-size: 17px; font-weight: 800; letter-spacing: .08em; text-align: center; }
.settings-list { display: flex; flex-direction: column; gap: 8px; }
.settings-item { width: 100%; text-align: center; }
.settings-item.danger { color: var(--danger); border-color: var(--danger-line); }
.danger-btn { background: var(--danger); border-color: var(--danger); color: #fff; }
.settings-theme { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.settings-section-label { font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--muted); text-align: center; }
.settings-theme-btns { display: flex; gap: 8px; }
.settings-theme-btns .btn { flex: 1; padding: 6px 4px; }
.theme-btn.active { background: var(--accent); border-color: var(--accent-dark); color: var(--accent-ink); font-weight: 700; }

#confettiWrap { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
#confettiWrap[hidden] { display: none; }
#confetti { width: 100%; height: 100%; display: block; }

@media (max-width: 640px) {
  .start-title-text { font-size: 26px; }
  .diff-card { min-width: 54px; min-height: 60px; padding: 8px 9px 7px; margin-left: -11px; }
  .diff-card .diff-num { font-size: 15px; }
}
