:root {
  color-scheme: dark;
  --bg: #121716;
  --panel: #191f1e;
  --outline: #343e39;
  --muted: #acb8ae;
  --paper: #f0efe5;
  --amber: #ffd26a;
  --green: #9be1c7;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--paper);
  background: radial-gradient(ellipse at 50% 0, #222a25, transparent 56%), var(--bg);
  font: 1rem/1.5 system-ui, sans-serif;
}
button, select { font: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible, canvas:focus-visible { outline: 2px solid var(--amber); outline-offset: -3px; }
.station {
  width: min(100%, 1424px);
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(6px, 1.6dvh, 18px);
  margin: 0 auto;
  padding: clamp(7px, 2.3dvh, 24px) clamp(10px, 2.6vw, 32px);
}
.mast, .identity, .foot { display: flex; align-items: center; }
.mast { justify-content: space-between; gap: 10px; }
.identity { gap: 15px; }
.mark { display: grid; place-content: center; grid-auto-flow: column; gap: 4px; width: 47px; height: 47px; border: 1px solid #78663f; border-radius: 6px; background: #2f2b20; }
.mark i { width: 4px; height: 19px; background: var(--amber); transform: skewX(-18deg); }
.mark i:last-child { opacity: .48; }
.eyebrow { margin: 0; color: var(--muted); font: 650 .875rem/1.25 var(--mono); letter-spacing: .075em; text-transform: uppercase; }
.identity .eyebrow { color: var(--amber); font-size: .75rem; }
h1, h2 { margin: 0; letter-spacing: -.045em; line-height: 1.05; }
h1 { font-size: clamp(1.65rem, 3vw, 2.4rem); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 7px 14px; border: 1px solid transparent; border-radius: 5px; font-size: .9rem; font-weight: 730; cursor: pointer; white-space: nowrap; }
.secondary { color: var(--paper); border-color: var(--outline); background: #242b26; }
.secondary:hover:not(:disabled) { background: #353e34; }
.primary { color: #211b0e; border-color: #ffe098; background: var(--amber); box-shadow: inset 0 -2px #0002; }
.primary:hover:not(:disabled) { background: #ffe199; }
button:disabled, select:disabled { opacity: .45; cursor: default; }
.sound-icon { width: 12px; height: 12px; background: currentColor; clip-path: polygon(0 29%, 35% 29%, 100% 0, 100% 100%, 35% 71%, 0 71%); color: var(--amber); }
[aria-pressed="false"] .sound-icon { color: var(--muted); }
.console { display: grid; grid-template: auto minmax(0, 1fr) auto / minmax(0, 1fr); overflow: hidden; border: 1px solid var(--outline); border-radius: 11px; background: var(--panel); box-shadow: 0 18px 60px #0004; }
.telemetry { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.2fr); border-bottom: 1px solid var(--outline); }
.telemetry > div { display: grid; gap: 5px; min-width: 0; padding: clamp(5px, 1.4dvh, 12px) clamp(6px, 2vw, 19px); border-right: 1px solid var(--outline); }
.telemetry > div:last-child { border-right: 0; }
.telemetry strong { font: 720 clamp(1rem, min(3.3vw, 5.5dvh), 1.95rem)/1.1 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.telemetry > div:first-child strong { color: var(--amber); }
.telemetry small { color: var(--muted); font-size: .57em; }
.ammo { position: relative; }
progress { appearance: none; position: absolute; top: 59%; right: 17px; width: 33%; height: 5px; border: 0; border-radius: 5px; background: #3b4135; color: var(--amber); overflow: hidden; }
progress::-webkit-progress-bar { background: #3b4135; }
progress::-webkit-progress-value { background: var(--amber); }
progress::-moz-progress-bar { background: var(--amber); }
.viewport { position: relative; min-height: 0; overflow: hidden; isolation: isolate; container-type: size; background: #202b2b; }
.viewport::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 70px #060b0aa0; z-index: 1; }
canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
#range { touch-action: none; }
.viewport.active #range { cursor: none; }
#effects { pointer-events: none; z-index: 2; }
.range-label { position: absolute; top: 15px; left: 17px; z-index: 3; display: flex; align-items: center; gap: 9px; padding: 7px 10px; border: 1px solid #61706a80; border-radius: 4px; color: #e0e8df; background: #101715de; font: 650 .8rem/1 var(--mono); text-transform: uppercase; letter-spacing: .07em; pointer-events: none; }
.lamp { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.active .lamp { background: var(--green); box-shadow: 0 0 9px var(--green); }
.notice { position: absolute; z-index: 3; left: 50%; bottom: 18px; transform: translateX(-50%); padding: 6px 13px; border-radius: 3px; color: var(--amber); background: #101715ed; font: 700 .85rem var(--mono); white-space: nowrap; pointer-events: none; }
.notice:empty { display: none; }
.brief { position: absolute; z-index: 4; inset: 0; display: grid; align-items: end; justify-items: center; padding: 17px; background: linear-gradient(0deg, #0b1312d9 0%, #0b131210 64%); pointer-events: none; }
.brief-card { width: min(100%, 410px); padding: 18px 22px; border: 1px solid #687068; border-top: 2px solid var(--amber); border-radius: 6px; background: #171e1bec; box-shadow: 0 12px 35px #0005; text-align: center; pointer-events: auto; }
.brief-card .eyebrow { color: var(--amber); font-size: .75rem; }
.brief-card h2 { margin-top: 6px; font-size: clamp(1.55rem, 4vw, 2.15rem); }
.brief-card p:not(.eyebrow) { margin: 7px 0 13px; color: #d0d9d0; }
.brief-card .primary { min-width: 155px; }
.reticle { position: absolute; z-index: 3; width: 27px; height: 27px; transform: translate(-50%, -50%); color: #fff6d1; filter: drop-shadow(0 1px 2px #000); pointer-events: none; }
.reticle.hit { color: var(--amber); transform: translate(-50%, -50%) rotate(45deg); }
.reticle.on-target { color: var(--amber); }
.reticle i, .reticle b { position: absolute; background: currentColor; border-radius: 1px; }
.reticle i:nth-child(1), .reticle i:nth-child(2) { top: 12px; width: 7px; height: 2px; }
.reticle i:nth-child(1) { left: 0; }
.reticle i:nth-child(2) { right: 0; }
.reticle i:nth-child(3), .reticle i:nth-child(4) { left: 12px; width: 2px; height: 7px; }
.reticle i:nth-child(3) { top: 0; }
.reticle i:nth-child(4) { bottom: 0; }
.reticle b { left: 12px; top: 12px; width: 2px; height: 2px; }
.reticle.shotgun { width: clamp(29px, 4.8cqh, 38px); height: clamp(29px, 4.8cqh, 38px); border: 1px solid currentColor; border-radius: 50%; }
.reticle.shotgun i { display: none; }
.reticle.shotgun b { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.deck { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: clamp(5px, 1.4dvh, 11px) clamp(8px, 1.7vw, 16px); border-top: 1px solid var(--outline); }
.actions, .keys, .keys > span, .range-settings, .range-picker { display: flex; align-items: center; }
.range-settings { gap: 20px; min-width: 0; }
.range-picker { gap: 10px; min-width: 0; }
.range-picker select { display: block; min-width: 0; padding-right: 9px; text-overflow: ellipsis; }
.distance-picker { display: grid; grid-template-columns: auto minmax(70px, 150px) 10ch; align-items: center; gap: 9px; min-width: 0; }
.distance-picker input { width: 100%; min-width: 0; height: 32px; margin: 0; accent-color: var(--amber); cursor: pointer; }
.distance-picker output { color: var(--paper); font: 650 .8rem var(--mono); white-space: nowrap; }
.actions, .keys span { gap: 6px; }
.fire { min-width: 72px; touch-action: none; user-select: none; }
kbd { padding: 1px 5px; border: 1px solid #536057; border-radius: 3px; color: #e1e6db; background: #2d3630; font: .75rem var(--mono); }
.foot { justify-content: flex-end; gap: 8px; color: var(--muted); font-size: .85rem; }
.foot-actions { display: flex; flex: none; gap: 6px; }
.keys, .touch-help { margin-right: auto; }
#credits-dialog, #instructions-dialog { width: min(36rem, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: clamp(12px, 4vw, 24px); border: 1px solid var(--outline); border-radius: 8px; color: var(--paper); background: var(--panel); }
#credits-dialog::backdrop, #instructions-dialog::backdrop { background: #0a0f0ed9; }
.model-credit { color: var(--muted); overflow-wrap: anywhere; }
.model-credit a { color: inherit; text-underline-offset: .2em; }
.keys { gap: 9px 15px; flex-wrap: wrap; }
.touch-help { display: none; }
.text-button { min-height: 31px; padding: 3px 8px; border: 1px solid var(--outline); border-radius: 4px; color: var(--paper); background: transparent; cursor: pointer; }
@media (max-width: 760px) {
  .telemetry .eyebrow { font-size: .72rem; letter-spacing: 0; white-space: nowrap; }
  progress { display: none; }
}
@media (pointer: coarse) {
  .keys, #reload kbd { display: none; }
  .touch-help { display: block; }
  .button { min-height: 44px; }
}
@media (max-width: 740px) and (min-height: 471px), (max-width: 580px) {
  .deck { align-items: stretch; flex-direction: column; }
  .range-settings { justify-content: space-between; gap: 10px; }
  .range-picker { flex-wrap: wrap; gap: 4px; }
  .range-picker select { max-width: 100%; }
  .deck .actions { justify-content: flex-end; }
}
@media (max-width: 430px) {
  .mark { display: none; }
  .identity .eyebrow { font-size: .66rem; }
  .deck .button { padding-inline: 9px; }
  .range-settings { align-items: stretch; flex-direction: column; gap: 4px; }
  .range-picker select { flex: 1; }
  .distance-picker { grid-template-columns: auto minmax(70px, 1fr) 10ch; }
  .fire { min-width: 56px; }
  #reload kbd { display: none; }
}
@media (max-width: 360px) {
  .sound-icon { display: none; }
}
@media (max-height: 470px) {
  .station { padding-block: 6px; }
  .mast .eyebrow, .mark, .keys, .touch-help, #reload kbd { display: none; }
  .button { min-height: 33px; padding-block: 4px; }
  .telemetry > div { gap: 2px; }
  .range-settings, .range-picker { gap: 6px; }
  .distance-picker { grid-template-columns: auto minmax(65px, 100px) auto; gap: 5px; }
}
@media (max-width: 430px) and (max-height: 470px) {
  .mast h1 { font-size: clamp(1.25rem, 6vw, 1.65rem); }
  .deck { gap: 6px; }
  .distance-picker { grid-template-columns: auto minmax(55px, 1fr) auto; }
}
@container (max-height: 210px) {
  .brief { align-items: center; padding: 5px; }
  .brief-card { padding: 7px 11px; }
  .brief-card .eyebrow { display: none; }
  .brief-card h2 { margin-top: 0; font-size: 1.2rem; }
  .brief-card p:not(.eyebrow) { margin: 4px 0 6px; font-size: .8rem; line-height: 1.2; }
  .range-label { top: 5px; left: 6px; padding: 4px 6px; font-size: .66rem; }
  .notice { bottom: 5px; }
}
@container (max-height: 115px) {
  .brief-card { display: flex; width: auto; align-items: center; gap: 9px; }
  .brief-card h2 { font-size: 1rem; }
  .brief-card p:not(.eyebrow) { display: none; }
  .brief-card .primary { min-width: 0; }
}

.aim-help{position:absolute;left:12px;bottom:10px;right:12px;text-align:center;font:12px var(--mono);color:var(--paper);padding:7px 10px;background:#121716ce;border-radius:4px;pointer-events:none}.aim-help[hidden]{display:none}.range-settings{flex-wrap:wrap;gap:10px 16px}

.shot-score { display:block; font-size:11px; margin-top:4px; color:var(--muted, #bcb69d); }
.scoring-key { font-size:11px; color:var(--muted, #bcb69d); margin:8px 0; }
.deck .actions { flex-wrap:wrap; }

/* Keep every range control on one compact, horizontally scrollable row. */
.deck { flex-direction:row; align-items:center; flex-wrap:nowrap; gap:10px; overflow-x:auto; }
.deck .range-settings { flex-direction:row; flex-wrap:nowrap; align-items:center; justify-content:flex-start; gap:10px; flex:1 0 auto; }
.deck .range-picker { flex-wrap:nowrap; flex:0 0 auto; gap:5px; }
.deck .range-picker select { flex:none; max-width:150px; }
.deck .eyebrow { font-size:10px; letter-spacing:.04em; white-space:nowrap; }
.deck .button { font-size:12px; padding-inline:9px; white-space:nowrap; }
.deck .distance-picker { flex:0 0 auto; grid-template-columns:auto 85px auto; gap:5px; }
.deck .distance-picker output { font-size:11px; }
.deck .actions { flex:0 0 auto; flex-wrap:nowrap; gap:6px; }
.deck .fire { min-width:56px; }

/* Stack settings above the action buttons whenever the viewport is narrow. */
@media (max-width: 900px) {
  .deck { flex-direction:column; align-items:stretch; overflow-x:visible; gap:8px; }
  .deck .range-settings { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px 10px; flex:none; }
  .deck .range-picker { min-width:0; }
  .deck .range-picker select { flex:1; width:0; max-width:none; }
  .deck .distance-picker { grid-template-columns:auto minmax(35px,1fr) auto; }
  .deck .actions { display:grid; grid-template-columns:1.5fr 1fr 1fr; gap:8px; }
  .deck .actions .button { min-width:0; min-height:44px; }
  .deck .actions kbd { display:none; }
}
@media (max-width: 380px) {
  .deck .range-settings { grid-template-columns:minmax(0,1fr); }
}

#instructions-dialog { line-height:1.55; }
#instructions-dialog h3 { margin-bottom:6px; }
#instructions-dialog .scoring-key { font-size:inherit; }
