/* The 3x Duo cover is 466 by 678 CSS px. Safari may reserve its side rail,
   leaving 382px. The inner display's Split View uses 385px.
   Move every dialog's close button an extra 18px left to clear the camera. */
@media (pointer: coarse) and (resolution: 3dppx) and (device-width: 466px) and (device-height: 678px) and (orientation: portrait) and ((width: 382px) or (width: 466px)) {
 .dialog-close { transform: translateX(calc(min(-130%, -38px) - 18px)); }
 #settings-title { padding-top:12px; }
}

/* Fixed phone helm: the scene gets the remaining height, never the control list. */
@media(max-width:1100px){
 html,body{height:100%;min-height:0;min-width:0;margin:0;overflow:hidden;overscroll-behavior:none}
 body{display:flex;flex-direction:column;height:100dvh;padding:env(safe-area-inset-top) 0 0}
 .topbar,.watch-strip,.bottom-bar{flex:none}
 button{touch-action:manipulation}
 .topbar{height:44px;min-height:44px;padding:0 max(8px,env(safe-area-inset-right)) 0 max(8px,env(safe-area-inset-left));gap:6px;flex-wrap:nowrap}
 .brand{font:500 13px var(--mono);letter-spacing:.5px;gap:5px;min-width:0;flex:1}.brand-mark{font-size:24px}.brand small,.top-coords{display:none}
 .top-actions{gap:3px;margin:0;width:auto}.top-actions button{min-height:44px;padding:0 5px;letter-spacing:0;font-size:12px}
 .top-actions #sound{min-width:59px;gap:4px}.top-actions #sound span{display:inline;font-size:12px}#sound svg{width:17px;height:17px}.top-actions #guide{font-size:0;min-width:32px}.top-actions #guide span{font-size:16px;margin:0}
 .top-actions .pause-button{font-size:0;min-width:58px;width:auto;height:36px;min-height:36px;padding:0 6px}.top-actions .pause-button:after{content:attr(data-short);font:12px var(--mono)}
 .console{display:block;flex:1;min-height:0;height:auto}
 .main-panel{height:100%;min-height:0;display:flex;flex-direction:column;min-width:0}
 .stations{height:44px;min-height:44px;grid-template-columns:repeat(7,minmax(0,1fr))}.stations:has([data-view=scope].hidden){grid-template-columns:repeat(6,minmax(0,1fr))}
 .stations button{font-size:0;padding:0 1px;min-width:0;letter-spacing:0}.stations button span{display:none}.stations button:after{content:attr(data-short);font:12px var(--mono)}.stations button.active:after{content:attr(data-short);height:auto;background:none;position:static}.stations button.active{box-shadow:inset 0 -2px var(--gold)}
 .mobile-panels,.touch-pad,.touch-aux,.helm,.helm-caption,.station-strip,.soundings-strip{display:none}
 .mobile-vitals{display:flex;justify-content:space-between;align-items:center;gap:5px;min-height:30px;height:30px;padding:3px 8px;background:#13272b;border-bottom:1px solid #364b43;font:12px var(--mono);white-space:nowrap;flex-shrink:0}
 .mobile-vitals b{font-weight:500;color:#d9e1c8}.mobile-vitals .caution{color:var(--gold)}.mobile-vitals .danger{color:#ffa484}
 .drone-monitor{min-height:28px;padding:2px 8px;font-size:11px;gap:5px}.drone-monitor>span{line-height:1.3}.drone-monitor button{min-height:26px;font-size:11px;padding:2px 6px}.drone-monitor #monitor-boat{display:none}
 .viewport{flex:1;min-height:100px;touch-action:none;overflow:hidden}
 .view-top{top:9px;left:9px;right:9px;font-size:12px}.view-top small{font-size:11px;line-height:1.6;max-width:100%}.view-tag{display:none}
 .compass{top:53px;left:12%;right:12%;font-size:12px}.look-heading{top:77px;font-size:13px}.bow-readout{top:104px;left:9px;right:auto;padding:3px 6px;font:11px/1.5 var(--mono);max-width:calc(100% - 18px)}
 .view-bottom{display:none}.drone-instruments{display:none!important}
 .station-actions{position:relative;display:flex;align-items:stretch;justify-content:space-between;gap:2px;height:44px;min-height:44px;padding:0 5px;background:#12292e;border-top:1px solid #526453;border-bottom:1px solid #3c5148;z-index:25;flex-shrink:0}
 .station-actions>div{position:static;display:flex;align-items:center;gap:2px;min-width:0;flex-wrap:nowrap;margin:0;padding:0;background:none;border:0}
 .station-actions button{min-height:44px;padding:0 6px;font:12px var(--mono);white-space:nowrap;color:#d6dfc6;max-width:none}
 .station-actions #scope-tools{flex:1;justify-content:space-around}.station-actions #scope-alignment{flex:none}.station-actions #scope-align-toggle{display:block;min-width:44px}.station-actions #scope-alignment>button:not(#scope-align-toggle){display:none}
 .station-actions #scope-toggle,.station-actions #photo{font-size:0;min-width:44px;padding:0 5px}.station-actions #scope-toggle:after{content:attr(data-short);font:12px var(--mono)}.station-actions #photo:after{content:'Photo';font:12px var(--mono)}
 .station-actions #scope-alignment.open>button:not(#scope-align-toggle){position:absolute;right:5px;bottom:44px;display:block;background:#183137f5;border:1px solid #7e8e72;padding:9px 12px;min-height:44px;z-index:30}.station-actions #scope-alignment.open #steer-scope{bottom:88px}
 .station-actions #zoom-tools{display:flex;gap:0;flex:none}.station-actions #zoom-tools button{min-width:35px;padding:0 4px}.station-actions #zoom-in,.station-actions #zoom-out{font-size:20px}.station-actions #zoom-readout{font-size:11px}
 .station-actions #drone-tools,.station-actions #gun-tools,.station-actions #chart-tools{width:100%;justify-content:space-around}.station-actions #drone-tools>span,.station-actions #gun-tools>span{display:none}.station-actions kbd{display:none}
 .station-actions #sonar-tools{width:100%;justify-content:space-between}.station-actions #sonar-tools small{font:11px var(--mono);color:#a8bbaa}.mobile-boat-resources{display:block;font:12px/1.6 var(--mono);color:#d1d7bd;padding:8px 12px;border-top:1px solid #42584c}body[data-drawer=mission] .mobile-boat-resources{display:none}
 #chart-tools #center-chart,#chart-tools #clear-route,#chart-tools #plot-home,#chart-tools #recon-place{font-size:0;padding:0 4px;min-width:44px}#center-chart:after{content:'Center';font:12px var(--mono)}#clear-route:after{content:'Clear';font:12px var(--mono)}#plot-home:after{content:'Home';font:12px var(--mono)}#recon-place:after{content:'Recon';font:12px var(--mono)}
 #chart-tools #chart-zoom-in,#chart-tools #chart-zoom-out{font-size:20px;min-width:35px;padding:0 5px}
 #gun-tools #gun-trigger{flex:1}#gun-tools #aim-gun{font-size:0;flex:1}#aim-gun:after{content:'Aim at target';font:12px var(--mono)}
 .mobile-fixed-helm{display:grid;grid-template-columns:1fr 1fr 1.12fr;height:122px;min-height:122px;background:#12262c;flex-shrink:0}
 .mobile-axis{min-width:0;border-right:1px solid #3a5048;position:relative}.mobile-order{display:flex;flex-direction:column;justify-content:center;align-items:center;gap:2px;width:100%;min-height:76px;padding:4px 2px;font:12px var(--mono)}.mobile-order small{font-size:11px;color:#a7bcb0}.mobile-order b{font-size:20px;font-weight:500;color:#e2e6ce}.mobile-order span{font-size:12px;color:#d9bf8b}
 .mobile-step-pair{display:flex;height:44px}.mobile-step-pair button{flex:1;min-width:44px;min-height:44px;border-top:1px solid #3a5048;padding:0 3px;font:12px var(--mono);user-select:none;-webkit-user-select:none;touch-action:none}.mobile-step-pair button.held{background:#b7c7a2;color:#10252b}
 .mobile-speed-axis{display:grid;grid-template-columns:minmax(0,1fr) var(--range-hit);border-right:0;padding-right:4px;gap:0}.mobile-speed-axis>.mobile-order{width:auto;min-width:0}.mobile-speed-axis .mobile-order b{font-size:18px;white-space:nowrap}.mobile-speed-axis .mobile-order span{font-size:11px;white-space:nowrap}
 .mobile-speed-track{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:3px 0;gap:2px;font:10px var(--mono);color:#9bb6a4}.mobile-speed-rail{position:relative;width:var(--range-hit);height:84px;--actual:0%}
 #mobile-speed{position:absolute;inset:0 auto auto 0;-webkit-appearance:none;appearance:none;--rail-size:4px 100%;writing-mode:vertical-lr;direction:rtl;width:100%;height:100%;padding:0;margin:0;background:transparent;accent-color:var(--gold);touch-action:none;min-height:0}
 .mobile-speed-tick{position:absolute;left:0;bottom:var(--actual);width:13px;height:2px;background:var(--cream);box-shadow:0 0 0 1px #112229;pointer-events:none;z-index:2}
 .bottom-bar{align-items:flex-end;height:calc(44px + env(safe-area-inset-bottom));min-height:44px;padding:0 0 env(safe-area-inset-bottom);position:relative;z-index:45;background:#0b181e}.bottom-bar>div:first-child,.bottom-bar>.time-controls{display:none}.bottom-bar>.mobile-footer-actions{display:grid;grid-template-columns:1fr 1.2fr 1fr .65fr;width:100%;height:44px}.mobile-footer-actions button{font:12px var(--mono);min-height:44px;border-right:1px solid #334b42}.mobile-footer-actions [aria-expanded=true]{background:#294238;color:var(--gold)}
 .left-panel,.right-panel{display:none;position:fixed;z-index:40;inset:auto max(7px,env(safe-area-inset-right)) calc(210px + env(safe-area-inset-bottom)) max(7px,env(safe-area-inset-left));height:auto;min-height:0;width:auto;max-height:min(53dvh,420px);overflow:auto;box-shadow:0 -8px 50px #0009;border:1px solid #70816b;background:#10272e;scrollbar-width:thin;overscroll-behavior:contain}
 body[data-drawer=mission] .left-panel,body[data-drawer=boat] .left-panel,body[data-drawer=contacts] .right-panel,body[data-drawer=recon] .right-panel{display:flex;flex-direction:column}
 .drawer-close{display:block;align-self:flex-end;min-height:36px;padding:0 12px;font:12px var(--mono);color:var(--gold);flex-shrink:0}.left-panel>.panel-label,.left-panel>.log-panel,.left-panel>.left-footer,.right-panel>.panel-label,.right-panel>.mini-sonar,.right-panel>.sonar-actions,.right-panel>.resources{display:none}
 body[data-drawer=mission] .boat-panel,body[data-drawer=mission] .drone-bay,body[data-drawer=mission] .mobile-boat-actions{display:none}body[data-drawer=boat] .mission-block,body[data-drawer=boat] .operation-card{display:none!important}
 .mission-block{padding:12px 15px}.mission-block h1{font-size:30px;margin:9px 0}.mission-block>p{font-size:13px;margin-bottom:10px}.objective p,.objective b,.extraction{font-size:12px}
 .boat-panel,.drone-bay{padding:12px 15px}.boat-profile{display:none}.system-detail{margin-top:10px}.mobile-boat-actions{display:grid;grid-template-columns:repeat(3,1fr);padding:0 8px 8px;gap:5px;flex-shrink:0}.mobile-boat-actions button{font:12px var(--mono);min-height:44px;padding:3px;border:1px solid #526d59}
 .right-panel .contacts-panel{display:flex;flex-direction:column;flex:1;min-height:80px;max-height:170px;height:auto;padding:7px 10px;overflow:hidden;border:0}.contacts-panel>#contacts{max-height:none;overflow:auto;margin-top:4px;padding-right:3px}.contact-row{min-height:48px;padding:5px 3px;grid-template-columns:1fr auto;gap:3px}.contact-icon{display:none}.contact-row strong{font-size:13px}.contact-row small,.contact-row .contact-bearing{font-size:11px}
 .right-panel .weapons{padding:8px 10px;border:0;flex-shrink:0}.weapons .section-heading{font-size:12px}.weapons .tubes{margin:6px 0}.weapons #fire{min-height:44px;font-size:13px;padding:8px}.weapons #weapon-hint{font-size:12px;line-height:1.5;margin:6px 0}.weapons .weapon-instructions{display:none}.weapons #decoy{font-size:12px;min-height:36px;padding:4px 0}.weapons .gun-control{display:none}.torpedo-status{font-size:11px;line-height:1.5}
 body[data-station=gun][data-drawer=contacts] .weapons>.section-heading,body[data-station=gun][data-drawer=contacts] .weapons>.tubes,body[data-station=gun][data-drawer=contacts] #fire,body[data-station=gun][data-drawer=contacts] #weapon-hint,body[data-station=gun][data-drawer=contacts] #torpedo-status{display:none}
 body[data-station=gun][data-drawer=contacts] .gun-control{display:block;padding-top:0;margin-top:0;border:0}.gun-control p,.gun-control #open-gun{display:none}.gun-control select{font-size:16px;min-height:44px;margin:6px 0}
 .right-panel .recon-panel{display:none}.recon-panel{padding:8px 12px;font-size:12px}.recon-panel p{font-size:13px;line-height:1.4}.recon-panel button{min-height:44px}.recon-panel>span{font-size:11px}
 body[data-drawer=recon] .right-panel>.contacts-panel,body[data-drawer=recon] .right-panel>.weapons{display:none}body[data-drawer=recon] .right-panel>.recon-panel{display:block}
 #drawer-backdrop{inset:88px 0 calc(210px + env(safe-area-inset-bottom));z-index:39}
 .order-sheet{bottom:5px;left:5px;right:5px;padding:10px;max-width:none}.order-sheet button{min-height:44px}.order-sheet label{margin:6px 0}.order-sheet input[type=range]{min-height:44px}.order-sheet>span{font-size:12px;margin-top:3px}
 .photo-gallery{inset:58px 8px 8px;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.photo-card{padding:5px;font-size:11px}.photo-card small{font-size:11px}.photo-empty{left:10%;right:10%;font-size:13px}
 #briefing{width:min(96vw,650px);max-height:94dvh}.briefing-art{display:none}.briefing-content{padding:25px 18px}.briefing-content h2{font-size:34px}.intro{font-size:15px}#mission-picker{max-height:250px}.mission-option b{font-size:13px}.mission-option small{font-size:11px}.mission-option>span:last-child{font-size:11px}.patrol-conditions select{font-size:16px}
 #help-dialog{padding:24px 18px;max-height:92dvh}.guide-grid{grid-template-columns:1fr}.paused .viewport:after{font:12px var(--mono);bottom:9px;max-width:95%;padding:8px}
 #toast{bottom:calc(213px + env(safe-area-inset-bottom));font-size:12px;max-width:94vw;width:max-content;padding:9px 12px;z-index:60}
}
@media(max-width:350px){
 .brand{font-size:11px;letter-spacing:0}.brand-mark{display:none}.top-actions #guide{min-width:26px}.top-actions button{padding:0 4px}#sound span{font-size:11px}.stations button:after{font-size:11px}.mobile-vitals{font-size:11px;gap:3px}.mobile-order b{font-size:18px}.mobile-order span{font-size:11px}.mobile-speed-axis{padding-right:1px;grid-template-columns:minmax(0,1fr) var(--range-hit)}.mobile-speed-axis .mobile-order b{font-size:16px}.station-actions button{font-size:11px;padding:0 4px}.station-actions #zoom-tools button{min-width:31px}
}
/* Use the long edge for the helm on foldables, tablets and rotated phones. */
@media (640px <= width <= 1100px), (max-width:1100px) and (orientation:landscape){
 /* Reserve usable helm space first. The safe-area padding sits outside it. */
 body{--helm-rail:calc(clamp(184px,16vw + 92px,244px) + env(safe-area-inset-right))}
 .main-panel{position:relative;display:grid;grid-template-columns:minmax(0,1fr) var(--helm-rail);grid-template-rows:auto auto auto minmax(0,1fr) auto}
 .stations{grid-column:1/-1;grid-row:1}
 .mobile-vitals{grid-column:1/-1;grid-row:2}
 .station-notices{grid-column:1/-1;grid-row:3}
 .viewport{grid-column:1;grid-row:4;min-height:80px}
 .station-actions{grid-column:1;grid-row:5}
 .mobile-fixed-helm{grid-column:2;grid-row:4/6;height:auto;min-height:0;grid-template-columns:minmax(0,1fr) clamp(70px,8vw,86px);grid-template-rows:1fr 1fr}
 .mobile-speed-axis{grid-column:2;grid-row:1/3;display:flex;flex-direction:column;padding:0}
 .mobile-order{min-height:48px;gap:0;padding:2px}
 .mobile-order b{font-size:17px}
 .mobile-step-pair button+button{border-inline-start:1px solid #3a5048}
 .mobile-speed-track{flex:1}.mobile-speed-rail{height:90px}
 .left-panel,.right-panel{bottom:calc(77px + env(safe-area-inset-bottom));right:calc(var(--helm-rail) + 8px);max-height:calc(100dvh - 115px - env(safe-area-inset-top) - env(safe-area-inset-bottom))}
 #drawer-backdrop{inset:70px var(--helm-rail) 76px 0}#toast{bottom:80px}
}
@media(max-width:1100px) and (orientation:landscape) and (max-height:540px){
 .topbar{height:36px;min-height:36px}.bottom-bar{height:calc(36px + env(safe-area-inset-bottom));min-height:36px}
 .bottom-bar>.mobile-footer-actions,.mobile-footer-actions button{height:36px;min-height:36px}
 .stations{height:34px;min-height:34px}.mobile-vitals{height:26px;min-height:26px}
 .drone-monitor{min-height:24px}.station-actions{height:40px;min-height:40px}.station-actions button{min-height:40px}
 .mobile-step-pair,.mobile-step-pair button{height:36px;min-height:36px}
 .view-top{top:5px}.view-top small,.bow-readout{display:none}.compass{top:30px}.look-heading{top:49px}.photo-gallery{inset:34px 8px 8px}
}
@media (640px <= width <= 1100px) and (min-height:541px){
 .mobile-axis:not(.mobile-speed-axis){display:flex;flex-direction:column;justify-content:center}
 .mobile-speed-rail{height:clamp(90px,22dvh,170px)}
 body[data-station=sonar] .viewport{grid-row:4/6}
 body[data-station=sonar] .mobile-fixed-helm{grid-row:4}
 body[data-station=sonar] .station-actions{grid-column:2;height:auto;padding:0 env(safe-area-inset-right) 0 0}
 body[data-station=sonar] #sonar-tools{flex-direction:column;align-items:stretch}
 body[data-station=sonar] .sonar-ranges button{flex:1;min-width:44px}
}

body[data-station=drone] .viewport{touch-action:none}
#rov-steering-hint{
 position:absolute;bottom:6px;left:50%;transform:translateX(-50%);
 width:max-content;max-width:calc(100% - 16px);padding:4px 7px;
 background:#0b181eda;color:var(--cream);font:11px/1.4 var(--mono);
 text-align:center;pointer-events:none
}
@media(max-width:1100px){
 .rov-touch-helm .mobile-fixed-helm{
  grid-template:minmax(0,1fr) calc(var(--range-hit) + 2px) / repeat(2,minmax(0,1fr));height:102px;min-height:102px
 }
 .rov-touch-helm .mobile-step-pair{display:none}
 .rov-touch-helm .mobile-order{min-height:46px;gap:0;padding:1px 2px;line-height:1.1}
 .rov-touch-helm .mobile-order b{font-size:15px}
 .rov-touch-helm .mobile-speed-axis{
  grid-area:2/1/3/-1;display:grid;grid-template-columns:max-content minmax(0,1fr) auto;
  align-items:center;gap:6px;padding:0 8px;border-top:1px solid #3a5048
 }
 .rov-touch-helm .mobile-speed-track{flex-direction:row-reverse;gap:4px;padding:0}
 #rov-stop{min-height:44px;padding:0 7px;font:12px var(--mono);border:1px solid var(--line);color:var(--cream)}
 .rov-touch-helm .mobile-speed-rail{flex:1;min-width:0;height:var(--range-hit)}
 .rov-touch-helm #mobile-speed{
  --rail-size:100% 4px;writing-mode:horizontal-tb;direction:ltr;
  width:100%;height:100%
 }
 .rov-touch-helm .mobile-speed-tick{left:var(--actual);bottom:7px;width:2px;height:6px}
}
@media (640px <= width <= 1100px), (max-width:1100px) and (orientation:landscape){
 .rov-touch-helm .mobile-fixed-helm{height:auto;grid-template-rows:minmax(46px,1fr) auto}
 .rov-touch-helm .mobile-speed-axis{grid-template-columns:1fr auto;gap:0 4px}
 .rov-touch-helm .mobile-speed-track{grid-area:2/1/3/-1}
}

#install-game{display:block;margin:12px 0 4px;padding:8px 12px;border:1px solid var(--line);min-height:44px}
#update-game{display:inline-flex;align-items:center;min-height:44px;color:var(--gold)}
#install-game[hidden],#install-help[hidden]{display:none}
#install-help{margin:8px 0;color:var(--muted);line-height:1.45}

.patrol-difficulty{margin:16px 0;padding:10px;border:1px solid var(--line)}
.patrol-difficulty summary{cursor:pointer}
#difficulty-options{display:grid;gap:12px;padding-top:12px}
#difficulty-options label{display:grid;grid-template-columns:1fr auto;gap:4px 10px;align-items:center}
#difficulty-options input[type=range]{grid-column:1/-1;width:100%}
#difficulty-options small{grid-column:1/-1;color:var(--muted)}
#difficulty-options input[type=checkbox]{width:20px;height:20px}
#settings-dialog{width:min(94vw,520px);max-height:85dvh;padding:24px}
.mobile-boat-actions .diesel-routing{grid-column:1/-1}
.mobile-boat-actions .diesel-routing select{min-height:44px}
.rov-invert{display:flex;align-items:center;gap:8px;min-height:44px;cursor:pointer}
.rov-invert input{width:20px;height:20px}
#shortcut-list{display:grid;gap:6px;margin:12px 0}
#shortcut-list button{display:flex;justify-content:space-between;text-align:left;padding:8px 10px;border:1px solid var(--line);min-height:38px}
#orbit-tools{position:absolute;z-index:3;right:max(12px,env(safe-area-inset-right));bottom:max(12px,env(safe-area-inset-bottom));display:flex;gap:8px}
#orbit-tools[hidden]{display:none}
body.orbiting.paused .viewport::after{content:'PATROL PAUSED';left:max(12px,env(safe-area-inset-left));top:max(12px,env(safe-area-inset-top));transform:none;padding:6px 10px;font-size:12px}
#orbit-tools button{min-height:44px;min-width:44px;background:#14242de6;border:1px solid var(--line);padding:8px 12px}
body.orbiting .viewport{position:fixed;inset:0;width:100vw;height:100dvh;z-index:90;touch-action:none}
body.orbiting .viewport>:not(#world,#orbit-tools,#pressure-warning){visibility:hidden}
body.orbiting>.topbar,body.orbiting>.bottom-bar,body.orbiting .console>:not(.main-panel),body.orbiting .main-panel>:not(.viewport){display:none!important}

#patrol-medals{margin:14px 0;color:var(--gold)}
#patrol-debrief{margin:14px 0}
#debrief-entries{max-height:23dvh;overflow:auto;padding-left:22px}
#debrief-entries li{margin:5px 0;color:var(--muted)}
.service-record{margin-top:11px}
@media(prefers-reduced-motion:no-preference){.viewport canvas{translate:var(--shock-x,0) var(--shock-y,0)}}

.watch-strip{display:none}
@media(max-width:1100px){
 .watch-strip{height:22px;display:flex;align-items:center;justify-content:space-evenly;background:#14232a;border-bottom:1px solid var(--line);color:var(--muted);font:12px var(--mono);font-variant-numeric:tabular-nums}
 .watch-strip time,.watch-strip b{color:var(--cream)}
 body.orbiting .watch-strip{display:none}
}
#pressure-warning{position:absolute;z-index:5;bottom:12%;left:50%;transform:translateX(-50%);max-width:95%;width:max-content;padding:7px 12px;background:#352819;color:#ffe4a5;border:1px solid currentColor;font:600 13px var(--mono);text-align:center;pointer-events:none}
#pressure-warning.critical{background:#691e20;color:#fff0e7;border:2px solid #ff776a}
#hull-limits,.voice-credit{color:var(--muted);font:12px/1.5 var(--mono)}
.dedication{border-top:1px solid var(--line);padding-top:14px;line-height:1.5}
.dedication a{color:var(--gold)}

/* The whole input accepts a drag. Only the center stripe is painted as a rail. */
@media (max-width:1100px), (any-pointer:coarse){
 :root{--range-hit:52px;--range-thumb:28px}
 .order-sheet input[type=range],#difficulty-options input[type=range],.dual-range input[type=range]{
  height:var(--range-hit);margin:0;padding:0;background:transparent;touch-action:pan-y
 }
 .dual-range{height:var(--range-hit)}
 .dual-range input[type=range]{inset:0}
 .dual-range .actual-tick{top:50%;transform:translate(-50%,-50%)}
 input[type=range]::-webkit-slider-runnable-track{
  block-size:100%;background:linear-gradient(#748884,#748884) center / var(--rail-size,100% 4px) no-repeat
 }
 input[type=range]::-webkit-slider-thumb,.dual-range input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none;width:var(--range-thumb);height:var(--range-thumb);box-sizing:border-box;
  margin-block-start:calc((var(--range-hit) - var(--range-thumb))/2);
  border:2px solid #253135;border-radius:50%;background:var(--gold)
 }
 input[type=range]::-moz-range-track{
  inline-size:100%;block-size:100%;background:linear-gradient(#748884,#748884) center / var(--rail-size,100% 4px) no-repeat
 }
 input[type=range]::-moz-range-thumb,.dual-range input[type=range]::-moz-range-thumb{
  width:var(--range-thumb);height:var(--range-thumb);box-sizing:border-box;
  border:2px solid #253135;border-radius:50%;background:var(--gold)
 }
 input[type=range]:focus-visible{outline:2px solid var(--gold);outline-offset:-2px}
}

/* Extend gameplay to both viewport edges while keeping controls clear of cutouts. */
@media (max-width:1100px){
 .stations,.watch-strip,.mobile-vitals,.station-actions,.mobile-footer-actions,.mobile-fixed-helm{
  padding-inline-start:env(safe-area-inset-left);padding-inline-end:env(safe-area-inset-right)
 }
}
@media (640px <= width <= 1100px), (max-width:1100px) and (orientation:landscape){
 .mobile-fixed-helm{padding-inline-start:0}.station-actions{padding-inline-end:0}
}
#current-patrol{border-block:1px solid var(--line);padding:12px 0;margin-bottom:10px}
#current-mission{display:block;margin:5px 0;color:var(--cream)}
.seed-actions{display:flex;align-items:stretch;gap:6px;flex-wrap:wrap}
.seed-actions input{flex:1 1 7em;min-width:0}
.seed-actions button,.slot-actions button{border:1px solid #526b61;padding:5px 10px;min-height:44px;color:var(--cream);font:12px var(--mono)}
.seed-actions button:hover,.slot-actions button:enabled:hover{background:#25413e}
#current-seed{font-variant-numeric:tabular-nums;color:var(--gold)}
#seed-status:empty{display:none}
#patrol-slots{margin:14px 0;color:var(--cream)}
#patrol-slots summary{cursor:pointer;padding:10px 0}
.slot-list{display:grid;gap:5px}
.patrol-slot{display:grid;grid-template-columns:64px minmax(0,1fr) auto;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--line)}
.slot-caption small,.slot-caption b{display:block}
.slot-caption small,#patrol-slots small[role=status]{color:#b9c8c1}
.slot-actions{display:flex;gap:4px;align-items:center;flex-wrap:wrap}
.slot-actions button:disabled{opacity:.45}
.slot-number,.slot-image{width:64px;aspect-ratio:240/104;background:#122a32;align-content:center;text-align:center;color:#a5b4aa}
@media(max-width:500px){
 .patrol-slot{grid-template-columns:64px minmax(0,1fr)}
 .slot-actions{grid-column:2}
}

#briefing{overscroll-behavior:contain}
#briefing::backdrop{background:#081219;backdrop-filter:none}
#red-beacon{
 --lamp-width:48px;position:relative;display:block;flex:0 0 var(--lamp-width);pointer-events:none;z-index:4;
 width:var(--lamp-width);height:var(--lamp-width);border-radius:50%;
 background:linear-gradient(145deg,#b2b7ab,#6c7570 19%,#333c3b 49%,#172120 74%,#69716a);
 box-shadow:inset 0 0 0 1px #1b2524,0 1px 4px #000a;
}
.beacon-lens{
 position:absolute;inset:8%;border-radius:50%;border:1px solid #2c1415;
 background:repeating-radial-gradient(circle,#f897831b 0 1px,transparent 1px 4px),
 radial-gradient(circle at 43% 40%,#753b3b,#451c20 67%,#290d11);
}
#red-beacon::after{
 content:'';position:absolute;inset:11%;border-radius:50%;
 background:radial-gradient(ellipse at 30% 20%,#fff3d952 0%,transparent 20%);
 box-shadow:inset 1px 1px 2px #ffdac437,inset -2px -2px 3px #3c090a99;
}
#red-beacon.lit .beacon-lens{
 border-color:#ec735c;background:repeating-radial-gradient(circle,#ffba8929 0 1px,transparent 1px 4px),
 radial-gradient(circle,#e34530,#9a1f25 72%,#600f17);box-shadow:0 0 12px 3px #ff30288a;
}
.beacon-rotor{display:none;position:absolute;inset:0}
#red-beacon.lit .beacon-rotor{display:block;animation:red-beacon-turn 1s linear infinite}
.beacon-rotor::before{
 content:'';position:absolute;left:50%;top:50%;width:clamp(230px,24vw,370px);aspect-ratio:1;translate:-50% -50%;
 background:conic-gradient(from -45deg,#ff392b88 0deg 90deg,transparent 90deg 180deg,#ff392b88 180deg 270deg,transparent 270deg);
 mask-image:radial-gradient(transparent calc(var(--lamp-width) / 2),black calc(var(--lamp-width) / 2 + 1px),#0009 38%,transparent 70%);
}
.beacon-rotor::after{
 content:'';position:absolute;inset:15%;border-radius:50%;
 background:radial-gradient(ellipse 31% 18% at 50% 20%,#fff5ca 15%,#ffbe75 54%,transparent 100%),
 radial-gradient(ellipse 31% 18% at 50% 80%,#fff5ca 15%,#ffbe75 54%,transparent 100%),
 radial-gradient(circle at center,#be7965 0 9%,#661c20 11% 18%,transparent 20%),
 conic-gradient(from -38deg,#ff8c65 0deg 76deg,transparent 76deg 180deg,#ff8c65 180deg 256deg,transparent 256deg);
}
@keyframes red-beacon-turn{to{transform:rotate(1turn)}}
body.paused #red-beacon.lit .beacon-rotor{animation-play-state:paused}
@media(max-width:1100px){#red-beacon{--lamp-width:37px}}
@media(max-width:520px){.topbar .brand-mark{display:none}#red-beacon{--lamp-width:32px}}
@media(max-height:500px){#red-beacon{--lamp-width:32px}}
#torpedo-tracks>div{padding:6px 0;border-top:1px solid var(--line);font:12px/1.55 var(--mono);color:#efd19a}
body.replaying .viewport>#replay-overlay{visibility:visible;position:absolute;inset:0;z-index:25;touch-action:none;user-select:none;display:flex;align-items:flex-start;justify-content:space-between;padding:max(12px,env(safe-area-inset-top)) max(28px,env(safe-area-inset-right)) 0 max(12px,env(safe-area-inset-left))}
body.replaying .viewport>#world{visibility:visible;display:block!important;filter:none!important;opacity:1!important}
body.replaying #pressure-warning,body.replaying #orbit-tools,body.replaying .viewport::after,body.replaying .viewport::before,body.replaying #toast,body.replaying #drawer-backdrop{display:none!important}
.replay-caption{pointer-events:none;display:grid;justify-items:start;gap:5px;color:#ffe061;font:600 12px var(--mono)}
.replay-caption strong{border:2px solid currentColor;padding:6px 10px;background:#161807de;font-size:15px;letter-spacing:1px;animation:replay-pulse 1.35s ease-in-out infinite}
.replay-caption span{padding:3px 6px;background:#102029df;color:#eee8d0}
#replay-exit{min-height:44px;padding:0 14px;border:1px solid #b4b0a0;background:#12222df2;color:#fff}
@keyframes replay-pulse{50%{opacity:.6}}
@media(prefers-reduced-motion:reduce){#red-beacon.lit .beacon-rotor,.replay-caption strong{animation:none}}

#patrol-standby{display:none}
body.standby{display:flex;flex-direction:column}
body.standby :is(.console,.watch-strip,.bottom-bar,.top-actions,.top-coords,#red-beacon){display:none}
body.standby #patrol-standby{flex:1;display:grid;place-content:center;justify-items:center;gap:18px}
#patrol-standby h1{margin:0}
#choose-mission{width:auto;padding-inline:24px}

.sight-header{display:contents}
.bow-readout>span{white-space:nowrap}
.bow-readout>span+span::before{content:"· "}
@media (max-width:480px) and (orientation:portrait){
 body[data-station=scope] .sight-header{
  position:absolute;inset:9px 9px auto;display:grid;grid-template-columns:minmax(0,1fr) auto;
  align-items:start;column-gap:8px;pointer-events:none;
 }
 body[data-station=scope] .sight-header :is(.view-top,.bow-readout){position:static}
 .sight-header .bow-readout{grid-column:2;max-width:none;text-align:right}
 .sight-header .bow-readout>span:not([hidden]){display:block}
 .sight-header .bow-readout>span+span::before{content:none}
 body[data-station=scope] .sight-header .compass{
  grid-column:1/-1;position:relative;inset:auto;margin:5px 10% 0;
 }
 body[data-station=scope] .sight-header .look-heading{
  grid-column:1/-1;justify-self:center;position:relative;inset:auto;transform:none;
 }
 body[data-station=scope] .sight-header .look-heading::before{top:-10px}
}

.captain-entry{margin-block:15px;color:var(--cream);font:13px var(--mono)}
.captain-entry label,.captain-entry small{display:block;margin:5px 0}
.captain-entry>div{display:flex;align-items:center;gap:10px}
#captain-name{width:100%;min-width:0;min-height:44px;padding:6px 9px;background:#102227;color:var(--cream);border:1px solid #526b61;font:16px var(--mono)}
#captain-name::placeholder{color:#a6b6ad}
.captain-entry small{color:#b6c8bb;line-height:1.5}
.transfer-actions{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-block:10px}
.transfer-actions button{min-height:44px;padding:5px 10px;border:1px solid var(--button-edge);border-radius:3px;background:var(--button-face);color:var(--cream);font:12px var(--mono)}
#transfer-confirm[hidden],#transfer-notice[hidden]{display:none}
#transfer-confirm span{flex-basis:100%}
#transfer-notice,#transfer-question{font:13px/1.5 var(--mono);color:var(--gold)}
#patrol-slots .patrol-slot{grid-template-columns:64px minmax(0,1fr)}
#patrol-slots .slot-actions{grid-column:2}
#captain-stars,#result-captain{color:var(--gold)}
