:root {
  color-scheme: dark;
  --bg: #0a100f;
  --panel: #111a17;
  --line: #2c3933;
  --text: #edf4ed;
  --dim: #a7b7ac;
  --mint: #a4f8bc;
  --amber: #ffbb6a;
  --mono: "IBM Plex Mono", Consolas, monospace;
  font: 16px/1.45 "Barlow", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(ellipse at 26% 0%, #18281f 0%, transparent 54%), var(--bg); }
.wrap { width: min(1240px, 92%); margin-inline: auto; }
.mast { border-bottom: 1px solid var(--line); background: #0d1612; }
.brand { height: 60px; display: flex; align-items: center; gap: 12px; font: 800 16px/1 "Barlow", "Segoe UI", sans-serif; letter-spacing: .12em; }
.mark { display: flex; gap: 3px; align-items: center; transform: skewX(-24deg); }
.mark i { background: var(--mint); width: 6px; height: 19px; }
.mark i:last-child { height: 11px; align-self: end; }
.heading, .panel-head, .legend, .actions, .guide, .charges { display: flex; align-items: center; }
.heading { justify-content: space-between; gap: 18px; padding: clamp(20px,3vw,44px) 0 24px; }
h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: clamp(40px,5.2vw,76px); line-height: .98; letter-spacing: -.07em; font-weight: 740; }
h1 span, .signal { color: var(--mint); }
.scenario { display: grid; gap: 4px; }
label, .label, legend, .guide h2 { color: var(--dim); font: 600 11px/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
button, select { line-height: 1.2; font-family: inherit; font-weight: 600; font-size: 14px; color: var(--text); border: 1px solid #415248; background: #1a2620; border-radius: 5px; }
select { padding: 9px 12px; min-width: 160px; }
button { cursor: pointer; padding: 10px 15px; }
button:hover { background: #293b30; border-color: #799c85; }
button:active { transform: translateY(1px); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
.layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(245px, .305fr); gap: 18px; align-items: stretch; }
.panel { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.panel-head { justify-content: space-between; min-height: 54px; border-bottom: 1px solid var(--line); padding: 12px 20px; }
h2 { font-size: 18px; letter-spacing: -.025em; }
.legend { gap: 17px; color: var(--dim); font: 12px var(--mono); }
.legend span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; background: var(--mint); border-radius: 2px; }
.legend span:last-child::before { background: var(--amber); }
.screen { padding: 12px; background: #0b120e; border-bottom: 1px solid var(--line); }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 840/388; background: #15231b; }
#field.aiming { cursor: crosshair; touch-action: none; }
#lob[aria-pressed=true] { color:var(--mint); border-color:var(--mint); }
#hint { margin: 16px 20px 12px; color: #c1d4c6; font-size: 14px; }
.actions { gap: 8px; flex-wrap: wrap; margin: 0 20px 18px; }
.primary { color: #0d2315; border-color: var(--mint); background: var(--mint); }
.primary:hover { background: #c6ffd5; }
.metrics { display: flex; flex-direction: column; }
.signal { letter-spacing: 2px; font-size: 12px; }
.scorebox, dl, fieldset, #feedback { margin-inline: 18px; }
.scorebox { margin-top: 17px; padding: 14px 16px; border: 1px solid #344c3d; border-radius: 5px; background: linear-gradient(110deg,#213529,#18251c); }
#score { display: block; font: 650 clamp(32px,3.2vw,46px)/1.2 var(--mono); letter-spacing: -.07em; color: var(--mint); }
small { color: var(--dim); font: 11px var(--mono); }
dl { margin-top: 10px; }
dl div { padding: 9px 0; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
dt { color: var(--dim); font-size: 13px; }
dd { font: 600 12px/1.5 var(--mono); text-align: right; }
fieldset { padding: 0; border: 0; min-width: 0; margin-block: 18px 12px; }
legend { padding: 0 0 7px; }
.charges { gap: 5px; }
.charges button { flex: 1; font: 12px var(--mono); padding: 8px 3px; }
.charges button[aria-pressed=true], .charges button.active { background: #253d2e; color: var(--mint); border-color: #759e7f; }
#feedback { color: #edc997; margin-block: auto 16px; padding-top: 6px; font: 12px/1.55 var(--mono); }
.guide { flex-wrap: wrap; gap: 12px 22px; padding: 20px 0 32px; color: var(--dim); }
.guide span { font-size: 12px; white-space: nowrap; }
kbd { display: inline-block; color: #d6e0d6; border: 1px solid #38473d; border-bottom-width: 2px; padding: 2px 5px; border-radius: 4px; font: 11px var(--mono); }
.touch { display: none; }
.screen { position: relative; }
.match-banner { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); width:max-content; max-width:92%; padding:.55em 1em; text-align:center; background:#0d1815ed; color:#d2ffdc; font-weight:750; border:1px solid #83b89b; border-radius:5px; pointer-events:none; }
.match-banner.victory-banner { top:10px; transform:translateX(-50%); }
button:disabled { opacity:.5; cursor:default; }
.screen { container-type:inline-size; }
.match-banner.countdown-banner {
  font:900 clamp(3.5rem,17cqw,10rem)/1 var(--mono);
  letter-spacing:-.08em; padding:0 .08em 0 0; color:#dcffe6;
  border:0; background:transparent; text-shadow:0 2px 5px #061109,0 0 .22em #0b3523;
  transform-origin:center;
}
@media (pointer: coarse) {
  .touch { display: flex; gap: 8px; margin: 0 20px 16px; }
  .touch button { touch-action: none; user-select: none; min-height: 44px; min-width: 44px; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .metrics { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .metrics .panel-head { grid-column: 1/-1; }
  .metrics #feedback { align-self: center; margin-block: 12px; }
}
@media (max-width: 520px) {
  .wrap { width: 94%; }
  .brand { height: 48px; }
  .heading { padding-block: 22px 16px; }
  select { min-width: 0; max-width: 145px; }
  .screen { padding: 5px; }
  .panel-head { padding: 10px 13px; min-height: 45px; }
  #hint, .actions, .touch, .scorebox, dl, fieldset, #feedback { margin-inline: 12px; }
  .actions button { padding-inline: 10px; }
  .guide { gap: 10px 13px; }
  .guide h2 { width: 100%; }
}

.brand nav { display: flex; gap: clamp(8px,2vw,22px); margin-inline-start: auto; }
.brand nav a { color: var(--mint); font-size: clamp(12px,2vw,14px); letter-spacing: 0; }
@media (pointer: coarse) {
  #fire { touch-action: none; user-select: none; min-height: 44px; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  .wrap { width: 97%; }
  .brand { height: 30px; }
  .heading, #match .heading { padding: 4px 0; min-height: 37px; }
  .heading h1, #match .heading h1 { font-size: 28px; }
  .scenario { display: flex; align-items: center; gap: 8px; }
  .heading button, .scenario select { padding: 5px 10px; }
  .layout { grid-template-columns: minmax(0,1fr) 172px; gap: 8px; }
  .field-panel { display: grid; grid-template-columns: minmax(0,1fr) 108px; align-content: start; }
  .field-panel .panel-head { grid-column: 1/-1; min-height: 27px; padding: 3px 8px; }
  .field-panel .screen { grid-row: 2/4; padding: 3px; }
  .field-panel .actions { grid-column: 2; grid-row: 2; margin: 4px; gap: 4px; justify-content: center; }
  .field-panel .actions button { padding: 4px 5px; }
  .field-panel #fire { width: 100%; }
  .field-panel .touch { grid-column: 2; grid-row: 3; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin: 3px 4px; }
  .field-panel .touch button { padding: 4px; }
  .field-panel #hint { grid-column: 1/-1; margin: 5px 8px; }
  .metrics { display: flex; }
  .metrics .panel-head { min-height: 28px; padding: 3px 8px; }
  .metrics .scorebox, .metrics dl, .metrics fieldset, .metrics #feedback { margin: 4px 8px; }
  .metrics .scorebox, .metrics dl div { padding: 3px 5px; }
  #score { font-size: 24px; }
}
.trace-option { display:inline-flex;align-items:center;gap:5px;cursor:pointer;color:var(--text);letter-spacing:0;text-transform:none; }
.trace-option input { accent-color:var(--mint);width:15px;height:15px;margin:0; }
@media (max-width: 365px) {
  .brand { gap: 6px; font-size: 12px; letter-spacing: .06em; }
  .brand nav { gap: 5px; }
  .brand a, .brand button { white-space: nowrap; }
  .brand button { padding: 7px; }
  .brand .mark { gap: 2px; }
  .brand .mark i { width: 4px; }
}

/* Seat editor in the match setup */
.slots { display: grid; gap: 6px; margin: 0; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
.slots legend { padding: 0 6px; color: var(--dim); font-size: 14px; }
.slot { display: grid; grid-template-columns: 4.6em minmax(0,15rem) minmax(0,7rem); gap: 8px; align-items: center; }
.slot select { box-sizing: border-box; width: 100%; min-width: 0; max-width: none; }
.slot span { color: var(--dim); font: 12px var(--mono); }
#setup-error { flex-basis: 100%; margin: 0; color: var(--amber); min-height: 1.2em; }
