:root {
  color-scheme: dark;
  --bg: #08111a;
  --panel: rgba(8, 22, 34, 0.92);
  --card: rgba(15, 34, 49, 0.88);
  --line: rgba(151, 210, 255, 0.18);
  --text: #edf7ff;
  --muted: #9db7cb;
  --accent: #58d4ff;
  --accent-2: #ff8a5b;
  --danger: #ff5d73;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(88, 212, 255, 0.18), transparent 34%),
    radial-gradient(circle at bottom right, rgba(255, 138, 91, 0.16), transparent 28%),
    linear-gradient(135deg, #02060a, var(--bg));
}

.protocol-warning {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 93, 115, 0.28);
  background: rgba(69, 11, 20, 0.96);
  color: #ffd7df;
  text-align: center;
}

.protocol-warning code {
  color: #fff3c7;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 100vh;
}

.panel {
  display: grid;
  gap: 18px;
  padding: 24px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 10px;
}

h2 {
  font-size: 1rem;
  margin-bottom: 14px;
}

.lead {
  color: var(--muted);
  line-height: 1.5;
}

.card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
}

label,
.stage-header {
  color: var(--muted);
}

select,
button,
input[type="range"] {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  font: inherit;
}

select {
  margin-top: 8px;
  padding: 12px;
  color: var(--text);
  background: rgba(6, 17, 26, 0.92);
}

label + select,
label + input[type="range"] {
  margin-bottom: 12px;
}

input[type="range"] {
  margin-top: 8px;
  accent-color: var(--accent);
  background: transparent;
  border: 0;
  padding: 0;
}

.slider-readout {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

button {
  padding: 12px 14px;
  color: #041017;
  background: linear-gradient(135deg, var(--accent), #94f0ff);
  cursor: pointer;
  font-weight: 700;
}

button.ghost {
  color: var(--text);
  background: rgba(6, 17, 26, 0.45);
}

.stats {
  display: grid;
  gap: 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(151, 210, 255, 0.08);
}

.stat-row:last-child {
  border-bottom: 0;
}

.leaderboard {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  display: grid;
  gap: 10px;
}

.leaderboard li {
  padding-left: 4px;
}

.stage-wrap {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: 18px;
}

.stage-wrap:fullscreen {
  padding: 0;
  gap: 0;
  background: #01060a;
}

.stage-wrap:fullscreen .stage-header {
  display: none;
}

.stage {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(7, 20, 31, 0.92), rgba(3, 9, 14, 0.98));
}

.stage-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.game-over-message {
  color: var(--danger);
  font-weight: 700;
}

canvas {
  width: 100%;
  height: calc(100vh - 66px);
  display: block;
  cursor: default;
  position: relative;
  z-index: 2;
  background: transparent;
}

.target-sprite-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.target-sprite {
  position: absolute;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  pointer-events: none;
  filter:
    drop-shadow(0 6px 10px rgba(0, 0, 0, 0.24))
    drop-shadow(0 0 10px rgba(255, 255, 255, 0.1));
}

.background-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  --bg-base-x: 0px;
  --bg-base-y: 0px;
}

.background-base {
  position: absolute;
  inset: -18%;
  transform-origin: center center;
  will-change: transform;
  background:
    linear-gradient(180deg, rgba(4, 10, 16, 0.08), rgba(3, 7, 10, 0.16)),
    url("./bg.png") center center / cover no-repeat;
  opacity: 0.98;
  transform: translate(var(--bg-base-x), var(--bg-base-y)) scale(1.24);
}

.hud-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.fullscreen-start-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: none;
}

.fullscreen-start-overlay[hidden] {
  display: none;
}

.fullscreen-start-card {
  width: min(420px, calc(100vw - 36px));
  padding: 22px 22px 20px;
  border: 1px solid rgba(151, 210, 255, 0.22);
  border-radius: 24px;
  background: rgba(4, 14, 22, 0.82);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
  pointer-events: auto;
  text-align: center;
}

.fullscreen-start-eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
}

.fullscreen-start-card h2 {
  margin-bottom: 10px;
  font-size: 1.8rem;
}

.fullscreen-start-card p {
  color: var(--muted);
  line-height: 1.5;
}

.fullscreen-start-button {
  margin-top: 18px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(151, 210, 255, 0.16);
  background: linear-gradient(135deg, var(--accent), #94f0ff);
  color: #041017;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  pointer-events: auto;
}

.compact-hud {
  position: absolute;
  inset: 14px 14px auto;
  display: grid;
  gap: 10px;
  opacity: 0;
  transform: translateY(-8px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.stage-wrap:fullscreen .compact-hud {
  opacity: 1;
  transform: translateY(0);
}

body.is-fullscreen .compact-hud {
  opacity: 1;
  transform: translateY(0);
}

body.is-fullscreen .compact-hud .hud-actions {
  justify-content: space-between;
}

.hud-stats,
.hud-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hud-actions {
  justify-content: flex-end;
}

.hud-pill,
.hud-button,
.hud-settings {
  border: 1px solid rgba(151, 210, 255, 0.18);
  background: rgba(4, 14, 22, 0.74);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.hud-pill {
  min-width: 92px;
  padding: 8px 12px;
  border-radius: 14px;
  display: grid;
  gap: 3px;
}

.hud-pill span {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud-pill strong {
  font-size: 0.96rem;
}

.hud-button {
  width: auto;
  min-width: 108px;
  padding: 10px 14px;
  border-radius: 999px;
  color: #041017;
  pointer-events: auto;
}

.hud-button.ghost {
  color: var(--text);
  background: rgba(4, 14, 22, 0.74);
}

.hud-settings {
  width: min(320px, calc(100vw - 28px));
  padding: 14px;
  border-radius: 18px;
  display: grid;
  gap: 10px;
  pointer-events: auto;
}

.hud-settings[hidden] {
  display: none;
}

.hud-settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.hud-settings-eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
}

.hud-settings h3 {
  margin: 0;
  font-size: 1.05rem;
}

.hud-close-button {
  width: auto;
  min-width: 86px;
  padding: 9px 12px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(6, 17, 26, 0.45);
  pointer-events: auto;
}

.hud-field {
  display: grid;
  gap: 6px;
}

.hud-settings label {
  font-size: 0.88rem;
  color: var(--text);
}

.slider-readout.compact {
  font-size: 0.82rem;
}

.reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
}

.reticle-ring,
.reticle-dot {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.reticle-ring {
  border: 1.5px solid rgba(213, 246, 255, 0.82);
  box-shadow:
    0 0 14px rgba(88, 212, 255, 0.45),
    inset 0 0 8px rgba(88, 212, 255, 0.18);
}

.reticle-dot {
  inset: 12px;
  background: #fff4d2;
}

.lock-hint {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  border: 1px solid rgba(151, 210, 255, 0.18);
  border-radius: 999px;
  background: rgba(4, 14, 22, 0.76);
  color: #d7efff;
  font-size: 0.92rem;
  backdrop-filter: blur(10px);
}

.stage-wrap:fullscreen .lock-hint {
  top: auto;
  bottom: 18px;
}

body.is-fullscreen .lock-hint {
  top: auto;
  bottom: 18px;
}

body.is-fullscreen .lock-hint[hidden] {
  display: none;
}

.bow-hud {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(26vw, 220px);
  height: min(36vh, 300px);
  transform: translateX(-50%);
  filter: drop-shadow(0 -6px 28px rgba(0, 0, 0, 0.55));
}

.bow-arc,
.bow-string,
.aim-line,
.arrow-shaft,
.arrow-head,
.arrow-fletch {
  position: absolute;
}

.aim-line {
  left: 50%;
  bottom: 34px;
  width: 8px;
  height: 58%;
  transform: translateX(-50%);
}

.arrow-shaft {
  left: 50%;
  bottom: 0;
  width: 3px;
  height: 100%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(190, 156, 111, 0.96), rgba(95, 66, 39, 0.98));
  box-shadow: 0 0 10px rgba(255, 208, 150, 0.12);
}

.arrow-head {
  left: 50%;
  top: -10px;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 18px solid rgba(201, 225, 236, 0.92);
}

.arrow-fletch {
  left: 50%;
  bottom: -1px;
  width: 20px;
  height: 18px;
  transform: translateX(-50%);
}

.arrow-fletch::before,
.arrow-fletch::after {
  content: "";
  position: absolute;
  bottom: 2px;
  width: 10px;
  height: 14px;
  background: linear-gradient(180deg, rgba(110, 214, 255, 0.88), rgba(45, 120, 148, 0.96));
}

.arrow-fletch::before {
  left: -2px;
  clip-path: polygon(0 100%, 100% 0, 100% 100%);
}

.arrow-fletch::after {
  right: -2px;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.bow-arc {
  left: 50%;
  bottom: 6px;
  width: 120px;
  height: 220px;
  transform: translateX(-50%);
  border-left: 5px solid rgba(115, 74, 40, 0.98);
  border-right: 5px solid rgba(115, 74, 40, 0.98);
  border-radius: 56% 56% 48% 48% / 52% 52% 48% 48%;
  box-shadow:
    inset 0 0 16px rgba(0, 0, 0, 0.24),
    0 0 18px rgba(0, 0, 0, 0.24);
}

.bow-string {
  left: 50%;
  bottom: 28px;
  width: 2px;
  height: 190px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(225, 238, 247, 0.55), rgba(236, 242, 248, 0.82), rgba(225, 238, 247, 0.55));
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.18);
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  canvas {
    height: min(64vh, 520px);
  }

  .stage-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .compact-hud {
    inset: 12px 12px auto;
  }

  .hud-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud-actions {
    justify-content: flex-start;
  }

  .bow-hud {
    width: min(32vw, 180px);
    height: min(30vh, 240px);
  }

  .lock-hint {
    max-width: calc(100% - 28px);
    text-align: center;
  }
}

body.is-fullscreen .panel {
  display: none;
}

body.is-fullscreen .app-shell {
  display: block;
}

body.is-fullscreen .stage-wrap {
  min-height: 100vh;
  padding: 0;
}

body.is-fullscreen .stage {
  border-radius: 0;
  border: 0;
}

body.is-fullscreen canvas {
  height: 100vh;
}
