/* One card, centred, legible on a phone. Dark by default to sit next to
   Discord; the light scheme follows the reader's system setting. */

:root {
  --bg: #1a1c22;
  --bg-glow: #232634;
  --surface: #24272f;
  --surface-2: #2b2f39;
  --border: #3a3f4b;
  --text: #f2f3f5;
  --text-dim: #b6bac2;
  --brand: #5865f2;
  --brand-hover: #4752c4;
  --ok: #3ba55d;
  --bad: #ed4245;
  --radius: 14px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef0f5;
    --bg-glow: #ffffff;
    --surface: #ffffff;
    --surface-2: #f4f5f8;
    --border: #d6d9e0;
    --text: #1f2126;
    --text-dim: #5c6067;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 24px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1100px 520px at 50% -10%, var(--bg-glow), var(--bg));
  line-height: 1.5;
}

.card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .28);
}

.card-header { text-align: center; }

.shield {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

h1 { font-size: 1.4rem; margin: 0 0 6px; }
h2 { font-size: 1.2rem; margin: 10px 0 6px; }

.subtitle { margin: 0; color: var(--text-dim); font-size: .95rem; }

.timer {
  margin: 18px 0 0;
  text-align: center;
  font-size: .85rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.timer.urgent { color: var(--bad); font-weight: 600; }

.panel { margin-top: 18px; }

.rules {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: grid;
  gap: 8px;
}
.rules li {
  display: grid;
  grid-template-columns: 5.6em 1fr;  /* wide enough for the three-icon row */
  align-items: center;
  gap: 10px;
  font-size: .9rem;
  line-height: 1.35;
  color: var(--text-dim);
}
.rule-icon {
  display: flex;
  justify-content: center;
  gap: 3px;
}
.rule-icon img { width: 1.5em; height: 1.5em; }

/* The arena is a fixed 320x400 logical space, scaled to the card; craft are
   placed by percentage so they land in the same spot at every size. */
.arena {
  position: relative;
  width: 100%;
  aspect-ratio: 320 / 400;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #070b1d 0%, #14204a 70%, #2a3a6e 100%);
  container-type: inline-size;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}
.arena.warn { box-shadow: inset 0 0 0 3px var(--bad); }
.arena.lost { filter: saturate(.4); }

.assets { position: absolute; inset: 0; pointer-events: none; }

/* Craft are PNG sprites (tools/render_sprites.py) so they look the same on
   every platform. Each is a square box with the sprite as its background;
   captcha.js rotates the box along the craft's path. */
.asset {
  position: absolute;
  width: 13cqw;
  height: 13cqw;
  transform: translate(-50%, -50%);
  background: center / contain no-repeat;
  pointer-events: none;
  will-change: left, top;
}
.asset.meteor {
  /* Set per challenge by captcha.js; the file is the fallback. */
  background-image: var(--meteor-sprite, url("/static/img/sprites/meteor.png"));
  /* per-meteor tint, set inline by captcha.js */
  filter: hue-rotate(var(--hue, 0deg)) saturate(var(--sat, 1)) brightness(var(--bri, 1))
          drop-shadow(0 0 6px rgba(255, 140, 60, .8));
}
/* Set per challenge by captcha.js, like the meteor above; the files remain
   the fallback for a page that could not reach the route. */
.asset.satellite { background-image: var(--satellite-sprite, url("/static/img/sprites/satellite.png")); }
.asset.plane     { background-image: var(--plane-sprite, url("/static/img/sprites/plane.png")); }
.asset.parachute { background-image: var(--parachute-sprite, url("/static/img/sprites/parachute.png")); }
.asset[hidden] { display: none; }

.flash {
  position: absolute;
  width: 15cqw;
  height: 15cqw;
  transform: translate(-50%, -50%);
  background: center / contain no-repeat;
  pointer-events: none;
  animation: flash .4s ease-out forwards;
}
.flash.boom { background-image: url("/static/img/sprites/boom.png"); }
.flash.warn { background-image: url("/static/img/sprites/warn.png"); }
@keyframes flash {
  from { opacity: 1; transform: translate(-50%, -50%) scale(.6); }
  to   { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

.city {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10%;
  pointer-events: none;
  background: url("/static/img/sprites/city.png") bottom center / 100% 100% no-repeat;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  background: rgba(5, 8, 20, .72);
  color: #f2f3f5;
}
.overlay[hidden] { display: none; }
.overlay p { margin: 0; font-size: 1.05rem; font-weight: 600; }
.overlay .btn { width: auto; min-width: 140px; }

.hud {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: .9rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
#hud-meteors { display: inline-flex; align-items: center; gap: 5px; }
.hud-icon { width: 1.2em; height: 1.2em; }

.btn {
  width: 100%;
  padding: 11px 14px;
  font-size: .98rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, opacity .15s ease;
}

.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn.primary:disabled { opacity: .55; cursor: not-allowed; }

.btn.ghost {
  margin-top: 10px;
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border);
}
.btn.ghost:hover { color: var(--text); }

.status {
  margin: 12px 0 0;
  min-height: 1.3em;
  text-align: center;
  font-size: .9rem;
  color: var(--text-dim);
}
.status.bad { color: var(--bad); }
.status.good { color: var(--ok); }

.success { text-align: center; }

.tick {
  width: 58px;
  height: 58px;
  margin: 4px auto 0;
  display: grid;
  place-items: center;
  font-size: 1.9rem;
  color: #fff;
  background: var(--ok);
  border-radius: 50%;
}

code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: .85em;
}

@media (max-width: 400px) {
  .card { padding: 22px 16px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
