/* Holiday Gift Exchange: midnight pine, brass and cranberry.
   Fonts (Fraunces for display, Figtree for everything else) are bundled in assets/fonts/. */
:root {
  /* Night sky and panels */
  --night: #09150F;
  --night-mid: #132C21;
  --night-glow: #1F4733;
  --panel: #11281D;
  --panel-raised: #183527;
  --field: #0A1912;
  /* Brass and gold */
  --brass: #E2B65A;
  --gold: #F3CF72;
  --line: rgba(226, 182, 90, .45);
  --line-soft: rgba(226, 182, 90, .28);
  /* Text */
  --cream: #FBF3E4;
  --mist: #B9CBBF;
  --ink: #2A140C;
  /* Ribbon colors */
  --cranberry: #B8262F;
  --ribbon: #8E1A22;
  --pine: #17402C;
  --warn: #FF8A80;
  /* Frozen (game over) */
  --ice: #A9D8FF;
  --ice-text: #BFE3FF;
  --frost: #2F5F8F;

  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --ui: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  font-family: var(--ui);
  color: var(--cream);
  background: radial-gradient(ellipse 62% 72% at 50% 54%, var(--night-glow) 0%, var(--night-mid) 50%, var(--night) 100%);
  background-color: var(--night);
}
button { font-family: inherit; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- scenery ---------- */
.snow, .trees, .lights { position: fixed; pointer-events: none; z-index: 0; }
.snow { inset: 0; overflow: hidden; }
.snow::before, .snow::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
}
.snow::before {
  top: -420px;
  background-size: 420px 420px;
  background-image:
    radial-gradient(circle at 8% 12%, rgba(255, 255, 255, .55) 0 2px, transparent 2.6px),
    radial-gradient(circle at 31% 44%, rgba(255, 255, 255, .35) 0 1.4px, transparent 2px),
    radial-gradient(circle at 54% 8%, rgba(255, 255, 255, .45) 0 1.8px, transparent 2.4px),
    radial-gradient(circle at 72% 63%, rgba(255, 255, 255, .5) 0 2.2px, transparent 2.8px),
    radial-gradient(circle at 92% 28%, rgba(255, 255, 255, .3) 0 1.4px, transparent 2px),
    radial-gradient(circle at 18% 82%, rgba(255, 255, 255, .4) 0 1.8px, transparent 2.4px),
    radial-gradient(circle at 44% 70%, rgba(255, 255, 255, .25) 0 1.2px, transparent 1.8px),
    radial-gradient(circle at 84% 90%, rgba(255, 255, 255, .45) 0 2px, transparent 2.6px);
  animation: snow-near 26s linear infinite;
}
.snow::after {
  top: -640px;
  background-size: 640px 640px;
  background-image:
    radial-gradient(circle at 14% 36%, rgba(255, 255, 255, .22) 0 3.4px, transparent 4.2px),
    radial-gradient(circle at 39% 14%, rgba(255, 255, 255, .18) 0 3px, transparent 3.8px),
    radial-gradient(circle at 63% 52%, rgba(255, 255, 255, .2) 0 3.6px, transparent 4.4px),
    radial-gradient(circle at 88% 74%, rgba(255, 255, 255, .16) 0 3px, transparent 3.8px),
    radial-gradient(circle at 27% 88%, rgba(255, 255, 255, .2) 0 3.2px, transparent 4px);
  animation: snow-far 48s linear infinite;
}
@keyframes snow-near { to { transform: translateY(420px); } }
@keyframes snow-far { to { transform: translateY(640px); } }

.trees { bottom: 0; height: 37vh; }
.trees-left { left: 0; width: calc(37vh * 342 / 400); }
.trees-right { right: 0; width: calc(37vh * 357 / 400); }

.lights { top: 0; left: 0; width: 100vw; height: 7.4vh; overflow: visible; }
.lights .wire { fill: none; stroke: #050D09; stroke-width: 3; }
.lights g { animation: twinkle 2.6s ease-in-out infinite alternate; }
.lights g:nth-of-type(2n) { animation-duration: 3.4s; animation-delay: -1.2s; }
.lights g:nth-of-type(3n) { animation-duration: 2.1s; animation-delay: -.5s; }
@keyframes twinkle { from { opacity: .6; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .snow::before, .snow::after, .lights g { animation: none; }
}
/* While the game starts, the lights chase each other in time with the welcome jingle. */
@media (prefers-reduced-motion: no-preference) {
  .celebrate .lights g,
  .celebrate .lights g:nth-of-type(2n),
  .celebrate .lights g:nth-of-type(3n) { animation: chase .32s step-end infinite; animation-delay: 0s; }
  .celebrate .lights g:nth-of-type(2n) { animation-delay: -.16s; }
  .celebrate .lights { filter: brightness(1.15) saturate(1.1); }
}
@keyframes chase {
  0% { opacity: .3; }
  50% { opacity: 1; }
}

/* ---------- layout ---------- */
/* No z-index here on purpose: #app must not form its own stacking layer, so the timer
   inside it can sit above the modals (see the layer list under "game timer"). It still
   paints above the scenery because it comes after it in the page. */
#app {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(56px, 7.4vh) 16px clamp(12px, 2.6vh, 28px);
}

.top {
  position: relative;
  z-index: 6; /* above the title slide's gift and the wheel as they move in when the game starts */
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vh, 22px);
}
.top h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(26px, 6.3vh, 68px);
  line-height: 1.05;
  letter-spacing: .005em;
  text-align: center;
  color: var(--gold);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .4), 0 0 32px rgba(243, 207, 114, .28);
}
.holly {
  flex: none;
  width: clamp(29px, 6.8vh, 74px);
  height: clamp(28px, 6.6vh, 72px);
}
.holly.flip { transform: scaleX(-1); }
@media (max-width: 700px) {
  .holly { display: none; }
}

/* ---------- game timer ---------- */
/* Layers, bottom to top: scenery 0, page, title slide 5, game title and H tip 6, result/
   game-over/how-to-play cards 10, confetti 15, editors 20, timer 30. The timer is the top-most
   item so the room can always see the clock, even while a card or editor is open
   (wide screens only; see below). */
.timer {
  position: fixed;
  top: clamp(12px, 3vh, 32px);
  left: clamp(12px, 3vh, 32px);
  z-index: 30;
  width: clamp(180px, 24.8vh, 280px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, .8vh, 8px);
  padding: clamp(10px, 1.7vh, 18px) clamp(12px, 1.9vh, 20px) clamp(10px, 1.5vh, 16px);
  border: 2px solid var(--brass);
  border-radius: clamp(16px, 2vh, 22px);
  background: var(--panel);
  box-shadow: inset 0 0 0 5px var(--panel), inset 0 0 0 6px rgba(226, 182, 90, .32), 0 16px 40px rgba(0, 0, 0, .5);
  text-align: center;
}
/* Narrow screens: drop the box into the page flow so it can't cover the title. Here
   the cards fill the screen, so the timer goes back under them rather than on top. */
@media (max-width: 700px) {
  .timer { position: static; z-index: auto; margin-top: 8px; } /* z-index still counts on a flex item */
}
.timer-time {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(32px, 7.8vh, 86px);
  line-height: 1.05;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -.01em;
  color: var(--cream);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .35);
}
.timer-status {
  font-size: clamp(12px, 1.6vh, 18px);
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--mist);
}
.timer-status:empty { display: none; }
.timer.paused .timer-time { opacity: .5; }
.timer.low .timer-time { color: var(--warn); }
.timer.final .timer-time { animation: pulse 1s ease-in-out infinite; }
.timer.over { border-color: var(--ice); box-shadow: inset 0 0 0 5px var(--panel), inset 0 0 0 6px rgba(169, 216, 255, .32), 0 16px 40px rgba(0, 0, 0, .5); }
.timer.over .timer-time,
.timer.over .timer-status { color: var(--ice-text); }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
.timer-controls { display: flex; justify-content: center; gap: 10px; margin-top: 2px; }
.timer-controls .icon-btn {
  width: clamp(36px, 4.1vh, 44px);
  height: clamp(36px, 4.1vh, 44px);
  background: var(--panel-raised);
  box-shadow: none;
}
.timer-controls .icon-btn svg { width: 45%; height: 45%; }

/* ---------- wheel ---------- */
.stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.wheel-wrap { position: relative; }
#wheel {
  display: block;
  cursor: pointer;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, .55));
}
/* Sized and placed relative to the wheel so its tip always meets the slices. */
.pointer {
  position: absolute;
  z-index: 2;
  top: -3.6%;
  left: 0;
  right: 0;
  width: 8.5%;
  height: auto;
  aspect-ratio: 60 / 72;
  margin: 0 auto;
  filter: drop-shadow(0 5px 6px rgba(0, 0, 0, .45));
  transform-origin: 50% 30%;
  pointer-events: none;
}
.pointer.tick { animation: tick .09s ease-out; }
@keyframes tick {
  0% { transform: rotate(0); }
  40% { transform: rotate(-14deg); }
  100% { transform: rotate(0); }
}

/* Game over: the wheel freezes over. */
.frozen #wheel {
  cursor: default;
  filter: grayscale(.7) brightness(.92) sepia(.3) hue-rotate(170deg) drop-shadow(0 18px 40px rgba(0, 0, 0, .55));
}
.frozen .wheel-wrap::after {
  content: '';
  position: absolute;
  inset: 1.5%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(225, 242, 255, 0) 45%, rgba(225, 242, 255, .38) 100%);
  box-shadow: inset 0 0 50px rgba(255, 255, 255, .55);
  pointer-events: none;
}

/* ---------- key hints ---------- */
.hint {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 30px;
  max-width: 100%;
  margin-top: clamp(6px, 1.3vh, 14px);
  padding: clamp(6px, .9vh, 10px) clamp(14px, 2.4vh, 26px);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(6, 16, 11, .6);
  color: var(--mist);
  font-size: clamp(13px, 1.6vh, 17px);
}
.hint > span { display: inline-flex; align-items: center; gap: 4px; }
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid rgba(243, 207, 114, .45);
  border-bottom-width: 3px;
  border-radius: 7px;
  background: var(--panel-raised);
  color: var(--cream);
  font: 700 14px/1 var(--ui);
}

/* ---------- corner buttons ---------- */
.corner {
  position: fixed;
  top: clamp(12px, 3vh, 32px);
  right: clamp(12px, 3vh, 32px);
  display: flex;
  gap: 12px;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(42px, 4.8vh, 52px);
  height: clamp(42px, 4.8vh, 52px);
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--cream);
  cursor: pointer;
  opacity: .75;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .35);
  transition: opacity .15s, border-color .15s, background-color .15s;
}
.icon-btn svg { width: 46%; height: 46%; }
.icon-btn:hover, .icon-btn:focus-visible { opacity: 1; border-color: var(--gold); background: var(--panel-raised); }
.icon-btn:disabled { opacity: .3; cursor: default; border-color: var(--line-soft); }
.icon-btn:focus-visible, .ui-toggle:focus-visible, .timer-time:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Clean display (H): hide the chrome so the room only sees the wheel and the clock.
   Fullscreen turns this on automatically. */
.clean .hint, .clean .corner, .clean .timer-controls, .clean .version { display: none; }
.clean .timer-time { cursor: default; }

/* Always-visible tip for toggling the clean display. */
.ui-toggle {
  position: fixed;
  right: clamp(12px, 3vh, 32px);
  bottom: clamp(12px, 2.4vh, 26px);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 5px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(6, 16, 11, .6);
  color: var(--mist);
  font: 600 15px/1.2 var(--ui);
  cursor: pointer;
  opacity: .75;
  transition: opacity .15s;
}
.ui-toggle:hover { opacity: 1; }
.clean .ui-toggle { opacity: .25; padding-right: 5px; border-color: transparent; background: none; }
.clean .ui-toggle:hover { opacity: .8; }
.clean .ui-toggle span { display: none; }

/* App version: faint, lower-left, only while the controls are visible. Links to the GitHub repo. */
.version {
  position: fixed;
  left: clamp(12px, 3vh, 32px);
  bottom: clamp(12px, 2.6vh, 28px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--mist);
  font: 14px/1.2 var(--ui);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  opacity: .6;
  user-select: none;
  transition: opacity .2s;
}
.version svg { width: 15px; height: 15px; flex: none; }
.version:hover, .version:focus-visible { opacity: 1; }
.version:hover span, .version:focus-visible span { text-decoration: underline; text-underline-offset: 3px; }
.version:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 3px; }
.version[hidden] { display: none; }

/* ---------- title slide ---------- */
/* Shown on load until the game starts. It lies over the game screen (same scenery), whose
   clock, wheel and key hints stay hidden but laid out, so the start can animate into them.
   The title is the game's own heading, scaled up into .splash-slot by app.js. */
.splash {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(56px, 7.4vh) 16px clamp(12px, 2.6vh, 28px);
  pointer-events: none; /* only its buttons take clicks, so the corner buttons stay usable */
}
.splash[hidden] { display: none; }
.splash button { pointer-events: auto; }
.splash-on .timer, .splash-on .stage, .splash-on #hint { visibility: hidden; }
.splash-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 3vh;
}
.splash-gift {
  position: relative;
  flex: none;
  width: clamp(100px, 24vh, 260px);
  height: clamp(100px, 24vh, 260px);
  margin-bottom: 1vh;
}
.splash-gift::before {
  content: '';
  position: absolute;
  inset: -8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(243, 207, 114, .3) 0, rgba(243, 207, 114, 0) 66%);
}
.splash-gift::after { /* shadow on the "floor" under the gift */
  content: '';
  position: absolute;
  left: 22%;
  right: 22%;
  top: 91%;
  height: 6%;
  border-radius: 50%;
  background: rgba(0, 0, 0, .35);
}
.gift-box {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-origin: 50% 50%;
}
.gift-spark { position: absolute; z-index: 1; color: var(--gold); }
.gift-spark.s1 { width: 10%; height: 10%; left: 2%; top: 20%; }
.gift-spark.s2 { width: 7%; height: 7%; right: 5%; top: 8%; color: #FFF2D6; }
.gift-spark.s3 { width: 6%; height: 6%; right: 1%; top: 58%; }
@media (prefers-reduced-motion: no-preference) {
  .gift-box { animation: bob 3.2s ease-in-out infinite; }
  .gift-spark { animation: sparkle 2.4s ease-in-out infinite; }
  .gift-spark.s2 { animation-delay: -.8s; }
  .gift-spark.s3 { animation-delay: -1.6s; }
}
@keyframes bob { 50% { transform: translateY(-3.5%); } }
@keyframes sparkle {
  0%, 100% { opacity: .25; transform: scale(.65); }
  50% { opacity: 1; transform: scale(1); }
}
.splash-slot { flex: none; }
.splash-sub {
  margin: 1.4vh 0 0;
  font-size: clamp(17px, 3.5vh, 38px);
  font-weight: 500;
  letter-spacing: .01em;
  text-align: center;
  color: var(--mist);
}
.splash-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(12px, 2.6vh, 28px);
  margin-top: clamp(20px, 5vh, 54px);
}
.splash-hint { flex: none; }

/* Game length: top left, where the clock appears once the game starts. Hidden with H. */
.game-length {
  position: fixed;
  top: clamp(12px, 3vh, 32px);
  left: clamp(12px, 3vh, 32px);
  display: flex;
  align-items: center;
  gap: 9px;
  height: clamp(42px, 4.8vh, 52px);
  padding: 0 16px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--cream);
  font-family: var(--ui);
  cursor: pointer;
  opacity: .75;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .35);
  transition: opacity .3s, border-color .15s, background-color .15s;
}
.game-length:hover, .game-length:focus-visible { opacity: 1; border-color: var(--gold); background: var(--panel-raised); }
.game-length:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.gl-icon { width: 20px; height: 20px; flex: none; color: var(--brass); }
.gl-label { font-size: 14px; font-weight: 600; color: var(--mist); }
.gl-value { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.gl-edit { width: 16px; height: 16px; flex: none; color: var(--mist); }
.clean .game-length { display: none; }

/* Pressing Start: the buttons and subtitle drop away while the title and gift move into the game. */
.splash-sub, .splash-buttons, .splash-hint, .splash-gift::before, .splash-gift::after, .gift-spark {
  transition: opacity .3s ease, transform .3s ease;
}
.splash.leaving button { pointer-events: none; }
.splash.leaving .splash-sub,
.splash.leaving .splash-buttons,
.splash.leaving .splash-hint { opacity: 0; transform: translateY(1em); }
.splash.leaving .game-length,
.splash.leaving .splash-gift::before,
.splash.leaving .splash-gift::after { opacity: 0; }
.splash.leaving .gift-spark { animation: none; opacity: 0; }

/* Big buttons: Start (cranberry with a gold ring) and How to play. */
.big-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55em;
  height: 2.7em;
  padding: 0 1.4em;
  border-radius: .8em;
  font: 800 clamp(18px, 3.1vh, 34px)/1 var(--ui);
  white-space: nowrap;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, background-color .15s, border-color .15s;
}
.big-btn[hidden] { display: none; }
.big-btn svg { width: .95em; height: .95em; flex: none; }
.big-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.big-btn.start {
  border: 2px solid var(--gold);
  background: var(--cranberry);
  color: var(--cream);
  box-shadow: inset 0 0 0 4px var(--cranberry), inset 0 0 0 5px rgba(243, 207, 114, .45), 0 12px 30px rgba(184, 38, 47, .35), 0 0 40px rgba(243, 207, 114, .15);
}
.big-btn.start svg { color: var(--gold); }
.big-btn.start:hover {
  background: #C9303A;
  box-shadow: inset 0 0 0 4px #C9303A, inset 0 0 0 5px rgba(243, 207, 114, .6), 0 14px 34px rgba(184, 38, 47, .45), 0 0 56px rgba(243, 207, 114, .3);
  transform: translateY(-2px);
}
.big-btn.soft {
  border: 1.5px solid rgba(226, 182, 90, .5);
  background: rgba(17, 40, 29, .85);
  color: var(--cream);
  font-weight: 700;
}
.big-btn.soft svg { color: var(--brass); }
.big-btn.soft:hover { border-color: var(--gold); background: var(--panel-raised); transform: translateY(-2px); }
.big-btn.small { font-size: clamp(15px, 2.6vh, 28px); height: 2.5em; padding: 0 1.2em; border-radius: .7em; }
.big-btn.ink {
  border: 1.5px solid rgba(42, 20, 12, .28);
  background: transparent;
  color: var(--ink);
  font-weight: 700;
}
.big-btn.ink svg { color: var(--ribbon); }
.big-btn.ink:hover { border-color: var(--ribbon); background: rgba(142, 26, 34, .06); }
.big-btn.ink:focus-visible { outline-color: var(--ribbon); }

/* ---------- result and game-over cards ---------- */
.result {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 13, 9, .62);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.result[hidden] { display: none; }
.result-card {
  --card: #FBF3E4;
  --ring: var(--brass);
  --ring-outer: var(--ribbon);
  --stitch: rgba(184, 38, 47, .32);
  position: relative;
  width: min(1180px, 90vw);
  padding: clamp(56px, 9vh, 96px) clamp(28px, 5vw, 96px) clamp(28px, 5.5vh, 60px);
  border-radius: 32px;
  background: var(--card);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 0 0 10px var(--ring), 0 0 0 16px var(--ring-outer), 0 40px 100px rgba(0, 0, 0, .6);
  animation: pop .45s cubic-bezier(.2, 1.4, .4, 1);
}
/* Stitched edge, like a gift tag. */
.result-card::before {
  content: '';
  position: absolute;
  inset: 16px;
  border: 2px dashed var(--stitch);
  border-radius: 22px;
  pointer-events: none;
}
.result-card > * { position: relative; }
.bow {
  position: absolute;
  --bow: clamp(130px, 21vh, 230px);
  width: var(--bow);
  height: calc(var(--bow) * 146 / 230);
  top: calc(var(--bow) * -.37);
  left: 0;
  right: 0;
  margin: 0 auto;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .3));
}
.result-kicker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  font-size: clamp(15px, 2.8vh, 30px);
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--cranberry);
}
.result-kicker .spark { flex: none; width: .9em; height: .9em; color: var(--brass); }
.result-text {
  margin-top: .17em;
  font-family: var(--display);
  font-size: clamp(40px, 12.2vh, 132px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -.01em;
  color: var(--pine);
  overflow-wrap: anywhere;
}
.result-details {
  max-width: 19em;
  margin: 0 auto;
  font-size: clamp(18px, 4.3vh, 46px);
  font-weight: 500;
  line-height: 1.3;
  color: #3A2A1C;
}
/* Ornament between the title and the details: a rule, a star, a rule. */
.result-details::before {
  content: '';
  display: block;
  width: min(330px, 70%);
  height: .4em;
  margin: .65em auto .55em;
  background:
    linear-gradient(var(--brass), var(--brass)) left center / 42% 2px no-repeat,
    linear-gradient(var(--brass), var(--brass)) right center / 42% 2px no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l3 7 7 3-7 3-3 7-3-7-7-3 7-3z' fill='%23B8262F'/%3E%3C/svg%3E") center / contain no-repeat;
}
.result-details[hidden] { display: none; }
.result-next {
  margin-top: 1.9em;
  font-size: clamp(13px, 2vh, 22px);
  font-weight: 600;
  color: #7A6A58;
}

.gameover { background: rgba(8, 20, 34, .58); }
.gameover .result-card {
  --card: #EEF6FF;
  --ring: var(--ice);
  --ring-outer: var(--frost);
  --stitch: rgba(47, 95, 143, .3);
  color: #1D3C5E;
}
.gameover .result-kicker { color: var(--frost); }
.gameover .result-kicker .spark { color: #7FB3E0; }
.gameover .result-text { color: #1D3C5E; }
.gameover .result-details { color: #24405C; }
.gameover .result-details::before {
  background:
    linear-gradient(var(--ice), var(--ice)) left center / 42% 2px no-repeat,
    linear-gradient(var(--ice), var(--ice)) right center / 42% 2px no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l3 7 7 3-7 3-3 7-3-7-7-3 7-3z' fill='%232F5F8F'/%3E%3C/svg%3E") center / contain no-repeat;
}
.gameover .result-next { color: #5E7A96; }
.medallion {
  position: absolute;
  --size: clamp(84px, 13.3vh, 144px);
  width: var(--size);
  height: var(--size);
  top: calc(var(--size) * -.56);
  left: 0;
  right: 0;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 6px solid var(--ice);
  background: #EEF6FF;
  color: var(--frost);
  box-shadow: 0 0 0 4px var(--frost), 0 10px 24px rgba(0, 0, 0, .3);
}
.medallion svg { width: 56%; height: 56%; }
.icicles {
  position: absolute;
  left: 7.5%;
  width: 85%;
  top: calc(100% + 12px);
  height: clamp(34px, 6.1vh, 66px);
  fill: #DCEEFF;
  stroke: var(--ice);
  stroke-width: 2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.icicles path { vector-effect: non-scaling-stroke; }
@keyframes pop {
  from { transform: scale(.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* How to play: the same gift tag, with a holly sprig on top and numbered steps. */
.rules-card {
  width: min(1100px, 92vw);
  padding: clamp(48px, 8vh, 88px) clamp(24px, 6vw, 100px) clamp(24px, 4.4vh, 48px);
  text-align: left;
}
.rules-card .rules-holly {
  position: absolute;
  --h: clamp(84px, 15vh, 170px);
  width: var(--h);
  height: calc(var(--h) * 64 / 66);
  top: calc(var(--h) * -.78);
  left: 0;
  right: 0;
  margin: 0 auto;
  transform: rotate(90deg); /* leaves up, berries resting on the card's edge */
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .3));
}
.rules-steps {
  list-style: none;
  margin: clamp(14px, 3.4vh, 36px) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .62em;
  font-size: clamp(18px, 3.9vh, 42px);
  line-height: 1.3;
  font-weight: 500;
  color: #3A2A1C;
}
.rules-steps li { display: flex; align-items: flex-start; gap: .7em; }
.step-num {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.6em;
  height: 1.6em;
  margin-top: -.08em;
  border-radius: 50%;
  background: var(--pine);
  box-shadow: 0 0 0 2px var(--brass);
  font: 700 .9em/1 var(--display);
  color: var(--gold);
}
.step-text strong { font-weight: 800; color: var(--pine); }
.rules-actions { display: flex; flex-wrap: wrap; gap: .32em; margin-top: .4em; }
.rules-chip {
  padding: .2em .65em;
  border-radius: .5em;
  background: #F1DFB8;
  color: #5A3A0E;
  font-size: .58em;
  font-weight: 700;
  line-height: 1.3;
}
.rules-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: clamp(18px, 4.2vh, 46px);
}

/* ---------- editors ---------- */
.editor {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(3, 9, 6, .66);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.editor[hidden] { display: none; }
.editor-card {
  width: min(940px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 32px 34px 28px;
  border: 1px solid rgba(226, 182, 90, .42);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 30px 80px rgba(0, 0, 0, .6);
}
.editor-head { display: flex; align-items: center; gap: 16px; }
.editor-badge {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--brass);
  color: var(--ink);
}
.editor-badge svg { width: 24px; height: 24px; }
.editor-card h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 36px;
  line-height: 1.1;
  color: var(--gold);
}
.editor-help { color: var(--mist); margin: 14px 0 18px; font-size: 18px; line-height: 1.5; }
.editor-help strong { color: var(--cream); }
.editor-card textarea {
  display: block;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid #2C4A3A;
  border-radius: 16px;
  background: var(--field);
  color: var(--cream);
  font: 500 18px/1.75 var(--ui);
  resize: vertical;
}
.timer-card { width: min(460px, 100%); }
.timer-field { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 600; }
.timer-field input {
  width: 120px;
  padding: 10px 14px;
  border: 1px solid #2C4A3A;
  border-radius: 12px;
  background: var(--field);
  color: var(--cream);
  font: 700 24px var(--ui);
}
.timer-field input:focus,
.editor-card textarea:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 4px rgba(243, 207, 114, .2);
}
.editor-error { color: var(--warn); min-height: 1.4em; margin: 12px 2px; font-size: 16px; font-weight: 600; }
.editor-buttons { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.editor-buttons .spacer { flex: 1; }
.btn {
  height: 48px;
  padding: 0 22px;
  border-radius: 12px;
  border: 1px solid rgba(226, 182, 90, .4);
  font: 700 17px var(--ui);
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.btn.ghost { background: transparent; color: var(--cream); }
.btn.ghost:hover { border-color: var(--gold); background: rgba(226, 182, 90, .08); }
.btn.primary {
  padding: 0 30px;
  border-color: var(--gold);
  background: var(--brass);
  color: var(--ink);
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(226, 182, 90, .25);
}
.btn.primary:hover { background: var(--gold); }

.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}
