:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #101416;
  color: #f4f5f0;
  --ink: #0a1115;
  --panel: #121c22;
  --line: #2b4148;
  --muted: #9da8ab;
  --paper: #f4f5f0;
  --yellow: #ffd45a;
  --red: #ff5c66;
  --teal: #39d0b1;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: radial-gradient(circle at 16% 0%, #17303a 0, #0a1115 38%, #070b0f 100%); overflow: hidden; }
button { font: inherit; letter-spacing: 0; }
button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid #24404a;
  background: rgba(8, 15, 18, .82);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .2);
  position: relative;
  z-index: 4;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  color: var(--paper);
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 11px 3px 11px 3px;
  background: linear-gradient(145deg, #ffe87e, var(--yellow));
  color: var(--ink);
  font-size: 14px;
  font-weight: 950;
  box-shadow: 0 0 0 4px rgba(255, 212, 90, .1), 0 7px 18px rgba(255, 212, 90, .18);
}
.brand b, .brand small { display: block; }
.brand b { font-size: 16px; letter-spacing: .04em; }
.brand small { color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 56vw; }
.top-actions { display: flex; gap: 8px; }
.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(25, 43, 50, .7);
  color: var(--paper);
  cursor: pointer;
  font-size: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 6px 16px rgba(0,0,0,.16);
  transition: transform .18s, border-color .18s, background .18s, box-shadow .18s;
}
.icon-button:hover { border-color: var(--yellow); background: rgba(255, 212, 90, .12); transform: translateY(-2px); box-shadow: 0 9px 20px rgba(0,0,0,.24); }
.icon-button.light { background: transparent; color: var(--ink); border-color: #bbc1bb; }

.game-shell {
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
}
.stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: #0e1a20;
  isolation: isolate;
}
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 0 38%, rgba(57, 208, 177, .045) 38.2% 38.5%, transparent 38.7% 100%), repeating-linear-gradient(0deg, rgba(255,255,255,.018) 0 1px, transparent 1px 4px);
  mix-blend-mode: screen;
}
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  box-shadow: inset 0 0 140px rgba(0, 0, 0, .58);
}
#gameCanvas { position: relative; z-index: 0; display: block; width: 100%; height: 100%; touch-action: none; }

.stage-hud {
  position: absolute;
  top: 18px;
  left: 20px;
  right: 20px;
  display: grid;
  grid-template-columns: minmax(130px, 220px) minmax(130px, 220px) 110px;
  gap: 12px;
  z-index: 4;
  pointer-events: none;
}
.metric, .timer {
  background: linear-gradient(145deg, rgba(25, 45, 52, .9), rgba(8, 17, 21, .9));
  border: 1px solid #37525a;
  border-radius: 12px;
  padding: 9px 11px;
  min-height: 62px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 10px 24px rgba(0,0,0,.22);
}
.metric { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; align-items: center; }
.metric span, .timer span { color: #a8c2c3; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.metric b { font-size: 18px; }
.metric i { grid-column: 1 / -1; display: block; height: 7px; border-radius: 99px; background: #0a1317; overflow: hidden; }
.metric em { display: block; width: 100%; height: 100%; background: var(--teal); transition: width .2s; }
.metric.danger em { width: 0; background: var(--red); }
.timer { text-align: right; }
.timer span, .timer b { display: block; }
.timer b { color: var(--yellow); font-size: 24px; margin-top: 2px; text-shadow: 0 0 18px rgba(255, 212, 90, .35); }
.timer.deadly { border-color: #c33f48; background: linear-gradient(145deg, rgba(70, 24, 29, .96), rgba(24, 12, 16, .96)); animation: death-pulse .8s ease-in-out infinite alternate; }
.timer.deadly span, .timer.deadly b { color: #ff7a80; }
@keyframes death-pulse { from { box-shadow: 0 10px 24px rgba(0,0,0,.18); } to { box-shadow: 0 0 26px rgba(255, 72, 82, .34); } }

.stage-message {
  position: absolute;
  top: 92px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 230px;
  max-width: min(560px, 80%);
  padding: 10px 14px;
  z-index: 3;
  background: rgba(10, 19, 23, .93);
  border: 1px solid #51716f;
  border-left: 5px solid var(--yellow);
  border-radius: 12px;
  color: var(--paper);
  font-size: 13px;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.stage-message.visible { opacity: 1; }
.stage-message.danger { border-color: var(--red); }

.start-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: clamp(28px, 7vw, 90px);
  z-index: 2;
  background: radial-gradient(circle at 16% 56%, rgba(57, 208, 177, .2), transparent 32%), linear-gradient(90deg, rgba(6, 14, 18, .9) 0%, rgba(6, 14, 18, .68) 48%, rgba(6, 14, 18, .06) 100%);
}
.start-panel::before { content: "SAFETY RUN / 01"; position: absolute; top: 17%; left: clamp(28px, 7vw, 90px); padding: 7px 10px; border: 1px solid rgba(255,212,90,.35); border-radius: 7px; color: rgba(255,212,90,.82); background: rgba(255,212,90,.06); font-size: 10px; letter-spacing: .16em; }
.start-panel::after { content: ""; position: absolute; left: clamp(28px, 7vw, 90px); top: 27%; width: 78px; height: 3px; background: var(--yellow); box-shadow: 0 0 18px rgba(255,212,90,.5); }
.start-panel.hidden { display: none; }
.eyebrow { margin: 0 0 10px; color: #9a7920; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.start-panel .eyebrow { color: #e5b942; margin-bottom: 11px; font-size: 11px; text-shadow: 0 0 12px rgba(255,212,90,.18); }
.start-panel h1 { max-width: min(690px, 82vw); margin: 0; font-size: clamp(30px, min(5.2vh, 4.2vw), 58px); line-height: 1.08; letter-spacing: -.035em; overflow-wrap: anywhere; text-wrap: balance; text-shadow: 0 7px 24px rgba(0,0,0,.42); }
.start-panel > p:not(.eyebrow) { max-width: 600px; color: #c9d0d1; font-size: 16px; line-height: 1.7; }
.start-panel #startCopy { display: none; }
.primary-button, .secondary-button {
  min-height: 44px;
  border-radius: 12px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 800;
}
.primary-button { border: 1px solid var(--yellow); background: linear-gradient(135deg, #ffe57a, var(--yellow)); color: var(--ink); }
.primary-button { box-shadow: 0 8px 24px rgba(255, 212, 90, .19); transition: transform .18s, box-shadow .18s, background .18s; }
.primary-button:hover { background: #ffdf77; transform: translateY(-2px); box-shadow: 0 12px 28px rgba(255, 212, 90, .3); }
.secondary-button { border: 1px solid #aab3b5; background: transparent; color: inherit; }
.controls { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 20px; color: #aeb7b9; font-size: 12px; }
.controls span { padding: 6px 9px; border: 1px solid rgba(157,168,171,.2); border-radius: 7px; background: rgba(8,17,21,.34); }
.mobile-control { display: none; }
.rotate-device { display: none; }

.isolate-button {
  position: absolute;
  left: 20px;
  bottom: 20px;
  width: 150px;
  height: 52px;
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-rows: 1fr 1fr;
  align-items: center;
  z-index: 3;
  border: 1px solid #a98b29;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(38, 41, 26, .96), rgba(18, 25, 25, .96));
  color: var(--paper);
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0,0,0,.28);
  transition: transform .18s, border-color .18s;
}
.isolate-button:hover { transform: translateY(-2px); border-color: var(--yellow); }
.isolate-button > span { grid-row: 1 / -1; color: var(--yellow); font-size: 18px; }
.isolate-button b { align-self: end; text-align: left; font-size: 13px; }
.isolate-button small { align-self: start; text-align: left; color: var(--muted); }
.isolate-button:disabled { border-color: #475154; color: #717b7e; cursor: default; }

.operations {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-left: 1px solid #24404a;
  background: linear-gradient(180deg, rgba(15, 29, 35, .98), rgba(8, 15, 18, .98));
  overflow: hidden;
}
.module-progress { padding: 20px; border-bottom: 1px solid var(--line); background: rgba(22, 44, 51, .26); }
.module-progress > div { display: flex; justify-content: space-between; margin-bottom: 10px; }
.module-progress span { color: var(--muted); font-size: 12px; }
.module-progress i { display: block; height: 8px; border-radius: 99px; background: #0a1519; overflow: hidden; }
.module-progress em { border-radius: 99px; box-shadow: 0 0 14px rgba(255, 212, 90, .5); }
.module-progress em { display: block; width: 8.33%; height: 100%; background: var(--yellow); transition: width .25s; }
.module-progress b { color: var(--yellow); font-size: 15px; }
.operation-section { padding: 20px; border-bottom: 1px solid var(--line); }
.operation-section h2 { margin: 0; font-size: 14px; letter-spacing: .08em; }
.operation-section h2::before { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 8px 2px 0; border-radius: 50%; background: var(--teal); box-shadow: 0 0 10px rgba(57,208,177,.55); }
.operation-section dl { margin: 17px 0 0; display: grid; gap: 12px; }
.operation-section dl div { display: flex; justify-content: space-between; align-items: baseline; }
.operation-section dt { color: var(--muted); font-size: 12px; }
.operation-section dd { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.scoreboard-section { padding-bottom: 16px; }
.high-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.high-scores div { padding: 9px 10px; border: 1px solid #30484f; border-radius: 9px; background: rgba(8, 18, 22, .5); }
.high-scores span, .high-scores b { display: block; }
.high-scores span { color: var(--muted); font-size: 10px; }
.high-scores b { margin-top: 4px; color: var(--yellow); font-size: 20px; }
.leaderboard-list { display: grid; gap: 5px; margin: 12px 0 0; padding: 0; list-style: none; counter-reset: ranking; }
.leaderboard-list li { display: grid; grid-template-columns: 24px 1fr auto; gap: 7px; align-items: center; padding: 5px 0; color: #bdc8c9; font-size: 11px; border-top: 1px solid rgba(43, 65, 72, .6); }
.leaderboard-list li::before { counter-increment: ranking; content: counter(ranking); color: var(--yellow); font-weight: 800; }
.leaderboard-list li b { color: var(--paper); font-size: 12px; }
.leaderboard-list li small { color: var(--muted); text-align: right; }
.leaderboard-list li[data-tier="clear"] > span { color: var(--teal); font-weight: 800; }
.leaderboard-list li[data-tier="death"] > span { color: #ff7a80; font-weight: 800; }
.leaderboard-list li[data-tier="high"] > span { color: var(--yellow); font-weight: 800; }
.leaderboard-list li[data-tier="mid"] > span { color: #a9d0c8; }
.leaderboard-list li[data-tier="early"] > span { color: #9da8ab; }
.leaderboard-list li[data-tier="clear"]::before { color: var(--teal); }
.leaderboard-list li[data-tier="death"]::before { color: #ff7a80; }
.leaderboard-list li[data-tier="high"]::before { color: var(--yellow); }
.leaderboard-list li:only-child { grid-template-columns: 1fr; color: var(--muted); }
.leaderboard-list li:only-child::before { content: none; }
.leaderboard-dialog { width: min(520px, calc(100vw - 32px)); }
.leaderboard-dialog-body { padding: 20px 22px 24px; }
.high-scores.large { margin: 0; }
.high-scores.large div { padding: 14px; }
.high-scores.large b { font-size: 30px; }
.leaderboard-dialog .leaderboard-list { margin-top: 18px; }
.leaderboard-dialog .high-scores div { background: #f0f3ee; border-color: #a8b7b0; }
.leaderboard-dialog .high-scores span { color: #687174; }
.leaderboard-dialog .high-scores b { color: #b17800; }
.leaderboard-columns { display: grid; grid-template-columns: 32px 1fr auto 88px; gap: 7px; margin-top: 20px; padding: 0 0 8px; border-bottom: 2px solid #9eaaa4; color: #687174; font-size: 11px; font-weight: 800; }
.leaderboard-columns span:nth-child(3), .leaderboard-columns span:nth-child(4) { text-align: right; }
.leaderboard-dialog .leaderboard-list { gap: 0; margin-top: 0; }
.leaderboard-dialog .leaderboard-list li { grid-template-columns: 32px 1fr auto 88px; gap: 7px; min-height: 50px; padding: 9px 0; color: #485255; border-top: 0; border-bottom: 1px solid #c4ccc7; }
.leaderboard-dialog .leaderboard-list li::before { color: #b17800; }
.leaderboard-dialog .leaderboard-list li b { color: #0a1115; font-size: 14px; }
.leaderboard-dialog .leaderboard-list li small { color: #687174; white-space: nowrap; text-align: right; }
.leaderboard-dialog .leaderboard-list li[data-tier="clear"] > span { color: #147d6e; }
.leaderboard-dialog .leaderboard-list li[data-tier="death"] > span { color: #b33c47; }
.leaderboard-dialog .leaderboard-list li[data-tier="high"] > span { color: #a16b00; }
.leaderboard-dialog .leaderboard-list li[data-tier="mid"] > span { color: #276d63; }
.leaderboard-dialog .leaderboard-list li[data-tier="early"] > span { color: #687174; }
.leaderboard-dialog .leaderboard-list li:only-child { display: block; min-height: auto; padding: 16px 0; }
.incident-feed { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.section-heading { display: flex; justify-content: space-between; align-items: center; }
.section-heading span { color: var(--muted); font-size: 11px; }
.incident-feed ol { min-height: 0; margin: 14px 0 0; padding: 0; list-style: none; overflow-y: auto; }
.incident-feed li { padding: 11px 0; border-top: 1px solid #283033; font-size: 12px; line-height: 1.45; }
.incident-feed li:first-child { border-top: 0; }
.incident-feed li b { display: block; color: var(--yellow); margin-bottom: 3px; }
.incident-feed li.harm b { color: #ff7777; }
.incident-feed .empty-feed { color: #778184; }

dialog {
  border: 0;
  border-radius: 22px;
  padding: 0;
  color: var(--ink);
  background: linear-gradient(145deg, #fbfcf5, #e7ede8);
  box-shadow: 0 22px 70px rgba(0,0,0,.5);
}
dialog::backdrop { background: rgba(5, 8, 9, .78); }
.module-dialog { width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: hidden; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; padding: 22px; border-bottom: 1px solid #ced2ce; }
.dialog-heading h2 { margin: 0; font-size: 24px; }
.module-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 14px; background: #d7dfda; overflow: auto; max-height: calc(100vh - 148px); }
.module-card {
  min-height: 184px;
  padding: 18px;
  border: 1px solid #c3cfca;
  border-radius: 16px;
  background: rgba(251, 252, 245, .88);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.module-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--module-accent, #f3c84b); }
.module-card:hover, .module-card.active { background: #fff8d8; border-color: var(--module-accent, #f3c84b); transform: translateY(-3px); box-shadow: 0 12px 24px rgba(19, 49, 53, .12); }
.module-card span { display: block; color: #687174; font-size: 11px; }
.module-card b { display: block; margin-top: 8px; font-size: 16px; line-height: 1.35; }
.module-card small { display: block; margin-top: 13px; color: #687174; }
.module-card .complete { color: #177c6f; font-weight: 800; }
.module-card .module-select { display: block; width: 100%; min-height: 34px; margin-top: 15px; padding: 7px 10px; border: 1px solid #aebbb5; border-radius: 8px; background: #edf2ed; color: var(--ink); text-align: left; cursor: pointer; font-weight: 800; }
.module-card .module-select:hover { border-color: #177c6f; background: #e0f1eb; }
.module-card .module-learn { display: inline-flex; align-items: center; margin-top: 9px; padding: 0; border: 0; background: transparent; color: #177c6f; cursor: pointer; font-size: 12px; font-weight: 800; }
.module-card .module-learn:hover { color: #0e554c; text-decoration: underline; }
.learn-dialog { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: hidden; }
.learn-content { padding: 20px 22px 24px; overflow-y: auto; max-height: calc(100vh - 126px); }
.learn-intro { margin: 0 0 18px; color: #485255; line-height: 1.6; }
.learn-block { padding: 14px 0; border-top: 1px solid #cbd3ce; }
.learn-block h3 { margin: 0 0 9px; color: #177c6f; font-size: 14px; }
.learn-block ul { margin: 0; padding-left: 19px; color: #485255; line-height: 1.65; }
.learn-block li + li { margin-top: 5px; }
.learn-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 16px; border-top: 1px solid #cbd3ce; }
.learn-footer span { color: #687174; font-size: 11px; }

.result-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; padding: 30px; }
.result-dialog h2 { margin: 0 0 12px; font-size: 27px; }
.result-score { margin: 22px 0; display: flex; align-items: baseline; gap: 10px; }
.result-score strong { font-size: 54px; color: #177c6f; }
.result-dialog.death .result-score strong { color: #d34850; }
.result-dialog.death .eyebrow { color: #c43f48; }
.result-score span { color: #647074; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); border-block: 1px solid #cbd0cc; }
.result-stats div { padding: 15px 8px; border-right: 1px solid #cbd0cc; }
.result-stats div:last-child { border-right: 0; }
.result-stats b, .result-stats span { display: block; }
.result-stats span { margin-top: 3px; color: #697477; font-size: 11px; }
.review-block { margin: 20px 0; padding: 15px; background: #e6e8e3; }
.review-block span { color: #697477; font-size: 11px; }
.review-block p { margin: 8px 0 0; line-height: 1.65; white-space: pre-line; font-size: 14px; }
.result-actions { display: flex; justify-content: flex-end; gap: 9px; }
.result-actions .secondary-button { color: var(--ink); }

@media (max-width: 820px) {
  body { overflow: auto; }
  .game-shell { height: auto; min-height: calc(100vh - 68px); grid-template-columns: 1fr; grid-template-rows: clamp(440px, 66svh, 580px) auto; }
  .operations { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .module-progress, .incident-feed { grid-column: 1 / -1; }
  .scoreboard-section .leaderboard-list { max-height: 120px; overflow-y: auto; }
  .stage-hud { grid-template-columns: 1fr 1fr 88px; }
  .timer { grid-column: auto; position: static; min-height: auto; padding: 7px 10px; }
  .timer span { display: none; }
  .timer b { margin: 0; }
  .stage-message { top: 92px; }
  .module-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .topbar { height: 60px; padding: 0 10px; }
  .brand { gap: 8px; }
  .brand-mark, .icon-button { width: 38px; height: 38px; }
  .brand small { max-width: 30vw; font-size: 11px; }
  .top-actions { gap: 5px; }
  .game-shell { min-height: calc(100svh - 60px); grid-template-rows: clamp(430px, 64svh, 540px) auto; }
  .stage-hud { top: 8px; left: 8px; right: 8px; grid-template-columns: 1fr 1fr 72px; gap: 6px; }
  .metric, .timer { min-height: 48px; padding: 6px 8px; border-radius: 10px; }
  .metric { gap: 4px 8px; }
  .metric span { font-size: 10px; }
  .metric b { font-size: 17px; }
  .metric i { height: 5px; }
  .timer { display: grid; place-items: center; }
  .timer b { font-size: 19px; }
  .stage-message { top: 66px; min-width: 0; width: calc(100% - 24px); max-width: none; padding: 8px 10px; font-size: 12px; }
  .start-panel { padding: 82px 16px 72px; justify-content: center; overflow-y: auto; }
  .start-panel::before, .start-panel::after { display: none; }
  .start-panel h1 { max-width: 100%; font-size: 30px; }
  .start-panel .eyebrow { font-size: 10px; }
  .controls { gap: 7px; margin-top: 14px; }
  .controls span { padding: 5px 7px; font-size: 11px; }
  .desktop-control { display: none; }
  .mobile-control { display: inline-flex; }
  .isolate-button { left: 10px; bottom: 10px; width: 142px; height: 48px; }
  .module-progress { padding: 14px 16px; }
  .operation-section { padding: 16px; }
  .operation-section dl { margin-top: 12px; gap: 8px; }
  .scoreboard-section > .leaderboard-list { display: none; }
  .high-scores { margin-top: 10px; }
  .incident-feed { min-height: 150px; }
  .module-grid { grid-template-columns: 1fr; }
  .module-card { min-height: 164px; }
  .learn-footer { align-items: stretch; flex-direction: column; }
  .learn-footer .primary-button { width: 100%; }
  .result-dialog { padding: 22px; }
  .result-actions { flex-direction: column-reverse; }
  .result-actions button { width: 100%; }

}

body[data-device="mobile"].is-playing { height: 100svh; overflow: hidden; }
body[data-device="mobile"].is-playing .topbar {
  position: fixed;
  top: 8px;
  right: max(8px, env(safe-area-inset-right));
  z-index: 8;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}
body[data-device="mobile"].is-playing .brand,
body[data-device="mobile"].is-playing #leaderboardButton,
body[data-device="mobile"].is-playing #soundButton { display: none; }
body[data-device="mobile"].is-playing .top-actions { display: block; }
body[data-device="mobile"].is-playing #pauseButton {
  width: 38px;
  height: 38px;
  background: rgba(8, 18, 22, .86);
}
body[data-device="mobile"].is-playing .game-shell {
  height: 100svh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 100svh;
}
body[data-device="mobile"].is-playing .stage { height: 100svh; }
body[data-device="mobile"].is-playing .stage-hud {
  top: 8px;
  left: max(8px, env(safe-area-inset-left));
  right: auto;
  width: min(430px, calc(100vw - 70px));
  grid-template-columns: 1fr 1fr 64px;
  gap: 6px;
}
body[data-device="mobile"].is-playing .metric,
body[data-device="mobile"].is-playing .timer {
  min-height: 42px;
  padding: 5px 7px;
  border-radius: 9px;
}
body[data-device="mobile"].is-playing .metric { gap: 2px 6px; }
body[data-device="mobile"].is-playing .metric span { font-size: 9px; }
body[data-device="mobile"].is-playing .metric b,
body[data-device="mobile"].is-playing .timer b { font-size: 16px; }
body[data-device="mobile"].is-playing .metric i { height: 4px; }
body[data-device="mobile"].is-playing .timer {
  display: grid;
  place-items: center;
  position: static;
}
body[data-device="mobile"].is-playing .timer span { display: none; }
body[data-device="mobile"].is-playing .timer b { margin: 0; }
body[data-device="mobile"].is-playing .stage-message { top: 58px; }
body[data-device="mobile"].is-playing .operations {
  display: block;
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 7;
  width: 148px;
  border: 0;
  background: transparent;
  overflow: visible;
}
body[data-device="mobile"].is-playing .operation-section { display: none; }
body[data-device="mobile"].is-playing .module-progress {
  padding: 8px 10px;
  border: 1px solid #52656b;
  border-radius: 12px;
  background: rgba(8, 18, 22, .9);
  box-shadow: 0 8px 22px rgba(0,0,0,.28);
}
body[data-device="mobile"].is-playing .module-progress > div { margin-bottom: 6px; }
body[data-device="mobile"].is-playing .module-progress i { height: 5px; }
body[data-device="mobile"].is-playing .isolate-button {
  left: max(10px, env(safe-area-inset-left));
  bottom: max(10px, env(safe-area-inset-bottom));
  width: 132px;
  height: 44px;
}
body[data-device="mobile"].rotate-required .rotate-device {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px;
  background: rgba(5, 11, 14, .96);
  text-align: center;
}
.rotate-device span { color: var(--yellow); font-size: 54px; line-height: 1; }
.rotate-device b { font-size: 24px; }
.rotate-device small { color: var(--muted); font-size: 13px; }

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