/* Layers: #bg photo / grid (z0) → #gl single WebGL canvas (z1) → #app DOM UI (z2).
   Areas that show 3D are transparent placeholders (.view-slot); never put an opaque fill over them. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--navy-950); color: var(--text); font-family: var(--font); font-size: 16px; -webkit-font-smoothing: antialiased; overflow: hidden; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
button, input { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .42; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.digits { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

#bg { position: fixed; inset: 0; z-index: 0; background: var(--grid-bg); }
body[data-screen=menu] #bg { background: url(../assets/menu-duel.webp) center / cover no-repeat, var(--navy-900); }
body[data-screen=level] #bg { background: #101922; }
body[data-screen=level] #bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(rgba(7, 26, 48, .28), rgba(7, 26, 48, 0) 30%); }
@media (orientation: portrait) { body[data-screen=menu] #bg { background-image: url(../assets/menu-duel-mobile.webp); } }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; display: block; }
#boot { position: fixed; inset: 0; z-index: 3; display: grid; place-items: center; font-size: 18px; color: var(--text-dim); background: var(--grid-bg); }
#app { position: fixed; inset: 0; z-index: 2; display: grid; grid-template-rows: var(--header-h) minmax(0, 1fr); padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }

/* Blueprint panel: the element's own fill is the outline colour; ::before is the inner grid fill.
   Two clip-paths keep the outline continuous along the chamfered corners. */
.bp, .btn, .icon-btn { position: relative; isolation: isolate; clip-path: var(--chamfer); }
.bp { background: var(--line-soft); padding: 16px 18px; }
.bp::before, .btn::before, .icon-btn::before { content: ''; position: absolute; inset: 1.5px; z-index: -1; clip-path: var(--chamfer); background: var(--grid-bg); }
.bp { box-shadow: var(--shadow); }

.btn { --cut: 9px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; padding: 10px 24px; border: 0; background: var(--line-soft); font-size: 17px; font-weight: 700; letter-spacing: .04em; }
.btn::before { background: rgba(11, 34, 64, .9); }
.btn-primary { background: var(--red-line); color: #fff; }
.btn-primary::before { background: linear-gradient(var(--red), var(--red-deep)); }
.btn-primary::after { content: '////'; position: absolute; right: 14px; bottom: 5px; font-size: 9px; letter-spacing: 1px; opacity: .65; }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn:focus-visible::before, .icon-btn:focus-visible::before, .piece:focus-visible { box-shadow: inset 0 0 0 3px var(--gold); }
.btn:focus-visible, .icon-btn:focus-visible { outline: none; }
.text-btn { background: none; border: 0; color: var(--text-dim); text-decoration: underline; text-underline-offset: 4px; min-height: 44px; padding: 6px 4px; font-size: 16px; }
.text-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.icon-btn { --cut: 8px; display: grid; place-items: center; width: 46px; height: 46px; border: 0; background: var(--line-soft); }
.chip { padding: 6px 12px; border: 1px solid var(--line-soft); border-radius: 999px; font-size: 16px; color: var(--text-dim); white-space: nowrap; }
.fine { font-size: 16px; color: var(--text-dim); line-height: 1.6; margin: 8px 0 0; }
.warn { font-size: 16px; color: #ffd28a; margin: 8px 0 0; }

/* Header */
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px max(16px, env(safe-area-inset-right)) 8px 16px; background: linear-gradient(rgba(7, 26, 48, .96), rgba(11, 34, 64, .92)); border-bottom: 1.5px solid var(--line-soft); }
.logo { display: block; height: 42px; padding: 5px 10px; background: #fff; border-radius: 6px; }
.bp-title { --cut: 10px; display: flex; align-items: center; gap: 14px; padding: 6px 18px; box-shadow: none; }
.bp-title h1 { margin: 0; font-size: 22px; letter-spacing: .06em; font-weight: 800; white-space: nowrap; }
.level-no { font-size: 22px; font-weight: 300; color: var(--line); border-left: 1px solid var(--line-soft); padding-left: 12px; }
.phase-name { flex: 1; margin: 0; color: var(--text-dim); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.screen { position: relative; min-height: 0; overflow: hidden; }

/* Menu */
.menu-panel { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: min(400px, calc(100vw - 40px)); padding: 28px 30px; }
.eyebrow { margin: 0 0 6px; font-size: 16px; letter-spacing: .28em; color: var(--line); }
.menu-panel h2 { margin: 0 0 22px; font-size: 44px; line-height: 1.12; font-weight: 800; letter-spacing: .04em; }
.menu-panel h2 span { color: var(--line); }
.menu-list { display: grid; gap: 10px; }
.menu-list .btn { justify-content: flex-start; text-align: left; }
.menu-list a.btn,.menu-list a.btn:visited { color:var(--text); text-decoration:none; }
.menu-list small { font-size: 16px; font-weight: 500; opacity: .8; min-width: 48px; }
.menu-list em { margin-left: auto; font-style: normal; font-size: 16px; font-weight: 500; color: var(--text-dim); }
.menu-start { min-height: 64px; font-size: 22px; }
.menu-progress { color: var(--text-dim); margin: 16px 0 0; font-size: 16px; }
.edition { position: absolute; right: 18px; bottom: 12px; margin: 0; font-size: 16px; color: rgba(238, 245, 252, .75); text-shadow: 0 1px 3px #0009; }
.certificate-layer:not([hidden]) { position:fixed; inset:0; z-index:30; display:grid; place-items:center; padding:18px; background:#06172beF; overflow:auto; }
.certificate-card { width:min(560px,100%); padding:clamp(22px,4vw,40px); color:#102c48; background:#f4f8fb; border:4px solid #bb8c2f; box-shadow:0 12px 40px #0007; }
.certificate-card h2 { margin:0; font-size:clamp(28px,5vw,44px); color:#0b3155; }.certificate-card h3 { font-size:19px; }
.certificate-name { font-size:24px; font-weight:800; color:#a32630; }.certificate-card dl { display:grid; grid-template-columns:1fr 1fr; gap:10px; font-size:18px; }.certificate-card dd { margin:0; font-weight:700; }.certificate-card li { padding:5px 0; font-size:16px; }
.certificate-card .text-btn { color:#234e72; }
.trail-choices { display:flex; flex-wrap:wrap; gap:6px; }.trail-choices button { min-width:44px; min-height:44px; padding:6px 12px; border:1px solid #285678; background:#e6f0f6; color:#102c48; }.trail-choices button[aria-pressed=true] { background:#20547d; color:white; }

/* Level: workbench */
.bench { position: absolute; inset: var(--gap); display: grid; grid-template-columns: minmax(300px, 43%) minmax(0, 1fr); gap: var(--gap); }
.tray { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: auto; }
.tray h2 { margin: 0; font-size: 18px; letter-spacing: .06em; }
.tray h2 small { display: block; font-size: 16px; font-weight: 400; color: var(--text-dim); letter-spacing: 0; margin-top: 3px; }
.part-group { display: grid; gap: 6px; }
.part-group h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.tag { font-size: 16px; font-weight: 500; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-soft); color: var(--text-dim); }
.tag-hot { border-color: var(--red-line); color: #ffd7dc; background: rgba(193, 31, 51, .3); }
.pieces { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.piece { position: relative; display: grid; grid-template-rows: 1fr auto; justify-items: center; min-height: 92px; padding: 6px 4px 7px; border: 1px solid var(--line-soft); border-radius: 8px; background: rgba(7, 26, 48, .5); touch-action: none; transition: border-color .15s, background .15s; }
.piece img { width: 100%; height: 100%; max-height: 74px; object-fit: contain; pointer-events: none; -webkit-user-drag: none; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .45)); }
.piece span { font-size: 16px; font-weight: 600; }
.piece[aria-pressed=true] { border: 2px solid var(--lime); background: rgba(22, 59, 102, .85); }
.piece[aria-pressed=true]::after { content: '✓'; position: absolute; top: 4px; right: 7px; color: var(--lime); font-weight: 800; }
.piece.locked { opacity: .55; }
.drag-ghost { position: fixed; z-index: 10; width: 110px; height: 90px; pointer-events: none; transform: translate(-50%, -50%) scale(1.1); filter: drop-shadow(0 12px 12px rgba(0, 0, 0, .5)); }
.drag-ghost img { width: 100%; height: 100%; object-fit: contain; }

.station { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; justify-items: center; align-items: center; min-height: 0; gap: 8px; border: 2px dashed transparent; border-radius: 12px; transition: border-color .15s; }
.station.over { border-color: var(--lime); background: rgba(140, 198, 63, .08); }
.steps { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; }
.steps li { --cut: 7px; display: flex; align-items: center; gap: 7px; padding: 7px 12px; clip-path: var(--chamfer); background: rgba(7, 26, 48, .78); font-size: 16px; font-weight: 600; color: var(--text-dim); }
.steps li b { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid currentColor; font-size: 16px; }
.steps li span { font-weight: 400; font-size: 16px; }
.steps li.next { color: #fff; background: var(--red-deep); }
.steps li.done { color: var(--lime); }
.ready-view { width: 100%; height: 100%; min-height: 180px; }
.ready-hint { margin: 0; padding: 7px 14px; border-radius: 6px; background: rgba(7, 26, 48, .78); font-size: 16px; text-align: center; }
.station-actions { display: flex; gap: 12px; }
.station-actions .btn-primary { min-width: 180px; }

/* Level: play */
.play-view { position: absolute; inset: 0; }
body:not([data-phase=choose]) .bench { display: none; }
body[data-phase=choose] .play-view { display: none; }
.rig { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.rig img { position: absolute; left: 0; top: 0; max-width: none; height: auto; transform-origin: 0 0; will-change: transform; }
#leftHand { z-index: 2; }
.launch-panel { --cut: 12px; position: absolute; left: 0; top: 0; width: 220px; padding: 14px 16px 12px; text-align: center; }
#countdown { display: block; font-size: 38px; font-weight: 800; line-height: 1.1; margin-bottom: 10px; }
.gauge { position: relative; height: 22px; background: #4f6b87; border-radius: 3px; overflow: hidden; }
#goodZone { position: absolute; top: 0; bottom: 0; background: var(--ok); }
#perfectZone { position: absolute; top: 0; bottom: 0; background: var(--lime); }
#needle { position: absolute; top: -2px; bottom: -2px; width: 4px; margin-left: -2px; background: #fff; box-shadow: 0 0 0 1px var(--navy-950); left: 0; }
.gauge-labels { display: flex; justify-content: space-between; font-size: 16px; color: var(--text-dim); margin: 5px 0 10px; }
.launch-panel .btn { width: 100%; font-size: 22px; min-height: 56px; }
.launch-panel .hint { margin: 6px 0 0; font-size: 16px; color: var(--text-dim); }

.timer-hud { --cut: 12px; position: absolute; top: 14px; right: 14px; min-width: 190px; padding: 10px 18px 12px; text-align: right; }
.timer-hud span { display: block; font-size: 16px; color: var(--text-dim); letter-spacing: .1em; }
.timer-hud strong { display: block; font-size: 52px; font-weight: 700; line-height: 1.05; }
.timer-hud small { font-size: 20px; font-weight: 500; margin-left: 2px; }
.timer-hud em { display: block; font-style: normal; font-size: 16px; color: var(--text-dim); }

.callout { --cut: 12px; position: absolute; right: 14px; bottom: 14px; display: flex; align-items: center; gap: 14px; width: 330px; padding: 12px 16px; }
.callout-lens { flex: none; width: 112px; height: 112px; border-radius: 50%; border: 2px solid var(--line); background: radial-gradient(circle at 50% 40%, #e9eef3, #a9b6c3 70%, #6d7e90); overflow: hidden; display: grid; place-items: center; }
.callout-lens img { width: 100%; height: 100%; object-fit: cover; }
.callout-body { display: grid; gap: 3px; min-width: 0; }
.callout-body strong { font-size: 24px; letter-spacing: .06em; }
.callout-body span { font-size: 16px; color: var(--text-dim); }
.dims { width: 120px; height: 56px; stroke: var(--line); stroke-width: 1; opacity: .8; }

.message { --cut: 10px; position: absolute; left: 14px; bottom: 14px; max-width: min(46%, 520px); margin: 0; padding: 10px 16px; font-size: 16px; line-height: 1.5; }
body[data-phase=choose] .message, .message:empty { display: none; }
.shade { position: absolute; inset: 0; background: rgba(4, 14, 28, .35); }
.sheet { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(440px, calc(100% - 28px)); max-height: calc(100% - 28px); overflow: auto; padding: 8px 22px 18px; }
.sheet-handle { display: grid; place-items: center; width: 100%; min-height: 44px; background: none; border: 0; padding: 0; }
.sheet-handle span { display: block; width: 44px; height: 4px; margin: 0 auto; border-radius: 2px; background: var(--line-soft); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 22px; }
.sub { margin: 4px 0 0; color: var(--text-dim); }
.score { font-size: 64px; font-weight: 800; line-height: 1.1; margin-top: 6px; }
.score small { font-size: 22px; font-weight: 500; margin-left: 4px; }
.grade { margin: 0 0 4px; font-weight: 600; color: var(--line); }
#stats { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 8px 0; font-size: 16px; }
#stats dt { color: var(--text-dim); }
#stats dd { margin: 0; font-weight: 600; }
.history p { margin: 2px 0; font-size: 16px; color: var(--text-dim); }
.sheet-actions { display: flex; gap: 10px; margin-top: 12px; }
.sheet-actions .btn { flex: 1; padding-inline: 12px; }
.show-result { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); }

/* Replay */
#replayScreen { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 12px; padding: 14px; }
.replay-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.replay-head h2 { margin: 0; font-size: 22px; letter-spacing: .04em; }
.segmented { display: flex; padding: 3px; gap: 3px; border: 1px solid var(--line-soft); border-radius: 8px; background: rgba(7, 26, 48, .6); }
.segmented button { min-height: 44px; padding: 6px 16px; border: 0; border-radius: 6px; background: none; font-weight: 600; }
.segmented button[aria-pressed=true] { background: var(--navy-700); box-shadow: inset 0 0 0 1px var(--line); }
.src-hint { font-size: 16px; color: var(--text-dim); }
.replay-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; min-height: 0; }
.replay-card { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; padding: 0; background: none; box-shadow: none; clip-path: none; border: 1.5px solid var(--line-soft); border-radius: 4px; }
.replay-card::before { display: none; }
.replay-card h3 { margin: 0; padding: 10px 14px; font-size: 17px; background: rgba(7, 26, 48, .82); border-bottom: 1px solid var(--line-soft); }
.replay-card h3 small { font-size: 16px; font-weight: 400; color: var(--text-dim); margin-left: 6px; }
.replay-view { min-height: 160px; }
.replay-card .status { justify-self: start; margin: 0 10px 10px; padding: 4px 10px; border-radius: 999px; font-size: 16px; background: rgba(7, 26, 48, .82); border: 1px solid var(--line-soft); }
.replay-controls { display: grid; grid-template-columns: auto minmax(120px, 1fr) auto; align-items: center; gap: 8px 16px; padding: 12px 16px; }
#replayTime { font-size: 20px; font-weight: 700; min-width: 128px; }
#replaySeek { width: 100%; accent-color: var(--red); height: 44px; }
.replay-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.replay-buttons .btn { min-height: 46px; padding: 8px 16px; font-size: 16px; }
.replay-controls .fine { grid-column: 1 / -1; margin: 0; }

#debug { position: fixed; z-index: 20; left: 8px; top: 72px; padding: 8px 10px; background: rgba(0, 0, 0, .72); color: #9effa8; font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; white-space: pre; pointer-events: none; }

/* Tablet portrait and phones */
@media (max-width: 900px) and (orientation: portrait), (max-width: 700px) {
  .bench { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .tray { overflow: visible; }
  .phase-name { display: none; }
  .callout { width: auto; left: 14px; right: auto; bottom: auto; top: 14px; padding: 8px 12px; gap: 10px; }
  .callout-lens { width: 72px; height: 72px; }
  .callout-body strong { font-size: 18px; }
  .dims { display: none; }
  .message { max-width: calc(100% - 28px); bottom: 84px; }
}
@media (max-width: 700px) {
  body { font-size: 16px; }
  .logo { height: 34px; padding: 4px 7px; }
  .bp-title { padding: 4px 12px; }
  .bp-title h1 { font-size: 17px; }
  .level-no, #progressChip { display: none; }
  .icon-btn { width: 44px; height: 44px; }
  .menu-panel { padding: 22px; }
  .menu-panel h2 { font-size: 34px; }
  .bench { inset: 8px; gap: 8px; }
  .tray { padding: 10px 12px; gap: 6px; }
  .tray h2 small { display: none; }
  .piece { min-height: 70px; }
  .piece img { max-height: 50px; }
  .steps li { padding: 5px 8px; font-size: 16px; }
  .steps li span { display: none; }
  .timer-hud { min-width: 0; padding: 6px 12px 8px; }
  .timer-hud strong { font-size: 34px; }
  .launch-panel { width: 168px; padding: 10px 12px; }
  #countdown { font-size: 28px; }
  .launch-panel .btn { min-height: 48px; font-size: 19px; }
  #replayScreen { overflow: auto; display: block; }
  .replay-head, .replay-controls { margin-bottom: 10px; }
  .replay-grid { grid-template-columns: 1fr; }
  .replay-view { height: 240px; }
  .replay-card { margin-bottom: 10px; }
  .replay-controls { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (orientation:portrait) {
 .menu-panel { padding:16px 20px; }
 .menu-panel h2 { font-size:clamp(25px,4vw,34px); margin-bottom:10px; }
 .menu-panel h2 br { display:none; }
 .menu-list { grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
 .menu-list .btn { min-height:48px; padding:6px 8px; justify-content:center; text-align:center; }
 .menu-list #startLevel,.menu-list a[href*="level=2"] { flex-direction:column; gap:1px; min-height:58px; }
 .menu-list small { min-width:0; }
 .menu-progress { margin:6px 0 0; }
}
@media (orientation:portrait) and (max-width:700px) { body[data-screen=menu] #bg { background-size:auto 110%; } }

/* Cover: the hall is the shared canvas view beneath this transparent menu. */
body[data-screen=menu] #bg { background:#e9e2d2; }
body[data-screen=menu] #app { display:block; padding:0; }
body[data-screen=menu] #app>.topbar { position:fixed; z-index:4; top:12px; right:12px; padding:6px 14px; background:#fff; border:0; }
body[data-screen=menu] #app>.topbar>*:not(.brand) { display:none; }
body[data-screen=menu] #app>.topbar .logo { height:36px; padding:0; }
body[data-screen=menu] #menuScreen { height:100%; }
body[data-screen=menu] .menu-panel { position:absolute; inset:0; transform:none; width:auto; padding:clamp(58px,8vh,84px) 16px clamp(14px,3vh,30px); display:flex; flex-direction:column; align-items:center; justify-content:space-between; background:linear-gradient(#ffffffe0 0,#ffffffb0 24%,#fff0 42%,#fff0 60%,#061022d0 100%); clip-path:none; box-shadow:none; pointer-events:none; }
body[data-screen=menu] .menu-panel::before { display:none; }
body[data-screen=menu] .menu-panel>* { pointer-events:auto; }
body[data-screen=menu] .menu-title { margin:0; }
body[data-screen=menu] .menu-foot { display:flex; flex-direction:column; align-items:center; gap:10px; width:min(860px,100%); }
body[data-screen=menu] .menu-panel h2 { margin:0; text-align:center; line-height:1.02; font-weight:900; font-size:clamp(50px,min(9.2vw,13vh),124px); letter-spacing:.02em; color:#c0141f; paint-order:stroke fill; -webkit-text-stroke:clamp(8px,1.1vw,14px) #fff; filter:drop-shadow(0 8px 10px #0005); }
body[data-screen=menu] .menu-panel h2 span { display:block; color:#14181f; }
.cover-tag { margin:6px 0 0; text-align:center; font-weight:900; font-size:clamp(17px,2vw,26px); color:#0b2a5c; paint-order:stroke fill; -webkit-text-stroke:5px #fff; }
body[data-screen=menu] #contestCountdown { margin:0; padding:6px 18px; background:#e5ce60; color:#14181f; font-weight:900; font-size:clamp(17px,1.9vw,23px); }
body[data-screen=menu] .menu-list { display:grid; grid-template-columns:1fr 1fr; gap:10px; width:min(860px,100%); }
body[data-screen=menu] .menu-list .btn { justify-content:center; text-align:center; }
body[data-screen=menu] .menu-start,body[data-screen=menu] .menu-second { min-height:clamp(66px,11vh,92px); font-size:clamp(23px,2.8vw,34px); flex-direction:column; gap:0; }
body[data-screen=menu] #app .menu-start strong,body[data-screen=menu] #app .menu-second strong { font-size:clamp(26px,2.8vw,34px); }
body[data-screen=menu] #app .menu-list small { font-size:17px; }
body[data-screen=menu] #app .menu-list a:not(.menu-second),body[data-screen=menu] #app .menu-list #certificateBtn,body[data-screen=menu] #app .menu-list #menuReplay { font-size:18px; }
body[data-screen=menu] .menu-second::before { background:linear-gradient(110deg,#0b6b3e,#0b2a5c); }
body[data-screen=menu] #menuProgress { margin:0; }

@media(min-width:901px) {
  .chip,.menu-list small,.menu-list em,.edition,.tag,.piece span,.steps li span,.steps li b { font-size:16px; }
  .fine,.warn,.tray h2 small { font-size:16px; }
  #app p,#app small,#app span,#app button,#app a { font-size:max(16px,1em); }
}

/* Legacy assembly and replay retain one spoken guidance box per screen. */
.legacy-bench-message { width:min(100%,520px); }
.legacy-bench-message .ready-hint { background:transparent; padding:0; color:#0b2240; }
.legacy-message { position:absolute; left:14px; top:14px; width:min(36%,420px); z-index:2; }
body[data-phase=choose] .legacy-message { display:none; }
.replay-message { width:100%; }
@media (orientation:portrait) { .legacy-message { width:calc(100% - 28px); } }

/* Keep the legacy play message in a reserved row above the arena and launch controls. */
body[data-screen=level]:not([data-phase=choose]) #levelScreen { display:grid; grid-template-columns:minmax(0,1fr); grid-template-rows:auto minmax(0,1fr); }
body[data-screen=level]:not([data-phase=choose]) .legacy-message { position:relative; left:auto; top:auto; width:auto; max-width:none; grid-column:1; grid-row:1; margin:8px 14px 18px; }
body[data-screen=level]:not([data-phase=choose]) #playView,body[data-screen=level]:not([data-phase=choose]) #rig { position:relative; inset:auto; grid-column:1; grid-row:2; width:100%; height:100%; min-height:0; }
body[data-screen=level]:not([data-phase=choose]) #launchPanel { position:relative; left:auto; top:auto; grid-column:1; grid-row:2; justify-self:start; align-self:start; }
body[data-screen=level]:not([data-phase=choose]) #timerHud { position:relative; top:auto; right:auto; grid-column:1; grid-row:2; justify-self:end; align-self:start; }
body[data-screen=level]:not([data-phase=choose]) #callout { position:relative; inset:auto; grid-column:1; grid-row:2; justify-self:end; align-self:end; }
body[data-screen=level]:not([data-phase=choose]) #resultShade { position:relative; inset:auto; grid-column:1; grid-row:2; }
body[data-screen=level]:not([data-phase=choose]) #resultSheet { position:relative; left:auto; bottom:auto; transform:none; grid-column:1; grid-row:2; justify-self:center; align-self:end; max-height:100%; }

/* The laboratory and forthcoming competition are separate modes. */
body[data-screen=menu] #app .menu-second strong { font-size:clamp(18px,2.5vw,30px); }
body[data-screen=menu] .menu-second:disabled { opacity:.68; }
body[data-screen=menu] .menu-second:disabled::before { background:linear-gradient(110deg,#334c5c,#24354e); }
@media(max-width:480px) { body[data-screen=menu] #app .menu-list small { font-size:13px; } body[data-screen=menu] #app .menu-start strong { font-size:clamp(21px,6vw,28px); } }
