:root {
  --night: #0b1533;
  --panel: rgba(12, 22, 54, 0.9);
  --snow: #f7fbff;
  --muted: #bfd0ee;
  --red: #d7263d;
  --red-dark: #9f1228;
  --gold: #ffd166;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--night);
  color: var(--snow);
  font-family: Georgia, "Times New Roman", serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#stage {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  container-type: inline-size;
  background: var(--night);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas { display: block; width: 100%; height: 100%; }

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.top-buttons {
  position: absolute;
  top: 1.2cqw;
  right: 1.2cqw;
  display: flex;
  gap: 0.7cqw;
  z-index: 3;
}

.top-buttons button {
  width: max(36px, 3.4cqw);
  height: max(36px, 3.4cqw);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(12, 22, 54, 0.7);
  font-size: max(14px, 1.3cqw);
}

.top-buttons button[aria-pressed="true"] { opacity: 0.55; text-decoration: line-through; }

.touch-controls {
  position: absolute;
  right: 2cqw;
  bottom: 2cqw;
  display: flex;
  flex-direction: column;
  gap: 1.2cqw;
  z-index: 2;
}

.touch-controls[hidden] { display: none; }

.touch-controls button {
  width: max(64px, 9cqw);
  height: max(64px, 9cqw);
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(215, 38, 61, 0.55);
  font-size: max(22px, 3cqw);
  touch-action: none;
}

.touch-controls button.active { background: rgba(255, 209, 102, 0.8); color: #3a1d00; }

#overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2cqw;
  background: rgba(6, 12, 34, 0.35);
  z-index: 4;
}

#overlay[hidden] { display: none; }

.panel {
  width: min(92%, 620px);
  max-height: 100%;
  padding: clamp(14px, 3cqw, 36px);
  overflow: auto;
  border: 2px solid rgba(255, 209, 102, 0.65);
  border-radius: 18px;
  background: var(--panel);
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.eyebrow {
  margin: 0 0 0.3em;
  color: var(--gold);
  font-size: clamp(11px, 1.3cqw, 15px);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 5cqw, 58px);
  line-height: 1.05;
}

.lede {
  margin: 0.7em auto 0;
  max-width: 34em;
  color: var(--muted);
  font-size: clamp(13px, 1.6cqw, 19px);
  line-height: 1.4;
}

.stars {
  margin-top: 0.3em;
  color: var(--gold);
  font-size: clamp(24px, 4cqw, 44px);
  letter-spacing: 0.1em;
}

.stars:empty { display: none; }
.stars .off { color: rgba(255, 255, 255, 0.2); }

.how-to {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4em 1.2em;
  margin: 1em 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: clamp(11px, 1.25cqw, 15px);
}

.how-to[hidden] { display: none; }

.treats { color: var(--snow); font-weight: bold; }
.treats li { display: inline-flex; align-items: center; gap: 0.2em; }
.treats img { width: 2.2em; height: 2.2em; margin: -0.3em 0; }

kbd {
  padding: 0.05em 0.4em;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--snow);
  font-family: inherit;
}

.primary {
  margin-top: 1em;
  min-height: 44px;
  padding: 0.55em 1.6em;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(var(--red), var(--red-dark));
  color: #fff;
  font-size: clamp(16px, 2cqw, 23px);
  font-weight: bold;
  box-shadow: 0 4px 0 #6d0b1b;
}

.primary:hover { filter: brightness(1.1); }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #6d0b1b; }

.party-link {
  display: block;
  width: fit-content;
  margin: 0.9em auto 0;
  color: var(--gold);
  font-size: clamp(13px, 1.35cqw, 16px);
  font-weight: bold;
  line-height: 1.3;
}

.party-link[hidden] { display: none; }
.party-link:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.rotate-note { display: none; margin: 12px 16px; color: var(--muted); text-align: center; }

@media (pointer: coarse) {
  #howTo { display: none; }
}

@media (max-height: 500px) {
  #overlay { padding: 8px; }
  .panel { width: min(94%, 680px); padding: 12px 18px; }
  h1 { font-size: 26px; }
  .lede { margin-top: 0.35em; font-size: 13px; line-height: 1.3; }
  #treats, #howTo { display: none; }
  .primary { min-height: 40px; margin-top: 0.55em; font-size: 16px; }
  .party-link { margin-top: 0.55em; font-size: 13px; }
}

@media (orientation: portrait) and (max-width: 700px) {
  .rotate-note { display: block; }
  #stage { container-type: normal; touch-action: auto; }
  canvas { touch-action: none; }
  #overlay {
    position: fixed;
    padding: 16px;
    background: rgba(6, 12, 34, 0.76);
    z-index: 10;
  }
  .panel { width: 100%; max-height: calc(100dvh - 32px); padding: 22px 18px; }
  h1 { font-size: 34px; }
  .eyebrow { font-size: 12px; }
  .lede { font-size: 16px; }
  .how-to { font-size: 13px; }
  .stars { font-size: 34px; }
  .primary { font-size: 19px; }
  .party-link { font-size: 15px; }
}
