:root {
  --bg: #05070f;
  --panel: rgba(16, 26, 54, 0.72);
  --panel-solid: #0e1730;
  --line: rgba(120, 200, 255, 0.18);
  --text: #dfe9ff;
  --muted: #8796b8;
  --cyan: #5fe3ff;
  --gold: #ffd76a;
  --teal: #2ee6c0;
  --red: #ff4d6a;
  --violet: #8a72ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: radial-gradient(ellipse at 50% 28%, #0f1b3d 0%, #05070f 68%) fixed;
  overflow: hidden;
}

[hidden] { display: none !important; }

#app {
  height: 100vh;
  height: 100dvh;
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-left));
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
  padding: 10px 2px 4px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.tools { display: flex; gap: 6px; }
.brand .tools { margin-left: auto; }
/* アプリのアイコン＝タイトルへ戻るボタン。枠線なし、ホバーで少し浮く */
.home-icon {
  flex: none; width: 40px; height: 40px; min-height: 40px; padding: 0;
  border-radius: 10px; overflow: hidden; background: none;
  box-shadow: 0 0 0 1px rgba(95, 227, 255, 0.25), 0 0 14px rgba(95, 227, 255, 0.18);
}
.home-icon img { display: block; width: 100%; height: 100%; }
.home-icon:hover:not(:disabled) { background: none; box-shadow: 0 0 0 1px rgba(95, 227, 255, 0.5), 0 0 18px rgba(95, 227, 255, 0.35); }
.home-icon:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
@media (pointer: coarse) { .home-icon { width: 44px; height: 44px; min-height: 44px; } }
.tools button.icon { width: 40px; min-height: 40px; height: 40px; border-radius: 10px; font-size: 16px; }
@media (pointer: coarse) { .tools button.icon { width: 44px; min-height: 44px; height: 44px; } }
.brand h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.28em;
  color: var(--cyan);
  text-shadow: 0 0 14px rgba(95, 227, 255, 0.55);
  white-space: nowrap;
}
.brand h1 span { color: var(--text); font-weight: 700; letter-spacing: 0.22em; }
.stats { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.stat, .badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 3px 9px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.stat b {
  color: var(--text);
  font-weight: 700;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}
.stat.score b { color: var(--gold); }

/* タイムアタック・エンドレスの帯: 何問目か（左）とタイム・残機（右）を大きく */
.modebar {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 6px 12px 7px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(20, 34, 72, 0.85), rgba(10, 18, 40, 0.85));
  box-shadow: inset 0 0 0 1px rgba(95, 227, 255, 0.22), 0 6px 22px rgba(0, 0, 0, 0.35);
}
.mb-cell { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.mb-cell.right { align-items: flex-end; position: relative; }
.mb-label { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; color: var(--muted); }
.mb-value { display: flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.mb-big {
  font-size: 30px;
  font-weight: 900;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 14px rgba(95, 227, 255, 0.35);
}
.mb-big.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-weight: 700; color: var(--gold); text-shadow: 0 0 14px rgba(255, 215, 106, 0.35); }
.modebar[data-kind="endless"] .mb-big.mono { font-family: inherit; color: #ff7a93; letter-spacing: 0.08em; font-size: 24px; text-shadow: 0 0 12px rgba(255, 122, 147, 0.45); }
.mb-big .off { color: rgba(255, 255, 255, 0.16); text-shadow: none; }
.mb-unit { font-size: 14px; font-weight: 700; color: var(--muted); }
.mb-sub { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.mb-diff { font-weight: 700; margin-right: 4px; }
.mb-diff[data-diff="easy"] { color: #7ef0c8; }
.mb-diff[data-diff="normal"] { color: var(--cyan); }
.mb-diff[data-diff="hard"] { color: #ff8aa0; }
.mb-score { color: var(--gold); font-variant-numeric: tabular-nums; }
.mb-pips { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }
.mb-pips i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.12); }
.mb-pips i.clear { background: var(--teal); }
.mb-pips i.skip, .mb-pips i.fail { background: #ff9a3c; }
.mb-pips i.now { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); animation: pulse 1.2s ease-in-out infinite; }
/* 20・30問は、点を細い棒にして1列に収める */
.mb-pips.bar { flex-wrap: nowrap; gap: 2px; min-width: 0; }
.mb-pips.bar i { flex: 1 1 0; min-width: 2px; width: auto; height: 8px; border-radius: 2px; }
.mb-pips.bar i.now { animation: none; box-shadow: 0 0 6px var(--cyan); }
@keyframes pulse { 50% { transform: scale(1.35); } }
.mb-pen {
  position: absolute;
  right: 0;
  top: -6px;
  font-size: 13px;
  font-weight: 900;
  color: #ff7a93;
  opacity: 0;
  pointer-events: none;
}
.mb-pen.pop { animation: penalty 1.3s ease-out; }
.mb-pen.gain { color: var(--gold); white-space: nowrap; }
.mb-pen.gain.pop { animation-duration: 1.8s; }
.mb-rec { font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: 0.06em; margin-right: 2px; }
.mb-rec-note { font-size: 11px; color: var(--muted); margin-left: 6px; white-space: nowrap; }
/* エンドレス: 左に何問目、右に残機。回復までの進み具合は下の段に横いっぱい */
.modebar[data-kind="endless"] { grid-template-columns: 1fr auto; }
.modebar[data-kind="endless"] .mb-cell:first-child { grid-column: 1; grid-row: 1; }
.modebar[data-kind="endless"] .mb-cell.right { grid-column: 2; grid-row: 1; }
.modebar[data-kind="endless"] .mb-pips { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; flex-wrap: nowrap; padding-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.mb-pips { align-items: center; }
@keyframes penalty {
  0% { opacity: 0; transform: translateY(8px); }
  15% { opacity: 1; transform: translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}
.stat.warn b { color: var(--red); }
.badge { font-weight: 700; letter-spacing: 0.06em; }
.badge[data-diff="easy"] { color: #7ef0c8; border-color: rgba(126, 240, 200, 0.4); }
.badge[data-diff="normal"] { color: var(--cyan); border-color: rgba(95, 227, 255, 0.4); }
.badge[data-diff="hard"] { color: #ff8aa0; border-color: rgba(255, 138, 160, 0.45); }

.infobar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  padding: 2px 2px 6px;
}
/* 問題がまだないときも場所は取っておく（盤面の大きさを変えない） */
.infobar.empty { visibility: hidden; }
/* 推理に要る条件（光源の数・反射上限）: 数字を大きく金色で。枠線は付けず、面の色で */
.infobar .cond-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 11px 3px 8px; border-radius: 999px;
  background: rgba(255, 215, 106, 0.1); box-shadow: inset 0 0 0 1px rgba(255, 215, 106, 0.18);
  color: var(--text); font-size: 13px; font-weight: 700; line-height: 1.2; white-space: nowrap;
}
.infobar .cond-chip svg { width: 15px; height: 15px; color: var(--gold); flex: none; filter: drop-shadow(0 0 4px rgba(255, 215, 106, 0.6)); }
.infobar .cond-chip b { font-size: 19px; font-weight: 900; color: var(--gold); text-shadow: 0 0 10px rgba(255, 215, 106, 0.45); font-variant-numeric: tabular-nums; }
.infobar b { color: var(--text); font-weight: 700; }
.infobar .glyph { font-size: 15px; font-weight: 900; color: var(--cyan); }
.infobar .rating { color: var(--gold); letter-spacing: 0.08em; }
.infobar small { color: var(--muted); font-size: 11px; margin-left: 2px; }
.infobar .mode { margin-left: auto; color: var(--violet); font-weight: 700; }

/* ---------- Stage ---------- */
.stage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage { position: relative; line-height: 0; }
#board {
  display: block;
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--line), 0 18px 60px rgba(0, 0, 0, 0.55);
  touch-action: none;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1.5;
  background: rgba(4, 7, 16, 0.55);
  border-radius: 14px;
  text-align: center;
  padding: 16px;
}
.loading p { margin: 0; font-size: 14px; }
.loading .sub { font-size: 12px; color: var(--muted); }
.spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(95, 227, 255, 0.15);
  border-top-color: var(--cyan);
  margin-bottom: 10px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.verdict {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: clamp(42px, 12vw, 92px);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1;
  opacity: 0;
}
.verdict.safe {
  color: var(--teal);
  text-shadow: 0 0 28px rgba(46, 230, 192, 0.85), 0 0 4px rgba(255, 255, 255, 0.8);
  animation: pop 1.9s ease-out forwards;
}
.verdict.exposed {
  color: var(--red);
  text-shadow: 0 0 28px rgba(255, 77, 106, 0.85), 0 0 4px rgba(255, 255, 255, 0.6);
  animation: pop 1.6s ease-out forwards;
}
.verdict.call {
  font-size: clamp(36px, 11vw, 76px);
  color: var(--text);
  text-shadow: 0 0 26px rgba(95, 227, 255, 0.8), 0 0 4px rgba(255, 255, 255, 0.7);
  animation: pop 1.1s ease-out forwards;
}
@keyframes pop {
  0% { opacity: 0; transform: scale(0.6); }
  14% { opacity: 1; transform: scale(1.08); }
  28% { transform: scale(1); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.02); }
}

/* ---------- Message / legend ---------- */
/* 盤面の下は高さを固定する。文言（3行ぶん）と凡例、練習の進行がこの中に収まる */
.below { flex: none; height: 86px; display: flex; flex-direction: column; overflow: hidden; }
body.practicing .below { height: 132px; }
.message {
  margin: 6px 0 0;
  height: 4.4em;
  overflow-y: auto;
  text-align: center;
  font-size: 13px;
  line-height: 1.45;
  color: #b8c5e4;
  word-break: auto-phrase;
  text-wrap: balance;
}
.message b { color: var(--text); }
.message .pen { color: var(--red); }
.message .orange { color: #ff9a3c; }
.message .gain { color: var(--gold); font-size: 15px; }
.legend.off { visibility: hidden; }
.legend {
  display: flex;
  flex: none;
  height: 16px;
  margin-top: 2px;
  overflow: hidden;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  font-size: 11px;
  color: var(--muted);
}
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.sw.lit { background: #ffd779; }
.sw.dark { background: #7052f0; }
.sw.ok { background: var(--teal); }
#btnPromo { color: var(--gold); }

/* ---------- Buttons ---------- */
/* ボタンの列も高さを固定する（ボタンが入れ替わっても盤面の大きさを変えない） */
.controls {
  flex: none;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 0 14px;
  min-height: 78px;
}
button {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  /* 枠線は付けない（キーボードで選んでいるボタンと、選んでいる選択肢だけに付ける）。面の色と影で押せることを示す */
  background: rgba(34, 54, 104, 0.78);
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  min-height: 44px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  transition: background 0.15s, transform 0.12s, box-shadow 0.12s, opacity 0.15s;
}
button:hover:not(:disabled) { background: rgba(50, 78, 142, 0.92); box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35); }
@media (hover: hover) { button:hover:not(:disabled) { transform: translateY(-2px); } }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
button:disabled { opacity: 0.4; cursor: default; }
button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
button.primary {
  background: linear-gradient(180deg, #1fb6d8, #1281a6);
  color: #04131c;
  min-width: 120px;
  box-shadow: 0 0 18px rgba(95, 227, 255, 0.28);
}
button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #38caea, #1691b9); }
button.ghost { background: transparent; color: var(--muted); box-shadow: none; }
button.ghost:hover:not(:disabled) { background: rgba(95, 227, 255, 0.08); color: var(--text); box-shadow: none; }
button.link { background: none; box-shadow: none; min-height: 32px; padding: 4px 6px; font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
button.link:hover:not(:disabled) { background: none; box-shadow: none; color: var(--text); transform: none; }
/* キーの表示（マウスとキーボードの端末だけ） */
button kbd { display: none; margin-left: 6px; padding: 1px 5px; border-radius: 4px; font: 700 10px ui-monospace, Consolas, monospace; background: rgba(0, 0, 0, 0.28); color: inherit; opacity: 0.75; vertical-align: 1px; }
@media (hover: hover) and (pointer: fine) { button kbd { display: inline-block; } }
button.icon { width: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
button.small { min-height: 36px; padding: 6px 12px; font-size: 13px; }
button.danger { color: #ff9aab; background: rgba(255, 77, 106, 0.08); box-shadow: none; }
.pill {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 10px;
  background: rgba(138, 114, 255, 0.3);
  color: #cdbfff;
  font-size: 12px;
  line-height: 20px;
}
/* ペナルティなどの添え書きは、ボタンの2行目に小さく出す */
button .cost { display: block; font-size: 11px; font-weight: 700; line-height: 1.2; color: #ff9aab; }

/* ---------- Dialogs ---------- */
.dlg {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  overflow: auto;
}
.dlg::backdrop { background: rgba(2, 4, 10, 0.7); backdrop-filter: blur(3px); }
.dlg form { padding: 20px 22px 18px; }
.dlg h2 { margin: 0 0 12px; font-size: 18px; color: var(--cyan); letter-spacing: 0.08em; }
.dlg h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 700; }
.dlg section { padding: 12px 0; border-top: 1px solid var(--line); }
.dlg p, .dlg li { font-size: 14px; line-height: 1.7; }
.dlg ol { padding-left: 1.3em; margin: 8px 0; }
.dlg ol.steps li { margin-bottom: 6px; }
.dlg .fold { padding: 10px 0; border-top: 1px solid var(--line); }
.dlg .fold summary {
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 0;
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dlg .fold summary::-webkit-details-marker { display: none; }
.dlg .fold summary::before { content: "▸"; color: var(--cyan); transition: transform 0.15s; }
.dlg .fold[open] summary::before { transform: rotate(90deg); }
.dlg .fold summary:hover { color: var(--text); }
.dlg .fold summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 4px; }
.dlg .fold[open] summary { margin-bottom: 6px; }
.dlg .gold { color: var(--gold); }
.dlg .teal { color: var(--teal); }
.dlg .orange { color: #ff9a3c; }
.result-best { margin: 0 0 8px; font-size: 14px; font-weight: 700; color: var(--gold); text-align: center; }
.result-hero { margin: 4px 0 6px; text-align: center; line-height: 1.1; }
.result-hero .hero-label { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 4px; }
.result-hero b { font-size: 44px; font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; text-shadow: 0 0 20px rgba(255, 215, 106, 0.4); }
.result-hero .hero-unit { font-size: 18px; font-weight: 700; color: var(--muted); margin-left: 4px; }
/* スコアボード */
.seg.sub { margin-top: 6px; }
.seg.sub button { min-height: 36px; padding: 4px 8px; font-size: 13px; }
.board-wrap { max-height: 52vh; }
.board td.rank { font-weight: 900; color: var(--muted); }
.board td.rank.r1 { color: var(--gold); }
.board td.rank.r2 { color: #d6e2ff; }
.board td.rank.r3 { color: #f0a46a; }
.board td.rec { font-weight: 700; color: var(--text); }
.board td.rec.full { color: var(--teal); }
.board tr.me td { background: rgba(95, 227, 255, 0.14); }
.splits.board th, .splits.board td { white-space: nowrap; }
.splits.board td.name, .splits.board th:nth-child(2) { text-align: left; max-width: 7.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .you { font-size: 10px; color: var(--cyan); font-weight: 700; margin-left: 4px; }
.seg.scope { margin-bottom: 6px; }
.name-row { margin: 8px 0 0; }
.name-row label { font-size: 13px; color: var(--muted); font-weight: 700; }
.name-row input { min-width: 0; text-transform: none; font-family: inherit; }
.rank-status { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-align: center; min-height: 1em; }
.rank-status:empty { display: none; }
#boardFoot:empty { display: none; }
.board td.empty { text-align: center; color: var(--muted); padding: 18px 8px; }
.vol { margin-left: 6px; color: var(--cyan); font-variant-numeric: tabular-nums; }
.slider { width: 100%; accent-color: var(--cyan); height: 32px; }
.table-wrap { max-height: 38vh; overflow: auto; margin: 4px 0 8px; border: 1px solid var(--line); border-radius: 10px; }
.splits { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.splits th, .splits td { padding: 5px 8px; text-align: right; border-bottom: 1px solid var(--line); }
.splits th { color: var(--muted); font-weight: 700; position: sticky; top: 0; background: var(--panel-solid); }
.splits td:nth-child(2), .splits th:nth-child(2) { text-align: center; }
.splits td.ch { font-size: 17px; font-weight: 900; color: var(--cyan); }
.splits .split-note { display: block; font-size: 10px; color: #ff9a3c; }
.splits tr.skip td, .splits tr.fail td { color: var(--muted); }
.splits .d-easy { color: #7ef0c8; } .splits .d-normal { color: var(--cyan); } .splits .d-hard { color: #ff8aa0; }
.note { font-size: 12px !important; color: var(--muted); margin: 8px 0 0; line-height: 1.6 !important; }
.note.error { color: var(--red); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; }
.seg button { background: rgba(255, 255, 255, 0.05); box-shadow: none; }
.seg button:disabled { opacity: 0.4; }
#boardModeSeg button { flex: 1.4; }
.seg button[aria-pressed="true"] { box-shadow: inset 0 0 0 1.5px var(--cyan); background: rgba(95, 227, 255, 0.16); color: var(--cyan); }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.row code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 15px;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 10px;
  border-radius: 8px;
}
.row input {
  flex: 1;
  min-width: 140px;
  font: inherit;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 15px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  text-transform: uppercase;
}
.row input:focus { outline: none; border-color: var(--cyan); }
.statgrid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  margin: 0 0 12px;
  font-size: 14px;
}
.statgrid dt { color: var(--muted); }
.statgrid dd { margin: 0; font-variant-numeric: tabular-nums; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ---------- Title ---------- */
.title-screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.title-fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.title-inner {
  position: relative;
  width: min(440px, 100%);
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.logo { margin: 0; line-height: 1.05; }
/* ロゴ画像の背景はページと同じ暗い色。screen で重ねて、後ろの光（タイトルの背景）を透かす */
.logo img { display: block; width: min(100%, 400px); height: auto; margin: 0 auto; mix-blend-mode: screen; }
.tagline { margin: 0 0 4px; font-size: 13px; line-height: 1.6; color: #b8c5e4; }
.modes { display: flex; flex-direction: column; gap: 10px; }
.mode-card {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name rec" "desc rec";
  align-items: center;
  gap: 2px 10px;
  text-align: left;
  padding: 12px 16px;
  min-height: 64px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(26, 44, 92, 0.92), rgba(12, 22, 50, 0.92));
  box-shadow: inset 0 0 0 1px rgba(95, 227, 255, 0.25), 0 8px 24px rgba(0, 0, 0, 0.4);
}
.mode-card:hover:not(:disabled) { background: linear-gradient(180deg, rgba(36, 62, 124, 0.95), rgba(16, 30, 66, 0.95)); }
.mode-card .mc-name { grid-area: name; font-size: 18px; font-weight: 900; color: var(--text); letter-spacing: 0.04em; }
.mode-card .mc-desc { grid-area: desc; font-size: 12px; font-weight: 400; color: var(--muted); }
.mode-card .mc-rec { grid-area: rec; font-size: 12px; font-weight: 700; color: var(--gold); text-align: right; max-width: 9.5em; line-height: 1.35; }
.mode-card[data-start="timeattack"] { box-shadow: inset 4px 0 0 var(--gold), 0 8px 24px rgba(0, 0, 0, 0.4); }
.mode-card[data-start="endless"] { box-shadow: inset 4px 0 0 #ff7a93, 0 8px 24px rgba(0, 0, 0, 0.4); }
.mode-card[data-start="free"] { box-shadow: inset 4px 0 0 var(--teal), 0 8px 24px rgba(0, 0, 0, 0.4); }
.mode-card.practice { min-height: 52px; grid-template-areas: "name" "desc"; grid-template-columns: 1fr; box-shadow: inset 4px 0 0 var(--violet), 0 8px 24px rgba(0, 0, 0, 0.4); background: linear-gradient(180deg, rgba(48, 36, 110, 0.92), rgba(22, 18, 60, 0.92)); }
.mode-card.practice .mc-name { font-size: 16px; }
.new-badge { display: inline-block; margin-left: 8px; padding: 1px 6px; border-radius: 6px; background: var(--gold); color: #1a1200; font-size: 10px; font-weight: 900; letter-spacing: 0.08em; vertical-align: 2px; }
.title-opts { display: flex; flex-direction: column; gap: 8px; }
.title-opts .opt { display: flex; align-items: center; gap: 10px; }
.title-opts .opt-label { flex: 0 0 7.4em; white-space: nowrap; font-size: 12px; font-weight: 700; color: var(--muted); text-align: left; }
.title-opts .seg { flex: 1; }
.title-opts .seg button { min-height: 38px; padding: 4px 6px; font-size: 13px; }
.title-links { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.title-links button { min-width: 0; padding: 8px 14px; }

@media (prefers-reduced-motion: reduce) {
  button, button:hover:not(:disabled), button:active:not(:disabled) { transition: none; transform: none; }
}

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  #app { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .hud { padding-top: 6px; gap: 6px; }
  .brand { width: 100%; justify-content: space-between; }
  .brand h1 { font-size: 13px; letter-spacing: 0.2em; }
  .stats { flex-wrap: nowrap; }
  .stat, .badge { padding: 3px 8px; font-size: 12px; }
  .stat b { margin-left: 4px; }
  .stat.score { margin-left: auto; }
  .stats { width: 100%; }
  .infobar { gap: 2px 10px; font-size: 12px; padding-top: 4px; }
  .infobar .kind { display: none; }
  .message { font-size: 13px; }
  /* 判定を真ん中に大きく、親指で押しやすく */
  .controls { display: grid; grid-template-columns: 1fr 1.25fr 1fr; align-content: center; gap: 8px; padding-bottom: max(10px, env(safe-area-inset-bottom)); min-height: 74px; }
  .controls.has-promo #btnNext, .controls #btnCoachStart { grid-column: 1 / 3; }
  .controls button { min-height: 52px; padding: 6px 6px; font-size: 14px; min-width: 0; white-space: nowrap; }
  .controls #btnNext { grid-column: 1 / -1; }
  .dlg form { padding: 18px 16px 14px; }
  .dlg-actions { flex-wrap: nowrap; gap: 6px; }
  .dlg-actions button { flex: 1 1 auto; min-width: 0; padding: 8px 10px; white-space: nowrap; }
  .splits th, .splits td { padding: 5px 6px; }
  .dlg .seg button { padding: 6px 4px; font-size: 13px; white-space: nowrap; min-width: 0; }
}
@media (max-width: 360px) {
  .dlg .seg button { font-size: 12px; letter-spacing: -0.02em; }
}
@media (max-width: 360px) {
  .brand h1 { font-size: 11px; letter-spacing: 0.12em; }
  .brand h1 span { letter-spacing: 0.08em; }
}
/* 縦長のスマホでは、盤面を上（情報の帯のすぐ下）に置き、すぐ下に案内の文言。余った高さは操作ボタンの上に回す。
   盤面の箱の高さは GameManager._observeSize が盤面と同じにする */
@media (max-width: 560px) and (orientation: portrait) {
  .stage-wrap { flex: none; align-items: flex-start; }
  .controls { margin-top: auto; }
}
/* 縦に余裕のあるスマホでは、練習の案内（文言＋ヒント）が欠けない高さにする（盤面は幅で決まるので大きさは変わらない） */
@media (max-width: 560px) and (orientation: portrait) and (min-height: 700px) {
  body.practicing .below { height: 176px; }
}

/* ---------- Low landscape (phone sideways) ---------- */
@media (orientation: landscape) and (max-height: 540px) {
  #app {
    display: grid;
    max-width: none;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 38%);
    grid-template-rows: auto auto 1fr auto;
    column-gap: 16px;
  }
  .stage-wrap { grid-column: 1; grid-row: 1 / -1; }
  .hud { grid-column: 2; grid-row: 1; }
  .infobar { grid-column: 2; grid-row: 2; }
  .below, body.practicing .below { grid-column: 2; grid-row: 3; height: auto; min-height: 0; justify-content: center; }
  .coach-text { font-size: 13px; }
  .controls { grid-column: 2; grid-row: 4; display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 6px; padding-bottom: max(8px, env(safe-area-inset-bottom)); min-height: 0; }
  .controls.has-promo #btnNext, .controls #btnCoachStart { grid-column: 1 / 3; }
  .controls button { min-width: 0; padding: 6px 8px; }
  .controls #btnNext { grid-column: 1 / -1; }
  .brand h1 { display: none; } /* 右の列は狭いので、操作のアイコンを優先する */
  .brand .tools { margin-left: 0; }
  .brand { justify-content: flex-end; }
  .infobar .kind { display: none; }
}

/* 横向きのスマホ: タイトルは左にロゴと設定、右にモードを並べる */
@media (orientation: landscape) and (max-height: 540px) {
  .title-inner {
    width: min(780px, 100%);
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    grid-template-areas: "logo practice" "tag modes" "opts modes" "links modes";
    align-items: center;
    gap: 8px 22px;
  }
  #btnPractice { grid-area: practice; min-height: 44px; padding: 6px 14px; }
  #btnPractice .mc-desc { display: none; }
  .logo { grid-area: logo; }
  .logo img { width: min(100%, 300px); } /* 844×390 でスクロールしない大きさ */
  .tagline { grid-area: tag; margin: 0; }
  .modes { grid-area: modes; gap: 8px; }
  .mode-card { min-height: 56px; padding: 8px 14px; }
  .title-opts { grid-area: opts; }
  .title-links { grid-area: links; }
}


/* ---------- 開いたときだけ表示する情報（部屋の詳細） ---------- */
.info-toggle {
  min-height: 28px; padding: 2px 8px; font-size: 12px; font-weight: 700; color: var(--muted);
  background: rgba(255, 255, 255, 0.05); box-shadow: none; border-radius: 8px;
}
.info-toggle .chev::after { content: "▾"; display: inline-block; margin-left: 4px; transition: transform 0.15s; }
.info-toggle[aria-expanded="true"] .chev::after { transform: rotate(180deg); }
@media (pointer: coarse) { .info-toggle { min-height: 34px; } }
/* 開いても下の要素を押し下げない（盤面の上に重ねて出す） */
.info-more {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 4;
  display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center;
  padding: 8px 12px; border-radius: 10px;
  background: rgba(14, 23, 48, 0.96); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}
.info-more[hidden] { display: none; }
.info-more .mode { margin-left: 0; }

/* ---------- 練習（チュートリアル） ---------- */
.coach {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 6px 0 0;
  padding: 10px 14px 10px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(48, 36, 110, 0.9), rgba(22, 18, 60, 0.9));
  box-shadow: inset 4px 0 0 var(--violet), 0 8px 24px rgba(0, 0, 0, 0.35);
}
.coach-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.coach-step { font-size: 11px; font-weight: 900; letter-spacing: 0.12em; color: #cdbfff; }
.coach-text { margin: 4px 0 0; font-size: 14px; line-height: 1.6; color: var(--text); word-break: auto-phrase; }
.coach-text.praise { color: var(--gold); font-weight: 900; font-size: 16px; }
.coach-hint { margin: 6px 0 0; font-size: 12px; line-height: 1.5; color: var(--gold); }
.coach-bar { margin-top: 8px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.coach-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--violet), var(--cyan)); transition: width 0.15s; }
body.practicing .message, body.practicing .legend { display: none; }
@media (max-height: 640px) {
  .coach { padding: 7px 12px 8px 14px; margin-top: 6px; }
  .coach-text { font-size: 13px; line-height: 1.5; }
  .coach-hint { margin-top: 4px; }
}
body.practicing .stat.score { display: none; }
/* 練習で操作する場所を光らせる（枠線ではなく光の輪） */
.tut-target { animation: tutGlow 1.3s ease-in-out infinite; }
@keyframes tutGlow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 215, 106, 0.35), 0 0 12px rgba(255, 215, 106, 0.25); }
  50% { box-shadow: 0 0 0 4px rgba(255, 215, 106, 0.75), 0 0 26px rgba(255, 215, 106, 0.55); }
}
/* 手本を見せる手（ドット絵）。指先が示す位置に来るように置く */
.ghost-hand { position: absolute; width: 33px; height: 39px; pointer-events: none; transform: translate(-11px, -2px); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6)); z-index: 2; line-height: 0; }
.ghost-hand .hand { width: 100%; height: 100%; }
.ghost-hand[data-anim="tap"] .hand { animation: handTap 1.1s ease-in-out infinite; transform-origin: 30% 0; }
.ghost-hand[data-anim="drag"] .hand { animation: handDrag 1.8s ease-in-out infinite; }
.ghost-hand[data-anim="tap"]::before {
  content: ""; position: absolute; left: 11px; top: 2px; width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 215, 106, 0.8); animation: handRing 1.1s ease-out infinite;
}
@keyframes handTap { 0%, 100% { transform: translateY(6px) scale(1); } 40% { transform: translateY(0) scale(0.92); } }
@keyframes handRing { 0%, 35% { opacity: 0; transform: scale(0.3); } 45% { opacity: 1; } 100% { opacity: 0; transform: scale(1.4); } }
@keyframes handDrag { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(26px, -10px); } 50% { transform: translate(34px, 16px); } 75% { transform: translate(6px, 22px); } }
@media (prefers-reduced-motion: reduce) {
  .tut-target, .ghost-hand .hand, .ghost-hand::before { animation: none !important; }
}

/* ---------- 遊び方（カード＋小さな部屋） ---------- */
.howto .howto-top { display: flex; justify-content: space-between; align-items: baseline; }
.howto-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.howto-deck { touch-action: pan-y; }
.howto-card h3 { margin: 0 0 8px; font-size: 16px; color: var(--text); }
.howto-card p { margin: 8px 0 0; font-size: 13px; line-height: 1.65; }
.howto-room { display: block; width: 100%; aspect-ratio: 4 / 3; border-radius: 12px; background: #070b18; touch-action: none; cursor: crosshair; }
.howto-try { color: #cdbfff; font-weight: 700; }
.howto-got { color: var(--gold); font-weight: 900; }
.howto-result { min-height: 3.3em; color: #b8c5e4; }
.howto-result.good { color: var(--teal); font-weight: 700; }
.howto-result.bad { color: #ff9a8a; font-weight: 700; }
.howto-k { margin-top: 8px; }
.howto-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.howto-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 10px 12px; min-height: 64px; }
.howto-tile b { font-size: 14px; }
.howto-tile span { display: none; font-size: 12px; font-weight: 400; line-height: 1.55; color: #b8c5e4; }
.howto-tile[aria-expanded="true"] { background: rgba(95, 227, 255, 0.12); }
.howto-tile[aria-expanded="true"] span { display: block; }
.howto-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 0 4px; }
.howto-nav .ghost { min-width: 44px; font-size: 22px; padding: 4px 10px; }
.howto-dots { display: flex; gap: 8px; }
.howto-dots button { width: 12px; height: 12px; min-height: 12px; padding: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.18); box-shadow: none; }
.howto-dots button[aria-current="true"] { background: var(--cyan); transform: scale(1.25); }
.howto-dots button.done { background: var(--gold); }
.howto-dots button.done[aria-current="true"] { background: var(--gold); box-shadow: 0 0 0 2px var(--cyan); }
@media (max-width: 360px) { .howto-tiles { grid-template-columns: 1fr; } }

/* タイトル: タイムアタック欄（問題数のボタン）とフリーの難易度選び */
.ta-card { grid-template-areas: "name" "desc" "lens"; grid-template-columns: 1fr; cursor: default; }
.ta-card:hover { background: linear-gradient(180deg, rgba(26, 44, 92, 0.92), rgba(12, 22, 50, 0.92)); }
.ta-lens { grid-area: lens; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.ta-lens button, .free-diffs button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; min-height: 52px; background: rgba(255, 215, 106, 0.1); }
.ta-lens button b, .free-diffs button b { font-size: 15px; }
.ta-lens button small { font-size: 11px; font-weight: 700; color: var(--gold); white-space: nowrap; }
.free-pick { margin-top: -10px; padding: 10px 12px; border-radius: 0 0 14px 14px; background: rgba(12, 22, 50, 0.92); box-shadow: inset 4px 0 0 var(--teal); }
.free-pick[hidden] { display: none; }
.free-diffs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.free-diffs button { background: rgba(46, 230, 192, 0.1); }
.free-diffs button small { font-size: 10px; font-weight: 400; color: var(--muted); line-height: 1.3; }
.free-diffs [data-free-diff="easy"] b { color: #7ef0c8; }
.free-diffs [data-free-diff="normal"] b { color: var(--cyan); }
.free-diffs [data-free-diff="hard"] b { color: #ff8aa0; }
.free-code { margin: 8px 0 0; }
.free-code input { min-width: 0; font-size: 13px; }
#btnFreeCard[aria-expanded="true"] { border-radius: 14px 14px 0 0; }
.chev-rec::after { content: "▾"; color: var(--teal); font-size: 14px; display: inline-block; transition: transform 0.15s; }
#btnFreeCard[aria-expanded="true"] .chev-rec::after { transform: rotate(180deg); }
.ta-card { box-shadow: inset 4px 0 0 var(--gold), 0 8px 24px rgba(0, 0, 0, 0.4); padding-bottom: 12px; }
#btnFreeCard { box-shadow: inset 4px 0 0 var(--teal), 0 8px 24px rgba(0, 0, 0, 0.4); }

/* ---------- 演出 ---------- */
/* 部品（js/fx.js の replay でかけ直す）。動きは上方向と足元からの拡大縮小だけ（はみ出してスクロールバーが出ないように） */
@keyframes fx-pop { 0% { transform: scale(.4) rotate(-4deg); opacity: 0; } 70% { transform: scale(1.08) rotate(1deg); opacity: 1; } 100% { transform: none; } }
.fx-pop { animation: fx-pop .32s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes fx-slam { 0% { transform: scale(1.9) rotate(-12deg); opacity: 0; } 55% { transform: scale(.94) rotate(-3deg); opacity: 1; }
  75% { transform: scale(1.05) rotate(-4deg); } 100% { transform: scale(1) rotate(-3deg); } }
.fx-slam { animation: fx-slam .42s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes fx-thud { 0% { transform: translateY(0); } 30% { transform: translateY(4px) scale(1.01, .98); } 100% { transform: none; } }
.fx-thud { animation: fx-thud .25s ease-out; }

/* 連続の段階・節目の帯。盤面の上のほうを左から右へ横切る（盤面の外へははみ出さない） */
.banner-clip { position: absolute; inset: 0; overflow: hidden; border-radius: 14px; pointer-events: none; }
.banner {
  --zone: 255, 215, 106;
  position: absolute; left: -4%; right: -4%; top: 16%;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 0 9px;
  line-height: 1;
  background: linear-gradient(90deg, rgba(var(--zone), 0), rgba(var(--zone), .28) 18%, rgba(8, 12, 28, .82) 50%, rgba(var(--zone), .28) 82%, rgba(var(--zone), 0));
  box-shadow: 0 0 0 1px rgba(var(--zone), .5), 0 0 30px rgba(var(--zone), .35);
  transform: translateX(-110%) skewX(-12deg);
}
.banner[hidden] { display: none; }
.banner b { font-size: clamp(22px, 7vw, 40px); font-weight: 900; letter-spacing: .08em; color: rgb(var(--zone)); text-shadow: 0 0 18px rgba(var(--zone), .9), 0 0 3px #fff; }
.banner small { font-size: 12px; font-weight: 700; letter-spacing: .14em; color: #fff; opacity: .85; }
@keyframes banner-run { 0% { transform: translateX(-110%) skewX(-12deg); } 18%, 78% { transform: translateX(0) skewX(-12deg); } 100% { transform: translateX(110%) skewX(-12deg); } }
.banner.run { animation: banner-run 1.6s cubic-bezier(.2, .8, .2, 1) both; }

/* 問題の始めの条件（光源の数・反射上限）。盤面の上端に大きく出て、上のチップへ吸い込まれる。タップは素通し */
.cond-callout {
  position: absolute; top: 10px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 10px;
  pointer-events: none; line-height: 1;
}
.cond-callout[hidden] { display: none; }
.cc-item {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 8px 16px 9px; border-radius: 999px;
  background: rgba(8, 12, 28, 0.82);
  box-shadow: inset 0 0 0 1px rgba(255, 215, 106, 0.45), 0 0 26px rgba(255, 215, 106, 0.3);
  white-space: nowrap;
}
.cc-label { font-size: 13px; font-weight: 700; color: var(--text); letter-spacing: .04em; }
.cc-item b { font-size: clamp(26px, 8.5vw, 36px); font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; text-shadow: 0 0 16px rgba(255, 215, 106, 0.75), 0 0 2px #fff; }
.cc-delta { font-style: normal; font-size: 13px; font-weight: 900; }
.cc-delta:empty { display: none; }
.cc-delta.up { color: #ff8aa0; }
.cc-delta.down { color: var(--teal); }
@keyframes cc-in { 0% { transform: translateY(-14px) scale(.7); opacity: 0; } 60% { transform: translateY(0) scale(1.06); opacity: 1; } 100% { transform: none; } }
.cond-callout.show .cc-item { animation: cc-in .3s cubic-bezier(.2, 1.5, .4, 1) both; }
.cond-callout.show .cc-item + .cc-item { animation-delay: .06s; }
/* 吸い込まれたチップは光の輪を広げて光る */
@keyframes cond-hit {
  0% { transform: scale(1.18); box-shadow: inset 0 0 0 1px rgba(255, 215, 106, 0.9), 0 0 0 0 rgba(255, 215, 106, 0.7); background: rgba(255, 215, 106, 0.32); }
  100% { transform: none; box-shadow: inset 0 0 0 1px rgba(255, 215, 106, 0.18), 0 0 0 10px rgba(255, 215, 106, 0); background: rgba(255, 215, 106, 0.1); }
}
.infobar .cond-chip.cond-hit { animation: cond-hit .6s ease-out both; }

/* ミスなしの連続のチップ（帯の左下）。段階に入ると段階の色で光る */
.mb-streak { --zone: 255, 255, 255; margin-left: 6px; padding: 0 6px; border-radius: 8px; font-size: 11px; font-weight: 900; color: rgba(var(--zone), .85); background: rgba(var(--zone), .1); }
.mb-streak.lit { color: rgb(var(--zone)); background: rgba(var(--zone), .16); box-shadow: 0 0 10px rgba(var(--zone), .55); }
.mb-streak[hidden] { display: none; }

/* ゴースト: 自己ベストとの差（帯の右下）。自己ベストがこの問題を終えた時刻を過ぎたら、タイムが赤みを帯びる */
.mb-ghost { margin-right: 8px; font-weight: 900; color: #ff8aa0; display: inline-block; }
.mb-ghost.ahead { color: var(--teal); }
.mb-ghost[hidden] { display: none; }
.modebar.ghost-over .mb-big.mono { color: #ff8aa0; text-shadow: 0 0 14px rgba(255, 122, 147, .45); transition: color .3s; }

/* 残機: 減ったハートは砕け、増えたハートは光が集まって満ちる。最後の1機は脈打つ */
.mb-big .h { position: relative; display: inline-block; }
.mb-big .h.broke { animation: heart-break .7s ease-out both; }
.mb-big .h.broke::before, .mb-big .h.broke::after { content: "♥"; position: absolute; left: 0; top: 0; color: #ff7a93; animation: heart-half .7s ease-out both; }
.mb-big .h.broke::before { clip-path: polygon(0 0, 55% 0, 40% 45%, 55% 70%, 45% 100%, 0 100%); --dx: -7px; --rot: -24deg; }
.mb-big .h.broke::after { clip-path: polygon(55% 0, 100% 0, 100% 100%, 45% 100%, 55% 70%, 40% 45%); --dx: 7px; --rot: 24deg; }
@keyframes heart-break { 0% { color: #fff; transform: scale(1.35); } 25% { color: rgba(255, 255, 255, 0.16); transform: scale(1); } 100% { color: rgba(255, 255, 255, 0.16); } }
@keyframes heart-half { 0% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translate(var(--dx), -10px) rotate(var(--rot)); } }
.mb-big .h.heal { animation: heart-heal .8s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes heart-heal { 0% { color: #fff; transform: scale(.2); text-shadow: 0 0 22px #fff; } 60% { transform: scale(1.3); color: var(--gold); } 100% { transform: none; } }
.modebar.danger .mb-big .h:not(.off) { animation: heart-beat 1s ease-in-out infinite; }
@keyframes heart-beat { 0%, 40%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } 28% { transform: scale(1.1); } }
/* 最後の1機の間は、盤面の縁が赤く脈打つ（操作の邪魔にならないよう、縁の内側だけ） */
.stage.danger::after { content: ""; position: absolute; inset: 0; border-radius: 14px; pointer-events: none; box-shadow: inset 0 0 26px rgba(255, 60, 90, .55); animation: danger 1s ease-in-out infinite; }
@keyframes danger { 0%, 100% { opacity: .35; } 15% { opacity: 1; } 40% { opacity: .5; } }

/* 結果発表 */
.result-dlg { overflow-x: hidden; } /* 判子が大きく落ちてくる間に、横のスクロールバーを出さない */
.result-dlg form { position: relative; }
.result-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.result-skip { display: block; height: 0; overflow: visible; position: relative; top: 10px; text-align: center; font-size: 12px; color: var(--muted); pointer-events: none; }
.result-skip[hidden] { display: none; }
.result-chars { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 2px 0 10px; }
.result-chars span {
  min-width: 26px; height: 26px; padding: 0 3px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #04121a; background: var(--teal);
  opacity: 0; transform: translateY(6px) scale(.5);
  transition: opacity .12s, transform .22s cubic-bezier(.2, 1.6, .4, 1);
}
.result-chars span.in { opacity: 1; transform: none; }
.result-chars span.missed { background: rgba(46, 230, 192, .42); }
.result-chars span.skip, .result-chars span.fail { background: #ff9a3c; }
.result-chars span.more { background: rgba(255, 255, 255, .14); color: var(--muted); font-size: 12px; }
.result-chars.many span { min-width: 20px; height: 20px; font-size: 12px; border-radius: 4px; }
.result-best.pending, .result-rest.pending { opacity: 0; }
.result-best, .result-rest { transition: opacity .25s; }
.result-best.stamp {
  width: fit-content; margin: 2px auto 12px; padding: 4px 12px;
  border: 3px double var(--gold); border-radius: 8px;
  color: var(--gold); font-size: 15px; font-weight: 900; letter-spacing: .06em;
  transform: rotate(-3deg);
  box-shadow: 0 0 18px rgba(255, 215, 106, .35), inset 0 0 12px rgba(255, 215, 106, .2);
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .fx-pop, .fx-slam, .fx-thud, .banner.run, .infobar .cond-chip.cond-hit, .mb-big .h.broke, .mb-big .h.broke::before, .mb-big .h.broke::after, .mb-big .h.heal { animation-duration: .01s !important; }
  .modebar.danger .mb-big .h:not(.off), .stage.danger::after { animation: none; }
  .result-chars span { transition: none; }
}

/* 設定: BGM と効果音のスライダーを1つの欄に並べる */
.dlg h3.vol-second { margin-top: 12px; }
