/* Presentation layer — game rules and progression live in game.js. */
/* State visibility must win over component display rules without the CDN runtime. */
.hidden { display:none!important; }
:root {
    --ink:#24344c; --muted:#718096; --line:#dfe7ef; --paper:#ffffff;
    --background:#eff4f8; --accent:#ef754d; --accent-dark:#cc5835;
    --blue:#506fa6; --mint:#437d70; --radius:24px;
    color-scheme:light;
}
html { background:var(--background); }
body {
    margin:0; min-height:100vh; min-height:100dvh; padding:24px 16px;
    display:flex; align-items:center; justify-content:center; color:var(--ink);
    background:var(--background); font-family:'Noto Sans KR',sans-serif;
    -webkit-font-smoothing:antialiased;
}
body.fever-bg { background:#f2edf9; }
button { -webkit-appearance:none; font-family:inherit; }
button:focus-visible,canvas:focus-visible { outline:3px solid #386fa9; outline-offset:4px; }
button { touch-action:manipulation; }
button:disabled { cursor:default; }
.icon { display:inline-block; flex:none; width:22px; height:22px; background:currentColor; mask:var(--icon) center/contain no-repeat; -webkit-mask:var(--icon) center/contain no-repeat; vertical-align:middle; }
.icon-map { --icon:url('./assets/icons/map.svg'); }
.icon-pause { --icon:url('./assets/icons/pause.svg'); }
.icon-bomb { --icon:url('./assets/icons/bomb.svg'); }
.icon-shuffle { --icon:url('./assets/icons/shuffle.svg'); }
.icon-timer { --icon:url('./assets/icons/timer.svg'); }
.icon-infinity { --icon:url('./assets/icons/infinity.svg'); }
.icon-trophy { --icon:url('./assets/icons/trophy.svg'); }
.icon-close { --icon:url('./assets/icons/x.svg'); }
.icon-home { --icon:url('./assets/icons/house.svg'); }
.icon-play { --icon:url('./assets/icons/play.svg'); }
.icon-retry { --icon:url('./assets/icons/rotate-ccw.svg'); }
.icon-flame { --icon:url('./assets/icons/flame.svg'); }
.icon-pointer { --icon:url('./assets/icons/mouse-pointer-2.svg'); }
.play-layout { width:100%; max-width:1000px; display:flex; align-items:center; justify-content:center; gap:88px; }
.game-app { width:100%; max-width:480px; flex:none; display:flex; flex-direction:column; gap:14px; }
.wordmark { display:flex; align-items:center; gap:11px; font:24px/1.2 'Jua',sans-serif; letter-spacing:-.5px; }
.wordmark img { object-fit:contain; border-radius:12px; }
.wordmark-small { font-size:21px; gap:8px; white-space:nowrap; }
.wordmark-small img { width:36px; height:36px; border-radius:10px; }
.desktop-intro { width:310px; flex:none; }
.desktop-intro .eyebrow { margin-top:68px; }
.eyebrow,.section-kicker { display:block; font-size:11px; font-weight:800; letter-spacing:2px; color:var(--blue); }
.desktop-intro h1 { margin:14px 0 20px; font:48px/1.28 'Jua',sans-serif; letter-spacing:-2px; }
em { color:var(--accent); font-style:normal; }
.intro-description { font-size:15px; line-height:1.9; color:var(--muted); }
.intro-portraits { display:flex; align-items:center; margin:30px 0 32px; padding-left:4px; }
.intro-portraits img { width:84px; height:84px; object-fit:contain; filter:drop-shadow(0 7px 6px #273e6012); }
.intro-portraits img:first-child { transform:rotate(-10deg); }
.intro-portraits img:nth-child(2) { transform:translateY(-7px) rotate(5deg); }
.intro-portraits img:last-child { transform:rotate(12deg); }
.intro-instructions { display:flex; gap:12px; align-items:center; font-size:13px; line-height:1.8; color:#62748b; }
.intro-instructions .icon { width:25px; height:25px; color:var(--blue); }
.intro-caption { display:block; margin-top:40px; color:#8b98aa; font-size:11px; }
.game-panel.game-hud { padding:18px 20px 16px; background:#fff; border:1px solid var(--line); border-radius:var(--radius); box-shadow:0 4px 0 #e4ebf2,0 12px 30px #2c486008; }
.hud-topline { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.game-controls { display:flex; gap:5px; }
.icon-button { width:40px; height:40px; border:1px solid #e4eaf1; border-radius:12px; background:#f6f8fb; color:#64758c; display:inline-flex; align-items:center; justify-content:center; flex:none; transition:background .15s,transform .15s; }
.icon-button .icon { width:19px; height:19px; }
.icon-button:hover:not(:disabled) { background:#e6edf6; color:var(--ink); }
.icon-button:active:not(:disabled) { transform:scale(.94); }
.icon-button:disabled { opacity:.45; }
.sound-button { font-size:0; }
.sound-button::before { content:''; display:block; width:19px; height:19px; background:currentColor; mask:url('./assets/icons/volume-2.svg') center/contain no-repeat; -webkit-mask:url('./assets/icons/volume-2.svg') center/contain no-repeat; }
.sound-button[aria-pressed=false]::before { mask-image:url('./assets/icons/volume-x.svg'); -webkit-mask-image:url('./assets/icons/volume-x.svg'); }
.score-line { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:20px 0 16px; }
.score-main { display:flex; flex-direction:column; gap:3px; }
.metric-label { font-size:12px; color:var(--muted); font-weight:600; }
#hud-score { font:42px/1.05 'Jua',sans-serif; letter-spacing:-1px; color:var(--ink); }
.round-information { text-align:right; }
#hud-mode-badge { display:inline-block; border-radius:7px; padding:5px 9px; background:#eef2fa; color:var(--blue); font:13px/1.2 'Jua',sans-serif; letter-spacing:.3px; }
#hud-mode-badge.bg-rose-500 { background:#ffebed; color:#bb425c; }
#hud-fever-pill { background:#f5e9f7; color:#9b439b; border-radius:7px; padding:5px 7px; font:12px 'Jua',sans-serif; margin-left:4px; }
#hud-sub-info { color:var(--muted); font-size:11px; margin-top:8px; line-height:1.6; }
#hud-sub-info .text-orange-600 { color:var(--accent-dark); }
#stage-mission-bar { background:#f6f8fc; border:1px solid #e9edf4; border-radius:14px; padding:11px 12px; margin-bottom:14px; gap:10px; align-items:center; justify-content:space-between; }
#stage-mission-bar:not(.hidden) { display:flex; }
#stage-mission-chips { display:flex; flex-wrap:wrap; gap:6px; flex:1; }
#stage-mission-chips > span,#stage-mission-chips > div { background:#fff; color:#506681; border:1px solid #e2e8f2; font-size:11px; border-radius:6px; padding:4px 7px; line-height:1.4; }
#stage-mission-chips .bg-emerald-100 { color:#2f7564; background:#e6f5ef; border-color:#bde3d4; }
.moves-stat { border-left:1px solid #dfe5ee; padding-left:12px; text-align:center; min-width:52px; }
#hud-moves-label { display:block; font-size:10px; color:var(--muted); }
#hud-moves-value { display:block; font:24px/1.2 'Jua',sans-serif; color:var(--accent-dark); }
#hud-moves-value.text-red-600 { color:#c84961; }
.gauges { display:grid; grid-template-columns:1.45fr 1fr; align-items:center; gap:20px; }
.time-gauge { display:flex; align-items:center; gap:7px; }
#hud-time-icon { color:#8997aa; line-height:1; }
#hud-time-icon .icon { width:17px; height:17px; }
.gauge-track { height:7px; overflow:hidden; border-radius:20px; background:#e9eef4; flex:1; }
#hud-time-bar { height:100%; background:#809ac2; border-radius:20px; transition:width .1s linear; }
#hud-time-bar.from-red-500 { background:#dc637a; }
#hud-time-bar.from-teal-400 { background:#6aa68c; }
#hud-time-text { min-width:33px; font:15px 'Jua',sans-serif; color:var(--ink); text-align:right; }
.fever-gauge { display:flex; flex-direction:column; gap:5px; }
.fever-label { display:flex; align-items:center; justify-content:space-between; color:#9675a1; font-size:10px; font-weight:800; letter-spacing:.3px; }
.fever-label .icon { width:14px; height:14px; }
.fever-gauge .gauge-track { flex:auto; height:6px; background:#eee8f2; }
#hud-fever-bar { height:100%; background:#bc8ec5; border-radius:20px; }
.board-shell { padding:10px; border:1px solid #d8e3ee; border-radius:27px; background:#fff; box-shadow:0 5px 0 #dce5ef,0 15px 35px #3046600a; overflow:hidden; }
.board-shell.fever-frame { border-color:#c89adb; box-shadow:0 5px 0 #d9c8e6,0 0 35px #d7b5e660; }
#canvas-wrapper { width:100%; aspect-ratio:1; position:relative; touch-action:none; overflow:hidden; border-radius:18px; }
#game-canvas { position:absolute; inset:0; width:100%; height:100%; border-radius:18px; background:#edf3f9; }
.game-tools { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:1px; }
.tool-button { display:flex; align-items:center; gap:10px; padding:13px 14px; border:1px solid #dfE6ee; background:#fff; border-radius:17px; text-align:left; box-shadow:0 3px 0 #e2e9f1; transition:transform .12s,background .15s; min-width:0; }
.tool-button:not(:disabled):hover { transform:translateY(-2px); background:#fafcff; }
.tool-button:not(:disabled):active { transform:translateY(2px); box-shadow:none; }
.tool-button:disabled { opacity:.5; }
.tool-symbol { display:flex; align-items:center; justify-content:center; width:38px; height:38px; border-radius:12px; color:#ac6975; background:#fceef0; }
.shuffle-tool .tool-symbol { background:#eaf1fc; color:#5a7fb2; }
.tool-copy { flex:1; min-width:0; }
.tool-copy strong { display:block; font:17px 'Jua',sans-serif; color:var(--ink); }
.tool-copy small { display:block; margin-top:3px; font-size:10px; color:var(--muted); white-space:nowrap; }
.tool-count { min-width:24px; height:24px; border-radius:8px; background:#f0f3f8; color:#64758c; display:flex; align-items:center; justify-content:center; font:14px 'Jua',sans-serif; }
.board-note { text-align:center; font-size:10px; line-height:1.7; color:#8d9bae; margin:0; }
.screen-overlay { position:fixed; inset:0; z-index:50; background:#23344b66; backdrop-filter:blur(9px); -webkit-backdrop-filter:blur(9px); padding:24px 16px; overflow-y:auto; overscroll-behavior:contain; align-items:center; justify-content:center; }
.screen-overlay:not(.hidden) { display:flex; }
.screen-overlay.hidden { display:none; }
.start-overlay { z-index:40; background:var(--background); padding:32px 24px; }
body:has(#modal-start:not(.hidden)) #play-layout { visibility:hidden; }
body:has(.screen-overlay:not(.hidden)) { overflow:hidden; }
.welcome-screen { width:100%; max-width:920px; display:grid; grid-template-columns:1fr 1fr; gap:64px; align-items:center; margin:auto; }
.welcome-art { padding:10px 0; }
.welcome-art .eyebrow { margin:60px 0 15px; }
.welcome-art h1 { font:58px/1.15 'Jua',sans-serif; letter-spacing:-2px; margin:0 0 20px; }
.welcome-description { font-size:15px; color:var(--muted); line-height:1.9; }
.welcome-portraits { display:flex; justify-content:center; align-items:center; margin:36px -5px 20px; padding:12px 0 20px; }
.welcome-portraits img { width:32%; max-width:142px; object-fit:contain; filter:drop-shadow(0 12px 8px #263f6017); }
.portrait-left { transform:rotate(-13deg) translateY(8px); }
.portrait-center { transform:rotate(-2deg) translateY(-12px); z-index:1; }
.portrait-right { transform:rotate(13deg) translateY(8px); }
.welcome-caption { display:block; text-align:center; font-size:12px; color:#8594a7; }
.welcome-actions { padding:34px 28px 24px; border-radius:30px; background:#fff; box-shadow:0 8px 0 #e2eaf3,0 24px 64px #2b43520a; border:1px solid var(--line); }
.welcome-actions > .section-kicker { letter-spacing:.5px; font-size:12px; color:var(--muted); }
.welcome-actions h2 { font:29px/1.3 'Jua',sans-serif; letter-spacing:-.6px; margin:9px 0 28px; }
#asset-load-status { color:var(--muted); font-size:12px; margin:0 0 16px; }
.mode-card { transition:transform .15s,box-shadow .15s; border-radius:20px; text-align:left; }
.mode-card:disabled { opacity:.45; }
.mode-card:not(:disabled):hover { transform:translateY(-3px); }
.mode-card:not(:disabled):active { transform:translateY(2px); box-shadow:none; }
.mode-stage { width:100%; position:relative; display:flex; gap:14px; align-items:center; padding:26px 18px; color:white; background:var(--accent); border:1px solid #dc653f; box-shadow:0 5px 0 #cf5b35; }
.mode-stage .mode-icon { width:49px; height:49px; display:flex; align-items:center; justify-content:center; border-radius:15px; background:#ffffff24; }
.mode-stage .mode-icon .icon { width:27px; height:27px; }
.mode-copy small { display:block; font-size:10px; color:#ffebe4; margin-bottom:5px; }
.mode-copy strong { display:block; font:25px/1.1 'Jua',sans-serif; letter-spacing:-.4px; }
.mode-copy > span { display:block; font-size:11px; margin-top:7px; color:#fff0e9; }
.mode-tag { position:absolute; top:11px; right:13px; font-size:8px; letter-spacing:.8px; color:#ffede6; }
.start-progress { display:flex; align-items:center; justify-content:center; gap:5px; margin:17px 0 24px; min-height:20px; font-size:9px; color:#7d899b; white-space:nowrap; }
.progress-dot { width:5px; height:5px; border-radius:50%; background:#83a991; flex:none; }
.secondary-modes { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.secondary-modes .mode-card { display:flex; flex-direction:column; align-items:flex-start; padding:20px 13px 19px; border:1px solid #e0e8f4; background:#f0f5fc; color:#4e6a94; box-shadow:0 3px 0 #e1e8f2; }
.secondary-modes .mode-icon { margin-bottom:17px; }
.secondary-modes .mode-icon .icon { width:25px; height:25px; }
.secondary-modes strong { font:17px/1.2 'Jua',sans-serif; white-space:nowrap; }
.secondary-modes .mode-card > span:last-child { font-size:10px; margin-top:7px; color:#7a8ea9; white-space:nowrap; }
.secondary-modes .mode-zen { border-color:#dcece6; background:#eef7f3; color:#477d6c; box-shadow:0 3px 0 #dfece5; }
.secondary-modes .mode-zen > span:last-child { color:#7c9a8f; }
.welcome-hint { display:flex; justify-content:center; align-items:center; gap:5px; color:#8a98ab; font-size:10px; margin-top:26px; white-space:nowrap; }
.welcome-hint .icon { width:13px; height:13px; }
.modal-card { width:100%; max-width:420px; margin:auto; padding:30px; background:#fff; color:var(--ink); border:1px solid #e3e9f2; border-radius:28px; box-shadow:0 12px 0 #142b4312,0 30px 80px #15233820; }
.modal-card h2 { font:30px/1.3 'Jua',sans-serif; letter-spacing:-.6px; color:var(--ink); }
.modal-card .section-kicker { font-size:9px; letter-spacing:1.6px; margin-bottom:7px; }
.stages-card { max-width:580px; display:flex; flex-direction:column; gap:0; max-height:calc(100dvh - 48px); padding:26px; }
.modal-heading { display:flex; justify-content:space-between; align-items:center; gap:8px; flex:none; }
.stage-heading-actions { display:flex; align-items:center; gap:12px; }
.total-stars { display:flex; gap:6px; align-items:center; background:#fff5dd; border:1px solid #f7e8c0; border-radius:10px; padding:9px 10px; font:17px 'Jua',sans-serif; color:#97722d; white-space:nowrap; }
.total-stars .icon { width:17px; height:17px; }
.total-stars small { font:10px 'Noto Sans KR',sans-serif; color:#b29a68; }
.stages-description { color:var(--muted); font-size:12px; margin:12px 0 22px; line-height:1.8; flex:none; }
#chapter-tabs { display:flex; gap:7px; margin-bottom:16px; padding:1px 0 5px; flex:none; overflow-x:auto; scroll-snap-type:x proximity; }
#chapter-tabs button { flex:0 0 calc((100% - 28px) / 5); min-width:64px; min-height:56px; padding:8px 4px; scroll-snap-align:start; background:#f5f7fb; border:1px solid #e6eaf2; border-radius:12px; color:#8b99ae; box-shadow:none; font:14px/1.4 'Jua',sans-serif; }
#chapter-tabs button > span:first-child { white-space:nowrap; }
#chapter-tabs button > span:last-child { font-size:10px; margin-top:3px; }
#chapter-tabs button.bg-orange-500 { background:#526e9d; border-color:#526e9d; color:#fff; box-shadow:0 3px 0 #354e78; }
#chapter-tabs button:not(.bg-orange-500):hover { background:#e8eef8; }
.chapter-banner { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px; background:#f2f6fb; border:1px solid #e1eaf6; border-radius:16px; margin-bottom:16px; flex:none; }
#chapter-title { font:17px/1.4 'Jua',sans-serif; color:#4a648b; word-break:keep-all; }
#chapter-desc { font-size:10px; line-height:1.7; color:#7c8da3; margin-top:5px; }
#chapter-star-badge { flex:none; white-space:nowrap; background:#fff; border-radius:8px; color:#987a3b; padding:6px 9px; font:13px 'Jua',sans-serif; }
#stage-buttons-grid { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:9px; overflow-y:auto; min-height:0; padding:1px 2px 5px; }
#stage-buttons-grid button { min-height:78px; border:1px solid #e0e7ef; border-radius:15px; background:#fff; color:var(--ink); box-shadow:0 3px 0 #e7edf4; padding:9px 4px; gap:4px; }
#stage-buttons-grid button:disabled { opacity:1; background:#f6f8fb; border-color:#e9edf4; box-shadow:none; color:#afbac9; }
#stage-buttons-grid button:disabled > div:first-child { color:#a3afc0; }
#stage-buttons-grid button:disabled > div:last-child { font-size:10px; opacity:.5; }
#stage-buttons-grid button:not(:disabled).bg-gradient-to-b { background:var(--accent); color:#fff; border-color:#df6841; box-shadow:0 4px 0 #cb5d38; }
#stage-buttons-grid button:not(:disabled) > div:first-child { color:#8b9ab0; font-size:9px; }
#stage-buttons-grid button.bg-gradient-to-b > div:first-child { color:#fff0e9; }
#stage-buttons-grid button > div:nth-child(2) { font:23px 'Jua',sans-serif; }
#stage-buttons-grid button > div:last-child { font-size:11px; }
.stage-bottom-actions { display:flex; align-items:center; justify-content:space-between; gap:12px; border-top:1px solid #edf0f5; margin-top:18px; padding-top:18px; flex:none; }
.btn-3d { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:44px; border:1px solid transparent; border-radius:12px; padding:11px 17px; font:16px/1.3 'Jua',sans-serif; text-shadow:none; transition:transform .12s,background .15s; }
.btn-3d:active:not(:disabled) { transform:translateY(2px); }
.btn-3d .icon { width:17px; height:17px; }
.btn-orange { background:var(--accent); color:white; border-color:#dc6741; box-shadow:0 3px 0 var(--accent-dark); }
.btn-orange:active:not(:disabled) { box-shadow:0 1px 0 var(--accent-dark); }
.btn-cream { background:#f4f7fb; color:#6b7e98; border-color:#e1e8f1; box-shadow:0 3px 0 #dee6ef; }
.btn-cream:active:not(:disabled) { box-shadow:0 1px 0 #dee6ef; }
.btn-sky { background:#edf3fc; color:#516e99; border-color:#dbe5f4; box-shadow:0 3px 0 #d5e0ef; }
.btn-sky:active:not(:disabled) { box-shadow:0 1px 0 #d5e0ef; }
.btn-pink { background:#fcf0f2; color:#a85e70; border-color:#efdae0; box-shadow:0 3px 0 #eed7df; }
.result-card { text-align:center; }
.result-badge { display:inline-block; padding:7px 11px; background:#eef3fa; color:#6c85a9; border-radius:8px; font:12px 'Jua',sans-serif; margin-bottom:14px; }
.result-stars { display:flex; justify-content:center; gap:15px; font-size:40px; margin:24px 0; }
.result-rank { margin:24px 0; }
#result-rank-badge { display:inline-flex; align-items:center; justify-content:center; width:76px; height:76px; background:#fcebd2; color:#b9822a; border:1px solid #f2d8af; border-radius:22px; font:42px 'Jua',sans-serif; }
.result-score-panel { display:flex; flex-direction:column; gap:7px; background:#f5f7fb; border:1px solid #e8edf4; border-radius:18px; padding:20px 10px; margin:20px 0; }
#result-score { font:46px/1.2 'Jua',sans-serif; color:var(--ink); }
#result-new-best { font:12px 'Jua',sans-serif; color:var(--accent-dark); }
#result-rating-detail { margin:4px 8px 0; color:var(--muted); font-size:11px; line-height:1.7; }
.result-stats { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; margin:0 0 27px; }
.result-stats > div+div { border-left:1px solid #e8edf4; }
.result-stats span { display:block; font-size:10px; color:var(--muted); }
.result-stats strong { display:block; font:18px 'Jua',sans-serif; margin-top:7px; }
.result-actions { display:flex; flex-direction:column; gap:12px; }
.result-actions > button { width:100%; }
.result-actions > div { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.result-actions .btn-3d { font-size:14px; padding-left:8px; padding-right:8px; }
.dialog-card { text-align:center; }
.dialog-icon { width:68px; height:68px; display:flex; align-items:center; justify-content:center; margin:0 auto 18px; background:#f0f4fa; border-radius:22px; font-size:29px; }
#dialog-body { color:var(--muted); font-size:14px; line-height:1.9; margin:13px 0 25px; }
#dialog-actions { display:flex; align-items:center; justify-content:center; gap:10px; flex-wrap:wrap; }
#toast-container { top:max(18px,env(safe-area-inset-top)); width:max-content; max-width:calc(100% - 32px); }
#toast-container > div { background:#263a52; color:#fff; border:1px solid #4e6075; border-radius:14px; padding:12px 18px; font:14px/1.5 'Jua',sans-serif; box-shadow:0 8px 25px #18324a20; text-align:center; }
@media(min-width:901px) { .game-app { max-width:460px; } }
@media(max-width:900px) { .desktop-intro { display:none; } .welcome-screen { gap:36px; } .welcome-art h1 { font-size:46px; } .welcome-actions { padding:28px 22px 22px; } }
@media(max-width:650px) {
    body { padding:16px 14px max(16px,env(safe-area-inset-bottom)); }
    .game-app { max-width:450px; gap:12px; }
    .start-overlay { padding:26px 22px; }
    .welcome-screen { display:flex; flex-direction:column; max-width:390px; gap:23px; }
    .welcome-art { width:100%; text-align:center; padding:0; }
    .welcome-art .wordmark { justify-content:center; font-size:20px; gap:8px; }
    .welcome-art .wordmark img { width:33px; height:33px; }
    .welcome-art .eyebrow { margin:27px 0 10px; font-size:9px; letter-spacing:2px; }
    .welcome-art h1 { font-size:42px; line-height:1.16; margin-bottom:10px; letter-spacing:-1.8px; }
    .welcome-art h1 br { display:none; }
    .welcome-art h1 em { display:block; }
    .welcome-description { font-size:12px; line-height:1.8; }
    .welcome-description br { display:none; }
    .welcome-portraits { max-width:270px; margin:17px auto 4px; padding:12px 0; }
    .welcome-portraits img { width:31%; max-width:100px; }
    .welcome-caption { font-size:10px; }
    .welcome-actions { width:100%; padding:24px 21px 19px; border-radius:24px; }
    .welcome-actions > .section-kicker { font-size:10px; }
    .welcome-actions h2 { font-size:25px; margin:6px 0 20px; }
    .mode-stage { padding:22px 17px; }
    .mode-copy strong { font-size:24px; }
    .mode-stage .mode-icon { width:43px; height:43px; }
    .start-progress { margin:15px -7px 20px; font-size:9px; }
    .secondary-modes .mode-card { padding:16px 13px; }
    .secondary-modes .mode-icon { margin-bottom:12px; }
    .secondary-modes strong { font-size:17px; }
    .welcome-hint { margin-top:20px; font-size:9px; }
    .stages-card { padding:22px 18px; }
    .modal-card h2 { font-size:27px; }
    .stages-description { font-size:11px; margin-bottom:18px; }
    #chapter-tabs { gap:5px; }
    #chapter-tabs button { min-height:51px; font-size:12px; }
    #chapter-tabs button > span:last-child { font-size:9px; }
    #stage-buttons-grid { gap:8px; }
    #stage-buttons-grid button { min-height:70px; }
    .chapter-banner { padding:12px; }
    #chapter-title { font-size:15px; }
    #chapter-desc { font-size:9px; }
    #chapter-star-badge { padding:5px 7px; font-size:11px; }
}
@media(max-width:390px) {
    body { padding-left:10px; padding-right:10px; }
    .game-panel.game-hud { padding:14px; border-radius:20px; }
    .wordmark-small { font-size:19px; }
    .wordmark-small img { width:30px; height:30px; }
    .icon-button { width:35px; height:35px; border-radius:10px; }
    .game-controls { gap:4px; }
    .score-line { margin-top:17px; }
    #hud-score { font-size:35px; }
    #hud-sub-info { font-size:10px; }
    .gauges { gap:13px; }
    .board-shell { padding:7px; border-radius:23px; }
    .tool-button { gap:8px; padding:11px 10px; }
    .tool-symbol { width:30px; height:34px; border-radius:10px; }
    .tool-symbol .icon { width:19px; height:19px; }
    .tool-copy small { font-size:8px; }
    .tool-count { min-width:20px; height:22px; }
    .board-note { font-size:9px; }
    .start-overlay { padding:22px 17px; }
    .welcome-art h1 { font-size:37px; }
    .welcome-actions { padding-left:17px; padding-right:17px; }
    .secondary-modes { gap:9px; }
    .secondary-modes strong { font-size:15px; }
    .secondary-modes .mode-card > span:last-child { font-size:9px; }
    .start-progress { font-size:8px; }
    .stages-card { padding:20px 14px; }
    #stage-buttons-grid { gap:6px; }
    #stage-buttons-grid button { min-height:65px; }
    #stage-buttons-grid button > div:first-child { font-size:8px; }
    .stage-heading-actions { gap:7px; }
    .total-stars { padding:8px; }
    .total-stars .icon { display:none; }
    .stage-bottom-actions .btn-3d { padding:11px 12px; font-size:14px; }
}
@media(max-height:780px) and (max-width:650px) {
    .start-overlay { padding-top:20px; padding-bottom:20px; }
    .welcome-screen { gap:18px; }
    .welcome-art .eyebrow { margin-top:15px; }
    .welcome-art h1 { font-size:36px; }
    .welcome-portraits { max-width:205px; margin-top:9px; margin-bottom:0; }
    .welcome-caption { display:none; }
    .welcome-actions { padding-top:20px; }
    .welcome-actions h2 { margin-bottom:16px; }
    .secondary-modes .mode-icon { margin-bottom:8px; }
    .welcome-hint { margin-top:17px; }
}
@media(prefers-reduced-motion:reduce) {
    *,*::before,*::after { animation-duration:.001ms!important; animation-iteration-count:1!important; transition-duration:.001ms!important; }
}

/* The dialog container itself is only a focus fallback during asset loading. */
.screen-overlay:focus { outline:none; }
/* Keep stage selection useful on compact phones and landscape screens. */
.start-progress { font-size:10px; line-height:1.7; white-space:normal; text-align:center; }
@media(max-width:650px) and (max-height:700px) {
    #modal-stages { padding:12px; }
    .stages-card { max-height:calc(100dvh - 24px); padding:18px 14px; }
    .stages-card .modal-heading h2 { font-size:24px; }
    .stages-description { display:none; }
    #chapter-tabs { margin-top:16px; margin-bottom:12px; }
    #chapter-tabs button { min-height:48px; padding:7px 2px; }
    #chapter-tabs button > span:first-child { font-size:10px; white-space:nowrap; }
    .chapter-banner { margin-bottom:12px; padding:10px; }
    #chapter-title { font-size:13px; }
    #chapter-desc { display:none; }
    .stage-bottom-actions { margin-top:12px; padding-top:12px; }
}

/* Mobile review: larger menu targets without changing game behavior. */
@media(max-width:650px) {
    .icon-button { width:44px; height:44px; min-width:44px; min-height:44px; }
    .wordmark-small { font-size:17px; gap:6px; }
    .wordmark-small img { width:27px; height:27px; }
    .game-controls { gap:3px; }
}

/* Fit the full board and items on short portrait screens. */
@media(max-width:650px) and (max-height:720px) and (orientation:portrait) {
    body { padding-top:max(6px,env(safe-area-inset-top)); padding-bottom:max(6px,env(safe-area-inset-bottom)); }
    .game-app { gap:8px; max-width:min(100%,calc(100dvh - 230px)); }
    .game-panel.game-hud { padding:10px; border-radius:18px; }
    .hud-topline { gap:4px; }
    .score-line { margin:7px 0; }
    .score-main { gap:1px; }
    .metric-label { font-size:10px; }
    #hud-score { font-size:29px; }
    #hud-sub-info { font-size:9px; margin-top:4px; }
    #hud-mode-badge { padding:4px 7px; font-size:11px; }
    #stage-mission-bar { padding:6px 8px; margin-bottom:7px; border-radius:10px; }
    #stage-mission-chips > :first-child { display:none; }
    #stage-mission-chips > span,#stage-mission-chips > div { font-size:10px; padding:3px 5px; }
    #hud-moves-value { font-size:20px; }
    #hud-moves-label { font-size:9px; }
    .moves-stat { min-width:45px; padding-left:8px; }
    .gauges { gap:12px; }
    .tool-button { padding:8px 10px; min-height:49px; }
    .tool-symbol { width:28px; height:30px; }
    .tool-copy strong { font-size:15px; }
    .tool-copy small { display:none; }
    .board-note { display:none; }
}

/* Landscape phones: controls beside a complete, square game board. */
@media(orientation:landscape) and (max-height:500px) and (max-width:1000px) {
    body { padding:12px max(12px,env(safe-area-inset-right)) 12px max(12px,env(safe-area-inset-left)); }
    .desktop-intro { display:none; }
    .game-app { display:grid; grid-template-columns:minmax(190px,1fr) minmax(240px,1.15fr); max-width:720px; gap:12px; align-items:start; }
    .game-panel.game-hud { grid-column:1; grid-row:1; padding:11px; border-radius:18px; }
    .hud-topline { gap:4px; }
    .wordmark-small span { display:none; }
    .wordmark-small img { width:29px; height:29px; }
    .icon-button { width:44px; height:44px; min-width:44px; min-height:44px; }
    .game-controls { gap:3px; }
    .score-line { margin:9px 0; }
    #hud-score { font-size:30px; }
    #hud-sub-info { font-size:9px; margin-top:4px; }
    #stage-mission-bar { padding:7px; margin-bottom:8px; }
    #stage-mission-chips > :first-child { display:none; }
    #stage-mission-chips > span,#stage-mission-chips > div { font-size:10px; padding:3px 5px; }
    #hud-moves-value { font-size:20px; }
    .gauges { gap:9px; }
    .board-shell { grid-column:2; grid-row:1 / span 3; width:100%; max-width:calc(100dvh - 24px); justify-self:center; padding:7px; border-radius:22px; }
    .game-tools { grid-column:1; grid-row:2; gap:8px; }
    .tool-button { padding:10px 8px; gap:7px; }
    .tool-symbol { width:28px; height:30px; }
    .tool-symbol .icon { width:19px; height:19px; }
    .tool-copy strong { font-size:15px; }
    .tool-copy small,.board-note { display:none; }
    .screen-overlay { padding:12px; }
    .stages-card { max-height:calc(100dvh - 24px); padding:14px 18px; }
    .stages-card .modal-heading h2 { font-size:24px; }
    .stages-card .section-kicker,.stages-description,#chapter-desc { display:none; }
    .stage-heading-actions { gap:8px; }
    .total-stars { padding:7px 9px; }
    #chapter-tabs { margin:10px 0; gap:7px; }
    #chapter-tabs button { min-height:44px; padding:5px; font-size:12px; }
    #chapter-tabs button > span:first-child { font-size:11px; white-space:nowrap; }
    #chapter-tabs button > span:last-child { margin-top:1px; font-size:9px; }
    .chapter-banner { padding:8px 11px; margin-bottom:10px; }
    #chapter-title { font-size:14px; }
    #stage-buttons-grid { gap:7px; }
    #stage-buttons-grid button { min-height:65px; }
    .stage-bottom-actions { margin-top:10px; padding-top:10px; }
    .stage-bottom-actions .btn-3d { padding:8px 14px; }
    .modal-card:not(.stages-card) { max-height:calc(100dvh - 24px); overflow-y:auto; padding:20px; }
    .start-overlay { padding:14px 20px; }
    .welcome-screen { display:grid; grid-template-columns:1fr 1.15fr; max-width:730px; gap:32px; }
    .welcome-art { text-align:left; padding:0; }
    .welcome-art .wordmark { justify-content:flex-start; font-size:20px; }
    .welcome-art .eyebrow { margin:18px 0 10px; font-size:9px; }
    .welcome-art h1 { font-size:34px; margin-bottom:10px; }
    .welcome-art h1 br { display:block; }
    .welcome-art h1 em { display:inline; }
    .welcome-description { font-size:11px; }
    .welcome-portraits { max-width:210px; margin:16px 0 0; padding:10px 0; }
    .welcome-caption { display:none; }
    .welcome-actions { padding:18px; border-radius:22px; }
    .welcome-actions h2 { font-size:22px; margin:5px 0 15px; }
    .welcome-actions > .section-kicker { font-size:10px; }
    .mode-stage { padding:16px 12px; gap:10px; }
    .mode-stage .mode-icon { width:34px; height:38px; }
    .mode-copy strong { font-size:21px; }
    .mode-copy small { font-size:9px; }
    .mode-copy > span { font-size:10px; margin-top:5px; }
    .mode-tag { font-size:7px; right:9px; top:8px; }
    .start-progress { margin:12px 0; font-size:9px; }
    .secondary-modes { gap:9px; }
    .secondary-modes .mode-card { padding:12px 10px; }
    .secondary-modes .mode-icon { margin-bottom:9px; }
    .secondary-modes strong { font-size:15px; }
    .secondary-modes .mode-card > span:last-child { font-size:9px; margin-top:5px; }
    .welcome-hint { display:none; }
}
@media(max-width:650px) and (max-height:600px) and (orientation:portrait) {
    .game-panel.game-hud { padding:9px; }
    .game-app { gap:7px; }
    .score-line { margin:5px 0; }
    .game-hud .metric-label,#hud-sub-info { display:none; }
}
@media(orientation:landscape) and (max-height:500px) and (max-width:1000px) {
    .game-app { row-gap:8px; }
}

/* Put the game name in the hero; the joke supports it rather than replacing it. */
.welcome-stamp { display:flex; align-items:center; }
.welcome-stamp img { width:40px; height:40px; border-radius:12px; }
.welcome-art .eyebrow { margin-top:38px; font-size:12px; letter-spacing:2px; }
.welcome-art #start-title { font-size:78px; line-height:1.02; letter-spacing:-3px; margin-bottom:22px; }
.welcome-art #start-title span,.welcome-art #start-title em { display:block; }
.welcome-art .welcome-description { font-family:'Jua',sans-serif; font-size:21px; line-height:1.5; color:#62748b; }
.welcome-art .welcome-description strong { font-weight:400; color:var(--ink); }
.desktop-intro h1 { font-size:34px; letter-spacing:-1px; line-height:1.4; }
@media(max-width:900px) {
    .welcome-art #start-title { font-size:65px; }
}
@media(max-width:650px) {
    .welcome-stamp { justify-content:center; }
    .welcome-stamp img { width:34px; height:34px; }
    .welcome-art .eyebrow { margin-top:20px; margin-bottom:10px; font-size:10px; }
    .welcome-art #start-title { font-size:54px; line-height:1.12; letter-spacing:-2px; margin-bottom:13px; white-space:nowrap; }
    .welcome-art #start-title span,.welcome-art #start-title em { display:inline; }
    .welcome-art .welcome-description { font-size:19px; line-height:1.5; }
    .welcome-art .welcome-description br { display:block; }
    .welcome-portraits { max-width:240px; margin-top:16px; }
}
@media(max-width:390px) {
    .welcome-art #start-title { font-size:48px; }
}
@media(max-width:650px) and (max-height:780px) {
    .welcome-art .eyebrow { margin-top:14px; }
    .welcome-art #start-title { font-size:46px; margin-bottom:10px; }
    .welcome-art .welcome-description { font-size:17px; }
    .welcome-portraits { max-width:205px; margin-top:12px; }
}
@media(orientation:landscape) and (max-height:500px) and (max-width:1000px) {
    .welcome-stamp { justify-content:flex-start; }
    .welcome-stamp img { width:30px; height:30px; }
    .welcome-art .eyebrow { margin:14px 0 10px; font-size:10px; }
    .welcome-art #start-title { font-size:51px; line-height:1.02; margin-bottom:13px; }
    .welcome-art #start-title span,.welcome-art #start-title em { display:block; }
    .welcome-art .welcome-description { font-size:16px; }
    .welcome-portraits { max-width:174px; margin-top:13px; }
}
