.mode-controls { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.tutorial-button, .level-trigger { display: flex; align-items: center; gap: 9px; height: 40px; padding: 0 12px; color: #aaa; border: 1px solid #333; border-radius: 5px; background: #0b0b0b; cursor: pointer; font-size: 12px; font-weight: 600; }
.tutorial-button svg, .level-trigger svg, .result-levels svg { width: 16px; height: 16px; flex: 0 0 auto; }
.tutorial-button:hover, .level-trigger:hover { color: #fff; border-color: #666; }
.tutorial-button[aria-pressed="true"] { color: #ff8a00; border-color: #685036; }
.level-trigger { width: 148px; justify-content: space-between; color: #eee; }
.level-trigger > span { min-width: 0; white-space: normal; overflow-wrap: anywhere; line-height: 1.3; text-align: left; }
.level-menu { width: min(396px, calc(100% - 32px)); max-height: min(670px, calc(100dvh - 32px)); padding: 0; border: 1px solid #444; border-radius: 8px; background: #111; color: #eee; overflow: hidden; box-shadow: 0 20px 70px #0009; }
.level-menu::backdrop { background: #000b; animation: dialogBackdrop 160ms ease-out; }
.level-menu[open] { animation: sheetEnter 200ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.level-sheet { display: flex; flex-direction: column; max-height: inherit; }
.level-sheet-header { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; padding: 18px 20px 12px; }
.level-sheet-header h2 { margin: 5px 0 0; font-size: 21px; font-weight: 500; }
.level-sheet-header .icon-button { width: 44px; height: 44px; border: 1px solid #333; }
.level-options { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; touch-action: pan-y; padding: 0 12px 12px; }
.level-options button { display: grid; grid-template-columns: 1fr 20px; gap: 5px 12px; align-items: center; width: 100%; min-height: 57px; padding: 10px 12px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: #c8c8c8; text-align: left; cursor: pointer; font-size: 13px; transition: background 120ms, color 120ms, border-color 120ms; }
.level-options button small { color: #8c8c8c; font: 9px ui-monospace, Consolas, monospace; white-space: nowrap; grid-column: 1; }
.level-options button svg { grid-column: 2; grid-row: 1 / 3; width: 16px; height: 16px; opacity: 0; }
.level-options button:hover { background: #222; color: #fff; }
.level-options button[aria-pressed="true"] { background: #e9e9e9; color: #111; }
.level-options button[aria-pressed="true"] small { color: #505050; }
.level-options button[aria-pressed="true"] svg { opacity: 1; }
.level-options button:focus-visible { outline-offset: -3px; }
.level-options .tutorial-option { margin-bottom: 8px; border-bottom-color: #333; }
.level-options .tutorial-option svg { opacity: 0.7; }
.level-sheet-footer { flex: 0 0 auto; padding: 14px 20px 18px; border-top: 1px solid #303030; background: #111; }
.level-sheet-footer p { margin: 0 0 12px; font: 10px/1.5 ui-monospace, Consolas, monospace; color: #999; }
.level-sheet-footer .luma-action { width: 100%; min-height: 48px; font-size: 12px; }
@keyframes sheetEnter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dialogBackdrop { from { background: #0000; } to { background: #000b; } }
.goal-stat { position: relative; }
.goal-track { position: absolute; top: calc(100% + 5px); width: 100%; height: 4px; background: #292929; overflow: hidden; }
.goal-track span { display: block; width: 100%; height: 100%; background: #ff8a00; transform-origin: left; transform: scaleX(0); transition: transform 100ms linear; }
.goal-track i { position: absolute; top: 0; bottom: 0; width: 1px; background: #ddd; transform: translateX(-1px); }
.goal-peak-value { position: absolute; top: calc(100% + 13px); color: #a3a3a3; white-space: nowrap; font: 9px ui-monospace, Consolas, monospace; }
.viewport.has-overlay { touch-action: pan-y; }
.viewport.has-result { isolation: auto; }
.maze-page.has-site-nav > .app-shell { z-index: auto; }
.viewport.has-overlay { isolation: auto; }
.overlay { position: fixed; inset: 0; z-index: 50; background: #000b; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.overlay-card { max-height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; touch-action: pan-y; }
.overlay:not([hidden]) .overlay-card { animation: sheetEnter 200ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.overlay-card:not(.is-result) { width: min(360px, 100%); padding: 24px; }
.overlay-card:not(.is-result) h2 { font-size: 27px; }
.overlay-card:not(.is-result) #overlayText { font-size: 12px; margin-bottom: 18px; }
.pause-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px 0; margin: 0 0 20px; border-top: 1px solid #303030; border-bottom: 1px solid #303030; text-align: left; }
.pause-stats dt { color: #999; font-size: 10px; margin-bottom: 8px; }
.pause-stats dd { margin: 0; color: #eee; font: 20px ui-monospace, Consolas, monospace; }
.pause-stats > div:first-child dd { color: #ff8a00; }
.overlay-card.is-result { width: min(420px, 100%); padding: 22px 24px; text-align: left; }
.is-result h2 { font-size: 24px; margin: 8px 0 6px; }
.is-result #overlayText { font-size: 10px; margin-bottom: 18px; color: #818181; }
.result-reach { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 4px 12px; }
.result-reach > span:first-child { grid-column: 1 / -1; color: #aaa; font-size: 10px; }
.result-reach strong { font: 500 38px/1.2 ui-monospace, Consolas, monospace; color: #f5f5f5; font-variant-numeric: tabular-nums; }
.result-reach strong small { font-size: 18px; color: #999; }
#resultCurrent { padding-bottom: 7px; font: 10px ui-monospace, Consolas, monospace; color: #ff8a00; }
.result-route { position: relative; margin-top: 16px; margin-bottom: 22px; height: 24px; font: 8px ui-monospace, Consolas, monospace; color: #8b8b8b; }
.result-route::before, .route-fill { position: absolute; top: 0; left: 0; right: 0; height: 4px; content: ""; background: #2c2c2c; }
.route-fill { right: auto; background: #f0f0f0; }
.route-now { position: absolute; top: -3px; width: 2px; height: 10px; background: #ff8a00; transform: translateX(-1px); }
.route-floor { position: absolute; top: 0; width: 1px; height: 7px; background: #777; }
.route-floor span { display: block; padding-top: 12px; white-space: nowrap; }
.route-flag { position: absolute; top: -1px; width: 6px; height: 6px; border: 1px solid #777; background: #101010; transform: translateX(-3px) rotate(45deg); }
.route-flag.is-saved { border-color: #ff8a00; background: #ff8a00; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; margin: 0 0 18px; padding: 13px 0; gap: 8px; border-top: 1px solid #303030; border-bottom: 1px solid #303030; }
.result-stats dt { font: 9px ui-monospace, Consolas, monospace; color: #777; margin-bottom: 6px; }
.result-stats dd { font: 13px ui-monospace, Consolas, monospace; margin: 0; color: #ddd; }
.result-map-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.result-map-heading > span { font-size: 10px; color: #aaa; flex: 0 0 auto; }
.result-floors { display: flex; min-width: 0; overflow-x: auto; scrollbar-width: thin; touch-action: pan-x; }
.result-floors button { height: 44px; min-width: 44px; padding: 0; border: 0; border-bottom: 1px solid transparent; background: transparent; color: #777; font: 10px ui-monospace, Consolas, monospace; cursor: pointer; }
.result-floors button[aria-pressed="true"] { color: #eee; border-color: #ff8a00; }
.result-floors button:disabled { color: #393939; cursor: default; }
#resultMap { width: 100%; height: 96px; display: block; background: #080808; border: 1px solid #292929; }
.result-map-key { display: flex; align-items: center; gap: 16px; margin: 9px 0 20px; font-size: 9px; color: #888; }
.result-map-key span { display: flex; align-items: center; gap: 5px; }
.result-map-key i { display: inline-block; width: 5px; height: 5px; border-radius: 50%; }
.key-current { background: #ff8a00; }
.key-peak { border: 1px solid #fff; }
.result-actions { display: flex; gap: 10px; align-items: center; justify-content: center; }
.is-result .result-actions { justify-content: space-between; }
.result-levels { display: flex; gap: 6px; align-items: center; padding: 0 8px; height: 44px; border: 0; border-radius: 4px; color: #aaa; background: transparent; font-size: 11px; cursor: pointer; }
.result-levels:hover { color: #fff; background: #222; }
.is-result .luma-action { min-width: 150px; padding-left: 16px; padding-right: 16px; }
.is-result .sound-control { margin: 12px 0 -8px auto; }
.tutorial-goals { position: absolute; z-index: 2; left: 50%; bottom: calc(var(--control-height, 0px) + 16px); transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid #252525; border-radius: 4px; background: #080808ed; color: #5d5d5d; font-size: 10px; white-space: nowrap; pointer-events: none; }
.tutorial-goals span[data-state="current"] { color: #ff8a00; }
.tutorial-goals span[data-state="done"] { color: #ddd; }
.tutorial-target { position: absolute; top: 0; left: 0; z-index: 1; width: 16px; height: 16px; border: 1px solid #ff8a0099; border-radius: 50%; pointer-events: none; }
.tutorial-target::after { content: ""; position: absolute; inset: 4px; border: 1px solid #ff8a00; border-radius: 50%; animation: targetPulse 1.4s ease-in-out infinite; }
@keyframes targetPulse { 50% { opacity: 0.35; transform: scale(0.75); } }
.tutorial-target.is-paused::after { animation-play-state: paused; }
button { -webkit-tap-highlight-color: transparent; }
:lang(ja) :is(.world-meta, .stage-hud, .world-label, .floor-status, .checkpoint-toast, .map-heading, .overlay-eyebrow, .overlay-card p, .footer, .level-options button small, .level-sheet-footer p, .goal-peak-value, #resultCurrent, .result-route, .result-stats dt, .result-stats dd, .result-floors button) {
  font-family: ui-monospace, Consolas, "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}
@media (max-width: 1100px) { .attempt-stat { display: none !important; } .toolbar { gap: 12px; } .stats { gap: 20px; } }
@media (max-width: 760px) {
  .toolbar { height: 110px; }
  .best-stat { display: none !important; }
  .stats { gap: 14px; }
  .mode-controls { gap: 6px; }
  .tutorial-button { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .tutorial-button span { display: none; }
  .level-trigger { width: 150px; height: 44px; font-size: 12px; }
  .level-menu { width: 100%; max-width: none; max-height: calc(100dvh - max(12px, env(safe-area-inset-top))); margin: auto 0 0; border-radius: 8px 8px 0 0; border-bottom: 0; }
  .level-sheet-header { padding: 14px 18px 10px; }
  .level-sheet-footer { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .tools .icon-button, .tools .luma-action { min-height: 44px; }
  .viewport:focus-visible { outline: none; }
  .overlay-card.is-result { padding: 18px 16px; }
  .is-result .luma-action { min-width: 140px; height: 44px; font-size: 11px; }
  .is-result #overlayText { margin-bottom: 12px; }
  .result-reach strong { font-size: 32px; }
  .result-stats { padding: 10px 0; margin-bottom: 8px; }
  .result-stats dd { font-size: 12px; }
  .result-map-heading { gap: 5px; }
  #resultMap { height: 76px; }
  .result-map-key { gap: 10px; margin-bottom: 14px; font-size: 8px; }
}
@media (max-width: 360px) { .stats { gap: 8px; } }
@media (any-pointer: coarse) { .tools .icon-button, .tools .luma-action, .tutorial-button, .level-trigger { min-height: 44px; } }
@media (max-height: 650px) {
  .overlay-card.is-result { padding: 16px; }
  .is-result h2 { font-size: 20px; margin: 6px 0; }
  .is-result #overlayText { font-size: 9px; margin-bottom: 10px; }
  .result-reach strong { font-size: 30px; }
  .result-route { margin-top: 10px; margin-bottom: 8px; }
  .result-stats { padding: 8px 0; margin-bottom: 6px; }
  .result-map-key { margin-top: 7px; margin-bottom: 12px; }
  .is-result .sound-control { display: none; }
}
@media (max-height: 500px) and (min-width: 600px) {
  .tutorial-button { width: 40px; padding: 0; justify-content: center; }
  .tutorial-button span { display: none; }
  .level-trigger { height: 40px; width: 150px; }
  .world-meta { display: none; }
  .best-stat { display: none !important; }
  .stats { padding-right: 170px; }
  .overlay-card.is-result { padding: 14px 18px; width: min(660px, 100%); }
  .is-result h2 { font-size: 20px; }
  .run-result { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
  .result-map-heading { grid-column: 2; grid-row: 1; }
  #resultMap { grid-column: 2; grid-row: 2 / 4; height: 76px; }
  .result-map-key { grid-column: 2; grid-row: 4; margin: 0; }
  .result-stats { grid-column: 1; margin: 0 0 10px; }
  .result-route { margin-top: 10px; margin-bottom: 10px; }
  .result-reach strong { font-size: 30px; }
  .is-result .sound-control { display: none; }
  .is-result .result-actions { justify-content: flex-start; }
}
