/* The readout occupies the existing service column; narrow screens place it
   after the boards. No viewport overlay and no additional combat clock. */
.terminal-readout { width:100%; min-width:0; color:var(--ink); background:#11160f; border-block:1px solid var(--line); padding:10px 8px; text-shadow:none; font-family:var(--i18n-read-font); }
.terminal-readout[hidden] { display:none!important; }
.terminal-readout header { display:flex; align-items:center; justify-content:space-between; gap:8px; padding-bottom:9px; }
.terminal-readout header strong { font-size:.75rem; font-weight:400; color:var(--gold); }
.terminal-summary { display:none; }
.terminal-readout button { font-family:var(--i18n-read-font); font-size:.72rem; text-shadow:none; white-space:normal; min-height:32px; padding:5px 7px; }
.terminal-readout [data-close] { border:0; padding-inline:0; background:transparent; }
.terminal-command-bar { display:flex; gap:5px; flex-wrap:wrap; padding-bottom:7px; }
.terminal-command-bar button, .terminal-readout [data-details] { border:1px solid var(--line); background:color-mix(in srgb,var(--gold) 5%,#11160f); }
.terminal-command-bar:empty { display:none; }
.terminal-receipt { font-size:.7rem; line-height:1.5; color:var(--muted); padding-bottom:8px; overflow-wrap:anywhere; }
.terminal-readout [data-details] { width:100%; text-align:left; margin-bottom:8px; }
.terminal-readout-content { max-height: min(410px, calc(100dvh - 285px)); overflow:auto; overscroll-behavior:contain; scrollbar-width:thin; }
.terminal-readout .word-tooltip.terminal-tooltip { position:static; display:grid; opacity:1; transform:none; width:100%; min-width:0; max-width:none; pointer-events:auto; border:0; padding:0; box-shadow:none; background:transparent; font-family:var(--i18n-read-font); text-shadow:none; }
.terminal-readout .tooltip-title { flex-wrap:wrap; }
.terminal-readout .tooltip-title strong { overflow-wrap:anywhere; }
.terminal-readout .tooltip-keyword-row { grid-template-columns:1fr; }
.terminal-readout[data-details=true] .tooltip-details { display:grid; gap:8px; }
.terminal-readout[data-details=true] .tooltip-quick { display:none; }
.terminal-readout .tooltip-keywords { display:grid; }
.side-flow-slot:has(.terminal-readout:not([hidden])) > .flow-panel { display:none; }
.app[data-phase] .right-market > #flowHome:has(.terminal-readout:not([hidden])) { display:block; visibility:visible; pointer-events:auto; }
.letter.terminal-selected { outline:1px solid var(--gold); outline-offset:-1px; background:color-mix(in srgb,var(--gold) 9%,transparent); }
.letter.terminal-selected .letter-glyph { text-shadow:0 0 5px currentColor; }
@media(max-width:995px) {
  .app[data-phase] .right-market:has(.terminal-readout:not([hidden])) { display:grid!important; width:100%; }
  .terminal-readout-content { max-height:320px; }
  .terminal-readout button { min-height:44px; }
}
@media(max-width:840px) {
  .app[data-phase] .right-market > #flowHome:has(.terminal-readout:not([hidden])) { grid-column:1 / -1; grid-row:1; min-height:0; }
}

/* Battle is one raster work surface. The original live nodes are docked here;
   other phases retain their service layout until their own migration. */
html[data-terminal-screen] body { background:#10150f; text-shadow:none; }
html[data-terminal-screen] body::before { opacity:.18; }
html[data-terminal-screen] .app[data-terminal-screen] { width:min(1120px,100%); padding:10px 18px; }
.app[data-terminal-screen] #arena { display:block; margin:0; padding:0; min-height:0; }
.app[data-terminal-screen] #battleFxLayer { overflow:hidden; }
.app[data-terminal-screen]:has(#terminalScreen[data-details=true]) #battleFxLayer { visibility:hidden; }
.app[data-terminal-screen] #arena > .bazaar-side,
.app[data-terminal-screen] #arena > .bazaar-board,
.app[data-terminal-screen] > .dseg-frame,
.app[data-terminal-screen]::before,
.app[data-terminal-screen]::after { display:none!important; }
#terminalScreen { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:stretch; width:100%; color:var(--ink); background:#10150f; font-family:var(--i18n-read-font); text-shadow:none; --slot-h:49px; --slot-font-size:2.65rem; }
#terminalScreen > * { grid-column:1 / -1; min-width:0; }
#terminalScreen .terminal-system-line { grid-row:1; display:flex; align-items:center; gap:12px; flex-wrap:wrap; padding:4px 0 8px; border-bottom:1px solid var(--line); font-size:.74rem; }
#terminalScreen .terminal-system-line > strong { font-weight:400; margin-right:auto; color:var(--gold); }
#terminalScreen .countdown-day { width:auto; gap:6px; font-size:.74rem; }
#terminalScreen .run-stats { display:flex; flex-wrap:wrap; gap:14px; align-items:center; max-width:none; }
#terminalScreen .operator-claim-readout { font-size:.7rem; }
#terminalScreen #operatorClaimState, #terminalScreen #operatorMemoryCount { display:none; }
#terminalScreen .enemy-hud { grid-row:2; }
#terminalScreen .enemy-shelf { grid-row:3; }
#terminalScreen .countdown-panel { grid-row:4; }
#terminalScreen .player-shelf { grid-row:5; }
#terminalScreen .player-hud { grid-row:6; }
#terminalScreen .hero-hud { width:100%; min-height:55px; grid-template-columns:84px minmax(0,1fr) 84px; gap:10px; padding:6px 0; background:transparent; box-shadow:none; }
#terminalScreen .combat-rail { padding:0; background:transparent; box-shadow:none; }
#terminalScreen .combatant-info { gap:3px; }
#terminalScreen .status-row:empty { display:none; }
#terminalScreen .identity-line { grid-template-columns:minmax(0,1fr) 30px minmax(75px,1fr); gap:10px; }
#terminalScreen #enemyAvatar,#terminalScreen #playerAvatar { font-size:1.45rem; }
#terminalScreen #enemyName,#terminalScreen #playerName { font-family:var(--i18n-read-font); font-size:.76rem; }
#terminalScreen #enemyHp,#terminalScreen #playerHp { font-size:1.05rem; }
#terminalScreen .hp-track { margin-top:3px; }
#terminalScreen .hp-track { height:5px; }
#terminalScreen .hp-segment { height:3px; font-size:0; background:currentColor; text-shadow:none; }
#terminalScreen .hp-device-zero:not(.anomalous),#terminalScreen .countdown-device-zero:not(.anomalous) { visibility:hidden; }
#terminalScreen .countdown-zero-array { width:42px; height:36px; }
#terminalScreen .hud-slots { grid-template-columns:repeat(3,22px); gap:5px; }
#terminalScreen .hud-slots > span:empty { opacity:.3; }
#terminalScreen .hud-slots > span:empty::before { display:none; }
#terminalScreen .shelf { width:100%; padding:3px 0; gap:4px; background:transparent; border:0; box-shadow:none; }
#terminalScreen .shelf::before,#terminalScreen .shelf::after,
#terminalScreen .dseg-frame,#terminalScreen .stall-code,
#terminalScreen .player-shelf-interaction-hint,#terminalScreen #playerShelfPurpose { display:none!important; }
#terminalScreen .shelf > header { min-height:16px; height:auto; font-size:.68rem; }
#terminalScreen .board { padding:0; }
#terminalScreen .protocol-line { grid-template-columns:repeat(10,minmax(0,1fr)); grid-template-rows:repeat(2,var(--slot-h)); column-gap:3px; row-gap:3px; min-height:0; padding:3px 0 8px; width:100%; }
#terminalScreen .protocol-line::after { display:none; }
#terminalScreen .protocol-address { visibility:hidden; }
#terminalScreen .letter { min-width:0; width:100%; height:var(--slot-h); text-shadow:0 0 2px currentColor; }
#terminalScreen .letter::before { opacity:.13; text-shadow:none; }
#terminalScreen .letter.terminal-selected { outline:0; background:color-mix(in srgb,var(--gold) 12%,transparent); box-shadow:inset 0 -1px var(--gold); }
#terminalScreen .letter.terminal-selected .letter-glyph { text-shadow:0 0 2px currentColor; }
#terminalScreen .letter.active,#terminalScreen .letter.flip { text-shadow:0 0 9px currentColor; }
#terminalScreen .countdown-panel { position:relative; inset:auto; transform:none; display:grid; grid-template-columns:44px minmax(0,1fr) auto; grid-template-rows:auto; align-items:center; justify-items:stretch; width:100%; min-height:48px; gap:10px; padding:6px 0; border-block:1px solid var(--line); background:transparent; box-shadow:none; }
#terminalScreen .countdown-panel::before,#terminalScreen .countdown-panel::after { display:none; }
#terminalScreen .countdown-core { display:block; grid-column:1; grid-row:1; width:auto; }
#terminalScreen #countdownRing { width:38px; height:36px; padding:0; border:0; background:transparent; box-shadow:none; }
#terminalScreen #countdownRing::before,#terminalScreen #countdownRing::after,#terminalScreen .game-countdown-frame { display:none; }
#terminalScreen #countdownNumber { position:static; width:38px; height:36px; font-size:2rem; line-height:1; text-shadow:0 0 3px currentColor; }
#terminalScreen .countdown-control-state { grid-column:3; grid-row:1; width:auto; }
#terminalScreen .countdown-control-hint { font-family:var(--i18n-read-font); font-size:.72rem; }
#terminalScreen .terminal-beat-tape { grid-column:2; grid-row:1; display:flex; justify-content:space-between; gap:3px; font-size:.74rem; color:var(--muted); }
#terminalScreen .terminal-beat-tape span { padding:2px 4px; white-space:nowrap; }
#terminalScreen .terminal-beat-tape .current { color:#10150f; background:var(--gold); }
#terminalScreen .mapping-tooltip { top:100%; bottom:auto; left:0; width:min(540px,100%); z-index:20; background:#10150f; box-shadow:none; padding:12px; border:1px solid var(--line); }
#terminalScreen .countdown-panel:not(.mapping-open) .mapping-tooltip { display:none; }
#terminalScreen .countdown-panel.mapping-open .mapping-tooltip { display:grid; opacity:1; transform:none; pointer-events:auto; }
#terminalScreen #terminalReadout { display:contents; }
#terminalScreen .terminal-summary { grid-column:1 / -1; grid-row:7; display:flex; flex-wrap:wrap; align-items:baseline; gap:4px 24px; padding:9px 0; border-top:1px solid var(--line); font-size:.76rem; min-height:42px; }
#terminalScreen .terminal-summary strong { font-weight:400; color:var(--gold); }
#terminalScreen .terminal-summary span { max-width:100%; overflow-wrap:anywhere; }
#terminalScreen .terminal-readout-content { display:none; }
#terminalScreen .terminal-receipt { grid-column:1 / -1; grid-row:8; margin:0; padding:4px 0; }
#terminalScreen .terminal-receipt[hidden] { display:none; }
#terminalScreen .terminal-controls { grid-column:1; grid-row:9; display:flex; align-items:center; gap:12px; flex-wrap:wrap; border-top:1px solid var(--line); padding:5px 0 0; }
#terminalScreen .terminal-controls header { order:2; padding:0; }
#terminalScreen .terminal-controls header strong { display:none; }
#terminalScreen .terminal-controls [data-details] { width:auto; margin:0; }
#terminalScreen .terminal-command-bar { padding:0; }
#terminalScreen .terminal-controls button,#terminalScreen .terminal-system-keys button { min-height:36px; padding:6px 8px; border:0; background:transparent; font-family:var(--i18n-read-font); font-size:.75rem; text-shadow:none; }
#terminalScreen .terminal-system-keys { grid-column:2; grid-row:9; display:flex; align-items:center; justify-content:flex-end; gap:8px; border-top:1px solid var(--line); padding-top:5px; }
#terminalScreen .countdown-command-line { width:auto; display:flex; gap:8px; }
#terminalScreen .countdown-command-line button:not(:disabled) { color:var(--ink); }
#terminalScreen button:focus-visible { outline:1px solid var(--gold); outline-offset:2px; }
#terminalScreen #tempoButton { position:static; width:32px; height:32px; padding:7px; margin:0; border:0; }
#terminalScreen .terminal-clock-key { color:var(--gold); }
#terminalScreen .terminal-clock-key::before { content:'›'; margin-right:6px; }
#terminalScreen[data-details=true] .shelf { display:none; }
#terminalScreen[data-details=true] .enemy-hud { grid-row:2; }
#terminalScreen[data-details=true] .player-hud { grid-row:3; }
#terminalScreen[data-details=true] .terminal-summary { display:none; }
#terminalScreen[data-details=true] .terminal-readout-content { display:block; grid-column:1 / -1; grid-row:5; padding:14px 0; min-height:180px; max-height:calc(100dvh - 250px); overflow:auto; }
#terminalScreen[data-details=true] .terminal-receipt { grid-row:6; }
#terminalScreen[data-details=true] .terminal-controls,#terminalScreen[data-details=true] .terminal-system-keys { grid-row:7; }
#terminalScreen[data-details=true] [data-details] { display:none; }
#terminalScreen .terminal-tooltip { gap:10px; }
#terminalScreen .terminal-tooltip .tooltip-title { font-size:1rem; }
#terminalScreen .terminal-tooltip .tooltip-keywords,#terminalScreen .terminal-tooltip .tooltip-keyword-row,#terminalScreen .terminal-tooltip .tooltip-new-keywords { background:transparent; box-shadow:none; border:0; padding:0; }
#terminalScreen .terminal-tooltip .tooltip-details { max-width:860px; }
#terminalScreen .terminal-tooltip .tooltip-new-keyword { display:none; }
#terminalScreen .terminal-tooltip .tooltip-feature-summary,#terminalScreen .terminal-tooltip .tooltip-compound-summary,#terminalScreen .terminal-tooltip .tooltip-summary { background:transparent; box-shadow:none; }
@media(max-width:620px) {
 html[data-terminal-screen] .app[data-terminal-screen] { padding:8px 10px; }
 #terminalScreen { --slot-h:35px; --slot-font-size:1.9rem; grid-template-columns:minmax(0,1fr); }
 #terminalScreen .terminal-system-line { gap:6px 12px; font-size:.7rem; }
 #terminalScreen .run-stats { gap:10px; }
 #terminalScreen .hero-hud { min-height:57px; grid-template-columns:54px minmax(0,1fr) 54px; gap:6px; }
 #terminalScreen .hud-slots { grid-template-columns:repeat(3,16px); gap:2px; }
 #terminalScreen .identity-line { grid-template-columns:minmax(0,1fr) 20px auto; gap:5px; }
 #terminalScreen #enemyHp,#terminalScreen #playerHp { font-size:.82rem; }
 #terminalScreen #enemyName,#terminalScreen #playerName { font-size:.68rem; }
 #terminalScreen .countdown-panel { grid-template-columns:38px minmax(0,1fr); grid-template-rows:auto auto; gap:3px 6px; padding:5px 0; }
 #terminalScreen .countdown-control-state { grid-column:2; justify-self:end; }
 #terminalScreen .terminal-beat-tape { grid-column:1 / -1; grid-row:2; font-size:.64rem; }
 #terminalScreen .terminal-beat-tape span { padding:2px 1px; }
 #terminalScreen .terminal-summary { gap:4px 12px; font-size:.72rem; }
 #terminalScreen .terminal-controls { grid-row:9; grid-column:1; padding-top:3px; }
 #terminalScreen .terminal-system-keys { grid-row:10; grid-column:1; justify-content:space-between; border:0; padding:0; }
 #terminalScreen .terminal-controls button,#terminalScreen .terminal-system-keys button { min-height:44px; font-size:.72rem; }
 #terminalScreen[data-details=true] .terminal-system-keys { grid-row:8; }
 #terminalScreen[data-details=true] .terminal-readout-content { max-height:calc(100dvh - 315px); }
}
@media(max-width:620px) and (max-height:650px) {
 #terminalScreen { --slot-h:27px; --slot-font-size:1.5rem; }
 #terminalScreen .hero-hud { min-height:38px; padding-block:3px; }
 #terminalScreen .shelf { padding-block:0; }
 #terminalScreen .terminal-system-line { padding-bottom:5px; }
 #terminalScreen .terminal-controls { border:0; }
}
@media(min-width:621px) and (max-height:620px) {
 html[data-terminal-screen] .app[data-terminal-screen] { padding-block:6px; }
 #terminalScreen { --slot-h:30px; --slot-font-size:1.7rem; }
 #terminalScreen .hero-hud { min-height:38px; padding-block:3px; }
 #terminalScreen .shelf > header { min-height:13px; }
 #terminalScreen .terminal-summary { min-height:32px; padding-block:5px; }
}
