:root {
  --bg: #0c1016;
  --panel: #141a22;
  --panel-2: #1a222c;
  --line: #2a3441;
  --text: #dfe5ec;
  --muted: #8b97a6;
  --accent: #ffb347;
  --good: #6ddc9a;
  --warn: #ffcc66;
  --bad: #ff6b6b;
  --info: #7fd4ff;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

#app { position: relative; width: 100vw; height: 100vh; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: none; }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- buttons */
/* One hit-target rule. Every button in the app inherits a solid, visible
   resting background so the click area is discoverable without hovering. */
button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
button:hover { background: #223040; border-color: #3c4a5c; }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button.primary {
  background: #2d4a2f;
  border-color: #48734c;
  color: #d9f5dc;
  font-weight: 600;
}
button.primary:hover { background: #375c3a; }

button.secondary { background: var(--panel-2); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 6px;
}
.icon-btn:hover { background: rgba(255, 255, 255, .16); }

/* ------------------------------------------------------------------- HUD */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
}
.hud-tl { position: absolute; top: 14px; left: 16px; }
.hud-tr { position: absolute; top: 14px; right: 16px; text-align: right; }
.hud-bl { position: absolute; bottom: 14px; left: 16px; }
.hud-br { position: absolute; bottom: 14px; right: 16px; text-align: right; }
.hud-center {
  position: absolute; top: 20%; left: 0; right: 0; text-align: center;
  font-size: 20px; font-weight: 700; letter-spacing: .06em; color: var(--accent);
}
.hud-lock {
  position: absolute; top: 50%; left: 0; right: 0; text-align: center;
  font-size: 15px; color: var(--muted);
}
.hud-drill { font-size: 13px; color: var(--text); font-weight: 600; }
.hud-string { color: var(--muted); }
.hud-timer { font-size: 30px; font-weight: 700; letter-spacing: .02em; }
.hud-par { color: var(--muted); }
.hud-ammo { font-size: 20px; font-weight: 700; }
.hud-ammo.low { color: var(--warn); }
.hud-ammo.empty { color: var(--bad); }
.hud-weapon { color: var(--muted); }
.hud-br div { line-height: 1.35; }
.rt { color: var(--info); }
.rt.false-start { color: var(--bad); }
.split { color: var(--muted); }
.zone-hit { color: var(--good); }
.zone-low { color: var(--warn); }
.zone-miss { color: var(--bad); }

/* --------------------------------------------------------------- overlay */
#overlay {
  position: absolute; inset: 0;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(8, 11, 15, .97), rgba(8, 11, 15, .99));
  backdrop-filter: blur(2px);
}
#overlay.hidden { display: none; }
.screen { max-width: 1180px; margin: 0 auto; padding: 34px 26px 60px; }

.masthead h1 { margin: 0; font-size: 30px; letter-spacing: .04em; }
.masthead .sub { color: var(--muted); max-width: 62ch; margin: 8px 0 26px; }

.cols { display: grid; grid-template-columns: 1.35fr 1fr; gap: 26px; align-items: start; }
.col h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); margin: 22px 0 10px; font-weight: 600;
}
.col h2:first-child { margin-top: 0; }

.cat { margin-bottom: 18px; }
.cat-label {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 7px;
}
.drill {
  display: block; width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 7px;
}
.drill:hover { background: var(--panel-2); border-color: #3c4a5c; }
.drill .name { font-weight: 600; font-size: 14px; }
.drill .desc { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.field { margin-bottom: 11px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field select, .field input[type="number"] {
  width: 100%; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font: inherit;
}
.field .hint { font-size: 11.5px; color: #6d7a89; margin-top: 4px; }
.field.check { display: flex; align-items: center; gap: 8px; }
.field.check label { margin: 0; color: var(--text); font-size: 13px; }
.field.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.timing, .history {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; font-family: var(--mono); font-size: 12px;
}
.timing div, .history div { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.timing .k, .history .k { color: var(--muted); }
.timing .note { display: block; color: #6d7a89; font-size: 11.5px; margin-top: 9px; line-height: 1.45; font-family: system-ui, sans-serif; }

/* -------------------------------------------------------------- briefing */
.brief {
  position: relative;
  max-width: 720px; margin: 6vh auto 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 26px 30px;
}
.brief-close { position: absolute; top: 14px; right: 14px; }
.brief h2 { margin: 0 0 6px; font-size: 22px; }
.brief .summary { color: var(--muted); margin: 0 0 16px; }
.brief .notice {
  background: rgba(224, 148, 74, .12); border: 1px solid rgba(224, 148, 74, .38);
  border-radius: 8px; padding: 9px 12px; margin: 0 0 14px; font-size: 13px;
}
.brief ul { padding-left: 20px; margin: 0 0 18px; }
.brief li { margin-bottom: 8px; }
.controls-ref {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 20px; font-family: var(--mono); font-size: 12px;
}
.controls-ref div { display: flex; justify-content: space-between; padding: 2px 0; }
.controls-ref .k { color: var(--accent); }

/* --------------------------------------------------------------- results */
.results { max-width: 1080px; margin: 0 auto; }
.results h2 { margin: 0 0 4px; font-size: 24px; }
.results .sub { color: var(--muted); margin: 0 0 20px; }

.headline {
  display: flex; align-items: baseline; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 22px; margin-bottom: 18px;
}
.headline .val { font-family: var(--mono); font-size: 40px; font-weight: 700; }
.headline .lab { color: var(--muted); }
.headline .pass { color: var(--good); font-weight: 700; }
.headline .fail { color: var(--bad); font-weight: 700; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.card h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.card .big { font-family: var(--mono); font-size: 26px; font-weight: 700; }
.card .sub2 { color: var(--muted); font-size: 12px; font-family: var(--mono); margin-top: 4px; }
.card .sub2 span { color: var(--text); }

.feedback { margin-bottom: 18px; }
.fb {
  border-left: 3px solid var(--line); background: var(--panel);
  padding: 11px 14px; border-radius: 0 8px 8px 0; margin-bottom: 8px;
}
.fb.good { border-left-color: var(--good); }
.fb.warn { border-left-color: var(--warn); }
.fb.critical { border-left-color: var(--bad); }

table.shots { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
table.shots th, table.shots td { text-align: right; padding: 5px 9px; border-bottom: 1px solid var(--line); }
table.shots th { color: var(--muted); font-weight: 600; text-align: right; }
table.shots th:first-child, table.shots td:first-child { text-align: left; }
table.shots tr.noshoot td { background: rgba(255, 107, 107, .1); }
table.shots tr.fs td { background: rgba(255, 204, 102, .1); }

.results-actions {
  max-width: 1080px; margin: 24px auto 0; display: flex; gap: 10px; flex-wrap: wrap;
}

@media (max-width: 860px) {
  .cols { grid-template-columns: 1fr; }
}
