/* Neon arcade skin ported from the tetris.bak look. Loaded after styles.css; delete this file to return to the muted theme. */
:root{
  --color-paper:#0b1030;
  --color-paper-2:#111844;
  --color-paper-3:#1c2566;
  --color-ink:#fff;
  --color-ink-2:#d3dcff;
  --color-muted:#a9b8ee;
  --color-rule:#4a559f;
  --color-primary:#8be9ff;
  --color-focus:#fff;
  --color-accent-ink:#050818;
  --surface-selected:linear-gradient(145deg,#232d6e,#12143a);
  --surface-score:linear-gradient(145deg,#2a3590,#1a1f5e);
  --surface-panel:linear-gradient(145deg,#0e1230e6,#090b20e6);
  --shadow-panel:0 20px 80px #000c,0 0 50px #6436ff40;
  --shadow-board:0 0 45px #7045ff77,0 0 90px #00d9ff22;
  --neon-grad:linear-gradient(135deg,#3d57ff,#a126ff);
  --neon-rim:linear-gradient(135deg,#8b39ff,#1edcff 45%,#ff3cc8 90%);
  /* shared by the intro launch and dialog primary (#start) so both read as one action style */
  --launch-bg:linear-gradient(180deg,#ffffff33 0,#ffffff00 52%),linear-gradient(90deg,#0b8fd8,#6d28d9 58%,#c026d3);
  --launch-bg-hover:linear-gradient(180deg,#ffffff40 0,#ffffff00 52%),linear-gradient(90deg,#1ba0ea,#7c3aed 58%,#d946ef);
}

/* backdrop */
html,body{background:#03030e}
body:before{background:
  radial-gradient(circle at 50% 35%,#48208066 0,transparent 40%),
  radial-gradient(circle at 15% 85%,#004dff44 0,transparent 35%),
  radial-gradient(circle at 85% 15%,#ff00cc3a 0,transparent 35%),
  linear-gradient(135deg,#020208,#0d0524 50%,#01030c)}
.spark{box-shadow:0 0 12px #fff}

/* in-game panels */
.side{border-color:#5d55d988;border-radius:22px;box-shadow:0 0 35px #000c,inset 0 0 25px #4e36ff15;backdrop-filter:blur(14px)}
.card{border-bottom-color:#5360a877}
.label{color:#8da7ed;letter-spacing:1px}
.value{text-shadow:0 0 14px #44cfff}
.mini-viewport{background:#05081a;border-color:#323d7588;box-shadow:inset 0 0 20px #000}
.logo{filter:drop-shadow(0 0 10px #8f5cff88)}

/* buttons */
button{background:var(--neon-grad);color:#fff;box-shadow:0 0 16px #623eff66,inset 0 1px #fff6}
button.secondary,.side.left > button.secondary,.modal button.secondary{background:#111b45;border:1px solid #5364ad;color:var(--color-ink-2);box-shadow:0 0 10px #0006}
@media(hover:hover) and (pointer:fine){
  button.secondary:hover{background:#1a2760;border-color:#7489e8}
  button:not(.secondary):hover{filter:brightness(1.12)}
}

/* board frame */
.boardFrame{border:0;background:var(--neon-rim);border-radius:24px}
.boardFrame.danger,.boardFrame.locking,.boardFrame.b2b{border:0}
.boardInner{background:#030514}

/* modal */
.modal{border-color:#8d5cffaa;border-radius:22px;background:linear-gradient(145deg,#121441fa,#08091ffa);box-shadow:0 0 50px #8156ff55,inset 0 0 24px #8156ff14}
.overlay.is-paused .modal{border-color:#38bdf8b8;box-shadow:0 0 50px #0ea5e947,inset 0 0 24px #38bdf80f}
.overlay.is-game-over .modal{border-color:#fb7185b8;box-shadow:0 0 50px #f43f5e47,inset 0 0 24px #fb71850f}
.modal button:not(.secondary){background:var(--neon-grad);color:#fff;border:0}

/* intro */
#introScreen{background:#03030e}
.intro-vignette{background:radial-gradient(ellipse at center,#0608171a 20%,#02020a8c 75%,#010106d9 100%)}
#intro3DCanvas{opacity:1}
.intro-shell{
  background:#0a0e26d9;border-color:#686eb354;border-radius:28px;align-items:center;text-align:center;
  box-shadow:0 24px 80px #02030ccc,0 0 48px #643cff1a,inset 0 1px 1px #ffffff14;
  backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);
}
.intro-shell::before,.intro-shell::after{content:"";position:absolute;width:18px;height:18px;pointer-events:none;border:0 solid #00f0ff}
.intro-shell::before{top:10px;left:10px;border-width:2px 0 0 2px}
.intro-shell::after{bottom:10px;right:10px;border-width:0 2px 2px 0}
.intro-badge{
  align-self:center;gap:8px;align-items:center;padding:5px 16px;border-radius:999px;
  background:#00f0ff0a;border:1px solid #00f0ff33;color:#a5f3fc;font-weight:600;letter-spacing:1px;box-shadow:none;
}
.intro-title-wrap{align-items:center}
.intro-title,.logo{background:linear-gradient(135deg,#fff 0%,#a5f3fc 20%,#f472b6 60%,#c084fc 100%);-webkit-background-clip:text;background-clip:text;color:transparent}
.intro-title{
  font-family:var(--font-display);
  filter:drop-shadow(0 0 20px #a855f74d);
}
.intro-title .title-3d,.logo small{background:linear-gradient(135deg,#00f0ff,#3b82f6);-webkit-background-clip:text;background-clip:text;color:transparent;text-shadow:0 0 20px #00f0ffcc}
.intro-tagline{color:#cbd5e1}
.intro-section-label{align-self:center;color:#94a3b8;letter-spacing:1px}
.intro-mode-card{background:#12183ccc;border-color:#505faa66;border-radius:16px;box-shadow:none}
.intro-mode-card:hover{background:#1c265ecc;border-color:#7797d4;box-shadow:0 6px 20px #02030c66}
.intro-mode-card.active{background:linear-gradient(145deg,#20365c,#131d3c);border:1px solid #52e5f5;color:#fff;box-shadow:0 0 20px #00f0ff1a,inset 0 0 20px #00f0ff0a}
.intro-mode-card.active::after{background:#00f0ff;color:#050818}
.intro-mode-card.active .intro-mode-name{color:#fff}
.intro-mode-card.active :is(.intro-mode-desc,.intro-mode-badge){color:var(--color-ink-2)}
.intro-mode-card.active .intro-mode-piece i.filled{background:var(--color-mode)}
.intro-goal{background:#0b1130cc;border:1px solid #5360a877}
.intro-level-pill{background:#12183c99;border-color:#505faa88}
.intro-level-pill.active{background:var(--neon-grad);border-color:transparent;color:#fff;box-shadow:0 0 16px #623eff66}
#introScreen[data-mode="classic"] [data-record-mode="classic"],
#introScreen[data-mode="speed"] [data-record-mode="speed"],
#introScreen[data-mode="sprint"] [data-record-mode="sprint"]{background:#2a359066;box-shadow:inset 0 0 0 1px #7489e8aa}
.intro-cta-wrap{border-top-color:#5360a866}
.intro-launch-btn{
  color:#fff;border:1px solid #ffffff55;background:linear-gradient(90deg,#3b82f6,#a21caf);
  box-shadow:0 0 30px #6437ff66,0 0 60px #00d2ff33;
}
.intro-launch-icon{color:#fff}
.intro-launch-key{border-color:#ffffff66;background:#ffffff26;color:#fff}
@media(hover:hover) and (pointer:fine){
  .intro-launch-btn:hover{background:linear-gradient(90deg,#4f93ff,#c026d3);box-shadow:0 0 45px #ff008099,0 0 90px #00d2ff66;transform:translateY(-2px)}
}

/* primary actions that styles.css pins to --color-primary */
.modal #start,.modal button#start,.pad-btn.act-slam{background:var(--neon-grad);color:#fff;border-color:#ffffff55;box-shadow:0 0 16px #623eff66,inset 0 1px #fff6}
.pad-btn.act-slam :is(.pad-icon,.pad-lbl){color:#fff}

/* labels sit on the bright frame gradient, so give them a dark pill */
.board-readout,.board-readout-bottom{background:#05081ae6;backdrop-filter:blur(6px)}


/* the frame glow was clipped to the wrapper rectangle, leaving square patches around the rounded corners */
.boardWrap{overflow:visible!important}

/* short screens: one compact action row so the sticky buttons leave room for the score */
@media(max-height:700px){
  .overlay-actions #start,
  .overlay:not(.is-paused) .overlay-actions #overlayMenuBtn{grid-column:auto}
  .modal .overlay-actions button,.modal .overlay-actions #start{min-height:44px;padding:6px 4px;font-size:13px;line-height:1.2}
}
@media(max-height:420px){
  .modal .overlay-title{font-size:18px}
  .overlay-value{font-size:24px}
  .overlay-metric{padding:8px 12px;margin-top:8px}
}

/* sticky action row blends into the modal gradient instead of showing as a flat patch */
.overlay-actions{background:linear-gradient(to bottom,transparent,#0b0d2a 12px);box-shadow:none}

/* short portrait phones: spend the vertical space on the board instead of the record-chase strip */
@media(max-width:800px) and (max-height:700px) and (orientation:portrait){
  .record-chase{display:none}
  #recordChase[data-mode="speed"]:not([hidden]){display:flex}
}

/* portrait phones: one-line mission strip; progress becomes a hairline along its bottom edge */
@media(max-width:800px) and (orientation:portrait){
  .mission-strip{position:relative;display:flex;align-items:center;gap:8px;padding:4px 9px 6px;overflow:hidden}
  .mission-heading{flex:1 1 auto;min-width:0}
  .mission-detail{flex:0 0 auto;margin-top:0;gap:6px}
  .mission-progress{position:absolute;left:0;right:0;bottom:0;height:3px;border-radius:0}
  .mission-strip.is-complete .mission-progress-fill{background:#6ee7b7}
  .mission-strip.has-choice{display:block}
  .mission-strip.has-choice .mission-detail{margin-top:3px}
  .mission-strip.has-choice .mission-progress{position:static;flex:1;min-width:16px;border-radius:3px}
  .mission-strip.has-choice .mission-goal{white-space:normal;overflow:visible}
}

/* phones: tighter corners so the board keeps its area (neon frame radius was 24px) */
@media(max-width:800px){
  .boardFrame{border-radius:12px!important}
  .boardInner{border-radius:8px!important}
}

/* a successful finish (Speed Rush time-up, Sprint clear) must not use the failure red */
.overlay:not(.is-paused) .modal:has(.overlay-title.success){border-color:#34d399b8;box-shadow:0 0 50px #10b98140,inset 0 0 24px #34d3990f}
.modal:has(.overlay-title.success) .run-end-feedback strong{color:var(--color-sprint)}

/* guide dialog confirm button matches the modal primary (resume/start) button */
.controls-dialog .controls-done-btn{background:var(--neon-grad);color:#fff;border:0}

/* three actions (e.g. puzzle clear): primary on top, the two secondary buttons share the row below */
.overlay:not(.is-paused) .overlay-actions:has(#overlayRestart:not([style*="none"])) #overlayMenuBtn{grid-column:auto}
@media(max-height:700px){
  .overlay:not(.is-paused) .overlay-actions:has(#overlayRestart:not([style*="none"])) #start{grid-column:1 / -1}
}

/* narrow phones: let the long theme name wrap onto two lines instead of truncating with an ellipsis */
@media(max-width:430px){
  .intro-aux-btns{grid-template-columns:auto minmax(0,1.3fr) auto}
  .intro-aux-btn{white-space:normal;overflow:visible;text-overflow:clip;line-height:1.25;word-break:keep-all}
}

/* phones: keep the intro scrollable on short screens but without a visible scrollbar */
@media(max-width:800px){
  #introScreen{scrollbar-width:none}
  #introScreen::-webkit-scrollbar{display:none}
}


/* mobile intro: arcade card look from the original design (icon + mode-colored tag, boxed sections, cyan launch) */
@media(max-width:560px){
  .intro-mode-grid{gap:14px 8px;margin-top:6px}
  .intro-mode-card{padding:16px 4px 10px;gap:2px;justify-content:center}
  .intro-mode-badge{
    position:absolute;top:-8px;left:50%;transform:translateX(-50%);white-space:nowrap;
    padding:2px 8px;border-radius:999px;background:var(--color-mode);color:#050818;
    font-size:10px;font-weight:800;letter-spacing:0;line-height:1.3;
  }
  .intro-mode-name::before{display:block;font-size:20px;line-height:1.2;margin-bottom:2px;color:var(--color-mode)}
  .intro-mode-card[data-mode="classic"] .intro-mode-name::before{content:"⚡" / ""}
  .intro-mode-card[data-mode="speed"] .intro-mode-name::before{content:"🔥" / ""}
  .intro-mode-card[data-mode="sprint"] .intro-mode-name::before{content:"⏱️" / ""}
  .intro-mode-card[data-mode="puzzle"] .intro-mode-name::before{content:"◆" / ""}
  .intro-mode-card[data-mode="battle"] .intro-mode-name::before{content:"VS" / "";font:800 15px/1.5 var(--font-display)}
  .intro-section-label{display:flex;align-items:center;gap:8px;width:100%;justify-content:center}
  .intro-section-label::before,.intro-section-label::after{content:"";height:1px;width:28px;background:#94a3b84d}
  .intro-level-box,.intro-records-box{
    flex:none;width:100%;padding:10px 12px;border:1px solid #5360a877;border-radius:16px;
    background:#0b1130b3;box-shadow:inset 0 0 18px #ffffff05;align-items:stretch;gap:8px;
  }
  .intro-box-title{color:#8da7ed;font-weight:800;letter-spacing:.5px}
  .intro-records-box .intro-box-title{text-align:center;width:100%}
  .intro-stat-item{align-items:center;text-align:center}
  .intro-launch-btn{justify-content:center;background:linear-gradient(90deg,#16c6ff,#7c3aed 60%,#b620e0);border-color:#ffffff66;box-shadow:0 0 28px #16c6ff55,0 0 50px #7c3aed44}
  .intro-launch-content{flex:0 1 auto;justify-content:center}
  .intro-aux-btn{background:linear-gradient(145deg,#141a4acc,#0b1030cc);border-color:#5364ad88;box-shadow:0 0 10px #0006}
  .intro-aux-btns .intro-aux-btn:first-child::before{content:"🕹️ " / ""}
  #introSoundToggle::before{content:"🔊 " / ""}
  .intro-vol-panel[open]{background:#0b1130b3;border-color:#5360a877;border-radius:16px;padding:0 12px 6px}
  .intro-vol-panel[open] > summary{border-bottom-color:#5360a833;color:#8da7ed;font-weight:800}
  .intro-vol-panel .intro-vol-row{margin-top:0;min-height:40px;gap:10px}
  .intro-vol-row > label::before,.intro-vol-row > #introMotionLabel::before{margin-right:6px}
  .intro-vol-row > label[for="introBgmVolSlider"]::before{content:"🎵" / ""}
  .intro-vol-row > label[for="introSfxVolSlider"]::before{content:"✨" / ""}
  .intro-vol-row > #introMotionLabel::before{content:"🌀" / ""}
  .intro-vol-panel .bgm-vol-slider{height:36px}
  .intro-vol-panel .bgm-vol-slider::-webkit-slider-runnable-track{background:#1a2155}
  .intro-vol-panel .bgm-vol-slider::-webkit-slider-thumb{background:#00e5ff;box-shadow:0 0 10px #00e5ffcc}
  .intro-vol-panel .bgm-vol-slider::-moz-range-thumb{background:#00e5ff;box-shadow:0 0 10px #00e5ffcc}
  .intro-vol-pct{color:#38d4ff;font-weight:800}
  .intro-vol-panel .reduce-motion-btn{min-height:36px}
  .intro-vol-row > label{min-width:76px}
}

@media(max-width:340px){
  .intro-aux-btns .intro-aux-btn:first-child::before,#introSoundToggle::before{content:none}
}

/* mobile intro: tighter corners (shell was 28px, boxes/cards 16px) */
@media(max-width:560px){
  .intro-shell{border-radius:14px}
  .intro-mode-card{border-radius:10px}
  .intro-goal,.intro-level-box,.intro-records-box,.intro-vol-panel,.intro-vol-panel[open]{border-radius:10px}
  .intro-level-pill,.intro-launch-btn,.intro-aux-btn{border-radius:8px}
}

/* desktop intro: launch button centered, helpers on their own row beneath it */
@media(min-width:561px){
  .intro-launch-btn{grid-column:1 / -1;justify-self:center;width:min(100%,460px);justify-content:center;position:relative}
  .intro-launch-content{flex:0 1 auto;justify-content:center}
  .intro-launch-key{position:absolute;right:16px;top:50%;transform:translateY(-50%)}
  .intro-aux-btns{grid-column:1 / -1;justify-self:center;width:min(100%,560px)}
}
@media(min-width:561px) and (max-height:860px){
  .intro-shell{gap:12px;padding-top:18px;padding-bottom:14px}
  .intro-cta-wrap{padding-top:10px;gap:8px 28px}
}
@media(min-width:561px) and (max-height:780px){
  .intro-badge{display:none}
}

/* launch button sits right under the mode cards; helpers stay at the bottom */
.intro-start-wrap{display:flex;justify-content:center;width:100%}
.intro-start-wrap .intro-launch-btn{width:100%}
@media(min-width:561px){
  .intro-start-wrap .intro-launch-btn{width:min(100%,460px)}
}

/* Roomier desktop cabinet; retain the centered arcade identity and five modes. */
@media(min-width:561px){
  .intro-shell{width:min(960px,96vw);padding:32px 32px 24px;align-items:center;text-align:center;gap:16px}
  .intro-section-label{display:flex;align-items:center;justify-content:center;gap:10px;width:100%;margin:0}
  .intro-section-label::before,.intro-section-label::after{content:"";height:1px;width:48px;background:#94a3b84d}
  .intro-mode-grid{gap:12px;margin-top:0}
  .intro-mode-card{padding:18px 8px 14px;align-items:center;text-align:center;gap:8px;border-radius:12px}
  .intro-mode-piece.mino{display:none}
  .intro-mode-badge{
    position:static;white-space:nowrap;padding:3px 8px;border-radius:6px;
    font-size:10px;font-weight:700;letter-spacing:0;line-height:1.4;
  }
  .intro-mode-name{font-size:15px}
  .intro-mode-desc{font-size:12px;line-height:1.4}
  .intro-mode-name::before{display:block;font-size:22px;line-height:1.2;margin-bottom:4px;color:var(--color-mode)}
  .intro-mode-card[data-mode="classic"] .intro-mode-name::before{content:"⚡" / ""}
  .intro-mode-card[data-mode="speed"] .intro-mode-name::before{content:"🔥" / ""}
  .intro-mode-card[data-mode="sprint"] .intro-mode-name::before{content:"⏱️" / ""}
  .intro-mode-card[data-mode="puzzle"] .intro-mode-name::before{content:"◆" / ""}
  .intro-mode-card[data-mode="battle"] .intro-mode-name::before{content:"VS" / "";font:800 17px/1.5 var(--font-display)}
  .intro-goal{display:flex;justify-content:center;align-items:baseline;gap:12px;padding:11px 16px;background:#00f0ff0a;border:0;border-left:3px solid #52e5f5;border-radius:4px;text-align:center}
  .intro-goal-rules{font-size:12px}
  .intro-sub-row{gap:16px;align-items:stretch}
  .intro-level-box,.intro-records-box{
    flex:none;padding:14px 16px;border:1px solid #5360a84d;border-radius:12px;background:#0b113099;
    box-shadow:none;align-items:stretch;gap:10px;
  }
  .intro-box-title{color:#b8c7ef;font-size:12px;font-weight:600;letter-spacing:0;text-align:center}
  .intro-setting-heading{justify-content:space-between}
  .intro-level-pills{justify-content:center}
  .intro-records-box .intro-box-title{width:100%}
  .intro-stat-item{align-items:center;text-align:center}
  .intro-launch-btn{background:linear-gradient(90deg,#16c6ff,#7c3aed 60%,#b620e0);border-color:#ffffff66;box-shadow:0 0 28px #16c6ff55,0 0 50px #7c3aed44}
  .intro-cta-wrap{grid-template-columns:minmax(0,1fr);justify-items:center;border-top:0;padding-top:4px}
  .intro-aux-btn{background:#111935;border-color:#5364ad66;box-shadow:none;border-radius:8px}
  .intro-aux-btns{grid-template-columns:repeat(3,auto);justify-content:center}
  .intro-aux-btns .intro-aux-btn:first-child::before{content:"🕹️ " / ""}
  #introSoundToggle::before{content:"🔊 " / ""}
  .intro-vol-panel{width:min(100%,460px);justify-self:center}
  .intro-vol-panel[open]{background:#0b1130b3;border-color:#5360a866;border-radius:12px;padding:0 14px 8px}
  .intro-vol-panel[open] > summary{border-bottom-color:#5360a833;color:#b8c7ef;font-weight:600;justify-content:center}
  .intro-vol-panel .intro-vol-row{margin-top:0;min-height:38px}
  .intro-vol-row > label::before,.intro-vol-row > #introMotionLabel::before{margin-right:6px}
  .intro-vol-row > label[for="introBgmVolSlider"]::before{content:"🎵" / ""}
  .intro-vol-row > label[for="introSfxVolSlider"]::before{content:"✨" / ""}
  .intro-vol-row > #introMotionLabel::before{content:"🌀" / ""}
  .intro-vol-row > label{min-width:84px}
  .intro-vol-panel .bgm-vol-slider::-webkit-slider-runnable-track{background:#1a2155}
  .intro-vol-panel .bgm-vol-slider::-webkit-slider-thumb{background:#00e5ff;box-shadow:0 0 10px #00e5ffcc}
  .intro-vol-panel .bgm-vol-slider::-moz-range-thumb{background:#00e5ff;box-shadow:0 0 10px #00e5ffcc}
  .intro-vol-pct{color:#38d4ff;font-weight:800}
  .intro-prompt{text-align:center;grid-column:1 / -1}
}
@media(min-width:561px) and (max-height:700px){
  .intro-tagline{display:none}
  .intro-shell{gap:8px;padding-top:14px}
  .intro-mode-name::before{display:none}
  .intro-mode-card{padding:14px 6px 8px}
}

/* Secondary controls stay touch-sized; the launch remains the only loud action. */
@media(min-width:561px){
  .intro-level-pill{min-height:44px;padding:6px 0;font-size:13px;box-shadow:none}
  .intro-stat-item{padding:6px 8px;gap:4px}
  .intro-stat-label{font-size:11px}
  .intro-stat-val{font-size:22px}
  .intro-aux-btn{min-height:44px;padding:8px 12px;font-size:12px}
  .intro-launch-btn{min-height:56px;padding:12px 20px}
  .intro-vol-panel > summary{display:flex;justify-content:center}
  .intro-vol-panel .intro-vol-row{min-height:44px}
  .intro-vol-panel .bgm-vol-slider{height:44px}
  .intro-vol-panel .reduce-motion-btn{min-height:44px}
}
@media(min-width:561px) and (max-height:780px){
  .intro-shell{gap:12px;padding:20px 24px 16px}
  .intro-mode-card{padding:12px 6px;gap:5px}
  .intro-level-box,.intro-records-box{padding:10px 12px;gap:6px}
}


/* mobile: goal line as the original cyan-bar banner, plus a few px trimmed to match the original height */
@media(max-width:560px){
  .intro-goal{background:#00f0ff12;border:0;border-left:3px solid #00e5ff;border-radius:4px;padding:5px 10px}
}

/* Mode colors identify the rules, while cyan alone identifies selection. */
.intro-mode-card .intro-mode-badge{border-radius:6px;background:#1c3462;color:#c9e7ff;letter-spacing:0;font-weight:700}
.intro-mode-card.active .intro-mode-badge{color:#c9e7ff}
.intro-mode-card[data-mode="speed"] .intro-mode-badge{background:#482814;color:#ffd4ad}
.intro-mode-card[data-mode="sprint"] .intro-mode-badge{background:#123d35;color:#acedd4}
.intro-mode-card[data-mode="puzzle"] .intro-mode-badge{background:#342451;color:#e1ceff}
.intro-mode-card[data-mode="battle"] .intro-mode-badge{background:#44321b;color:#ffe0a5}
@media(max-width:560px){
  .intro-mode-badge{padding:3px 7px;font-size:10px;letter-spacing:0}
}

/* mobile result card: centered, one-line score, pill stats (original design); semantic title colors are kept */
@media(max-width:560px),(max-height:540px) and (orientation:landscape){
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)){text-align:center;padding:16px 14px 12px}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) #overlayText{margin-bottom:10px}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .overlay-title{font-size:26px;line-height:1.2}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .overlay-subtitle{margin-top:2px;font-size:13px}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .overlay-metric{
    flex-direction:row;justify-content:center;align-items:baseline;gap:8px;
    margin-top:8px;padding:0;background:none;border-radius:0;
  }
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .overlay-caption{font-size:15px;font-weight:500;color:var(--color-ink-2)}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .overlay-value{font-size:34px;color:#00e5ff;text-shadow:0 0 14px #00e5ff66}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .record-result{margin-top:4px;padding:0;background:none;text-align:center;color:#fcd34d;font-size:14px}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .run-end-feedback{margin-top:10px;padding:0;background:none;align-items:center;text-align:center;gap:2px}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .run-end-feedback strong{font-size:14px}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .run-summary{
    display:flex;flex-wrap:wrap;justify-content:center;gap:6px;margin-top:12px;padding-top:0;border-top:0;
  }
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .run-summary > span{
    padding:3px 10px;border-radius:999px;border:1px solid #5360a888;background:#0b1130b3;
    font-size:12px;line-height:1.4;white-space:nowrap;
  }
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .technique-summary{margin-top:6px}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .technique-summary > span{border-color:#8a6d2f99;color:#fde68a}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .overlay-actions{margin-top:14px;gap:8px;padding-top:0;background:none}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) #overlayMenuBtn::before{content:"🏠 " / ""}
}

/* phone landscape: the board is a ~160px strip, so pause and result dialogs float centered over the whole screen instead */
@media(max-height:540px) and (orientation:landscape){
  .boardFrame:has(.overlay:not([style*="none"])){transform:none!important;will-change:auto!important;animation:none!important}
  .overlay:not([style*="none"]){position:fixed;inset:0;z-index:60;padding:8px}
  .overlay:not([style*="none"]) .modal{width:min(460px,94vw);max-height:100%}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)){padding:10px 14px 8px}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .overlay-title{font-size:20px}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .overlay-value{font-size:26px}
  .overlay:not(.is-paused) .modal:has(.overlay-title:is(.success,.failure)) .run-end-feedback span{font-size:11px}
  /* the paused backdrop must not eat taps, so the HUD resume button stays reachable */
  .overlay.is-paused:not([style*="none"]){pointer-events:none}
  .overlay.is-paused:not([style*="none"]) .modal{pointer-events:auto;padding:12px 16px 10px}
  .overlay.is-paused:not([style*="none"]) .overlay-actions{grid-template-columns:repeat(3,minmax(0,1fr));margin-top:0}
  .overlay.is-paused:not([style*="none"]) .overlay-actions #start{grid-column:auto}
  .overlay.is-paused:not([style*="none"]) .overlay-actions #overlayMenuBtn{grid-column:auto}
  .overlay.is-paused:not([style*="none"]) .overlay-title{font-size:22px}
  .overlay.is-paused:not([style*="none"]) #overlayText{margin-bottom:8px}
  .overlay.is-paused:not([style*="none"]) .mobile-pause-extra{margin-top:8px;padding-top:8px;gap:6px}
}

/* dialog primary buttons: keep the gradient on hover and lift with a purple glow, as in the original design */
@media(hover:hover) and (pointer:fine){
  .modal #start:not(:disabled):hover,.controls-dialog .controls-done-btn:hover,.bgm-dialog .bgm-done-btn:hover{
    background:var(--neon-grad);filter:brightness(1.2);transform:translateY(-2px);
    box-shadow:0 0 24px #623effaa,inset 0 1px #fff6;
  }
}
.modal #start:not(:disabled):active,.controls-dialog .controls-done-btn:active,.bgm-dialog .bgm-done-btn:active{transform:scale(.97) translateY(0)}
/* dialog primaries (resume/start/retry, guide and music confirm) match the intro launch: same gradient, gloss, rim light and bottom lip */
.modal button#start,.controls-dialog .controls-done-btn,.bgm-dialog .bgm-done-btn{background:var(--launch-bg);color:#fff;border:1px solid #ffffff70;text-shadow:0 1px 2px #0008;box-shadow:0 0 16px #623eff66,inset 0 1px #fff9,inset 0 -3px #1a0a4d66}
@media(hover:hover) and (pointer:fine){
  .modal button#start:not(:disabled):hover,.controls-dialog .controls-done-btn:hover,.bgm-dialog .bgm-done-btn:hover{background:var(--launch-bg-hover);filter:brightness(1.05);box-shadow:0 0 24px #623effaa,inset 0 1px #fff9,inset 0 -3px #1a0a4d66}
}

/* Glossy arcade launch: static at rest, tactile on hover and press. */
#introStart{
  overflow:hidden;padding-inline:26px;font-size:20px;letter-spacing:.02em;
  text-shadow:0 1px 2px #0008;border-color:#ffffff70;
  /* deeper stops keep white label legible (cyan start was ~2:1) */
  background:var(--launch-bg);
  box-shadow:0 6px 24px #623eff40,inset 0 1px #ffffff66;
  transition:transform var(--dur-short) var(--ease-out),filter var(--dur-short) var(--ease-out);
}
/* Arcade-key depth: top rim light and bottom lip. */
#introStart::before{
  content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;
  box-shadow:inset 0 1px #fff9,inset 0 -3px #1a0a4d66;
}
#introStart .intro-launch-icon{
  box-sizing:border-box;width:1.4em;height:1.4em;padding:.32em .26em .32em .38em;
  border-radius:50%;background:#fff;color:#5b21b6;box-shadow:0 0 12px #ffffffaa;filter:none;
}
#introStart .intro-launch-key{border-color:#ffffff55;background:#0a0f2e40;color:#ffffffe6}
@media(hover:hover) and (pointer:fine){
  #introStart:hover{background:var(--launch-bg-hover);filter:brightness(1.05);transform:translateY(-2px)}
}
#introStart:active:not(:focus-visible){transform:translateY(1px) scale(.985);filter:brightness(.95)}

/* short landscape phones (e.g. 667x375): trim vertical padding so the whole intro card fits without scrolling */
@media(max-height:380px) and (orientation:landscape){
  #introScreen .intro-shell{gap:4px;padding-top:6px;padding-bottom:4px}
  #introScreen .intro-mode-card{padding:10px 6px 4px}
  #introScreen .intro-launch-btn{min-height:36px;padding:4px 16px}
  #introScreen .intro-aux-btn{min-height:28px}
  #introScreen .intro-level-pill{min-height:28px}
  #introScreen .intro-cta-wrap{padding-top:4px}
  #introScreen .intro-mode-card{min-height:0}
  #introScreen :is(.intro-level-box,.intro-records-box){padding:4px 12px;gap:3px}
  #introScreen .intro-stat-val{font-size:15px}
  #introScreen .intro-goal{padding-block:3px}
  #introScreen .intro-vol-panel:not([open]) > summary{min-height:24px;padding-block:2px}
}

/* narrow phones: keep the mission goal ("한 번에 2줄 지우기") on one line so the strip never grows and shrinks the board */
@media(max-width:430px){
  .mission-goal{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
}
@media(max-width:380px){
  .mission-strip,.mission-heading,.mission-detail{gap:4px}
  .mission-reward{font-size:10px}
  #feverProgress{flex-basis:10px;width:10px}
}

/* short landscape phones: keep number, goal and fever on one row (styles.css wraps the goal onto its own row, making the strip taller) */
@media(max-height:400px) and (orientation:landscape){
  .mission-heading{flex-wrap:nowrap;row-gap:0}
  .mission-number{display:none}
  .mission-goal{flex:1 1 auto;order:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .mission-strip.has-choice .mission-heading{flex-wrap:wrap;row-gap:2px}
  .mission-strip.has-choice .mission-goal{flex:1 0 100%;order:1;white-space:normal;overflow:visible}
  .mission-strip.has-choice .mission-detail{flex-wrap:wrap;justify-content:space-between}
  .mission-strip.has-choice .mission-progress{flex-basis:100%;order:1}
}

/* 320px phones: drop the Enter key hint and tighten type so the start label stays on one line */
@media(max-width:340px){
  #introStart{font-size:18px;padding-inline:18px}
  #introStart .intro-launch-key{display:none}
  #introLaunchLabel{white-space:nowrap}
}

/* very low landscape phones (e.g. 720x312): all five mode cards on one row and no goal banner, so the intro fits without scrolling */
@media(max-height:340px) and (orientation:landscape){
  #introScreen .intro-mode-grid{grid-template-columns:repeat(5,minmax(0,1fr))}
  #introScreen .intro-mode-card[data-mode="battle"]{grid-column:auto}
  #introScreen .intro-goal{display:none}
}
/* too narrow to sit beside the level box: the best-records panel would be pushed off-screen */
@media(max-height:340px) and (max-width:540px) and (orientation:landscape){
  #introScreen .intro-records-box{display:none}
}

/* Fit phone intros to the available viewport; keep scrolling as a zoom fallback. */
@media(max-width:560px) and (orientation:portrait){
  #introScreen{
    padding:max(8px,env(safe-area-inset-top,0px)) max(8px,env(safe-area-inset-right,0px)) max(8px,env(safe-area-inset-bottom,0px)) max(8px,env(safe-area-inset-left,0px));
  }
  .intro-shell{gap:10px;padding:16px 12px}
  .intro-mode-grid{gap:14px 8px}
  .intro-mode-card{padding:16px 4px 10px}
  .intro-level-box,.intro-records-box{box-sizing:border-box;padding:6px 10px;gap:4px}
  .intro-level-pill{min-height:44px}
  .intro-stat-item{padding:3px 4px;gap:2px}
  .intro-stat-val{font-size:16px}
  .intro-cta-wrap{padding-top:10px;gap:6px}
  .intro-launch-btn{min-height:44px;padding:8px 16px}
  .intro-aux-btn{min-height:44px;padding:5px 4px}
}
@media(max-width:560px) and (max-height:760px) and (orientation:portrait){
  .intro-badge,.intro-tagline{display:none}
  .intro-shell{gap:6px;padding:8px 10px}
  .intro-title{font-size:28px}
  .intro-section-label{margin:0}
  .intro-mode-name::before{display:none}
  .intro-mode-card{padding:10px 4px 6px}
  .intro-goal{padding-block:4px;gap:2px}
}
@media(max-width:560px) and (max-height:600px) and (orientation:portrait){
  .intro-shell{gap:4px}
  .intro-section-label{display:none}
  .intro-mode-card{min-height:48px}
  .intro-title{font-size:22px}
  .intro-sub-row{gap:4px}
  .intro-level-box,.intro-records-box{padding:4px 6px;gap:3px}
  .intro-records-box .intro-box-title{display:none}
  .intro-stat-item{padding:2px;gap:1px}
  .intro-stat-val{font-size:13px}
  #introStart{font-size:16px;padding-inline:12px}
}
/* Settings expand in flow, never cover difficulty, records or helper actions. */
#introAudioDetails,#introAudioDetails[open]{
  display:block;position:relative;box-sizing:border-box;width:min(100%,460px);padding:0 12px;
}
#introAudioDetails > summary{
  display:flex;min-height:44px;justify-content:center;border:0;
}
#introAudioDetails[open] > summary{border-bottom:1px solid #5360a833}
#introAudioDetails[open]{background:#0b1130;border:1px solid #5360a866;padding-bottom:8px}
#introAudioDetails .intro-vol-row{min-height:44px;margin:0}
#introAudioDetails :is(.bgm-vol-slider,.reduce-motion-btn){min-height:44px}
@media(max-width:560px) and (min-height:761px) and (orientation:portrait){
  .intro-goal{padding:9px 10px;gap:5px}
  .intro-goal-target{font-size:13px}
  .intro-goal-rules{font-size:11px;line-height:1.5}
  .intro-box-title,.intro-setting-hint{font-size:11px}
  .intro-records-box,.intro-level-box{padding:10px;gap:8px}
  #introStart{min-height:52px}
}
@media(pointer:coarse){
  #introStart .intro-launch-key{display:none}
}
