:root {
  --night: #0d1238;
  --night2: #1a2766;
  --card: #141c52;
  --gold: #f5c542;
  --gold-dk: #c98a17;
  --blue: #2f6bff;
  --sky: #8fb8ff;
  --ink: #120b2e;
  --white: #fff8e7;
  --px: 4px;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --body: "VT323", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  background: linear-gradient(180deg, var(--night) 0%, var(--night2) 70%, #23358a 100%);
  color: var(--white);
  font-family: var(--body);
  font-size: 24px;
  line-height: 1.15;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }

#stars { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; image-rendering: pixelated; }

main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 28px 18px 24px;
  flex: 1;
}

.px { image-rendering: pixelated; image-rendering: crisp-edges; }

/* Title */
.title { text-align: center; }
.kicker {
  margin: 0 0 14px;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--sky);
}
h1 {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(22px, 7.4vw, 32px);
  line-height: 1.35;
  color: var(--gold);
  text-transform: uppercase;
  text-shadow: 3px 3px 0 var(--blue), 6px 6px 0 var(--ink);
}

/* Chanukiah */
.menorah-wrap { text-align: center; margin: 18px 0 6px; }
#chanukiah { width: 240px; height: 176px; display: block; margin: 0 auto; }
.night {
  margin: 2px 0 0;
  font-family: var(--pixel);
  font-size: 9px;
  color: var(--sky);
  text-transform: uppercase;
  opacity: 0;
  transition: opacity .4s;
}
.night.on { opacity: 1; }

/* Card with stepped pixel border */
.card {
  position: relative;
  margin: 18px 6px 0;
  padding: 22px 20px 24px;
  background: var(--card);
  box-shadow:
    0 calc(-1 * var(--px)) 0 0 var(--gold),
    0 var(--px) 0 0 var(--gold),
    calc(-1 * var(--px)) 0 0 0 var(--gold),
    var(--px) 0 0 0 var(--gold),
    0 calc(-2 * var(--px)) 0 0 var(--ink),
    0 calc(2 * var(--px)) 0 0 var(--ink),
    calc(-2 * var(--px)) 0 0 0 var(--ink),
    calc(2 * var(--px)) 0 0 0 var(--ink),
    0 calc(4 * var(--px)) 0 0 rgba(0,0,0,.35);
}
.screen p { margin: 0 0 14px; }
.screen { text-align: left; }
.big { font-family: var(--pixel); font-size: 15px; line-height: 1.5; color: var(--gold); text-align: center; }
.small { font-size: 20px; color: var(--sky); }
.label { font-family: var(--pixel); font-size: 9px; text-transform: uppercase; color: var(--sky); margin: 0 0 8px; }
.center { text-align: center; }
.blink { text-align: center; font-family: var(--pixel); font-size: 12px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Player */
.player { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.avatar {
  width: 88px; height: 88px; flex: none;
  image-rendering: pixelated;
  background: var(--blue);
  box-shadow: 0 0 0 4px var(--gold), 0 0 0 8px var(--ink);
  margin: 8px;
}
.pname { font-family: var(--pixel); font-size: 18px; color: var(--gold); margin: 0; text-transform: uppercase; word-break: break-word; }

/* Dreidel */
.dreidel { display: block; margin: 6px auto 18px; width: 64px; height: 92px; animation: wobble 1.6s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes wobble { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.spin-stage { position: relative; height: 210px; display: flex; align-items: flex-end; justify-content: center; margin-bottom: 8px; }
.big-dreidel { width: 112px; height: 161px; margin: 0 0 22px; animation: none; position: relative; z-index: 1; }
.dshadow { position: absolute; bottom: 14px; left: 50%; width: 80px; height: 12px; margin-left: -40px; background: rgba(0,0,0,.35); border-radius: 50%; }

/* Buttons */
.btn {
  display: block;
  width: 100%;
  font-family: var(--pixel);
  font-size: 13px;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--gold);
  border: 0;
  padding: 18px 12px;
  cursor: pointer;
  box-shadow:
    0 calc(-1 * var(--px)) 0 0 var(--ink),
    0 var(--px) 0 0 var(--ink),
    calc(-1 * var(--px)) 0 0 0 var(--ink),
    var(--px) 0 0 0 var(--ink),
    inset 0 calc(-1 * var(--px)) 0 0 var(--gold-dk),
    0 calc(2 * var(--px)) 0 0 var(--ink);
  transition: transform .05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(var(--px)); box-shadow: 0 calc(-1 * var(--px)) 0 0 var(--ink), 0 var(--px) 0 0 var(--ink), calc(-1 * var(--px)) 0 0 0 var(--ink), var(--px) 0 0 0 var(--ink); }
.btn:focus-visible { outline: 3px dashed var(--white); outline-offset: 8px; }
#spinBtn { animation: pulse 1.2s steps(2) infinite; }
@keyframes pulse { 50% { background: #ffd96b; } }
.btn-ghost { background: transparent; color: var(--sky); box-shadow: 0 0 0 3px var(--sky); font-size: 10px; padding: 14px 10px; margin-top: 8px; }
.btn-ghost:active { box-shadow: 0 0 0 3px var(--sky); }

/* Reveal */
.photo-frame {
  width: min(240px, 70vw);
  aspect-ratio: 1;
  margin: 8px auto 18px;
  background: var(--blue);
  box-shadow: 0 0 0 6px var(--gold), 0 0 0 12px var(--ink), 0 16px 0 6px rgba(0,0,0,.3);
}
#reveal { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.target {
  min-height: 1.5em;
  font-family: var(--pixel);
  font-size: clamp(22px, 7vw, 28px);
  text-align: center;
  color: var(--gold);
  text-transform: uppercase;
  text-shadow: 3px 3px 0 var(--blue), 5px 5px 0 var(--ink);
  margin: 4px 0 18px !important;
}
.rules { list-style: none; margin: 0 0 10px; padding: 0; opacity: 0; transform: translateY(8px); transition: opacity .5s, transform .5s; }
.rules.on { opacity: 1; transform: none; }
.rules li { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-top: 2px dashed rgba(143,184,255,.3); }
.rules li:first-child { border-top: 0; }
.rules .k { flex: none; width: 76px; font-family: var(--pixel); font-size: 9px; text-transform: uppercase; color: var(--gold); }
#rBudget { font-size: 30px; color: var(--gold); margin-right: 6px; line-height: 1; }
.rules li:first-child { align-items: center; }

.footnote { text-align: center; font-size: 20px; color: var(--sky); margin: 26px 0 0; }

/* Ground and marching Maccabees */
.ground {
  position: relative;
  z-index: 1;
  height: 92px;
  margin-top: 24px;
  background:
    linear-gradient(var(--ink), var(--ink)) 0 52px / 100% 4px no-repeat,
    repeating-linear-gradient(90deg, #3a2a6e 0 16px, #2c1f58 16px 32px) 0 56px / 100% 36px no-repeat;
  overflow: hidden;
}
.march { position: absolute; inset: 0; }
.mac { position: absolute; bottom: 40px; width: 48px; height: 64px; image-rendering: pixelated; animation: walk linear infinite; }
@keyframes walk { from { left: -60px; } to { left: 100%; } }

/* Confetti */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.bit { position: absolute; top: -40px; image-rendering: pixelated; animation: fall linear forwards; }
@keyframes fall {
  to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); }
}

@media (min-width: 700px) {
  main { padding-top: 44px; }
  #chanukiah { width: 300px; height: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  .dreidel, #spinBtn, .blink, .mac { animation: none !important; }
}
