:root {
  color-scheme: dark;
  --night: #101d35;
  --night-soft: #192b49;
  --panel: #f7f1e5;
  --paper: #fffaf0;
  --ink: #15233c;
  --muted: #77849a;
  --line: #d9d7cd;
  --coral: #f17c68;
  --gold: #f5be68;
  --mint: #9bd3bd;
  --serif: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  --sans: "Yu Gothic UI", "Meiryo", "Noto Sans JP", sans-serif;
  font-family: var(--sans);
  background: var(--night);
  color: #fffaf0;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% -25%, #31476a 0, transparent 54%),
    linear-gradient(180deg, #101d35 0%, #14233d 58%, #0e1930 100%);
}
button, textarea, input { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, label:focus-visible, textarea:focus-visible {
  outline: 3px solid #f5be68;
  outline-offset: 3px;
}
a { color: inherit; }
[hidden] { display: none !important; }

.page-shell { width: min(1240px, calc(100% - 48px)); margin: 0 auto; }
.topbar { min-height: 83px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid #ffffff19; }
.brand { display:flex; align-items:center; gap:12px; }
.brand-mark { display:grid; place-items:center; width:39px; height:39px; border:1px solid #f5be6875; border-radius:14px 14px 14px 4px; color:var(--gold); font:29px/1 var(--serif); transform:rotate(-6deg); }
.brand small, .brand strong { display:block; }
.brand small { color:#99a9c1; font-size:8px; font-weight:800; letter-spacing:2.1px; }
.brand strong { margin-top:3px; font:700 15px/1 var(--serif); letter-spacing:1.3px; }
.brand em { color:var(--coral); font-style:normal; }
.topbar-right { display:flex; align-items:center; gap:21px; }
.edition { color:#a6b0c1; font-size:9px; font-weight:700; letter-spacing:1.55px; }
.edition i, .live-light { display:inline-block; width:7px; height:7px; margin-right:7px; border-radius:50%; background:var(--mint); box-shadow:0 0 13px #9bd3bd8a; }
.quiet-button, .save-button { border:0; cursor:pointer; }
.quiet-button { padding:9px 0; background:none; color:#dce2eb; font-size:12px; }
.quiet-button:hover { color:var(--gold); }
.save-button { padding:9px 13px; border:1px solid #8290a844; border-radius:5px; background:#ffffff08; color:#fffaf0; font-size:11px; }
.save-button:hover { border-color:#f5be68aa; }

.dashboard { padding:31px 0 23px; }
.dashboard-title { display:flex; align-items:baseline; justify-content:space-between; gap:20px; margin-bottom:17px; }
.eyebrow { display:block; color:#e5ae67; font-size:9px; font-weight:800; letter-spacing:2.25px; }
.dashboard h1 { margin:6px 0 0; color:#fff9ed; font:500 clamp(21px, 3vw, 30px)/1.2 var(--serif); letter-spacing:.04em; }
.stats-grid { display:grid; grid-template-columns:1.2fr 1fr 1fr 1.12fr; gap:10px; }
.stat-card { position:relative; min-height:77px; overflow:hidden; padding:13px 17px; border:1px solid #ffffff16; border-radius:6px; background:linear-gradient(125deg, #1b2c48de, #172540a8); }
.stat-label { display:flex; align-items:baseline; justify-content:space-between; gap:5px; color:#aab6c8; font-size:10px; letter-spacing:.08em; }
.stat-label small { color:#92a0b5; font-size:8px; font-weight:500; letter-spacing:0; white-space:nowrap; }
.stat-label small b { color:#f0d39c; font-variant-numeric:tabular-nums; }
.stat-card strong { display:flex; align-items:baseline; gap:5px; margin-top:7px; color:#fffaf0; font-size:22px; font-weight:700; line-height:1; font-variant-numeric:tabular-nums; }
.stat-card strong small { color:#acb7c8; font-size:10px; font-weight:500; }
.stat-cash strong { color:#f8ca7c; }
.stat-ornament { position:absolute; right:14px; bottom:8px; color:#f6c87719; font:36px/1 var(--serif); font-style:normal; }
.stat-level strong { color:#f4c477; }
.enemy-state { display:block; overflow:hidden; margin-top:4px; color:#a9b3c3; font-size:9px; text-overflow:ellipsis; white-space:nowrap; }

.run-card { padding:18px; border:1px solid #ffffff1a; border-radius:8px; background:linear-gradient(160deg, #1b2c49, #172540); box-shadow:0 18px 70px #06102044; }
.run-heading { display:flex; align-items:center; justify-content:space-between; gap:18px; padding:0 4px 14px; }
.run-heading h2, .section-heading h2 { margin:4px 0 0; color:#fff8eb; font:500 19px/1.25 var(--serif); letter-spacing:.035em; }
.run-flags { display:flex; align-items:center; gap:15px; }
.no-wave { display:flex; align-items:center; gap:6px; color:#bac6d8; font-size:9px; letter-spacing:.13em; }
.no-wave b { color:#f0bd70; font:19px/1 var(--serif); }
.save-status { color:#98cdb8; font-size:9px; }
.save-status[data-state="error"] { color:#ff9c88; }
.scene-frame { position:relative; overflow:hidden; border:1px solid #465b75; border-radius:5px; background:#101d35; }
#run-scene { display:block; width:100%; aspect-ratio:1200 / 520; }
.scene-meta { position:absolute; right:0; bottom:0; left:0; display:flex; justify-content:space-between; padding:9px 13px; border-top:1px solid #fff4; background:linear-gradient(90deg,#101d35bc,#101d3555); color:#fffaf0; font-size:10px; letter-spacing:.04em; pointer-events:none; }
.scene-meta>span:first-child { display:flex; align-items:center; }
.live-light { width:6px; height:6px; margin-right:8px; }
.scene-overlay { position:absolute; z-index:2; inset:0; display:flex; align-items:center; justify-content:center; flex-direction:column; padding:24px; text-align:center; background:linear-gradient(180deg,#101d35a8,#101d35bd); backdrop-filter:blur(3px); }
.overlay-overline { color:#f6bf73; font-size:9px; font-weight:800; letter-spacing:2.25px; }
.scene-overlay h2 { margin:13px 0 9px; color:#fff8eb; font:500 clamp(24px,4.5vw,38px)/1.15 var(--serif); letter-spacing:.04em; }
.scene-overlay p { margin:0 0 18px; color:#e0e5eb; font-size:12px; line-height:1.9; }
.scene-overlay small { margin-top:11px; color:#d2d9e1; font-size:9px; }
.primary-button { display:inline-flex; align-items:center; justify-content:center; gap:20px; min-height:43px; padding:0 19px; border:0; border-radius:4px; background:var(--coral); color:#fffdf7; cursor:pointer; font-size:12px; font-weight:700; box-shadow:0 5px 18px #f17c6830; transition:transform .16s, filter .16s; }
.primary-button:hover { filter:brightness(1.08); transform:translateY(-1px); }
.primary-button span { font-size:16px; }
.pause-overlay { background:#121f39b8; }
.scene-bottom { display:flex; min-height:59px; align-items:center; justify-content:space-between; gap:15px; padding:8px 3px 0; }
.scene-bottom p { margin:0; color:#d2d8e1; font:13px var(--serif); }
.run-options { display:flex; align-items:center; gap:11px; }
.pace-switch { display:flex; padding:3px; border:1px solid #ffffff22; border-radius:5px; background:#0d1a31; }
.pace-switch button { display:flex; min-width:68px; justify-content:center; align-items:center; gap:5px; padding:6px 9px; border:0; border-radius:3px; background:transparent; color:#abb6c7; cursor:pointer; }
.pace-switch button[aria-pressed="true"] { background:#f5be6830; color:#ffdd9d; box-shadow:inset 0 0 0 1px #f5be6860; }
.pace-switch span { font-size:11px; }
.pace-switch small { color:#a9b5c6; font-size:8px; }
.pause-button { display:flex; align-items:center; gap:6px; padding:9px 10px; border:1px solid #ffffff25; border-radius:4px; background:#ffffff08; color:#e5e9ed; cursor:pointer; font-size:11px; }
.pause-button:disabled { opacity:.4; cursor:not-allowed; }

.control-shop-grid { display:grid; grid-template-columns:minmax(270px,.87fr) minmax(0,1.7fr); gap:15px; margin-top:15px; }
.enemy-panel, .upgrade-panel { min-width:0; padding:17px 18px 15px; border:1px solid #ffffff18; border-radius:7px; background:#f6f0e5; color:var(--ink); }
.section-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; }
.section-heading .eyebrow { color:#a66a43; font-size:8px; letter-spacing:1.8px; }
.section-heading h2 { color:var(--ink); font-size:18px; }
.section-index { color:#c5c2b8; font:18px/1 var(--serif); }
.panel-intro { margin:11px 0 12px; color:#758096; font-size:10px; }
.level-picker { display:flex; align-items:center; justify-content:center; gap:15px; padding:3px 0 12px; }
.level-step { display:grid; width:40px; height:40px; place-items:center; border:1px solid #c5c5bd; border-radius:50%; background:#fffaf0; color:#263954; cursor:pointer; font-size:25px; line-height:1; transition:background .15s, color .15s, border-color .15s; }
.level-step:hover { border-color:#ee9279; background:#f17c68; color:white; }
.level-readout { min-width:115px; text-align:center; }
.level-readout small { display:flex; align-items:center; justify-content:space-between; gap:4px; color:#94999e; font-size:8px; font-weight:800; letter-spacing:1.7px; white-space:nowrap; }
.level-step-select { display:inline-flex; align-items:center; gap:3px; color:#7b8490; font-size:8px; font-weight:700; letter-spacing:0; }
.level-step-select select { max-width:46px; padding:2px 3px; border:1px solid #d5d2c8; border-radius:3px; background:#fffdf7; color:#34455e; font:700 9px/1.1 var(--sans); cursor:pointer; }
.level-readout strong { display:block; margin-top:2px; color:#192c48; font:500 28px/1.1 var(--serif); font-variant-numeric:tabular-nums; }
.reward-preview { display:flex; align-items:center; justify-content:space-between; padding:10px 11px; border:1px solid #e9d5a9; border-radius:4px; background:#fff4da; }
.reward-preview span { display:flex; align-items:center; gap:5px; color:#8b7a59; font-size:10px; }
.reward-preview span small { color:#b0773b; font-size:8px; font-weight:700; white-space:nowrap; }
.reward-preview strong { color:#8b5b20; font-size:14px; font-variant-numeric:tabular-nums; }
.combat-preview { margin-top:6px; padding:6px; border:1px solid #e3dfd4; border-radius:4px; background:#fffaf1; font-variant-numeric:tabular-nums; }
.combat-preview-title { display:block; margin-bottom:4px; color:#7d8790; font-size:9px; }
.pace-preview-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px; }
.pace-preview { display:grid; min-width:0; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:2px 4px; padding:5px; border:1px solid #e3dfd4; border-left:2px solid #77aa91; border-radius:3px; background:#fffdf8; }
.pace-preview[data-active="true"] { box-shadow:inset 0 0 0 1px #e8bd7080; }
.pace-preview-label { color:#596779; font-size:9px; font-weight:700; }
.pace-preview-label small { display:block; margin-top:1px; color:#89919a; font-size:8px; font-weight:500; }
.pace-preview>strong { color:#426b5a; font-size:10px; text-align:right; white-space:nowrap; }
.pace-recommendation { display:flex; grid-column:1/-1; align-items:center; justify-content:space-between; gap:4px; margin-top:1px; color:#748174; font-size:9px; white-space:nowrap; }
.pace-recommendation b { color:#3b6653; font-variant-numeric:tabular-nums; }
.pace-recommendation button { min-width:43px; padding:2px 6px; border:1px solid #cad8ce; border-radius:3px; background:#edf4ed; color:#365845; cursor:pointer; font:700 9px/1.35 var(--sans); }
.pace-recommendation button:hover:not(:disabled) { border-color:#82a98c; background:#e1efe1; }
.pace-recommendation button:disabled { border-color:#e5e2db; background:#f3f1ec; color:#92968f; cursor:default; }
.pace-preview>small { grid-column:1/-1; color:#878d91; font-size:9px; text-align:right; white-space:nowrap; }
.pace-preview>small b { color:#526d60; }
.pace-preview[data-status="tight"] { border-left-color:#d39a52; background:#fff8e9; }
.pace-preview[data-status="tight"]>strong { color:#9a692d; }
.pace-preview[data-status="escape"] { border-left-color:#dc7868; background:#fff5f1; }
.pace-preview[data-status="escape"]>strong { color:#ad5148; }
.combat-preview-note { display:block; margin-top:4px; color:#878d91; font-size:8px; text-align:right; }
.clear-button { display:flex; width:100%; align-items:center; gap:10px; margin-top:11px; padding:9px 10px; border:1px solid #d8d6cd; border-radius:4px; background:#fffdf7; color:#263954; cursor:pointer; text-align:left; transition:border-color .16s, transform .16s; }
.clear-button:hover { border-color:#e78877; transform:translateY(-1px); }
.clear-icon { display:grid; width:29px; height:29px; place-items:center; border-radius:50%; background:#fce4df; color:#d76454; font-size:22px; }
.clear-button>span:nth-child(2) { flex:1; }
.clear-button strong, .clear-button small { display:block; }
.clear-button strong { font-size:11px; }
.clear-button small { margin-top:2px; color:#848b96; font-size:8px; }
.clear-button kbd { padding:3px 5px; border:1px solid #e0ded5; border-radius:3px; background:#f4f1e9; color:#747c8b; font-size:9px; }
.micro-note { margin:7px 0 0; color:#999b9c; font-size:8px; }

.upgrade-list { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:9px; margin-top:15px; }
.upgrade-card { display:grid; min-height:129px; grid-template-columns:36px 1fr; grid-template-rows:36px auto auto; align-items:center; column-gap:7px; padding:11px 10px 9px; border:1px solid #dbd8ce; border-radius:5px; background:#fffaf0; color:#1b2d49; cursor:pointer; text-align:left; transition:transform .16s, border-color .16s, box-shadow .16s; }
.upgrade-card:hover:not(:disabled) { transform:translateY(-2px); border-color:#e89b78; box-shadow:0 7px 17px #30436314; }
.upgrade-card:disabled { cursor:not-allowed; opacity:.56; }
.upgrade-icon { display:grid; width:31px; height:31px; place-items:center; border-radius:10px 10px 10px 3px; background:#fae5df; color:#db705e; font-size:18px; font-weight:800; }
.icon-rate { background:#e7edf2; color:#507797; }
.icon-bounty { background:#faedd2; color:#b58135; font:17px var(--serif); }
.upgrade-copy { min-width:0; }
.upgrade-copy strong, .upgrade-copy small { display:block; }
.upgrade-copy strong { color:#1c2d47; font-size:11px; }
.upgrade-copy small { margin-top:2px; color:#92989d; font-size:8px; }
.upgrade-level { grid-column:1/-1; justify-self:start; margin-top:9px; color:#7f8793; font-size:9px; }
.upgrade-level b { color:#293a55; font-size:11px; }
.upgrade-price { display:flex; grid-column:1/-1; align-items:center; justify-content:space-between; margin-top:4px; padding-top:7px; border-top:1px solid #e8e4da; color:#a46c39; font-size:10px; font-variant-numeric:tabular-nums; }
.upgrade-price i { color:#db8267; font-style:normal; font-size:14px; }
.shop-footnote { display:flex; align-items:center; gap:7px; margin:10px 0 0; padding-top:9px; border-top:1px solid #dfddd5; color:#858c92; font-size:8px; }
.shop-footnote strong { margin-right:11px; color:#283951; font-size:9px; font-variant-numeric:tabular-nums; }
.page-footer { display:flex; align-items:center; justify-content:space-between; gap:15px; min-height:58px; margin-top:13px; color:#9aa7ba; font-size:8px; letter-spacing:1.1px; }
.page-footer b { color:#c5cfda; font-weight:600; }

.modal { position:relative; width:min(590px,calc(100% - 26px)); max-height:min(88vh,820px); overflow:auto; padding:31px 34px 27px; border:1px solid #61718a; border-radius:8px; background:#f7f1e5; color:var(--ink); box-shadow:0 25px 100px #030914aa; }
.modal::backdrop { background:#071225c9; backdrop-filter:blur(4px); }
.modal-close { position:absolute; top:11px; right:12px; width:31px; height:31px; border:1px solid #d9d6cb; border-radius:50%; background:#fffbf3; color:#566377; cursor:pointer; font-size:19px; }
.modal .eyebrow { color:#ad7244; }
.modal h2 { margin:8px 0 14px; color:#172944; font:500 25px/1.3 var(--serif); }
.confirm-modal { width:min(480px,calc(100% - 26px)); }
.confirm-message { margin:0; color:#536176; font-size:13px; line-height:1.9; white-space:pre-line; }
.confirm-actions { display:flex; justify-content:flex-end; gap:9px; margin-top:23px; }
.confirm-actions .secondary-button, .confirm-actions .primary-button { min-height:42px; padding:0 16px; font-size:12px; }
.help-list { display:grid; gap:0; margin:8px 0 18px; padding:0; list-style:none; }
.help-list li { display:grid; grid-template-columns:34px 1fr; gap:9px; padding:12px 0; border-bottom:1px solid #e3dfd4; }
.help-list li>b { color:#e18469; font:17px/1 var(--serif); }
.help-list strong { font-size:12px; }
.help-list p { margin:4px 0 0; color:#6f7a89; font-size:10px; line-height:1.8; }
.modal-note, .save-modal>p { color:#808995; font-size:10px; line-height:1.8; }
.modal-done { display:flex; margin:19px 0 0 auto; }
.save-modal { width:min(670px,calc(100% - 26px)); }
.save-actions { display:flex; flex-wrap:wrap; gap:8px; margin:17px 0; }
.secondary-button, .file-button { display:inline-flex; align-items:center; justify-content:center; min-height:35px; padding:0 11px; border:1px solid #c9c6bd; border-radius:4px; background:#fffbf4; color:#293b56; cursor:pointer; font-size:10px; text-decoration:none; }
.secondary-button:hover, .file-button:hover { border-color:#e78877; }
.save-label { display:block; margin:13px 0 6px; color:#42536b; font-size:10px; font-weight:700; }
#save-code { width:100%; min-height:125px; resize:vertical; padding:11px; border:1px solid #d1cec4; border-radius:4px; background:#fffdf8; color:#283850; font:10px/1.6 ui-monospace,Consolas,monospace; }
.save-actions-bottom { align-items:center; justify-content:space-between; }
.text-button { border:0; background:transparent; color:#9a6840; cursor:pointer; font-size:10px; text-decoration:underline; text-underline-offset:3px; }
.save-feedback { min-height:17px; margin:3px 0; color:#648976; font-size:10px; }
.reset-button { padding:0; border:0; background:transparent; color:#9a7772; cursor:pointer; font-size:9px; text-decoration:underline; text-underline-offset:3px; }
.toast { position:fixed; z-index:10; right:20px; bottom:20px; max-width:min(360px,calc(100vw - 40px)); padding:11px 15px; border:1px solid #ffffff27; border-radius:5px; background:#10203aee; color:#fff8eb; font-size:11px; opacity:0; pointer-events:none; transform:translateY(8px); transition:opacity .2s, transform .2s; }
.toast[data-visible="true"] { opacity:1; transform:translateY(0); }

@media (max-width:850px) {
  .page-shell { width:min(100% - 28px,740px); }
  .edition { display:none; }
  .dashboard { padding-top:25px; }
  .run-card { padding:12px; }
  .control-shop-grid { grid-template-columns:1fr; }
  .enemy-panel { display:grid; grid-template-columns:1fr 1fr; column-gap:16px; }
  .enemy-panel .section-heading, .enemy-panel .panel-intro, .enemy-panel .micro-note { grid-column:1/-1; }
  .enemy-panel .section-heading { grid-row:1; }
  .enemy-panel .panel-intro { grid-row:2; }
  .enemy-panel .level-picker { grid-column:1; grid-row:3; }
  .enemy-panel .reward-preview { grid-column:2; grid-row:3; align-self:center; }
  .enemy-panel .combat-preview { grid-column:1/-1; grid-row:4; }
  .enemy-panel .clear-button { grid-column:1/-1; grid-row:5; }
  .enemy-panel .micro-note { grid-row:6; }
}
@media (max-width:560px) {
  .page-shell { width:calc(100% - 20px); }
  .topbar { min-height:67px; }
  .brand { gap:8px; }
  .brand-mark { width:32px; height:32px; font-size:24px; }
  .brand small { font-size:7px; letter-spacing:1.5px; }
  .brand strong { font-size:12px; }
  .topbar-right { gap:10px; }
  .quiet-button { font-size:10px; }
  .save-button { padding:8px 9px; font-size:9px; }
  .dashboard { padding:20px 0 14px; }
  .dashboard-title { display:block; margin-bottom:12px; }
  .dashboard h1 { font-size:23px; }
  .stats-grid { grid-template-columns:1fr 1fr; gap:7px; }
  .stat-card { min-height:67px; padding:10px 12px; }
  .stat-card strong { margin-top:5px; font-size:19px; }
  .run-card { padding:9px; border-radius:6px; }
  .run-heading { align-items:flex-end; padding:0 2px 10px; }
  .run-heading h2 { font-size:16px; }
  .run-heading .eyebrow { font-size:7px; letter-spacing:1.3px; }
  .run-flags { align-items:flex-end; flex-direction:column; gap:4px; }
  .no-wave { font-size:7px; }
  .no-wave b { font-size:15px; }
  .save-status { font-size:8px; }
  #run-scene { min-height:0; }
  .scene-meta { padding:7px 9px; font-size:8px; }
  .scene-overlay { padding:12px; }
  .overlay-overline { font-size:7px; letter-spacing:1.4px; }
  .scene-overlay h2 { margin:8px 0 6px; font-size:clamp(19px,6vw,27px); }
  .scene-overlay p { margin-bottom:10px; font-size:9px; line-height:1.6; }
  .primary-button { min-height:36px; padding:0 13px; font-size:10px; }
  .scene-overlay small { margin-top:7px; font-size:7px; }
  .scene-bottom { min-height:52px; align-items:flex-start; padding-top:9px; }
  .scene-bottom p { max-width:105px; padding-top:5px; font-size:10px; }
  .run-options { gap:6px; }
  .pace-switch button { min-width:48px; flex-direction:column; gap:1px; padding:5px 6px; }
  .pace-switch span { font-size:9px; }
  .pace-switch small { font-size:7px; }
  .pause-button { gap:3px; padding:8px 7px; font-size:9px; }
  .control-shop-grid { gap:9px; margin-top:9px; }
  .enemy-panel, .upgrade-panel { padding:13px 12px; }
  .section-heading h2 { font-size:16px; }
  .panel-intro { margin:8px 0; font-size:9px; }
  .enemy-panel { column-gap:8px; }
  .enemy-panel .level-picker { gap:8px; }
  .enemy-panel .level-picker { grid-column:1/-1; }
  .enemy-panel .reward-preview { grid-column:1/-1; grid-row:4; }
  .enemy-panel .combat-preview { grid-row:5; }
  .enemy-panel .clear-button { grid-row:6; }
  .enemy-panel .micro-note { grid-row:7; }
  .level-step { width:34px; height:34px; font-size:21px; }
  .level-readout { min-width:77px; }
  .level-readout strong { font-size:23px; }
  .reward-preview { padding:8px; }
  .reward-preview span { font-size:9px; }
  .reward-preview span small { font-size:8px; }
  .reward-preview strong { font-size:12px; }
  .clear-button { gap:7px; margin-top:8px; padding:7px; }
  .clear-button small { font-size:8px; }
  .micro-note { font-size:8px; }
  .upgrade-list { gap:5px; margin-top:11px; }
  .upgrade-card { min-height:118px; grid-template-columns:25px 1fr; column-gap:4px; padding:8px 5px 7px; }
  .upgrade-icon { width:24px; height:24px; border-radius:7px 7px 7px 2px; font-size:14px; }
  .upgrade-copy strong { font-size:10px; }
  .upgrade-copy small { font-size:8px; }
  .upgrade-level { margin-top:6px; font-size:9px; }
  .upgrade-price { font-size:9px; }
  .shop-footnote { flex-wrap:wrap; gap:4px; font-size:8px; }
  .shop-footnote strong { margin-right:3px; font-size:8px; }
  .page-footer { min-height:43px; gap:8px; font-size:6px; letter-spacing:.3px; }
  .modal { padding:27px 19px 20px; }
  .modal h2 { font-size:21px; }
  .help-list p { font-size:9px; }
  .save-actions { gap:6px; }
  .secondary-button, .file-button { min-height:32px; padding:0 8px; font-size:8px; }
  .toast { right:10px; bottom:10px; font-size:10px; }
}

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

@media (min-width:1000px) and (min-height:680px) {
  .page-shell {
    display:flex;
    width:min(1360px, calc(100% - 40px));
    height:100vh;
    height:100dvh;
    min-height:0;
    flex-direction:column;
    overflow:hidden;
  }
  .topbar { min-height:52px; flex:0 0 52px; }
  main {
    display:grid;
    min-height:0;
    flex:1 1 auto;
    grid-template-columns:minmax(0, 1.8fr) minmax(300px, 1fr);
    grid-template-rows:auto minmax(0, 1fr) auto;
    grid-template-areas:"dashboard dashboard" "game controls" "footer footer";
    column-gap:12px;
    row-gap:8px;
  }
  .dashboard {
    display:grid;
    grid-area:dashboard;
    grid-template-columns:minmax(195px, .72fr) minmax(0, 2.8fr);
    align-items:center;
    gap:13px;
    padding:4px 0 0;
  }
  .dashboard-title { display:block; margin:0; }
  .dashboard-title .eyebrow { font-size:8px; letter-spacing:1.8px; }
  .dashboard h1 { margin-top:4px; font-size:19px; }
  .stats-grid { grid-template-columns:repeat(4, minmax(0, 1fr)); gap:6px; }
  .stat-card { min-height:51px; padding:7px 10px; }
  .stat-label { font-size:9px; }
  .stat-card strong { gap:4px; margin-top:4px; font-size:18px; }
  .stat-ornament { right:9px; bottom:5px; font-size:27px; }

  .run-card {
    grid-area:game;
    align-self:start;
    min-width:0;
    padding:10px;
  }
  .run-heading { padding:0 2px 8px; }
  .run-heading h2 { font-size:16px; }
  .run-heading .eyebrow { font-size:8px; letter-spacing:1.7px; }
  .scene-bottom { min-height:42px; }
  .scene-bottom p { font-size:11px; }
  .run-options { gap:7px; }
  .pace-switch button { min-width:58px; padding:5px 7px; }
  .pause-button { padding:7px 8px; font-size:10px; }

  .control-shop-grid {
    grid-area:controls;
    display:grid;
    min-width:0;
    min-height:0;
    grid-template-columns:minmax(0, 1fr);
    grid-template-rows:auto minmax(0, 1fr);
    align-content:start;
    gap:8px;
    margin:0;
  }
  .enemy-panel, .upgrade-panel { min-width:0; padding:11px 12px; }
  .section-heading .eyebrow { font-size:7px; letter-spacing:1.5px; }
  .section-heading h2 { font-size:16px; }
  .panel-intro { margin:7px 0 8px; font-size:9px; }
  .level-picker { gap:10px; padding:0 0 8px; }
  .level-step { width:34px; height:34px; font-size:22px; }
  .level-readout { min-width:90px; }
  .level-readout strong { font-size:24px; }
  .reward-preview { padding:8px 9px; }
  .clear-button { gap:8px; margin-top:8px; padding:7px 8px; }
  .clear-icon { width:26px; height:26px; font-size:19px; }
  .micro-note { margin-top:5px; font-size:7px; }

  .upgrade-panel { display:flex; flex-direction:column; }
  .upgrade-list { grid-template-columns:minmax(0, 1fr); gap:5px; margin-top:8px; }
  .upgrade-card {
    min-height:43px;
    height:43px;
    grid-template-columns:28px minmax(0, 1fr) 42px 72px;
    grid-template-rows:1fr;
    column-gap:7px;
    padding:4px 7px;
  }
  .upgrade-icon { grid-column:1; grid-row:1; width:26px; height:26px; font-size:15px; }
  .upgrade-copy { grid-column:2; grid-row:1; }
  .upgrade-copy strong { font-size:10px; }
  .upgrade-copy small { font-size:7px; }
  .upgrade-level { grid-column:3; grid-row:1; justify-self:end; margin-top:0; font-size:8px; }
  .upgrade-level b { font-size:10px; }
  .upgrade-price { grid-column:4; grid-row:1; justify-content:flex-end; gap:4px; margin-top:0; padding-top:0; border-top:0; font-size:8px; white-space:nowrap; }
  .upgrade-price i { font-size:11px; }
  .shop-footnote { flex-wrap:nowrap; gap:4px; margin-top:auto; padding-top:7px; font-size:7px; }
  .shop-footnote strong { margin-right:5px; font-size:8px; white-space:nowrap; }

  .page-footer { grid-area:footer; min-height:28px; margin:0; font-size:7px; }
}

.journey-panel { min-width:0; padding:13px 15px; border:1px solid #ffffff18; border-radius:7px; background:#f6f0e5; color:var(--ink); }
.journey-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.journey-heading .eyebrow { color:#a66a43; font-size:8px; letter-spacing:1.7px; }
.journey-heading h2 { margin:3px 0 0; color:var(--ink); font:500 17px/1.2 var(--serif); }
.journey-bonus { display:flex; align-items:baseline; gap:5px; color:#9a713c; white-space:nowrap; }
.journey-bonus small { color:#898b87; font-size:8px; }
.journey-bonus b { font-size:13px; }
.journey-progress { height:5px; overflow:hidden; margin-top:9px; border-radius:99px; background:#deddd4; }
.journey-progress span { display:block; width:0; height:100%; border-radius:inherit; background:linear-gradient(90deg,#e8a071,#e5be74); transition:width .24s ease; }
.journey-target { display:flex; justify-content:space-between; gap:7px; margin-top:5px; color:#747f88; font-size:8px; }
.journey-target b { color:#556274; font-weight:700; white-space:nowrap; }
.signs-open { display:flex; width:100%; align-items:center; justify-content:space-between; gap:8px; margin-top:8px; padding:7px 0 0; border:0; border-top:1px solid #dedbd1; background:none; color:#31435c; cursor:pointer; text-align:left; }
.signs-open>span, .signs-open>span strong, .signs-open>span small { display:block; }
.signs-open>span strong { font-size:9px; }
.signs-open>span small { margin-top:2px; color:#888e93; font-size:8px; }
.signs-open>b { display:flex; align-items:center; gap:6px; color:#9a6a3c; font-size:8px; white-space:nowrap; }
.signs-open i { font:18px/1 var(--serif); font-style:normal; }
.signs-open:hover>span strong { color:#d4745f; }
.signs-modal { width:min(850px,calc(100% - 26px)); }
.sign-summary { margin:0 0 13px; color:#7c8490; font-size:10px; }
.sign-list { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.sign-card { display:grid; min-width:0; grid-template-columns:25px minmax(0,1fr) auto; grid-template-rows:auto 4px auto; align-items:center; column-gap:7px; padding:9px; border:1px solid #dedbd2; border-radius:5px; background:#fffaf1; color:#748091; }
.sign-card.is-unlocked { border-color:#e5cfaa; background:#fff2d8; color:#45596d; }
.sign-seal { grid-column:1; grid-row:1 / span 2; display:grid; width:23px; height:23px; place-items:center; border-radius:50%; background:#eceae3; color:#9da2a1; font-size:13px; }
.sign-card.is-unlocked .sign-seal { background:#e8c77e; color:#fffaf0; }
.sign-copy { grid-column:2; grid-row:1; min-width:0; }
.sign-copy strong, .sign-copy small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sign-copy strong { color:#35465e; font-size:9px; }
.sign-copy small { margin-top:2px; color:#90959a; font-size:7px; }
.sign-reward { grid-column:3; grid-row:1; color:#a5753c; font-size:9px; }
.sign-track { grid-column:2 / -1; grid-row:2; display:block; overflow:hidden; height:4px; border-radius:99px; background:#e4e2db; }
.sign-track i { display:block; height:100%; border-radius:inherit; background:#df9a68; }
.sign-progress-label { grid-column:2 / -1; grid-row:3; justify-self:end; margin-top:3px; color:#8b9195; font-size:7px; font-variant-numeric:tabular-nums; }

@media (min-width:760px) and (min-height:500px) {
  .page-shell { display:flex; width:min(1680px,calc(100% - 16px)); height:100vh; height:100dvh; min-height:0; flex-direction:column; overflow:hidden; }
  .topbar { min-height:43px; flex:0 0 43px; }
  main { position:relative; display:grid; min-height:0; flex:1 1 auto; grid-template-columns:minmax(0,2.25fr) minmax(270px,.85fr); grid-template-rows:auto minmax(0,1fr); grid-template-areas:"dashboard dashboard" "game controls"; gap:8px 12px; }
  .dashboard { display:grid; grid-area:dashboard; grid-template-columns:minmax(190px,.72fr) minmax(0,2.8fr); align-items:center; gap:12px; padding:2px 0 0; }
  .dashboard-title { margin:0; }
  .dashboard-title .eyebrow { font-size:7px; letter-spacing:1.55px; }
  .dashboard h1 { margin-top:3px; font-size:17px; }
  .stats-grid { grid-template-columns:repeat(4,minmax(0,1fr)); gap:5px; }
  .stat-card { min-height:43px; padding:5px 8px; border-radius:4px; }
  .stat-label { font-size:9px; }
  .stat-card strong { gap:3px; margin-top:3px; font-size:16px; }
  .stat-card strong small { font-size:8px; }
  .stat-ornament { right:7px; bottom:4px; font-size:22px; }
  .enemy-state { font-size:7px; }

  .run-card { display:flex; min-width:0; min-height:0; grid-area:game; flex-direction:column; align-self:stretch; padding:9px; border-radius:6px; }
  .run-heading { flex:0 0 auto; padding:0 2px 6px; }
  .run-heading h2 { margin-top:2px; font-size:15px; }
  .run-heading .eyebrow { font-size:7px; letter-spacing:1.45px; }
  .run-flags { gap:9px; }
  .no-wave { gap:4px; font-size:8px; }
  .no-wave b { font-size:16px; }
  .save-status { font-size:9px; }
  .scene-frame { width:100%; margin:auto 0; }
  .scene-meta { padding:6px 9px; font-size:8px; }
  .scene-bottom { min-height:39px; flex:0 0 39px; padding:5px 2px 0; }
  .scene-bottom p { font-size:10px; }
  .run-options { gap:6px; }
  .pace-switch button { min-width:53px; padding:4px 6px; }
  .pace-switch span { font-size:9px; }
  .pace-switch small { font-size:7px; }
  .pause-button { gap:4px; padding:6px 7px; font-size:9px; }

  .control-shop-grid { display:grid; min-width:0; min-height:0; grid-area:controls; grid-template-columns:minmax(0,1fr); grid-template-rows:auto auto auto; align-content:start; gap:7px; margin:0; overflow-y:auto; scrollbar-width:thin; scrollbar-color:#8290a866 transparent; }
  .enemy-panel, .upgrade-panel, .journey-panel { min-width:0; padding:8px 10px; border-radius:5px; }
  .enemy-panel { display:block; }
  .section-heading { align-items:center; }
  .section-heading .eyebrow { font-size:8px; letter-spacing:1.25px; }
  .section-heading h2 { margin-top:2px; font-size:15px; }
  .section-index { font-size:16px; }
  .panel-intro, .micro-note { display:none; }
  .level-picker { gap:9px; padding:6px 0; }
  .level-step { width:34px; height:34px; font-size:22px; }
  .level-readout { min-width:88px; }
  .level-readout small { font-size:8px; letter-spacing:1.25px; }
  .level-step-select { font-size:9px; }
  .level-step-select select { max-width:46px; font-size:9px; }
  .level-readout strong { font-size:24px; }
  .reward-preview { padding:6px 8px; }
  .reward-preview span { font-size:9px; }
  .reward-preview span small { font-size:8px; }
  .reward-preview strong { font-size:12px; }
  .combat-preview { margin-top:6px; padding:6px; }
  .combat-preview-title, .combat-preview-note { font-size:9px; }
  .pace-preview-list { gap:4px; }
  .pace-preview { gap:2px 4px; padding:4px; }
  .pace-preview-label, .pace-preview>small { font-size:9px; }
  .pace-preview-label small { font-size:8px; }
  .pace-preview>strong { font-size:10px; }
  .clear-button { gap:8px; margin-top:7px; padding:6px 7px; }
  .clear-icon { width:25px; height:25px; font-size:18px; }
  .clear-button strong { font-size:12px; }
  .clear-button small { font-size:9px; }
  .clear-button kbd { padding:2px 4px; font-size:9px; }

  .upgrade-panel { display:flex; flex-direction:column; }
  .upgrade-list { grid-template-columns:minmax(0,1fr); gap:5px; margin-top:7px; }
  .upgrade-card { min-height:44px; height:44px; grid-template-columns:24px minmax(0,1fr) 40px 68px; grid-template-rows:1fr; column-gap:5px; padding:4px 6px; border-radius:4px; }
  .upgrade-icon { grid-column:1; grid-row:1; width:24px; height:24px; border-radius:6px 6px 6px 2px; font-size:14px; }
  .upgrade-copy { grid-column:2; grid-row:1; }
  .upgrade-copy strong { font-size:11px; }
  .upgrade-copy small { margin-top:1px; font-size:9px; }
  .upgrade-level { grid-column:3; grid-row:1; justify-self:end; margin:0; font-size:9px; }
  .upgrade-level b { font-size:10px; }
  .upgrade-price { grid-column:4; grid-row:1; justify-content:flex-end; gap:3px; margin:0; padding:0; border:0; font-size:9px; white-space:nowrap; }
  .upgrade-price i { font-size:12px; }
  .shop-footnote { flex-wrap:nowrap; gap:4px; margin:7px 0 0; padding:6px 0 0; font-size:9px; }
  .shop-footnote strong { margin-right:4px; font-size:9px; white-space:nowrap; }

  .journey-heading .eyebrow { font-size:8px; letter-spacing:1.25px; }
  .journey-heading h2 { margin-top:2px; font-size:16px; }
  .journey-bonus small { font-size:8px; }
  .journey-bonus b { font-size:13px; }
  .journey-progress { height:5px; margin-top:7px; }
  .journey-target { margin-top:5px; font-size:9px; }
  .signs-open { margin-top:6px; padding-top:6px; }
  .signs-open>span strong { font-size:9px; }
  .signs-open>span small, .signs-open>b { font-size:9px; }
  .signs-modal { width:min(850px,calc(100% - 26px)); }
  .sign-list { gap:6px; }
  .sign-card { padding:7px; }
}

@media (min-width:760px) and (min-height:500px) and (max-height:570px) {
  .topbar { min-height:36px; flex-basis:36px; }
  .brand-mark { width:30px; height:30px; font-size:22px; }
  .dashboard { grid-template-columns:minmax(170px,.62fr) minmax(0,2.8fr); }
  .dashboard h1 { font-size:15px; }
  .stat-card { min-height:38px; padding:4px 7px; }
  .stat-card strong { font-size:14px; }
  .run-heading { padding-bottom:4px; }
  .scene-bottom { min-height:35px; flex-basis:35px; }
  .enemy-panel, .upgrade-panel, .journey-panel { padding:7px 8px; }
  .control-shop-grid { gap:5px; }
  .level-picker { padding:4px 0; }
  .level-step { width:30px; height:30px; }
  .upgrade-card { height:42px; min-height:42px; }
  .journey-target { font-size:9px; }
  .signs-open { margin-top:3px; padding-top:3px; }
}

@media (max-width:759px) {
  .sign-list { grid-template-columns:repeat(2,minmax(0,1fr)); }
}

@media (max-width:480px) {
  .sign-list { grid-template-columns:1fr; }
  .journey-target { font-size:8px; }
  .journey-heading h2 { font-size:15px; }
}

/* Compact controls live over the running scene so the playfield keeps its width. */
.run-card { position:relative; }
.game-menu-dock { display:flex; justify-content:flex-end; gap:7px; margin-top:9px; }
.game-menu-button { display:flex; min-width:74px; min-height:49px; flex-direction:column; align-items:center; justify-content:center; gap:3px; padding:5px 9px; border:1px solid #ffffff35; border-radius:5px; background:#101d35e8; color:#dbe4ef; cursor:pointer; box-shadow:0 3px 12px #08132655; }
.game-menu-button:hover, .game-menu-button[aria-expanded="true"] { border-color:#f5be68a8; background:#263957f2; color:#ffdb98; }
.game-menu-button svg { width:19px; height:19px; fill:none; stroke:currentColor; stroke-linecap:round; stroke-linejoin:round; stroke-width:1.6; }
.game-menu-button span { font-size:10px; font-weight:700; line-height:1.1; }
.game-menu-drawer { position:relative; display:flex; max-height:70vh; flex-direction:column; margin-top:8px; overflow:hidden; border:1px solid #d4cfc2; border-radius:6px; background:#f7f1e5; color:var(--ink); box-shadow:0 14px 42px #03091466; }
.game-menu-heading { display:flex; min-height:46px; align-items:center; justify-content:space-between; gap:12px; padding:7px 11px 7px 15px; border-bottom:1px solid #ded9cd; background:#fffaf0; }
.game-menu-heading h2 { margin:0; color:#1a2d49; font:600 15px/1.3 var(--serif); }
.game-menu-heading button { display:grid; width:30px; height:30px; place-items:center; border:1px solid #d9d6cd; border-radius:50%; background:#fffdf8; color:#526176; cursor:pointer; font-size:21px; line-height:1; }
.game-menu-heading button:hover { border-color:#e78877; color:#c65d51; }
.game-menu-scroll { min-height:0; overflow:auto; overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:#8290a866 transparent; }
.game-menu-drawer .control-shop-grid { display:block; min-width:0; min-height:0; margin:0; overflow:visible; }
.game-menu-drawer .enemy-panel, .game-menu-drawer .upgrade-panel, .game-menu-drawer .journey-panel, .game-menu-drawer .rebirth-panel { display:block; min-width:0; margin:0; padding:15px 16px 14px; border:0; border-radius:0; background:transparent; color:var(--ink); }
.game-menu-drawer .section-heading .eyebrow, .game-menu-drawer .journey-heading .eyebrow { color:#a66a43; font-size:9px; letter-spacing:1.6px; }
.game-menu-drawer .section-heading h2, .game-menu-drawer .journey-heading h2 { margin-top:3px; color:var(--ink); font-size:19px; }
.game-menu-drawer .section-index { font-size:18px; }
.game-menu-drawer .panel-intro, .game-menu-drawer .micro-note { display:block; font-size:11px; line-height:1.6; }
.game-menu-drawer .panel-intro { margin:9px 0 10px; }
.game-menu-drawer .level-picker { gap:13px; padding:6px 0 10px; }
.game-menu-drawer .level-step { width:42px; height:42px; font-size:26px; }
.game-menu-drawer .level-readout { min-width:116px; }
.game-menu-drawer .level-readout small { font-size:9px; letter-spacing:1.3px; }
.game-menu-drawer .level-step-select { font-size:10px; }
.game-menu-drawer .level-step-select select { max-width:53px; font-size:11px; }
.game-menu-drawer .level-readout strong { font-size:29px; }
.game-menu-drawer .reward-preview { padding:9px 10px; }
.game-menu-drawer .reward-preview span { font-size:12px; }
.game-menu-drawer .reward-preview span small { font-size:10px; }
.game-menu-drawer .reward-preview strong { font-size:16px; }
.game-menu-drawer .combat-preview { margin-top:8px; padding:8px; }
.game-menu-drawer .combat-preview-title, .game-menu-drawer .combat-preview-note { font-size:10px; }
.game-menu-drawer .pace-preview { gap:3px 6px; padding:7px; }
.game-menu-drawer .pace-preview-label, .game-menu-drawer .pace-preview>small { font-size:10px; }
.game-menu-drawer .pace-preview-label small { font-size:9px; }
.game-menu-drawer .pace-preview>strong { font-size:11px; }
.game-menu-drawer .clear-button { gap:10px; margin-top:9px; padding:9px; }
.game-menu-drawer .clear-icon { width:31px; height:31px; font-size:22px; }
.game-menu-drawer .clear-button strong { font-size:13px; }
.game-menu-drawer .clear-button small, .game-menu-drawer .clear-button kbd { font-size:10px; }
.game-menu-drawer .micro-note { margin-top:7px; }
.game-menu-drawer .upgrade-list { grid-template-columns:minmax(0,1fr); gap:7px; margin-top:12px; }
.game-menu-drawer .upgrade-card { min-height:62px; height:auto; grid-template-columns:36px minmax(0,1fr) 50px 94px; grid-template-rows:1fr; column-gap:8px; padding:7px 9px; }
.game-menu-drawer .upgrade-icon { grid-column:1; grid-row:1; width:32px; height:32px; font-size:18px; }
.game-menu-drawer .upgrade-copy { grid-column:2; grid-row:1; }
.game-menu-drawer .upgrade-copy strong { font-size:13px; }
.game-menu-drawer .upgrade-copy small { font-size:10px; }
.game-menu-drawer .upgrade-level { grid-column:3; grid-row:1; justify-self:end; margin:0; font-size:10px; }
.game-menu-drawer .upgrade-level b { font-size:12px; }
.game-menu-drawer .upgrade-price { grid-column:4; grid-row:1; justify-content:flex-end; gap:4px; margin:0; padding:0; border:0; font-size:11px; white-space:nowrap; }
.game-menu-drawer .upgrade-price i { font-size:14px; }
.game-menu-drawer .shop-footnote { flex-wrap:wrap; gap:6px; margin-top:11px; padding-top:9px; font-size:10px; }
.game-menu-drawer .shop-footnote strong { margin-right:8px; font-size:11px; }
.game-menu-drawer .journey-heading h2 { font-size:21px; }
.game-menu-drawer .journey-bonus small { font-size:10px; }
.game-menu-drawer .journey-bonus b { font-size:16px; }
.game-menu-drawer .journey-progress { height:7px; margin-top:11px; }
.game-menu-drawer .journey-target { margin-top:8px; font-size:11px; }
.game-menu-drawer .signs-open { margin-top:10px; padding-top:9px; }
.game-menu-drawer .signs-open>span strong, .game-menu-drawer .signs-open>span small, .game-menu-drawer .signs-open>b { font-size:11px; }
.rebirth-readouts { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin-top:13px; }
.rebirth-readouts article { display:flex; min-width:0; flex-direction:column; gap:5px; padding:11px 12px; border:1px solid #e0dbcf; border-radius:5px; background:#fffaf0; }
.rebirth-readouts article>span { color:#788393; font-size:10px; }
.rebirth-readouts article>strong { overflow:hidden; color:#243956; font-size:22px; font-variant-numeric:tabular-nums; text-overflow:ellipsis; white-space:nowrap; }
.rebirth-readouts article:nth-child(2)>strong { color:#a66a30; }
.rebirth-permanent { display:grid; grid-template-columns:1fr auto; align-items:baseline; gap:6px 10px; margin-top:8px; padding:10px 12px; border:1px solid #e9d5a9; border-radius:5px; background:#fff4da; color:#7d6a4c; font-size:11px; }
.rebirth-permanent>span { display:flex; align-items:baseline; justify-content:space-between; gap:8px; }
.rebirth-permanent>span b, .rebirth-permanent>span strong { color:#8b5b20; font-size:14px; font-variant-numeric:tabular-nums; }
.rebirth-permanent>small { grid-column:1/-1; color:#99794c; font-size:10px; }
.rebirth-formula, .rebirth-reset-note { margin:10px 0; color:#758096; font-size:10px; line-height:1.7; }
.rebirth-button { display:flex; width:100%; min-height:46px; align-items:center; justify-content:center; margin-top:11px; padding:8px 12px; border:1px solid #d49b55; border-radius:5px; background:#f1c276; color:#3b2d1a; cursor:pointer; font-size:13px; font-weight:800; }
.rebirth-button:hover:not(:disabled) { border-color:#bb7c3a; background:#ffd78f; }
.rebirth-button:disabled { border-color:#d8d5cc; background:#e8e5dd; color:#8d9297; cursor:not-allowed; }
.rebirth-reset-note { margin-bottom:0; padding-top:9px; border-top:1px solid #e1ddd4; }
.rebirth-reset-note strong { color:#354a64; }

@media (min-width:760px) and (min-height:500px) {
  .page-shell { width:min(1680px,calc(100% - 16px)); }
  main { display:grid; min-height:0; flex:1 1 auto; grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr); grid-template-areas:"dashboard" "game"; gap:8px; overflow:hidden; }
  .dashboard { display:grid; grid-area:dashboard; grid-template-columns:minmax(0,1fr); align-items:stretch; gap:6px; padding:3px 0 0; }
  .dashboard-title { display:flex; align-items:baseline; justify-content:flex-start; gap:12px; margin:0; }
  .dashboard-title .eyebrow { font-size:8px; letter-spacing:1.7px; }
  .dashboard h1 { margin:0; font-size:19px; }
  .stats-grid { grid-template-columns:repeat(4,minmax(0,1fr)); gap:7px; }
  .stat-card { min-height:49px; padding:6px 10px; }
  .stat-label { font-size:10px; }
  .stat-card strong { margin-top:4px; font-size:18px; }
  .stat-card strong small { font-size:9px; }
  .stat-ornament { right:9px; bottom:5px; font-size:26px; }
  .enemy-state { font-size:9px; }
  .run-card { display:flex; width:100%; min-width:0; min-height:0; grid-area:game; align-self:stretch; flex-direction:column; overflow:visible; padding:10px; }
  .run-heading { flex:0 0 auto; padding:0 2px 7px; }
  .run-heading h2 { font-size:16px; }
  .run-heading .eyebrow { font-size:8px; letter-spacing:1.6px; }
  .run-flags { gap:12px; }
  .no-wave { font-size:9px; }
  .save-status { font-size:9px; }
  .scene-frame { display:grid; width:min(100%,calc(230.769dvh - 581.538px)); min-height:0; flex:0 1 auto; place-items:center; margin:auto; background:#101d35; }
  /* Keep the 1200:520 stage inside the height left by the HUD and controls. */
  #run-scene { width:100%; height:auto; max-width:100%; max-height:none; aspect-ratio:1200 / 520; }
  .scene-meta { padding:7px 10px; font-size:9px; }
  .scene-bottom { min-height:43px; flex:0 0 auto; padding:6px 2px 0; }
  .scene-bottom p { font-size:11px; }
  .run-options { gap:8px; }
  .pace-switch button { min-width:59px; padding:5px 7px; }
  .pace-switch span { font-size:10px; }
  .pace-switch small { font-size:8px; }
  .pause-button { padding:7px 8px; font-size:10px; }
  .game-menu-dock { position:absolute; z-index:4; top:60px; right:13px; display:flex; width:50px; flex-direction:column; gap:7px; margin:0; }
  .game-menu-button { width:50px; min-width:0; min-height:53px; padding:5px 3px; }
  .game-menu-button svg { width:20px; height:20px; }
  .game-menu-button span { font-size:10px; }
  .game-menu-drawer { position:absolute; z-index:5; top:12px; right:74px; bottom:auto; width:min(440px,46vw,calc(100% - 88px)); height:fit-content; max-height:min(80dvh,calc(100% - 64px)); margin:0; }
  .game-menu-heading { min-height:49px; flex:0 0 49px; }
  .game-menu-heading h2 { font-size:16px; }
  .game-menu-scroll { flex:0 1 auto; max-height:calc(80dvh - 49px); }
}

@media (min-width:760px) and (max-width:1099px) {
  .game-menu-drawer .pace-preview-list { grid-template-columns:minmax(0,1fr); }
}

@media (min-width:760px) and (min-height:500px) and (max-aspect-ratio:5/4) {
  .page-shell { display:flex; height:100vh; height:100dvh; min-height:0; flex-direction:column; overflow:hidden; }
  main { min-height:0; flex:1 1 auto; grid-template-rows:auto minmax(0,1fr); align-content:stretch; overflow:hidden; }
  .run-card { height:auto; min-height:0; align-self:stretch; }
  .scene-frame { flex:1 1 auto; margin:0; }
  #run-scene { width:100%; height:100%; max-width:100%; aspect-ratio:auto; }
}

@media (max-width:759px), (max-height:499px) and (min-width:760px) {
  .game-menu-dock { align-items:stretch; }
  .game-menu-button { flex:0 1 88px; }
  .game-menu-drawer { width:100%; }
  .game-menu-drawer .upgrade-card { grid-template-columns:32px minmax(0,1fr) 44px 82px; column-gap:5px; }
}

@media (max-width:560px) {
  .game-menu-dock { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); justify-content:center; gap:6px; }
  .game-menu-button { width:100%; min-width:0; min-height:46px; }
  .game-menu-drawer .enemy-panel, .game-menu-drawer .upgrade-panel, .game-menu-drawer .journey-panel, .game-menu-drawer .rebirth-panel { padding:13px 12px; }
  .game-menu-drawer .section-heading h2, .game-menu-drawer .journey-heading h2 { font-size:17px; }
  .game-menu-drawer .panel-intro, .game-menu-drawer .micro-note { font-size:10px; }
  .game-menu-drawer .level-picker { gap:8px; }
  .game-menu-drawer .level-step { width:36px; height:36px; font-size:23px; }
  .game-menu-drawer .level-readout { min-width:100px; }
  .game-menu-drawer .reward-preview span { font-size:11px; }
  .game-menu-drawer .pace-preview { padding:5px; }
  .game-menu-drawer .upgrade-card { min-height:58px; grid-template-columns:29px minmax(0,1fr) 39px 76px; column-gap:5px; padding:6px; }
  .game-menu-drawer .upgrade-icon { width:27px; height:27px; }
  .game-menu-drawer .upgrade-copy strong { font-size:11px; }
  .game-menu-drawer .upgrade-copy small { font-size:9px; }
  .game-menu-drawer .upgrade-level, .game-menu-drawer .upgrade-price { font-size:9px; }
  .game-menu-drawer .upgrade-level b { font-size:10px; }
  .rebirth-readouts article { padding:9px; }
  .rebirth-readouts article>span { font-size:9px; }
  .rebirth-readouts article>strong { font-size:19px; }
  .rebirth-permanent { font-size:10px; }
  .rebirth-permanent>span b, .rebirth-permanent>span strong { font-size:12px; }
  .rebirth-formula, .rebirth-reset-note { font-size:9px; }
  .rebirth-button { min-height:42px; font-size:11px; }
}
