* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1a3a;
  color: #f5e9c8;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.halloween {
  background: #4a1b5e;
}

#sky {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px 24px 22px;
  /* About twice the first size; smaller on narrow screens so it fits. */
  font-size: clamp(1.25rem, 5vw, 2.5rem);
  font-weight: 600;
  pointer-events: none;
  background: linear-gradient(rgba(5, 12, 30, 0.6), rgba(5, 12, 30, 0));
}

.hud-score {
  justify-self: start;
}

.hud-target {
  justify-self: center;
  font-size: clamp(1.5rem, 6vw, 3rem);
  color: #ffd27a;
}

.hud-lives {
  justify-self: end;
  display: flex;
  gap: clamp(6px, 1.5vw, 14px);
}

.hud-lives svg {
  width: clamp(22px, 5.5vw, 44px);
  height: clamp(32px, 8vw, 64px);
  transition: opacity 0.6s ease, filter 0.6s ease;
}

.hud-level {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 1.1em; /* room for the mark labels under the bar */
  font-size: 0.55em;
}

.hud-level-name {
  white-space: nowrap;
}

/* 0 to 200 points; the marks sit at 100 and at the end, 200. */
.hud-progress {
  position: relative;
  flex: 1;
  height: 22px;
  margin-right: 24px;
  border: 2px solid rgba(255, 154, 60, 0.85);
  border-radius: 999px;
  background: rgba(20, 8, 30, 0.55);
  box-shadow: 0 0 12px rgba(255, 140, 40, 0.35);
}

.hud-progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(#ffb04a, #ff7a12);
  box-shadow: 0 0 10px rgba(255, 130, 30, 0.8);
  transition: width 0.3s ease;
}

/* A tick across the bar, with its number in a badge below. */
.hud-progress-mark {
  position: absolute;
  top: -6px;
  height: 30px;
  border-left: 3px solid #fff1cf;
  transform: translateX(-1.5px);
}

.hud-progress-mark span {
  position: absolute;
  top: 32px;
  left: 0;
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: clamp(0.8rem, 2.6vw, 1rem);
  font-weight: 800;
  line-height: 1.2;
  color: #2a1700;
  background: #ffc35c;
}

.hud-lives svg.lost {
  opacity: 0.2;
  filter: grayscale(1);
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 12, 30, 0.55);
}

/* Lighter, so the attract mode behind it shows through. */
#start-overlay {
  background: rgba(5, 12, 30, 0.25);
}

.overlay[hidden] {
  display: none;
}

.panel {
  text-align: center;
  padding: 32px 48px;
  border-radius: 16px;
  background: rgba(15, 30, 66, 0.85);
  box-shadow: 0 0 40px rgba(255, 190, 90, 0.15);
}

.panel h1 {
  margin: 0 0 24px;
  font-size: 3rem;
  color: #ffd27a;
  text-shadow: 0 0 18px rgba(255, 180, 70, 0.6);
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 2.25rem;
  color: #ffd27a;
}

.panel p {
  margin: 0 0 8px;
}

.panel .hint {
  margin: 0;
  opacity: 0.7;
}

.panel .result {
  font-size: 1.25rem;
}

.panel .buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.panel .start-level {
  margin: -12px 0 20px;
}

.banner {
  position: fixed;
  top: 40%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(2.5rem, 10vw, 5rem);
  font-weight: 800;
  color: #ffd27a;
  text-shadow: 0 0 24px rgba(255, 180, 70, 0.8);
  pointer-events: none;
}

.banner[hidden] {
  display: none;
}

.banner.show {
  animation: banner 1.8s ease forwards;
}

@keyframes banner {
  0% { opacity: 0; transform: scale(0.8); }
  15% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

.panel button {
  font: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  padding: 12px 40px;
  border: none;
  border-radius: 999px;
  color: #2a1700;
  background: #ffc35c;
  cursor: pointer;
}

.panel button:hover,
.panel button:focus-visible {
  background: #ffd98f;
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 210, 122, 0.4);
}

.start-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.panel .toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  font-size: 1.1rem;
  color: #f5e9c8;
  background: rgba(255, 255, 255, 0.08);
  touch-action: manipulation;
}

.panel .toggle:hover,
.panel .toggle:focus-visible {
  background: rgba(255, 255, 255, 0.16);
}

.toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  transition: background 0.2s ease;
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f5e9c8;
  transition: transform 0.2s ease;
}

.toggle[aria-checked="true"] .toggle-track {
  background: #ff7a1a;
}

.toggle[aria-checked="true"] .toggle-knob {
  transform: translateX(20px);
}
