:root {
  --navy: #1c3f62;
  --ink: #102e47;
  --teal: #00688a;
  --rim: #00929c;
  --lime: #b0b749;
  --gold: #e8c253;
  --light: #f4f4dd;
  --muted: #c1d3df;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { background: var(--navy); scrollbar-color: var(--rim) var(--navy); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  padding: 24px;
  background: var(--navy);
  color: var(--light);
  font-family: 'Roboto Mono', monospace;
  font-size: 16px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
::selection { background: var(--gold); color: var(--ink); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; text-underline-offset: 5px; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
h1, h2, p { margin: 0; }
img { display: block; max-width: 100%; height: auto; }
[hidden] { display: none !important; }
#particles-js { position: fixed; inset: 0; pointer-events: none; opacity: .65; }
#particles-js canvas { display: block; pointer-events: none; }
main, #credits { position: relative; }
.button {
  min-height: 56px;
  padding: 14px 24px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--ink);
  color: var(--light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 140ms ease-out, color 140ms ease-out, transform 140ms ease-out;
}
.button:active { transform: translateY(2px); }
.button:disabled { cursor: default; opacity: .6; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 5px; }
#startContainer :focus-visible, .popup :focus-visible { outline-color: var(--ink); }
@media (hover: hover) {
  .button:hover { background: #0a2133; }
  .button-secondary:hover { background: var(--light); color: var(--ink); }
  .home-link:hover { text-decoration-thickness: 2px; }
}
#startContainer {
  width: min(100%, 1000px);
  padding: 56px 64px 32px;
  background: var(--lime);
  color: var(--ink);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: .8fr 1.2fr;
  gap: 32px 56px;
}
.start-crest { display: flex; align-items: center; justify-content: center; }
.start-crest img { width: 220px; }
.start-copy h1 { font-size: clamp(36px, 4vw, 54px); line-height: 1.12; letter-spacing: -.035em; font-weight: 700; }
.start-copy > p { margin: 24px 0; font-size: 15px; }
.start-copy .button { min-width: 240px; }
.start-rules { grid-column: 1 / -1; padding-top: 24px; border-top: 1px solid #7c8534; text-align: center; font-size: 14px; line-height: 1.8; }
#credits { color: var(--muted); font-size: 12px; text-align: center; }
#credits strong { color: var(--light); font-weight: 500; }
.game-page { gap: 12px; }
#gameContainer { width: min(100%, 1120px); height: calc(100vh - 92px); height: calc(100svh - 92px); max-height: 900px; min-height: 300px; display: flex; flex-direction: column; }
.game-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; margin-bottom: 20px; }
.game-header h1 { font-size: 19px; font-weight: 700; line-height: 1.4; letter-spacing: -.02em; }
.game-header h1 span { font-size: 13px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.time-display { display: flex; align-items: baseline; justify-content: center; gap: 10px; white-space: nowrap; }
#timer { font-size: 40px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.time-label { color: var(--muted); font-size: 12px; }
.time-display[data-ending="true"] #timer { color: var(--gold); }
.button-secondary { justify-self: end; border-color: #7493a8; background: transparent; padding: 10px 16px; min-height: 46px; font-size: 14px; gap: 10px; }
.button-secondary svg { width: 18px; height: 18px; }
#targetSpawnArea { flex: 1; min-height: 0; position: relative; background: var(--teal); border: 4px solid var(--rim); border-radius: var(--radius); overflow: hidden; }
#target {
  position: absolute;
  width: auto;
  height: min(148px, 25svh);
  aspect-ratio: 244 / 384;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  /* No entrance or movement animation: every new target is immediately hittable. */
}
#target img { width: 100%; height: 100%; pointer-events: none; }
#target:focus-visible { outline-color: var(--gold); }
#playInstructions { padding-top: 12px; font-size: 12px; color: var(--muted); text-align: center; }
.no-script { color: var(--gold); text-align: center; }
.popup {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100svh - 32px);
  padding: 32px 40px;
  border: 0;
  border-radius: var(--radius);
  background: var(--gold);
  color: var(--ink);
  text-align: center;
  overflow-y: auto;
  box-shadow: 0 20px 64px #00000040;
}
.popup::backdrop { background: #102e47c9; }
.popup[open] { animation: round-finished 240ms cubic-bezier(.16, 1, .3, 1); }
.result-crest { width: 48px; margin: 0 auto 16px; }
.popup h2 { font-size: 36px; line-height: 1.2; letter-spacing: -.03em; }
.popup > p { margin-top: 10px; font-size: 14px; }
.results-stats { display: grid; grid-template-columns: .8fr 1.2fr; margin: 28px 0; padding: 20px 0; border-block: 1px solid #a58a36; gap: 16px; }
.results-stats dt { font-size: 12px; }
.results-stats dd { margin: 6px 0 0; font-size: 36px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-unit { font-size: 16px; font-weight: 500; }
.popup .button { width: 100%; }
.home-link { display: inline-block; padding: 12px 4px 0; min-height: 44px; font-size: 13px; }
@keyframes round-finished { from { transform: translateY(10px); } to { transform: translateY(0); } }
@media (max-width: 700px) {
  body { padding: 20px 16px; gap: 20px; }
  #startContainer { width: min(100%, 440px); grid-template-columns: 1fr; padding: 28px 24px 24px; gap: 24px; text-align: center; }
  .start-crest img { width: 100px; }
  .start-copy h1 { font-size: clamp(32px, 7.8vw, 40px); }
  .start-copy > p { margin: 20px 0; font-size: 13px; }
  .start-copy .button { width: 100%; min-width: 0; }
  .start-rules { padding-top: 20px; font-size: 12px; }
  #credits { font-size: 11px; }
  .game-page { padding: 16px; gap: 12px; }
  #gameContainer { height: calc(100vh - 64px); height: calc(100svh - 64px); }
  .game-header { grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; margin-bottom: 16px; }
  .game-header h1 { font-size: 16px; }
  .game-header h1 span { display: block; font-size: 12px; max-width: 16ch; }
  .time-display { flex-direction: column; align-items: center; gap: 5px; }
  #timer { font-size: 34px; }
  .time-label { font-size: 11px; }
  .button-secondary { gap: 6px; padding: 10px; font-size: 12px; }
  #targetSpawnArea { border-width: 3px; }
  #target { height: min(124px, 25svh); }
  #playInstructions { font-size: 12px; padding-top: 12px; }
  .popup { padding: 28px 24px 20px; }
  .popup h2 { font-size: 32px; }
  .results-stats { gap: 8px; }
  .results-stats dt { font-size: 12px; }
  .results-stats dd { font-size: 30px; }
}
@media (max-height: 500px) and (min-width: 701px) {
  body { padding-block: 12px; }
  #startContainer { padding: 24px 40px; gap: 16px 40px; }
  .start-crest img { width: 120px; }
  .start-copy h1 { font-size: 32px; }
  .start-copy > p { margin: 12px 0; }
  .start-rules { padding-top: 12px; }
  .game-header { margin-bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .button:active { transform: none; }
}
@media (max-height: 500px) and (min-width: 600px) {
  .popup { width: min(640px, calc(100% - 32px)); padding: 24px; }
  .popup[open] { display: grid; grid-template-columns: 1fr 1.2fr; column-gap: 24px; align-items: center; }
  .result-crest { display: none; }
  .popup h2, .popup > p { grid-column: 1; }
  .popup h2 { font-size: 28px; }
  .popup > p { font-size: 13px; }
  .results-stats { grid-column: 2; grid-row: 1 / span 2; margin: 0; padding: 12px 0; }
  .results-stats dd { font-size: 28px; }
  .popup .button { grid-column: 1 / -1; margin-top: 24px; }
  .home-link { grid-column: 1 / -1; }
}
