/* Shared screen layout for the browser and offline Android game. */
body { overflow: hidden; }
.shell {
  height: 100dvh;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 0px) max(18px, 4vw, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(18px, 4vw, env(safe-area-inset-left, 0px));
}
.topbar { height: 62px; min-height: 0; flex: 0 0 62px; }
.brand { font-size: 18px; gap: 10px; }
.brand-mark { width: 30px; height: 30px; font-size: 26px; }
.build-tag { font-size: 10px; }
.game-wrap { padding: 14px 0 0; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.play-screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* The opening has one primary action. Gameplay is hidden and inert here. */
.welcome {
  position: relative;
  isolation: isolate;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  padding: clamp(24px, 6vw, 80px);
  overflow: auto;
  border: 1px solid #34404a;
  border-radius: 16px;
  background: radial-gradient(ellipse at 90% 90%, #33443866, transparent 60%), #18212b;
}
.welcome-copy { position: relative; z-index: 1; width: 100%; max-width: 600px; }
.welcome-kicker { color: #b6c5a4; font-size: 11px; letter-spacing: 1.4px; }
.welcome h1 { display: block; font: 500 clamp(42px, 5.8vw, 78px)/1.02 'Space Grotesk', sans-serif; letter-spacing: -3px; margin: 28px 0 18px; }
.welcome h1 em { color: var(--lime); font-style: normal; }
.welcome-line { margin: 0; color: #afbdc7; font-size: 17px; line-height: 1.5; }
.welcome-actions { margin-top: 36px; max-width: 330px; }
.welcome .primary-btn { width: 100%; min-height: 60px; font-size: 17px; gap: 16px; }
.welcome .primary-btn #start-label { font-size: inherit; }
.welcome-resume { min-height: 18px; margin: 10px 0 4px; color: #b7c2cb; font-size: 12px; line-height: 1.5; }
.welcome-resume:empty { min-height: 0; margin: 0; }
.welcome-menu { width: 100%; display: flex; justify-content: space-between; align-items: center; min-height: 48px; margin-top: 12px; padding: 10px 3px; background: transparent; border: 0; color: #aebbc4; font-size: 14px; }
.welcome-menu:hover { color: var(--lime); }
.welcome-art { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.welcome-art>span { position: absolute; right: 2%; top: 8%; color: #879aab0d; font: 700 clamp(200px, 35vw, 480px)/1 'Space Grotesk', sans-serif; letter-spacing: -30px; }
.welcome-floor { position: absolute; bottom: 16%; right: 5%; width: 26%; height: 15px; border-top: 3px solid #6e8178; background: #2b3b3b; transform: rotate(-5deg); }
.welcome-door { position: absolute; right: 9%; bottom: 18%; width: 67px; height: 118px; border: 3px solid #bddf65; border-radius: 12px 12px 0 0; opacity: .6; transform: rotate(-5deg); }
.welcome-door::after { content: ''; position: absolute; top: 54%; right: 10px; height: 7px; width: 4px; background: #d4ff63; }
.welcome-player { position: absolute; right: 25%; bottom: 22%; width: 50px; height: 60px; border-radius: 12px 12px 6px 6px; background: var(--lime); transform: rotate(8deg); box-shadow: 0 0 40px #d4ff6312; }
.welcome-player i { position: absolute; top: 20px; width: 7px; height: 10px; background: #233213; }
.welcome-player i:first-child { left: 13px; }
.welcome-player i:last-child { right: 13px; }
.welcome-player::after { content: ''; position: absolute; top: 40px; left: 24px; width: 7px; height: 2px; background: #233213; }

/* Compact context above the board; nothing is drawn over live gameplay. */
.stagebar { flex: 0 0 auto; min-height: 43px; margin: 0 0 8px; gap: 14px; }
.stage-name { min-width: 0; }
.stage-name .eyebrow { font-size: 10px; letter-spacing: 1px; }
.stagebar h1 { font-size: 20px; line-height: 1.15; gap: 10px; margin: 5px 0 0; }
#stage-num { padding-right: 10px; }
#stage-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats { gap: 20px; }
.stats div { min-width: 44px; gap: 3px; }
.stats div>span { font-size: 9px; letter-spacing: .6px; }
.stats b { font-size: 21px; }
.stats small { font-size: 11px; }
.section-strip { flex: 0 0 26px; min-height: 26px; margin: 0 0 5px; gap: 10px; font-size: 12px; }
.section-strip>span:first-child { font-size: 11px; letter-spacing: .6px; }
#section-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #91a0ae; }
#section-pips { flex-shrink: 0; }
.section-strip .objective { position: static; margin-left: auto; max-width: 48%; font-size: 11px; line-height: 1.2; letter-spacing: .3px; text-align: right; }
.objective:empty { display: none; }
.message-area { flex: 0 0 66px; height: 66px; display: flex; align-items: stretch; gap: 14px; padding: 8px 0; margin-bottom: 8px; border-top: 1px solid #303c43; border-bottom: 1px solid #303c43; }
.message-copy { flex: 1; min-width: 0; display: grid; align-items: center; }
.message-copy>p { grid-area: 1 / 1; min-width: 0; margin: 0; padding: 0; font-size: 14px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
#clue { color: #c5d0d7; }
.message-copy .lesson { visibility: hidden; position: static; max-width: none; max-height: none; background: none; border: 0; color: #f6bc9e; pointer-events: none; }
.message-copy .lesson:empty { display: -webkit-box; }
.message-copy .toast { visibility: hidden; opacity: 1; position: static; transform: none; width: auto; max-width: none; border: 0; border-radius: 0; background: none; text-align: left; color: var(--lime); transition: none; }
.message-area.has-lesson #clue,
.message-area.has-toast #clue,
.message-area.has-toast .lesson { visibility: hidden; }
.message-area.has-lesson:not(.has-toast) .lesson,
.message-area.has-toast .toast { visibility: visible; }
#hint-button { align-self: center; flex-shrink: 0; min-width: 72px; min-height: 44px; padding: 8px 12px; background: #252d35; color: #d4dfd4; border: 1px solid #465548; border-radius: 9px; font-size: 13px; }
#hint-button span { color: var(--lime); margin-left: 3px; }
#hint-button:hover { background: #344035; }
.arena { flex: 1 1 auto; height: auto; min-height: 120px; border-radius: 11px; }
.arena.reading::after { display: none; }
.arena canvas { touch-action: none; }
.section-overlay { z-index: 2; }
.section-overlay h2 { font-size: clamp(22px, 3vw, 32px); }

/* Controls remain outside the board in portrait and landscape. */
.play-actions { flex: 0 0 auto; }
.underbar { min-height: 52px; padding: 5px 0; gap: 0; flex-wrap: nowrap; }
.control-tools { flex: 1; flex-wrap: nowrap; justify-content: flex-end; gap: 8px; }
.underbar:has(#echo:not(.hidden)) .control-tools { flex: 1; }
.underbar #echo { margin-right: auto; min-height: 44px; padding: 7px 10px; border: 1px solid #544566; background: #252231; font-size: 13px; }
.underbar #echo.ready { border-color: #9cac71; color: var(--lime); background: #303c27; }
.underbar:has(#echo:not(.hidden)) #echo { min-height: 44px; }
.quick-btn { min-width: 84px; min-height: 44px; padding: 8px 12px; font-size: 13px; }
.touch-controls { position: static; left: auto; right: auto; bottom: auto; padding: 2px 0 4px; gap: 14px; pointer-events: auto; }
.d-pad { display: flex; gap: 0; flex-shrink: 0; border: 1px solid #59646e; border-radius: 15px; overflow: hidden; background: #242d37; touch-action: none; user-select: none; -webkit-user-select: none; }
.touch-controls .d-pad button { width: 72px; height: 62px; border: 0; border-radius: 0; background: transparent; opacity: 1; font-size: 29px; touch-action: none; }
.touch-controls .d-pad button+button { border-left: 1px solid #48545f; }
.touch-controls .d-pad button.held { color: var(--lime); background: #3e5032; }
.touch-controls .jump-btn { flex-shrink: 0; min-width: 116px; width: 116px; height: 64px; border-radius: 15px; padding: 0 14px; gap: 12px; justify-content: space-between; opacity: 1; background: var(--lime); color: #19260c; font-size: 16px; touch-action: none; }
.touch-controls .jump-btn.held { background: #e5ffad; box-shadow: inset 0 0 0 3px #7f9d3d; }
#touch-hint { max-width: 150px; color: #aab5be; font-size: 11px; line-height: 1.45; }
.game-footer { justify-content: center; flex: 0 0 auto; min-height: 0; margin-top: 5px; padding: 7px 0 2px; font-size: 11px; border: 0; }
.menu-progress { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; color: #bdc9b3; font-size: 12px; }
.menu-progress .progress-track { display: block; flex: 1; max-width: 90px; }
.menu-content .save-note { color: #929fa9; font-size: 12px; text-align: center; line-height: 1.45; }
.menu-content .legacy-note { font-size: 12px; }
.hint-content { padding-top: 18px; }
#hint-panel { white-space: pre-line; font-size: 16px; line-height: 1.6; color: #e2d5ed; }
.hint-controls { font-size: 13px; line-height: 1.5; color: #b3c1c8; padding-top: 14px; border-top: 1px solid #3a4149; }
.hint-content .primary-btn { width: 100%; margin-top: 24px; }
.controls-content { padding-top: 10px; }
.controls-content dl { margin: 0; }
.controls-content dl>div { padding: 16px 0; border-bottom: 1px solid #343d46; }
.controls-content dt { color: var(--lime); font-weight: 600; margin-bottom: 6px; }
.controls-content dd { margin: 0; color: #c0cbd1; font-size: 14px; line-height: 1.6; }

@media (pointer: coarse), (max-width: 760px) {
  .touch-controls { display: flex; }
  .game-footer { display: none; }
  .tool-btn kbd { display: none; }
}
@media (max-width: 760px) {
  .shell { padding-right: max(14px, env(safe-area-inset-right, 0px)); padding-left: max(14px, env(safe-area-inset-left, 0px)); }
  .topbar { height: 43px; flex-basis: 43px; }
  .brand { font-size: 15px; letter-spacing: 1.2px; }
  .brand-mark { width: 25px; height: 25px; font-size: 22px; border-radius: 6px; }
  .game-wrap { padding-top: 8px; }
  .stagebar { min-height: 40px; margin-bottom: 5px; gap: 8px; }
  .stage-name .eyebrow { font-size: 8px; letter-spacing: .6px; }
  .stagebar h1 { font-size: 16px; gap: 7px; margin-top: 4px; }
  #stage-num { padding-right: 7px; }
  .stats { gap: 12px; }
  .stats div { min-width: 31px; }
  .stats div>span { font-size: 8px; }
  .stats b { font-size: 18px; }
  .section-strip { flex-basis: 24px; min-height: 24px; gap: 7px; margin-bottom: 4px; }
  .section-strip>span:first-child { font-size: 10px; }
  #section-title { display: none; }
  #section-pips i { width: 10px; }
  .section-strip .objective { font-size: 10px; }
  .message-area { height: 76px; flex-basis: 76px; gap: 10px; padding-block: 7px; margin-bottom: 7px; }
  .message-copy>p { font-size: 13px; line-height: 1.4; }
  #hint-button { min-width: 64px; padding-inline: 9px; font-size: 12px; }
  #hint-button span { display: none; }
  .underbar { min-height: 52px; padding-block: 4px; }
  .quick-btn { min-width: 76px; }
  .touch-controls { gap: 9px; }
  .touch-controls .d-pad button { width: 67px; }
  .touch-controls .jump-btn { width: 110px; min-width: 110px; }
  #touch-hint { max-width: 105px; font-size: 10px; }
  .welcome { align-items: center; padding: 34px 26px; border-radius: 13px; }
  .welcome-kicker { font-size: 9px; letter-spacing: 1px; }
  .welcome h1 { font-size: clamp(37px, 9vw, 61px); letter-spacing: -1.8px; margin-top: 24px; }
  .welcome-line { font-size: 15px; }
  .welcome-actions { margin-top: 32px; max-width: none; }
  .welcome-art { opacity: .25; }
  .welcome-door { right: 12%; bottom: 8%; width: 40px; height: 70px; }
  .welcome-player { right: 35%; bottom: 10%; transform: scale(.65) rotate(8deg); transform-origin: bottom; }
  .welcome-floor { bottom: 6%; width: 48%; }
  .welcome-art>span { top: auto; bottom: 0; right: 8%; font-size: 250px; }
}
@media (max-width: 370px) {
  .shell { padding-inline: max(10px, env(safe-area-inset-left, 0px)) max(10px, env(safe-area-inset-right, 0px)); }
  .touch-controls .d-pad button { width: 61px; }
  .touch-controls .jump-btn { width: 100px; min-width: 100px; gap: 12px; }
  #touch-hint { font-size: 9px; }
  .welcome { padding-inline: 22px; }
  .welcome h1 { font-size: 35px; }
}
@media (max-height: 680px) and (orientation: portrait) {
  .topbar { height: 36px; flex-basis: 36px; }
  .game-wrap { padding-top: 5px; }
  .stagebar { min-height: 35px; margin-bottom: 3px; }
  .stagebar h1 { font-size: 15px; }
  .message-area { height: 66px; flex-basis: 66px; }
  .message-copy>p { font-size: 12px; }
  .touch-controls .d-pad button, .touch-controls .jump-btn { height: 56px; }
  .welcome { padding-block: 22px; }
  .welcome-actions { margin-top: 24px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .shell { padding-inline: max(18px, env(safe-area-inset-left, 0px)) max(18px, env(safe-area-inset-right, 0px)); padding-bottom: max(5px, env(safe-area-inset-bottom, 0px)); }
  .topbar { height: 32px; flex-basis: 32px; }
  .brand { font-size: 13px; }
  .brand-mark { width: 23px; height: 23px; font-size: 20px; }
  .game-wrap { padding: 4px 0 0; }
  .stagebar { min-height: 29px; margin-bottom: 2px; }
  .stage-name .eyebrow { display: none; }
  .stagebar h1 { font-size: 15px; margin: 0; }
  .stats { gap: 16px; }
  .stats div { display: flex; align-items: baseline; gap: 6px; }
  .stats b { font-size: 16px; }
  .stats div>span { font-size: 8px; }
  .section-strip { min-height: 20px; flex-basis: 20px; margin: 0; }
  #section-title { display: block; font-size: 11px; }
  .message-area { flex-basis: 48px; height: 48px; padding: 2px 0; margin-bottom: 4px; }
  .message-copy>p { font-size: 12px; -webkit-line-clamp: 2; }
  #hint-button { min-height: 40px; }
  .arena { min-height: 100px; }
  .play-actions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; padding-top: 5px; }
  .underbar { grid-area: 1 / 2; min-height: 48px; padding: 0; }
  .underbar:has(#echo:not(.hidden)) .control-tools { flex: 1; }
  .control-tools { gap: 6px; }
  .quick-btn { min-width: 72px; min-height: 44px; padding: 7px 10px; }
  .underbar #echo, .underbar:has(#echo:not(.hidden)) #echo { min-height: 44px; margin: 0; padding-inline: 10px; }
  .touch-controls { display: contents; position: static; }
  .d-pad { grid-area: 1 / 1; justify-self: start; border-radius: 12px; }
  .touch-controls .d-pad button { width: 62px; height: 50px; }
  .touch-controls .jump-btn { grid-area: 1 / 3; justify-self: end; min-width: 100px; width: 100px; height: 52px; border-radius: 12px; padding-inline: 10px; gap: 8px; }
  #touch-hint, .game-footer { display: none; }
  .welcome { padding: 20px 6%; }
  .welcome-copy { display: grid; grid-template-columns: minmax(0, 1fr) minmax(210px, .7fr); column-gap: 44px; max-width: 900px; align-items: center; }
  .welcome-kicker { grid-column: 1; font-size: 9px; }
  .welcome h1 { grid-column: 1; font-size: 38px; margin: 16px 0 12px; }
  .welcome-line { grid-column: 1; font-size: 14px; }
  .welcome-actions { grid-column: 2; grid-row: 1 / 4; margin: 0; }
  .welcome .primary-btn { min-height: 54px; }
  .welcome-art { opacity: .18; }
  .overlay:not(.intro) { padding: 16px; align-items: center; }
}
