:root {
  --bg: #021826;
  --bg-soft: rgba(4, 31, 48, 0.9);
  --panel: rgba(8, 39, 58, 0.86);
  --panel-strong: rgba(6, 31, 48, 0.96);
  --line: rgba(123, 171, 196, 0.12);
  --line-strong: rgba(123, 171, 196, 0.24);
  --text: #eef6fb;
  --muted: #8eb3c9;
  --accent: #ff6230;
  --accent-soft: #ff835d;
  --accent-shadow: rgba(255, 98, 48, 0.35);
  --success: #82ffd0;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: "Bahnschrift", "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    linear-gradient(rgba(132, 181, 209, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(132, 181, 209, 0.09) 1px, transparent 1px),
    radial-gradient(circle at top, #08304a 0%, #031827 48%, #02131f 100%);
  background-size: 180px 180px, 180px 180px, auto;
}

button,
input {
  font: inherit;
}

.page-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: min(1480px, calc(100% - 24px));
  margin: 0 auto;
  padding: clamp(6px, 0.7vh, 10px) 0 clamp(6px, 0.8vh, 12px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: clamp(4px, 0.5vh, 8px);
  flex-shrink: 0;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(2, 18, 28, 0.62);
  backdrop-filter: blur(10px);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.github-link:hover,
.github-link:focus-visible {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(8, 39, 58, 0.9);
}

.github-link__icon {
  flex-shrink: 0;
  opacity: 0.7;
}

.github-link:hover .github-link__icon {
  opacity: 1;
}

.mute-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(2, 18, 28, 0.62);
  backdrop-filter: blur(10px);
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.mute-btn:hover,
.mute-btn:focus-visible {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(8, 39, 58, 0.9);
}

.mute-btn.is-muted {
  color: var(--accent);
  border-color: rgba(255, 98, 48, 0.36);
}

.mute-btn .icon-off { display: none; }
.mute-btn.is-muted .icon-on { display: none; }
.mute-btn.is-muted .icon-off { display: block; }

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(2, 18, 28, 0.62);
  backdrop-filter: blur(10px);
}

.lang-switch__btn {
  min-width: 46px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.lang-switch__btn:hover,
.lang-switch__btn:focus-visible {
  transform: translateY(-1px);
}

.lang-switch__btn.is-active {
  color: var(--text);
  background: rgba(255, 98, 48, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 98, 48, 0.36);
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.35vw, 2.6rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand__eyebrow,
.panel-card__eyebrow,
.overlay-card__eyebrow,
.tips__label {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--accent-soft);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}


.trainer-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.control-panel {
  display: flex;
  min-height: 0;
  overflow-y: auto;
}

.panel-card {
  width: 100%;
  padding: clamp(10px, 1.2vh, 16px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(7, 37, 56, 0.96), rgba(4, 24, 38, 0.94));
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.panel-card h2,
.overlay-card h2 {
  margin: 0 0 8px;
  font-size: clamp(1.2rem, 1.6vw, 1.8rem);
}

.panel-card__copy,
.overlay-card p,
.tips p {
  margin: 0;
  color: #d3e8f5;
  line-height: 1.35;
  font-size: 0.9rem;
}

.settings-form {
  display: grid;
  gap: clamp(6px, 0.8vh, 10px);
  margin-top: clamp(6px, 0.8vh, 12px);
}

.field {
  display: grid;
  gap: 4px;
}

.field span:first-child {
  color: var(--muted);
  font-size: 0.82rem;
}

.field__inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(1, 17, 28, 0.52);
}

.field input {
  min-width: 0;
  color: var(--text);
  font-size: 0.95rem;
  background: transparent;
  border: 0;
  outline: none;
}

.field__suffix {
  color: var(--accent-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.preset-btn,
.action-btn,
.secondary-btn {
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.preset-btn {
  padding: clamp(5px, 0.7vh, 9px) 6px;
  color: var(--text);
  font-size: 0.76rem;
  white-space: nowrap;
  border-radius: 999px;
  background: rgba(7, 31, 47, 0.92);
  border: 1px solid var(--line);
}

.preset-btn:hover,
.preset-btn:focus-visible,
.action-btn:hover,
.action-btn:focus-visible {
  transform: translateY(-1px);
}

.preset-btn.is-active {
  background: rgba(255, 98, 48, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 98, 48, 0.5);
}

.difficulty-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.difficulty-btn {
  padding: clamp(6px, 0.8vh, 10px) 8px;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: var(--radius-md);
  background: rgba(7, 31, 47, 0.92);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.difficulty-btn:hover,
.difficulty-btn:focus-visible {
  transform: translateY(-1px);
}

.difficulty-btn.is-active {
  background: rgba(255, 98, 48, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 98, 48, 0.5);
}

.action-btn {
  padding: 12px 18px;
  color: white;
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff7344 0%, #ff5621 100%);
  box-shadow: 0 18px 40px var(--accent-shadow);
}

.secondary-btn {
  padding: 10px 14px;
  color: var(--text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(3, 20, 31, 0.78);
  backdrop-filter: blur(10px);
}

.secondary-btn {
  box-shadow: inset 0 0 0 1px rgba(123, 171, 196, 0.12);
}

.arena-section {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* During a round the arena fills the whole browser window even if real fullscreen was
   refused, so the field is never squeezed next to the settings panel. */
.arena-section.is-playing {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #020f19;
}

.arena-section.is-playing .arena-frame {
  flex: 1;
  height: 100%;
  border: 0;
  border-radius: 0;
}

.arena-section.is-playing .arena {
  height: 100%;
}

.arena-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(2, 24, 38, 0.82), rgba(1, 17, 27, 0.92));
  box-shadow: var(--shadow);
}

.arena-grid {
  position: absolute;
  inset: 0;
  /* Line width and cell size follow the field scale (--grid-line, --stage-scale from app.js) */
  background:
    linear-gradient(rgba(139, 184, 206, 0.08) var(--grid-line, 1px), transparent var(--grid-line, 1px)),
    linear-gradient(90deg, rgba(139, 184, 206, 0.08) var(--grid-line, 1px), transparent var(--grid-line, 1px));
  /* Exactly 7 x 4 cells across the 1280x720 field */
  background-size: calc(1280px / 7 * var(--stage-scale, 1)) calc(720px / 4 * var(--stage-scale, 1));
  background-position: var(--stage-x, 0px) var(--stage-y, 0px);
}

.arena {
  position: relative;
  height: 100%;
  min-height: 0;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke='%235dff5d' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M16 2v9'/%3E%3Cpath d='M16 21v9'/%3E%3Cpath d='M2 16h9'/%3E%3Cpath d='M21 16h9'/%3E%3C/g%3E%3Ccircle cx='16' cy='16' r='2.5' fill='%235dff5d'/%3E%3C/svg%3E") 16 16, crosshair;
  isolation: isolate;
  overflow: hidden;
}

/* Fixed 1280x720 logical field. JS scales it to fit the arena (see fitStage in app.js),
   so sizes inside it are in field pixels and do not depend on browser zoom. */
.arena-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 720px;
  transform-origin: 0 0;
}

/* On screens that are not 16:9 the spare strips are dimmed: targets never appear there. */
.arena.is-running .arena-stage {
  box-shadow: 0 0 0 9999px rgba(1, 9, 14, 0.28);
}

/* ── In-game HUD ─────────────────────────────────────────────
   Placed before #arena in the DOM, so targets are painted on top of it.
   pointer-events: none lets every click fall through to the targets. */
.arena-hud {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px 28px;
  pointer-events: none;
  user-select: none;
}

.arena-hud.hidden {
  display: none;
}

.arena-hud__stats {
  display: flex;
  align-items: flex-start;
  gap: 26px;
}

.arena-hud__stat {
  display: grid;
  gap: 4px;
  opacity: 0.6;
  transition: opacity 200ms ease;
}

.arena-hud__label {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.arena-hud__value {
  color: var(--text);
  font-family: "Consolas", "Lucida Console", monospace;
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.65);
  transition: color 200ms ease;
}

/* Score looks different from the clock-style timer on purpose:
   divider + extra space, bold slanted sans-serif, green/red tint, pop on change. */
.arena-hud__stat--score {
  padding-left: 26px;
  border-left: 1px solid rgba(238, 246, 251, 0.14);
  opacity: 0.72;
}

.arena-hud__value--score {
  font-family: "Bahnschrift", "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 35px;
  font-weight: 800;
  letter-spacing: 0.01em;
  transform: skewX(-8deg);
  transform-origin: left bottom;
  transition: color 200ms ease, text-shadow 200ms ease;
}

.arena-hud__value--score.is-positive {
  color: var(--success);
  text-shadow: 0 0 16px rgba(130, 255, 208, 0.38), 0 1px 6px rgba(0, 0, 0, 0.6);
}

.arena-hud__value--score.is-negative {
  color: #ff6b6b;
  text-shadow: 0 0 16px rgba(255, 107, 107, 0.4), 0 1px 6px rgba(0, 0, 0, 0.6);
}

.arena-hud__value--score.is-bump {
  animation: hud-score-bump 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes hud-score-bump {
  0%   { scale: 1; }
  35%  { scale: 1.16; }
  100% { scale: 1; }
}

/* Last seconds of the round: brighter, red and softly pulsing */
.arena-hud__stat--time.is-low {
  opacity: 0.95;
}

.arena-hud__stat--time.is-low .arena-hud__value {
  color: var(--accent);
  text-shadow: 0 0 18px rgba(255, 98, 48, 0.55);
  animation: hud-low-pulse 1s ease-in-out infinite;
}

@keyframes hud-low-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* Keyboard hint, not a button: nothing to misclick while aiming */
.arena-hud__exit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border: 1px solid rgba(238, 246, 251, 0.16);
  border-radius: 999px;
  background: rgba(2, 18, 28, 0.22);
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.6;
}

.arena-hud__exit kbd {
  padding: 3px 7px;
  border: 1px solid rgba(238, 246, 251, 0.34);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.overlay-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(560px, calc(100% - 40px));
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: rgba(6, 29, 44, 0.94);
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
  z-index: 3;
}

.overlay-card--intro {
  width: min(620px, calc(100% - 40px));
  max-height: calc(100% - 20px);
  overflow-y: auto;
}

.countdown-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at center, rgba(4, 25, 38, 0.28), rgba(1, 10, 16, 0.72));
  z-index: 5;
  pointer-events: none;
}

.countdown-overlay span {
  color: #fff5ec;
  font-family: "Consolas", "Lucida Console", monospace;
  /* Scaled with the field (--stage-scale from app.js) so browser zoom does not blow it up */
  font-size: calc(150px * var(--stage-scale, 1));
  font-weight: 700;
  line-height: 1;
  text-shadow:
    0 0 calc(24px * var(--stage-scale, 1)) rgba(255, 98, 48, 0.55),
    0 0 calc(48px * var(--stage-scale, 1)) rgba(255, 98, 48, 0.28);
}

.timeup-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at center, rgba(4, 25, 38, 0.45), rgba(1, 10, 16, 0.85));
  z-index: 5;
  pointer-events: none;
  animation: timeup-fade-in 0.18s ease forwards;
}

.timeup-overlay.hidden {
  display: none;
}

@keyframes timeup-fade-in {
  from { opacity: 0; transform: scale(1.08); }
  to   { opacity: 1; transform: scale(1); }
}

.timeup-overlay span {
  color: #fff5ec;
  font-family: "Consolas", "Lucida Console", monospace;
  font-size: calc(105px * var(--stage-scale, 1));
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow:
    0 0 calc(24px * var(--stage-scale, 1)) rgba(255, 98, 48, 0.7),
    0 0 calc(60px * var(--stage-scale, 1)) rgba(255, 98, 48, 0.35);
}

.overlay-card__note {
  margin-top: 6px;
  color: var(--accent-soft);
}

.overlay-card .overlay-card__controls {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.overlay-actions .action-btn,
.overlay-actions .secondary-btn {
  flex: 1 1 220px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 14px;
}

.results-grid div {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.results-grid__score {
  background: rgba(255, 98, 48, 0.12) !important;
  border-color: rgba(255, 98, 48, 0.28) !important;
}

.results-grid dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

.results-grid dd {
  margin: 0;
  color: var(--accent-soft);
  font-size: 1.28rem;
  font-family: "Consolas", "Lucida Console", monospace;
}

.results-grid__score dd {
  color: var(--accent);
  font-size: 1.52rem;
}

.result-explainer {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.result-explainer__title {
  margin-bottom: 8px !important;
  color: var(--accent-soft) !important;
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-explainer p + p {
  margin-top: 4px;
}

.score-legend {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.score-legend__title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.score-legend__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.score-legend__group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.score-legend__name {
  color: var(--text);
  font-size: 0.76rem;
  margin-bottom: 4px;
  font-weight: 600;
}

.score-legend__pos {
  color: var(--success);
  font-size: 0.8rem;
  font-family: "Consolas", "Lucida Console", monospace;
}

.score-legend__neg {
  color: #ff6b6b;
  font-size: 0.8rem;
  font-family: "Consolas", "Lucida Console", monospace;
}

.hidden {
  display: none;
}

.target {
  position: absolute;
  border: 0;
  padding: 0;
  border-radius: 50%;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cg fill='none' stroke='%235dff5d' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M16 2v9'/%3E%3Cpath d='M16 21v9'/%3E%3Cpath d='M2 16h9'/%3E%3Cpath d='M21 16h9'/%3E%3C/g%3E%3Ccircle cx='16' cy='16' r='2.5' fill='%235dff5d'/%3E%3C/svg%3E") 16 16, crosshair;
  opacity: 0;
  --target-scale: 0.12;
  --phase-duration: 1350ms;
  transform: translate(-50%, -50%) scale(var(--target-scale));
  background:
    radial-gradient(circle, #ff6a39 0 10%, #ffffff 10% 18%, #ff6a39 18% 25%, #ffffff 25% 42%, #ff6a39 42% 56%, #ffffff 56% 74%, #ff6a39 74% 100%);
  box-shadow:
    0 0 0 6px rgba(255, 98, 48, 0.09),
    0 0 32px rgba(255, 98, 48, 0.28);
  transition:
    transform var(--phase-duration) cubic-bezier(0.16, 1, 0.3, 1),
    opacity 180ms ease,
    box-shadow 220ms ease,
    filter 220ms ease;
}

.target::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.target.is-arriving,
.target.is-holding {
  opacity: 1;
  --target-scale: 1;
}

.target.is-arriving {
  --phase-duration: var(--grow-duration, 1350ms);
}

.target.is-departing {
  opacity: 0.2;
  --target-scale: 0.16;
  --phase-duration: var(--shrink-duration, 1350ms);
  box-shadow:
    0 0 0 4px rgba(255, 98, 48, 0.06),
    0 0 18px rgba(255, 98, 48, 0.18);
}

.target.is-hit {
  pointer-events: none;
  animation: target-hit 150ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.arena.is-running::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 0%, rgba(1, 9, 14, 0.08) 100%);
  pointer-events: none;
}

@keyframes target-hit {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    filter: brightness(1) saturate(1);
  }

  28% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.22);
    filter: brightness(2.2) saturate(2.2);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.18) rotate(14deg);
    filter: brightness(1.1) saturate(0.2);
  }
}

.impact-burst,
.miss-marker {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.impact-burst {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.96) 0 10%, rgba(255, 227, 146, 0.94) 10% 22%, rgba(255, 124, 68, 0.76) 22% 34%, transparent 36%),
    conic-gradient(from 0deg, rgba(255, 255, 255, 0.94), rgba(255, 132, 67, 0.12), rgba(255, 255, 255, 0.94), rgba(255, 132, 67, 0.12), rgba(255, 255, 255, 0.94), rgba(255, 132, 67, 0.12), rgba(255, 255, 255, 0.94));
  box-shadow:
    0 0 24px rgba(255, 205, 118, 0.74),
    0 0 54px rgba(255, 112, 58, 0.28);
  mix-blend-mode: screen;
  animation: impact-burst 140ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.impact-burst::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 3px solid rgba(255, 245, 220, 0.96);
  box-shadow: 0 0 18px rgba(255, 214, 134, 0.62);
}

.impact-burst::after {
  content: "";
  position: absolute;
  inset: 15px;
  clip-path: polygon(50% 0%, 63% 26%, 100% 50%, 63% 74%, 50% 100%, 37% 74%, 0% 50%, 37% 26%);
  background: radial-gradient(circle, rgba(255, 255, 255, 1) 0%, rgba(255, 224, 152, 0.96) 46%, rgba(255, 127, 72, 0.08) 100%);
}

.miss-marker {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(227, 239, 248, 0.96);
  box-shadow: 0 0 0 6px rgba(227, 239, 248, 0.12);
  animation: miss-blink 100ms linear forwards;
}

@keyframes impact-burst {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.22) rotate(0deg);
  }

  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.42) rotate(18deg);
  }
}

@keyframes miss-blink {
  from {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1);
  }

  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
  }
}

.arena-section:fullscreen {
  width: 100%;
  height: 100%;
  background: #020f19;
}

.arena-section:fullscreen .arena-frame {
  min-height: 100vh;
  height: 100vh;
  border: 0;
  border-radius: 0;
}

.arena-section:fullscreen .arena {
  height: 100%;
  min-height: 0;
}



@media (max-width: 780px) {
  body {
    overflow-y: auto;
  }

  .page-shell {
    height: auto;
    min-height: 100%;
    width: calc(100% - 16px);
    padding: 8px 0;
  }

  /* Compact topbar */
  .topbar {
    gap: 8px;
    margin-bottom: 6px;
  }

  .brand h1 {
    font-size: 1.3rem;
  }

  .brand__eyebrow {
    display: none;
  }

  .github-link__text {
    display: none;
  }

  .github-link {
    padding: 7px;
  }

  /* Compact settings panel */
  .trainer-layout {
    grid-template-columns: 1fr;
    flex: none;
    min-height: auto;
    gap: 8px;
  }

  .panel-card {
    padding: 12px;
    border-radius: 20px;
  }

  .panel-card h2 {
    font-size: 1rem;
    margin-bottom: 4px;
  }

  .panel-card__eyebrow {
    display: none;
  }

  .settings-form {
    margin-top: 8px;
  }

  .preset-btn {
    padding: 6px 4px;
    font-size: 0.72rem;
  }

  .difficulty-btn {
    padding: 7px 6px;
    font-size: 0.76rem;
  }

  /* Arena */
  .arena-frame {
    flex: none;
    min-height: auto;
    border-radius: 20px;
  }

  .arena {
    height: auto;
    /* Tall enough for the start and result cards even at a big browser zoom */
    min-height: max(58vh, 340px);
  }
}

/* No Esc key on touch-only devices (phones, tablets). Hidden by input type, not by width,
   so a zoomed-in desktop page still shows the hint. */
@media (hover: none) and (pointer: coarse) {
  .arena-hud__exit {
    display: none;
  }
}

/* ── Armored target ──────────────────────────────────────────── */
.target--armored {
  background:
    radial-gradient(circle, #c8e4ff 0 8%, #1a4878 8% 18%, #2a5a90 18% 28%, #123050 28% 38%, #2a6090 38% 50%, #1a4878 50% 62%, #2a5a90 62% 76%, #0d2540 76% 100%);
  box-shadow:
    0 0 0 6px rgba(80, 160, 255, 0.14),
    0 0 28px rgba(80, 160, 255, 0.42);
}

.target--armored::after {
  border-color: rgba(120, 200, 255, 0.38);
}

.target--armored::before {
  content: attr(data-hits-left);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.95);
  font-family: "Consolas", "Lucida Console", monospace;
  font-size: var(--target-font-size, 13px);
  font-weight: 900;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.9), 0 0 10px rgba(80, 180, 255, 0.6);
  z-index: 1;
  pointer-events: none;
}

/* Damage states – target shifts from blue → orange as hits land */
.target--armored[data-hits-left="4"] { filter: brightness(1.08); }
.target--armored[data-hits-left="3"] { filter: brightness(1.18) hue-rotate(-15deg); }
.target--armored[data-hits-left="2"] {
  filter: brightness(1.32) hue-rotate(-30deg);
  box-shadow: 0 0 0 6px rgba(255, 160, 80, 0.2), 0 0 30px rgba(255, 120, 50, 0.42);
}
.target--armored[data-hits-left="1"] {
  filter: brightness(1.52) hue-rotate(-50deg);
  box-shadow: 0 0 0 6px rgba(255, 100, 50, 0.32), 0 0 36px rgba(255, 70, 20, 0.58);
}

@keyframes armored-hit-flash {
  0%   { filter: brightness(3) saturate(2.5); }
  100% { filter: brightness(1) saturate(1); }
}

.target--armored.is-armored-hit {
  animation: armored-hit-flash 160ms ease-out forwards;
}

/* Armored burst explosion (blue, bigger than normal) */
.armored-burst {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(220, 242, 255, 0.98) 0 8%, rgba(120, 210, 255, 0.9) 8% 20%, rgba(50, 140, 220, 0.72) 20% 33%, transparent 36%),
    conic-gradient(from 0deg,
      rgba(200, 235, 255, 0.96), rgba(70, 150, 220, 0.12),
      rgba(200, 235, 255, 0.96), rgba(70, 150, 220, 0.12),
      rgba(200, 235, 255, 0.96), rgba(70, 150, 220, 0.12),
      rgba(200, 235, 255, 0.96), rgba(70, 150, 220, 0.12));
  box-shadow:
    0 0 32px rgba(90, 180, 255, 0.85),
    0 0 80px rgba(60, 130, 220, 0.52);
  mix-blend-mode: screen;
  animation: armored-burst-anim 280ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.armored-burst::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 3px solid rgba(190, 235, 255, 0.97);
  box-shadow: 0 0 22px rgba(130, 210, 255, 0.76);
}

.armored-burst::after {
  content: "";
  position: absolute;
  inset: 14px;
  clip-path: polygon(50% 0%, 63% 26%, 100% 50%, 63% 74%, 50% 100%, 37% 74%, 0% 50%, 37% 26%);
  background: radial-gradient(circle, rgba(255, 255, 255, 1) 0%, rgba(170, 228, 255, 0.96) 46%, rgba(60, 150, 220, 0.08) 100%);
}

@keyframes armored-burst-anim {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.18) rotate(0deg);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.9) rotate(30deg);
  }
}

/* ── Flying target (enemy fighter jet) ──────────────────────── */
.target--flying {
  border-radius: 0 !important;
  transition: none !important;
  opacity: 0;
  clip-path: polygon(
    50%  0%,
    64%  20%,
    100% 40%,
    76%  52%,
    68%  100%,
    50%  84%,
    32%  100%,
    24%  52%,
    0%   40%,
    36%  20%
  );
  background: linear-gradient(
    180deg,
    #ff1a1a 0%,
    #cc0a00 24%,
    #dd2200 52%,
    #991800 78%,
    #ff5500 100%
  ) !important;
  box-shadow: none !important;
  filter: drop-shadow(0 0 7px rgba(255, 55, 0, 0.92));
}

.target--flying::after {
  display: none !important;
}

/* Engine flame — flickers at the rear */
.target--flying::before {
  content: "";
  position: absolute;
  bottom: 6%;
  left: 50%;
  width: 30%;
  height: 38%;
  transform: translateX(-50%);
  background: linear-gradient(0deg,
    rgba(255, 210, 70, 0.96),
    rgba(255, 120, 30, 0.82),
    transparent
  );
  clip-path: polygon(15% 0%, 85% 0%, 50% 100%);
  pointer-events: none;
  animation: engine-flicker 130ms ease-in-out infinite alternate;
}

@keyframes engine-flicker {
  from { opacity: 0.6; transform: translateX(-50%) scaleY(0.72); }
  to   { opacity: 1;   transform: translateX(-50%) scaleY(1.18); }
}

/* JS drives position + rotation via rAF; is-flying just makes it visible */
.target--flying.is-flying {
  opacity: 1;
}

/* Flying burst — bigger, fire-orange, dramatic */
.flying-burst {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background:
    radial-gradient(circle,
      rgba(255, 255, 200, 0.98) 0 7%,
      rgba(255, 210, 60, 0.92)  7% 18%,
      rgba(255, 90,  0,  0.76) 18% 33%,
      transparent 36%),
    conic-gradient(from 0deg,
      rgba(255, 220, 70,  0.96), rgba(200, 70, 0, 0.13),
      rgba(255, 220, 70,  0.96), rgba(200, 70, 0, 0.13),
      rgba(255, 220, 70,  0.96), rgba(200, 70, 0, 0.13),
      rgba(255, 220, 70,  0.96), rgba(200, 70, 0, 0.13),
      rgba(255, 220, 70,  0.96), rgba(200, 70, 0, 0.13));
  box-shadow:
    0 0 36px rgba(255, 190, 30, 0.92),
    0 0 90px rgba(255, 80,  0,  0.54);
  mix-blend-mode: screen;
  animation: flying-burst-anim 320ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.flying-burst::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border: 3px solid rgba(255, 245, 180, 0.97);
  box-shadow: 0 0 24px rgba(255, 210, 80, 0.8);
}

.flying-burst::after {
  content: "";
  position: absolute;
  inset: 14px;
  clip-path: polygon(50% 0%, 65% 27%, 100% 50%, 65% 73%, 50% 100%, 35% 73%, 0% 50%, 35% 27%);
  background: radial-gradient(circle,
    rgba(255, 255, 255, 1)     0%,
    rgba(255, 240, 130, 0.96) 44%,
    rgba(255, 100, 0,   0.08) 100%
  );
}

@keyframes flying-burst-anim {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.16) rotate(0deg);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(2.1) rotate(36deg);
  }
}

@media (max-width: 760px) {
  .overlay-card {
    padding: 16px;
  }
}

/* Shared leaderboard */
.leaderboard-open {
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(2, 18, 28, 0.76);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.leaderboard-open:hover,
.leaderboard-open:focus-visible {
  border-color: var(--accent);
  color: var(--accent-soft);
}

.overlay-card--result {
  max-height: calc(100% - 20px);
  overflow-y: auto;
}

.score-submit {
  display: grid;
  gap: 10px;
  margin: 12px 0 10px;
  padding: 14px;
  border: 1px solid rgba(255, 98, 48, 0.45);
  border-radius: 16px;
  background: rgba(255, 98, 48, 0.08);
  box-shadow: 0 0 0 4px rgba(255, 98, 48, 0.06);
}

.score-submit.hidden { display: none; }

.score-submit label {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
}

.score-submit__row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.score-submit input,
.leaderboard-filters input,
.leaderboard-filters select {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(2, 18, 28, 0.9);
  color: var(--text);
}

.score-submit input { flex: 1 1 150px; font-size: 1rem; }
.score-submit input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-shadow); }
.score-submit button { flex: 0 1 auto; }
.score-submit button:disabled { opacity: 0.55; cursor: default; }
.score-submit__status { min-height: 1.2em; margin: 8px 0 0; color: var(--muted); font-size: 0.82rem; }
.score-submit__status:empty { min-height: 0; margin: 0; }
.score-submit__status.is-success { color: var(--success); font-weight: 700; }

.result-board {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.result-board__header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.result-board__title { margin: 0 !important; color: var(--muted) !important; font-size: 0.7rem !important; letter-spacing: 0.14em; text-transform: uppercase; }
.result-board__mode { color: var(--accent-soft); font-size: 0.78rem; font-weight: 700; white-space: nowrap; }

.leaderboard-dialog {
  width: min(560px, calc(100% - 24px));
  max-height: min(80vh, 700px);
  padding: 20px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: #061d2c;
  color: var(--text);
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.leaderboard-dialog::backdrop { background: rgba(0, 8, 16, 0.75); }
.leaderboard-dialog__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.leaderboard-dialog__header h2 { margin: 0; font-size: 1.4rem; }
.leaderboard-close { border: 0; background: transparent; color: var(--muted); font-size: 1.8rem; cursor: pointer; }
.leaderboard-close:hover { color: var(--text); }
.leaderboard-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.leaderboard-filters label { display: grid; gap: 6px; color: var(--muted); font-size: 0.82rem; }
#leaderboard-status { min-height: 1.3em; color: var(--muted); }
.leaderboard-list { margin: 0; padding-left: 32px; }
.leaderboard-list li { padding: 10px 4px; border-bottom: 1px solid var(--line); }
.leaderboard-list li::marker { color: var(--accent-soft); font-weight: 700; }
.leaderboard-list__row { display: flex; justify-content: space-between; gap: 12px; }
.leaderboard-list__name { overflow-wrap: anywhere; }
.leaderboard-list__score { color: var(--accent-soft); font-family: Consolas, monospace; font-weight: 700; white-space: nowrap; }
.leaderboard-list--compact li { padding: 6px 4px; font-size: 0.88rem; }
.leaderboard-list--compact li:last-child { border-bottom: 0; }
.leaderboard-list li.is-current { border-radius: 10px; background: rgba(255, 98, 48, 0.14); box-shadow: inset 0 0 0 1px rgba(255, 98, 48, 0.4); }
.leaderboard-list li.is-current .leaderboard-list__name { color: var(--accent-soft); font-weight: 700; }

@media (max-width: 780px) {
  .leaderboard-open { padding: 7px 9px; }
  .leaderboard-open span { display: none; }
}
