@import url("https://fonts.googleapis.com/css2?family=Lilita+One&family=Nunito:wght@700;800;900&display=swap");

/* ==========================================================================
   Home Alone Pop-Up Trivia - shared design system
   --------------------------------------------------------------------------
   Used by /tv (1080p, old Chromecast Chrome), / (phones, 320-430 px) and
   /stream (laptop). See README.md in this folder for the full reference.

   Compatibility rules followed in this file (the TV runs a Chrome 68-era
   engine): no flexbox `gap`, no `inset`, no clamp()/min()/max() without a
   fallback, no :is()/:where(), no aspect-ratio, no backdrop-filter, and
   animations stick to transform/opacity so they stay on the compositor.

   SIZING: every shared component is sized in multiples of --u ("one design
   pixel"). Phones keep the default (1px). The TV sets it from the viewport,
   e.g.  :root { --u: calc(100vw / 1280); }  so everything is 1.5x at 1080p.
   --u can also be set on any container to rescale just that subtree.
   ========================================================================== */

/* Chunky offline stand-in for Lilita One: the first locally installed heavy
   face wins, so headings stay fat even when Google Fonts cannot be reached. */
@font-face {
  font-family: "HA Chunky";
  font-style: normal;
  font-weight: 400;
  src: local("Arial Rounded MT Bold"), local("ArialRoundedMTBold"),
       local("Segoe UI Black"), local("SegoeUIBlack"),
       local("Avenir Next Heavy"), local("AvenirNext-Heavy"),
       local("Roboto Black"), local("Roboto-Black"),
       local("Arial Black"), local("Arial-Black");
}

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* the scaling unit - see the note at the top of the file */
  --u: 1px;

  /* palette */
  --night: #0b1a2e;
  --night-deep: #060f1d;
  --night-light: #14294a;
  --night-lighter: #1d3a66;
  --pine: #0f5132;
  --pine-light: #1a7a4c;
  --pine-dark: #0a3a24;
  --red: #c8102e;
  --red-bright: #e63946;
  --red-dark: #8e0b20;
  --gold: #ffd166;
  --gold-dark: #e0a021;
  --gold-deep: #a86f00;
  --snow: #fffdf7;
  --snow-dim: rgba(255, 253, 247, 0.68);
  --snow-shade: #cfe0ee;
  --ice: #9be0ff;
  --ice-dark: #2b93c7;
  --ink: #10213a;
  --line: rgba(255, 253, 247, 0.16);
  --shade: rgba(6, 15, 29, 0.6);

  /* answer colours A-D: face, 3D edge, text on the face */
  --ans-0: #e63946;
  --ans-0-dark: #9c0f25;
  --ans-0-ink: #ffffff;
  --ans-1: #1b9455;
  --ans-1-dark: #0c5a31;
  --ans-1-ink: #ffffff;
  --ans-2: #ffd166;
  --ans-2-dark: #cf8f12;
  --ans-2-ink: #33210a;
  --ans-3: #6fcdf7;
  --ans-3-dark: #2484b8;
  --ans-3-ink: #06283d;

  /* type */
  --font-display: "Lilita One", "HA Chunky", "Arial Rounded MT Bold", "Segoe UI Black", "Arial Black", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Nunito", "Segoe UI", system-ui, -apple-system, "Roboto", "Helvetica Neue", Arial, sans-serif;

  /* spacing / radii / shadows. These resolve against the --u of :root, so use
     them in page CSS; shared components spell out calc(n * var(--u)) so that
     a local --u override rescales them. */
  --sp-1: calc(4 * var(--u));
  --sp-2: calc(8 * var(--u));
  --sp-3: calc(12 * var(--u));
  --sp-4: calc(16 * var(--u));
  --sp-5: calc(24 * var(--u));
  --sp-6: calc(32 * var(--u));
  --sp-7: calc(48 * var(--u));
  --r-sm: calc(10 * var(--u));
  --r-md: calc(16 * var(--u));
  --r-lg: calc(24 * var(--u));
  --r-xl: calc(32 * var(--u));
  --r-pill: 999px;
  --shadow-1: 0 calc(4 * var(--u)) 0 rgba(0, 0, 0, 0.28);
  --shadow-2: 0 calc(8 * var(--u)) 0 rgba(0, 0, 0, 0.28), 0 calc(18 * var(--u)) calc(30 * var(--u)) rgba(0, 0, 0, 0.35);
  --shadow-text: 0 calc(3 * var(--u)) 0 rgba(0, 0, 0, 0.3);

  /* motion */
  --ease-spring: cubic-bezier(0.2, 1.5, 0.4, 1);
  --ease-out: cubic-bezier(0.2, 0.8, 0.3, 1);

  /* layers */
  --z-sky: 0;
  --z-base: 1;
  --z-snow: 5;
  --z-lights: 20;
  --z-overlay: 100;
  --z-bubble: 200;
  --z-modal: 500;
  --z-toast: 800;
  --z-confetti: 900;

  /* safe areas (need viewport-fit=cover in the viewport meta tag) */
  --safe-t: 0px;
  --safe-r: 0px;
  --safe-b: 0px;
  --safe-l: 0px;
}

@supports (padding-top: env(safe-area-inset-top)) {
  :root {
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
  }
}

/* the narrowest phones get everything 10% smaller */
@media (max-width: 345px) {
  :root { --u: 0.9px; }
}

/* --------------------------------------------------------------------------
   2. Reset and base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: #060f1d;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: #0b1a2e;
  background-image: radial-gradient(ellipse 130% 75% at 50% 0%, #21467a 0%, #14305a 32%, #0b1a2e 68%, #060f1d 100%);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  color: var(--snow);
  font-family: var(--font-body);
  font-size: calc(18 * var(--u));
  font-weight: 800;
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;
  overscroll-behavior: none;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; margin: 0; }
button { cursor: pointer; touch-action: manipulation; }
a { color: var(--gold); }
[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   3. Layout helpers
   -------------------------------------------------------------------------- */

/* One full-viewport screen. 100dvh follows the mobile URL bar; 100vh is the
   fallback for engines without dynamic viewport units. */
.ha-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: calc(var(--safe-t) + 16 * var(--u)) calc(var(--safe-r) + 16 * var(--u)) calc(var(--safe-b) + 16 * var(--u)) calc(var(--safe-l) + 16 * var(--u));
  overflow: hidden;
}
.ha-screen--flush { padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
.ha-screen--scroll { overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; }
/* leaves room for a .ha-lights string along the top edge */
.ha-screen--lights { padding-top: calc(var(--safe-t) + 54 * var(--u)); }

.ha-stack { display: flex; flex-direction: column; }
.ha-stack > * + * { margin-top: calc(16 * var(--u)); }
.ha-stack--tight > * + * { margin-top: calc(8 * var(--u)); }
.ha-stack--loose > * + * { margin-top: calc(28 * var(--u)); }

.ha-row { display: flex; flex-direction: row; align-items: center; }
.ha-row > * + * { margin-left: calc(12 * var(--u)); }
.ha-row--tight > * + * { margin-left: calc(6 * var(--u)); }
.ha-row--between { justify-content: space-between; }
.ha-row--center { justify-content: center; }
.ha-row--wrap { flex-wrap: wrap; }

.ha-grow { flex: 1 1 auto; min-width: 0; min-height: 0; }
.ha-center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ha-hidden { display: none !important; }
.ha-nosel { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ha-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   4. Type
   -------------------------------------------------------------------------- */
.ha-display {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.05;
}

/* big chunky headline with a hard 3D drop */
.ha-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: calc(40 * var(--u));
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: var(--snow);
  text-shadow: 0 calc(3 * var(--u)) 0 var(--red), 0 calc(7 * var(--u)) 0 rgba(0, 0, 0, 0.35);
}
.ha-title--gold { color: var(--gold); text-shadow: 0 calc(3 * var(--u)) 0 #b0721a, 0 calc(7 * var(--u)) 0 rgba(0, 0, 0, 0.35); }
.ha-title--sm { font-size: calc(28 * var(--u)); text-shadow: 0 calc(2 * var(--u)) 0 var(--red), 0 calc(5 * var(--u)) 0 rgba(0, 0, 0, 0.35); }
.ha-title--lg { font-size: calc(64 * var(--u)); text-shadow: 0 calc(5 * var(--u)) 0 var(--red), 0 calc(11 * var(--u)) 0 rgba(0, 0, 0, 0.35); }

.ha-h2 { font-family: var(--font-display); font-weight: 400; font-size: calc(28 * var(--u)); line-height: 1.1; }
.ha-h3 { font-family: var(--font-display); font-weight: 400; font-size: calc(22 * var(--u)); line-height: 1.15; }
.ha-text { font-size: calc(18 * var(--u)); font-weight: 800; line-height: 1.3; }
.ha-text--sm { font-size: calc(15 * var(--u)); }
.ha-text--lg { font-size: calc(22 * var(--u)); }
.ha-label {
  font-family: var(--font-body);
  font-size: calc(13 * var(--u));
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--ice);
}
.ha-muted { color: var(--snow-dim); }
.ha-text-gold { color: var(--gold); }
.ha-text-red { color: var(--red-bright); }
.ha-text-green { color: #3ed087; }
.ha-text-ice { color: var(--ice); }
.ha-text-ink { color: var(--ink); }

/* --------------------------------------------------------------------------
   5. Icons and avatars
   -------------------------------------------------------------------------- */

/* every SVG from HA.icon() carries this class; it sizes with the text unless
   a parent component gives it a fixed box */
.ha-icon {
  display: inline-block;
  flex: none;
  width: 1.3em;
  height: 1.3em;
  vertical-align: -0.28em;
  overflow: visible;
}
.ha-icon--sm { width: calc(20 * var(--u)); height: calc(20 * var(--u)); }
.ha-icon--md { width: calc(32 * var(--u)); height: calc(32 * var(--u)); }
.ha-icon--lg { width: calc(48 * var(--u)); height: calc(48 * var(--u)); }
.ha-icon--xl { width: calc(96 * var(--u)); height: calc(96 * var(--u)); }

/* the SVG from HA.logo(): fills the width of whatever box it is put in */
.ha-logo { display: block; width: 100%; height: auto; overflow: visible; }

/* round "sticker" that holds a player's avatar icon */
.ha-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: calc(48 * var(--u));
  height: calc(48 * var(--u));
  padding: calc(7 * var(--u));
  border: calc(3 * var(--u)) solid #ffffff;
  border-radius: 50%;
  background: #d9f0ff;
  box-shadow: 0 calc(3 * var(--u)) 0 rgba(0, 0, 0, 0.3);
}
.ha-avatar > svg { width: 100%; height: 100%; }
.ha-avatar--sm { width: calc(34 * var(--u)); height: calc(34 * var(--u)); padding: calc(4 * var(--u)); border-width: calc(2 * var(--u)); }
.ha-avatar--lg { width: calc(72 * var(--u)); height: calc(72 * var(--u)); padding: calc(10 * var(--u)); border-width: calc(4 * var(--u)); }
.ha-avatar--xl { width: calc(112 * var(--u)); height: calc(112 * var(--u)); padding: calc(16 * var(--u)); border-width: calc(5 * var(--u)); box-shadow: 0 calc(6 * var(--u)) 0 rgba(0, 0, 0, 0.3); }
/* optional per-avatar background tint: data-avatar = player.avatar (0-11) */
.ha-avatar[data-avatar="0"]  { background: #ffe3b3; }
.ha-avatar[data-avatar="1"]  { background: #d9f0ff; }
.ha-avatar[data-avatar="2"]  { background: #ffd9de; }
.ha-avatar[data-avatar="3"]  { background: #ffe9a8; }
.ha-avatar[data-avatar="4"]  { background: #d5f5e3; }
.ha-avatar[data-avatar="5"]  { background: #cfe6ff; }
.ha-avatar[data-avatar="6"]  { background: #d9f0ff; }
.ha-avatar[data-avatar="7"]  { background: #ffd9de; }
.ha-avatar[data-avatar="8"]  { background: #d5f5e3; }
.ha-avatar[data-avatar="9"]  { background: #fff3c9; }
.ha-avatar[data-avatar="10"] { background: #d9f0ff; }
.ha-avatar[data-avatar="11"] { background: #ffd9de; }

/* --------------------------------------------------------------------------
   6. Buttons
   -------------------------------------------------------------------------- */
.ha-btn {
  --btn-bg: var(--snow);
  --btn-edge: #a9bfd3;
  --btn-ink: var(--ink);
  --btn-ts: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: calc(56 * var(--u));
  min-height: calc(56 * var(--u));
  padding: calc(8 * var(--u)) calc(24 * var(--u));
  border: 0;
  border-radius: calc(18 * var(--u));
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-family: var(--font-display);
  font-size: calc(22 * var(--u));
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.02em;
  text-align: center;
  text-decoration: none;
  text-shadow: var(--btn-ts);
  white-space: nowrap;
  max-width: 100%;
  /* top gloss, bottom shade, the chunky 3D edge, then a soft drop */
  box-shadow:
    inset 0 calc(3 * var(--u)) 0 rgba(255, 255, 255, 0.35),
    inset 0 calc(-3 * var(--u)) 0 rgba(0, 0, 0, 0.12),
    0 calc(6 * var(--u)) 0 var(--btn-edge),
    0 calc(11 * var(--u)) calc(14 * var(--u)) rgba(0, 0, 0, 0.35);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  transition: transform 0.07s ease-out, box-shadow 0.07s ease-out, opacity 0.15s;
}
.ha-btn > * + * { margin-left: calc(10 * var(--u)); }
.ha-btn > .ha-icon { width: calc(28 * var(--u)); height: calc(28 * var(--u)); }

.ha-btn:active,
.ha-btn.is-pressed {
  transform: translateY(calc(4 * var(--u)));
  box-shadow:
    inset 0 calc(3 * var(--u)) 0 rgba(255, 255, 255, 0.35),
    inset 0 calc(-3 * var(--u)) 0 rgba(0, 0, 0, 0.12),
    0 calc(2 * var(--u)) 0 var(--btn-edge),
    0 calc(4 * var(--u)) calc(6 * var(--u)) rgba(0, 0, 0, 0.3);
}
.ha-btn:focus { outline: none; }
.ha-btn:focus-visible { outline: calc(3 * var(--u)) solid var(--gold); outline-offset: calc(3 * var(--u)); }

.ha-btn:disabled,
.ha-btn.is-disabled,
.ha-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  transform: translateY(calc(3 * var(--u)));
  box-shadow:
    inset 0 calc(3 * var(--u)) 0 rgba(255, 255, 255, 0.2),
    0 calc(3 * var(--u)) 0 var(--btn-edge);
}

.ha-btn--primary { --btn-bg: var(--red-bright); --btn-edge: var(--red-dark); --btn-ink: #ffffff; --btn-ts: 0 calc(2 * var(--u)) 0 rgba(0, 0, 0, 0.28); }
.ha-btn--gold { --btn-bg: var(--gold); --btn-edge: #c98a10; --btn-ink: #33210a; --btn-ts: 0 calc(1 * var(--u)) 0 rgba(255, 255, 255, 0.45); }
.ha-btn--green { --btn-bg: var(--ans-1); --btn-edge: var(--ans-1-dark); --btn-ink: #ffffff; --btn-ts: 0 calc(2 * var(--u)) 0 rgba(0, 0, 0, 0.28); }
.ha-btn--ice { --btn-bg: var(--ans-3); --btn-edge: var(--ans-3-dark); --btn-ink: #06283d; --btn-ts: 0 calc(1 * var(--u)) 0 rgba(255, 255, 255, 0.45); }
/* danger: dark coal with a red rim, so it never competes with the red primary */
.ha-btn--danger { --btn-bg: #4a0f1b; --btn-edge: #25060c; --btn-ink: #ff9aa3; border: calc(3 * var(--u)) solid var(--red-bright); }
/* ghost: a quiet secondary action that still reads as a button on any backdrop */
.ha-btn--ghost {
  --btn-bg: #1b3358;
  --btn-edge: #0a1528;
  --btn-ink: var(--snow);
  border: calc(3 * var(--u)) solid rgba(255, 253, 247, 0.55);
  box-shadow:
    0 calc(5 * var(--u)) 0 var(--btn-edge),
    0 calc(9 * var(--u)) calc(12 * var(--u)) rgba(0, 0, 0, 0.3);
}
.ha-btn--ghost:active,
.ha-btn--ghost.is-pressed {
  box-shadow: 0 calc(1 * var(--u)) 0 var(--btn-edge);
}

.ha-btn--sm { min-width: calc(44 * var(--u)); min-height: calc(44 * var(--u)); padding: calc(6 * var(--u)) calc(16 * var(--u)); border-radius: calc(14 * var(--u)); font-size: calc(17 * var(--u)); }
.ha-btn--sm > .ha-icon { width: calc(22 * var(--u)); height: calc(22 * var(--u)); }
.ha-btn--lg { min-height: calc(72 * var(--u)); padding: calc(10 * var(--u)) calc(34 * var(--u)); border-radius: calc(24 * var(--u)); font-size: calc(30 * var(--u)); }
.ha-btn--lg > .ha-icon { width: calc(38 * var(--u)); height: calc(38 * var(--u)); }
.ha-btn--block { display: flex; width: 100%; }
.ha-btn--wrap { white-space: normal; }
/* square, icon-only */
.ha-btn--icon { width: calc(56 * var(--u)); padding: 0; }
.ha-btn--icon.ha-btn--sm { width: calc(44 * var(--u)); }
.ha-btn--icon.ha-btn--lg { width: calc(72 * var(--u)); }
.ha-btn--round { border-radius: 999px; }

@media (hover: hover) {
  .ha-btn:hover { filter: brightness(1.07); }
}

/* --------------------------------------------------------------------------
   7. Form controls: text input, toggle switch, range slider
   -------------------------------------------------------------------------- */
.ha-field { display: block; }
.ha-field > .ha-label { display: block; margin-bottom: calc(7 * var(--u)); }

.ha-input {
  display: block;
  width: 100%;
  min-height: calc(58 * var(--u));
  padding: calc(8 * var(--u)) calc(18 * var(--u));
  border: calc(3 * var(--u)) solid var(--snow-shade);
  border-radius: calc(16 * var(--u));
  background: var(--snow);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 900;
  font-size: calc(20 * var(--u));
  line-height: 1.2;
  box-shadow: inset 0 calc(4 * var(--u)) 0 rgba(16, 33, 58, 0.1), 0 calc(5 * var(--u)) 0 rgba(0, 0, 0, 0.28);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  -webkit-user-select: text;
  user-select: text;
}
.ha-input::placeholder { color: #93a3b5; opacity: 1; }
.ha-input:focus { border-color: var(--gold); box-shadow: inset 0 calc(4 * var(--u)) 0 rgba(16, 33, 58, 0.1), 0 0 0 calc(4 * var(--u)) rgba(255, 209, 102, 0.45), 0 calc(5 * var(--u)) 0 rgba(0, 0, 0, 0.28); }
.ha-input.is-error { border-color: var(--red-bright); animation: ha-shake 0.45s both; }
/* room-code entry: big spaced capitals */
.ha-input--code {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: calc(34 * var(--u));
  letter-spacing: 0.32em;
  /* balances the trailing letter-spacing so the letters sit centred */
  padding-left: calc(18 * var(--u) + 0.32em);
  text-align: center;
  text-transform: uppercase;
}
.ha-input--code::placeholder { letter-spacing: 0.32em; }
/* never below 16px, otherwise iOS zooms the page when a field gets focus.
   Kept behind @supports because a var() declaration that fails at computed
   time does not fall back to the earlier declaration. */
@supports (font-size: max(1px, 2px)) {
  .ha-input { font-size: max(16px, calc(20 * var(--u))); }
  .ha-input--code { font-size: max(24px, calc(34 * var(--u))); }
}

/* <label class="ha-toggle"><input type="checkbox"><span class="ha-toggle__track"></span><span class="ha-toggle__label">..</span></label> */
.ha-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: calc(44 * var(--u));
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.ha-toggle > input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}
.ha-toggle__track {
  position: relative;
  flex: none;
  width: calc(64 * var(--u));
  height: calc(36 * var(--u));
  border: calc(3 * var(--u)) solid var(--snow);
  border-radius: 999px;
  background: #33445c;
  box-shadow: inset 0 calc(3 * var(--u)) 0 rgba(0, 0, 0, 0.3), 0 calc(3 * var(--u)) 0 rgba(0, 0, 0, 0.25);
  transition: background-color 0.15s;
}
/* the knob is a little snowball */
.ha-toggle__track::after {
  content: "";
  position: absolute;
  top: calc(2 * var(--u));
  left: calc(2 * var(--u));
  width: calc(26 * var(--u));
  height: calc(26 * var(--u));
  border-radius: 50%;
  background: var(--snow);
  box-shadow: inset 0 calc(-3 * var(--u)) 0 var(--snow-shade), 0 calc(2 * var(--u)) 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.2s var(--ease-spring);
}
.ha-toggle > input:checked + .ha-toggle__track { background: var(--ans-1); }
.ha-toggle > input:checked + .ha-toggle__track::after { transform: translateX(calc(28 * var(--u))); }
.ha-toggle > input:focus-visible + .ha-toggle__track { outline: calc(3 * var(--u)) solid var(--gold); outline-offset: calc(3 * var(--u)); }
.ha-toggle > input:disabled + .ha-toggle__track { opacity: 0.45; }
.ha-toggle__label { margin-left: calc(12 * var(--u)); font-size: calc(17 * var(--u)); font-weight: 800; line-height: 1.2; }
/* settings-row layout: label on the left, switch on the right */
.ha-toggle--block { display: flex; flex-direction: row-reverse; justify-content: space-between; width: 100%; min-height: calc(56 * var(--u)); }
.ha-toggle--block .ha-toggle__label { margin-left: 0; margin-right: calc(12 * var(--u)); }

/* <input type="range" class="ha-range" style="--p:0.4">  (--p = value as 0..1,
   keep it in sync from JS so the filled part of the track follows the thumb) */
.ha-range {
  --p: 0.5;
  display: block;
  width: 100%;
  height: calc(44 * var(--u));
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: pan-y;
}
.ha-range:focus { outline: none; }
.ha-range::-webkit-slider-runnable-track {
  height: calc(14 * var(--u));
  border: calc(3 * var(--u)) solid var(--snow);
  border-radius: 999px;
  background: linear-gradient(to right, var(--gold) 0, var(--gold) calc(var(--p) * 100%), #1a2c49 calc(var(--p) * 100%), #1a2c49 100%);
  box-sizing: content-box;
}
.ha-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: calc(32 * var(--u));
  height: calc(32 * var(--u));
  margin-top: calc(-9 * var(--u));
  border: calc(4 * var(--u)) solid var(--snow);
  border-radius: 50%;
  background: var(--red-bright);
  box-shadow: 0 calc(3 * var(--u)) 0 rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
}
.ha-range::-moz-range-track {
  height: calc(14 * var(--u));
  border: calc(3 * var(--u)) solid var(--snow);
  border-radius: 999px;
  background: #1a2c49;
}
.ha-range::-moz-range-progress {
  height: calc(14 * var(--u));
  border-radius: 999px;
  background: var(--gold);
}
.ha-range::-moz-range-thumb {
  width: calc(32 * var(--u));
  height: calc(32 * var(--u));
  border: calc(4 * var(--u)) solid var(--snow);
  border-radius: 50%;
  background: var(--red-bright);
  box-shadow: 0 calc(3 * var(--u)) 0 rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   8. Panels and the snow-cap
   -------------------------------------------------------------------------- */
.ha-panel {
  position: relative;
  padding: calc(20 * var(--u));
  border: calc(3 * var(--u)) solid rgba(255, 253, 247, 0.2);
  border-radius: calc(24 * var(--u));
  background-color: #14294a;
  background-image: linear-gradient(180deg, #1d3a66 0%, #14294a 100%);
  color: var(--snow);
  box-shadow: 0 calc(8 * var(--u)) 0 rgba(0, 0, 0, 0.28), 0 calc(18 * var(--u)) calc(30 * var(--u)) rgba(0, 0, 0, 0.35);
}
.ha-panel--snow { border-color: #ffffff; background-color: var(--snow); background-image: linear-gradient(180deg, #ffffff 0%, #eef5fb 100%); color: var(--ink); }
.ha-panel--pine { border-color: rgba(255, 253, 247, 0.3); background-color: var(--pine); background-image: linear-gradient(180deg, #1a7a4c 0%, #0f5132 100%); }
.ha-panel--red { border-color: rgba(255, 253, 247, 0.35); background-color: var(--red); background-image: linear-gradient(180deg, #e63946 0%, #c8102e 100%); }
.ha-panel--gold { border-color: #fff3c9; background-color: var(--gold); background-image: linear-gradient(180deg, #ffe08a 0%, #ffc94a 100%); color: #33210a; }
.ha-panel--flat { box-shadow: none; }
.ha-panel--tight { padding: calc(12 * var(--u)); border-radius: calc(18 * var(--u)); }
.ha-panel__title { margin: 0 0 calc(12 * var(--u)); font-family: var(--font-display); font-weight: 400; font-size: calc(24 * var(--u)); line-height: 1.1; }

/* Snow drift along the top edge of any box (uses ::before). The same drift is
   built into .ha-bubble. The tile is rounded to a whole number of repeats so
   no drip is ever cut in half. */
.ha-snowcap { position: relative; }
.ha-snowcap::before,
.ha-bubble::before {
  content: "";
  position: absolute;
  top: calc(-15 * var(--u));
  left: calc(-5 * var(--u));
  right: calc(-5 * var(--u));
  height: calc(34 * var(--u));
  border-radius: calc(13 * var(--u)) calc(13 * var(--u)) calc(9 * var(--u)) calc(9 * var(--u));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 34' preserveAspectRatio='none'%3E%3Cpath transform='translate(0 3.5)' fill='%23a9cfe8' d='M0 9C10 3 22 3 32 7C42 2 56 2 66 7C78 3 92 2 102 7C108 5 114 6 120 9V19C114 19 112 20 110 23C108 28 102 28 100 23C99 19 94 17 88 18C82 19 82 22 80 24C78 27 73 27 72 23C71 19 66 17 58 18C50 18 49 21 48 25C47 30 40 30 39 25C38 20 34 18 27 18C21 18 21 20 20 22C19 25 14 25 13 22C12 19 6 19 0 19Z'/%3E%3Cpath fill='%23fffdf7' d='M0 9C10 3 22 3 32 7C42 2 56 2 66 7C78 3 92 2 102 7C108 5 114 6 120 9V19C114 19 112 20 110 23C108 28 102 28 100 23C99 19 94 17 88 18C82 19 82 22 80 24C78 27 73 27 72 23C71 19 66 17 58 18C50 18 49 21 48 25C47 30 40 30 39 25C38 20 34 18 27 18C21 18 21 20 20 22C19 25 14 25 13 22C12 19 6 19 0 19Z'/%3E%3C/svg%3E");
  background-repeat: round no-repeat;
  background-size: calc(120 * var(--u)) 100%;
  pointer-events: none;
  z-index: 2;
}
/* keep headings clear of the drips */
.ha-panel.ha-snowcap { padding-top: calc(30 * var(--u)); }

/* --------------------------------------------------------------------------
   9. Candy-cane bar (question timer / progress)
   --------------------------------------------------------------------------
   <div class="ha-candy" style="--p:0.62"><div class="ha-candy__fill"></div></div>
   --p is the filled fraction, 0..1. Add .is-paused while the movie is paused
   and .is-urgent for the last 5 seconds.                                     */
.ha-candy {
  --p: 1;
  --candy-a: #e63946;
  --candy-b: #fffdf7;
  position: relative;
  height: calc(26 * var(--u));
  border: calc(3 * var(--u)) solid var(--snow);
  border-radius: 999px;
  background: #08142a;
  box-shadow: 0 calc(4 * var(--u)) 0 rgba(0, 0, 0, 0.32);
  overflow: hidden;
  /* own stacking context so the rounded clip also applies to the animated
     stripe layer in Safari */
  transform: translateZ(0);
}
.ha-candy__fill {
  position: relative;
  width: calc(var(--p) * 100%);
  height: 100%;
  border-radius: 999px;
  background: var(--candy-a);
  overflow: hidden;
  transition: width 0.3s linear;
}
/* the stripes live on a layer one tile wider than the fill and slide by
   exactly one tile, so the loop is seamless and compositor-only */
.ha-candy__fill::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(-40 * var(--u));
  right: 0;
  background-image: linear-gradient(135deg, var(--candy-a) 25%, var(--candy-b) 25%, var(--candy-b) 50%, var(--candy-a) 50%, var(--candy-a) 75%, var(--candy-b) 75%);
  background-size: calc(40 * var(--u)) calc(40 * var(--u));
  animation: ha-candy-slide 0.9s linear infinite;
}
/* gloss */
.ha-candy::after {
  content: "";
  position: absolute;
  top: calc(3 * var(--u));
  left: calc(8 * var(--u));
  right: calc(8 * var(--u));
  height: calc(5 * var(--u));
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
  pointer-events: none;
}
.ha-candy--green { --candy-a: #1b9455; }
.ha-candy--gold { --candy-a: #f0a92b; }
.ha-candy--sm { height: calc(16 * var(--u)); border-width: calc(2 * var(--u)); }
.ha-candy--sm::after { top: calc(2 * var(--u)); height: calc(3 * var(--u)); }
.ha-candy--lg { height: calc(38 * var(--u)); border-width: calc(4 * var(--u)); }
.ha-candy--lg::after { top: calc(5 * var(--u)); height: calc(7 * var(--u)); }
/* jump straight to a new --p (use when a fresh question starts) */
.ha-candy.is-snap .ha-candy__fill { transition: none; }

/* paused = frozen: the stripes stop and turn icy */
.ha-candy.is-paused { --candy-a: #6fcdf7; --candy-b: #e8f7ff; }
.ha-candy.is-paused .ha-candy__fill::before { animation-play-state: paused; }

/* last five seconds: faster stripes, gold rim, a heartbeat */
.ha-candy.is-urgent { border-color: var(--gold); animation: ha-urgent 0.5s ease-in-out infinite; }
.ha-candy.is-urgent .ha-candy__fill::before { animation-duration: 0.4s; }
.ha-candy.is-urgent.is-paused { animation: none; }

@keyframes ha-candy-slide {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(calc(40 * var(--u)), 0, 0); }
}
@keyframes ha-urgent {
  0%, 100% { transform: translateZ(0) scale(1, 1); }
  50% { transform: translateZ(0) scale(1.015, 1.22); }
}

/* --------------------------------------------------------------------------
   10. Ornament answer buttons
   --------------------------------------------------------------------------
   <div class="ha-answers">
     <button class="ha-answer" data-choice="0">
       <span class="ha-answer__chip">A</span>
       <span class="ha-answer__text">A tarantula</span>
       <span class="ha-answer__meta"></span>   (optional: vote count / tick)
     </button> ...
   </div>                                                                    */
.ha-answers {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-gap: calc(18 * var(--u));
  gap: calc(18 * var(--u));
}
.ha-answers--grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-gap: calc(22 * var(--u)); gap: calc(22 * var(--u)); }

.ha-answer {
  --a: var(--ans-0);
  --a-dark: var(--ans-0-dark);
  --a-ink: var(--ans-0-ink);
  --a-ts: 0 calc(2 * var(--u)) 0 rgba(0, 0, 0, 0.25);
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: calc(68 * var(--u));
  padding: calc(10 * var(--u)) calc(16 * var(--u)) calc(10 * var(--u)) calc(12 * var(--u));
  border: 0;
  border-radius: calc(22 * var(--u));
  background: var(--a);
  color: var(--a-ink);
  font-family: var(--font-body);
  font-size: calc(20 * var(--u));
  font-weight: 900;
  line-height: 1.15;
  text-align: left;
  text-shadow: var(--a-ts);
  box-shadow:
    inset 0 calc(3 * var(--u)) 0 rgba(255, 255, 255, 0.32),
    inset 0 calc(-4 * var(--u)) 0 rgba(0, 0, 0, 0.14),
    0 calc(7 * var(--u)) 0 var(--a-dark),
    0 calc(12 * var(--u)) calc(16 * var(--u)) rgba(0, 0, 0, 0.35);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out, opacity 0.2s, background-color 0.2s;
}
.ha-answer[data-choice="1"] { --a: var(--ans-1); --a-dark: var(--ans-1-dark); --a-ink: var(--ans-1-ink); }
.ha-answer[data-choice="2"] { --a: var(--ans-2); --a-dark: var(--ans-2-dark); --a-ink: var(--ans-2-ink); --a-ts: 0 calc(1 * var(--u)) 0 rgba(255, 255, 255, 0.4); }
.ha-answer[data-choice="3"] { --a: var(--ans-3); --a-dark: var(--ans-3-dark); --a-ink: var(--ans-3-ink); --a-ts: 0 calc(1 * var(--u)) 0 rgba(255, 255, 255, 0.4); }

/* the letter sits in a white bauble with a gold cap and hanging loop */
.ha-answer__chip {
  position: relative;
  flex: none;
  width: calc(44 * var(--u));
  height: calc(44 * var(--u));
  margin: calc(6 * var(--u)) calc(14 * var(--u)) 0 0;
  border-radius: 50%;
  background-color: var(--snow);
  background-image: radial-gradient(circle at 30% 26%, #ffffff 0, #ffffff 16%, rgba(255, 255, 255, 0) 17%), linear-gradient(180deg, #fffdf7 40%, #dbe7f1 100%);
  color: var(--a-dark);
  font-family: var(--font-display);
  font-size: calc(26 * var(--u));
  font-weight: 400;
  line-height: calc(44 * var(--u));
  text-align: center;
  text-shadow: none;
  box-shadow: 0 0 0 calc(3 * var(--u)) rgba(6, 15, 29, 0.22), 0 calc(3 * var(--u)) 0 calc(3 * var(--u)) rgba(6, 15, 29, 0.18);
}
.ha-answer__chip::before {
  content: "";
  position: absolute;
  top: calc(-8 * var(--u));
  left: 50%;
  width: calc(16 * var(--u));
  height: calc(10 * var(--u));
  margin-left: calc(-8 * var(--u));
  border-radius: calc(3 * var(--u)) calc(3 * var(--u)) calc(1 * var(--u)) calc(1 * var(--u));
  background: linear-gradient(180deg, #ffe08a 0%, #e0a021 100%);
  box-shadow: 0 0 0 calc(2 * var(--u)) rgba(6, 15, 29, 0.28);
}
.ha-answer__chip::after {
  content: "";
  position: absolute;
  top: calc(-15 * var(--u));
  left: 50%;
  width: calc(10 * var(--u));
  height: calc(10 * var(--u));
  margin-left: calc(-5 * var(--u));
  border: calc(2.5 * var(--u)) solid #ffe08a;
  border-bottom-color: transparent;
  border-radius: 50%;
}
.ha-answer__text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.ha-answer__meta {
  flex: none;
  margin-left: calc(10 * var(--u));
  font-family: var(--font-display);
  font-size: calc(22 * var(--u));
  font-weight: 400;
  line-height: 1;
}
.ha-answer__meta:empty { display: none; }
.ha-answer__meta > .ha-icon { width: calc(34 * var(--u)); height: calc(34 * var(--u)); vertical-align: middle; }

.ha-answer:active {
  transform: translateY(calc(5 * var(--u)));
  box-shadow:
    inset 0 calc(3 * var(--u)) 0 rgba(255, 255, 255, 0.32),
    inset 0 calc(-4 * var(--u)) 0 rgba(0, 0, 0, 0.14),
    0 calc(2 * var(--u)) 0 var(--a-dark),
    0 calc(4 * var(--u)) calc(6 * var(--u)) rgba(0, 0, 0, 0.3);
}
.ha-answer:focus { outline: none; }
.ha-answer:focus-visible { outline: calc(3 * var(--u)) solid var(--snow); outline-offset: calc(3 * var(--u)); }

/* the player's pick: pushed in, with a fat snow-white ring */
.ha-answer.is-selected {
  transform: translateY(calc(5 * var(--u)));
  box-shadow:
    inset 0 calc(3 * var(--u)) 0 rgba(255, 255, 255, 0.32),
    inset 0 calc(-4 * var(--u)) 0 rgba(0, 0, 0, 0.14),
    0 0 0 calc(5 * var(--u)) var(--snow),
    0 calc(5 * var(--u)) 0 calc(5 * var(--u)) rgba(6, 15, 29, 0.55);
}
/* answers are in: nothing is tappable, everything but the pick fades back */
.ha-answer.is-locked,
.ha-answer:disabled { pointer-events: none; cursor: default; }
.ha-answer.is-locked:not(.is-selected):not(.is-correct),
.ha-answer.is-dimmed { opacity: 0.4; }
.ha-answer.is-dimmed { pointer-events: none; }

.ha-answer.is-correct {
  opacity: 1;
  box-shadow:
    inset 0 calc(3 * var(--u)) 0 rgba(255, 255, 255, 0.32),
    inset 0 calc(-4 * var(--u)) 0 rgba(0, 0, 0, 0.14),
    0 0 0 calc(5 * var(--u)) var(--snow),
    0 0 0 calc(10 * var(--u)) var(--gold),
    0 calc(7 * var(--u)) 0 calc(10 * var(--u)) rgba(6, 15, 29, 0.55);
  animation: ha-correct 0.7s var(--ease-spring) both;
  z-index: 1;
}
.ha-answer.is-wrong {
  --a: #5a6680;
  --a-dark: #343e52;
  --a-ink: #e3e9f1;
  --a-ts: 0 calc(2 * var(--u)) 0 rgba(0, 0, 0, 0.25);
  opacity: 1;
  animation: ha-shake 0.45s both;
}
.ha-answer.is-wrong .ha-answer__chip { color: #343e52; }

@keyframes ha-correct {
  0% { transform: scale(1); }
  35% { transform: scale(1.06) rotate(-1deg); }
  60% { transform: scale(0.98) rotate(1deg); }
  100% { transform: scale(1) rotate(0); }
}

/* --------------------------------------------------------------------------
   11. Gift-tag name badge
   --------------------------------------------------------------------------
   <span class="ha-tag">
     <span class="ha-tag__avatar">{HA.avatar(i)}</span>
     <span class="ha-tag__name">Kevin</span>
     <span class="ha-tag__score">1,250</span>   (optional)
   </span>                                                                   */
.ha-tag {
  position: relative;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: calc(46 * var(--u));
  padding: calc(4 * var(--u)) calc(10 * var(--u)) calc(4 * var(--u)) calc(30 * var(--u));
  border: calc(3 * var(--u)) solid var(--red-bright);
  border-radius: calc(23 * var(--u)) calc(12 * var(--u)) calc(12 * var(--u)) calc(23 * var(--u));
  background-color: #fff6dc;
  background-image: linear-gradient(180deg, #fffaf0 0%, #ffeec2 100%);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: calc(18 * var(--u));
  font-weight: 900;
  line-height: 1.1;
  box-shadow: 0 calc(4 * var(--u)) 0 rgba(6, 15, 29, 0.45), 0 calc(8 * var(--u)) calc(10 * var(--u)) rgba(0, 0, 0, 0.3);
  vertical-align: middle;
}
/* punched hole with a brass eyelet */
.ha-tag::before {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(9 * var(--u));
  width: calc(11 * var(--u));
  height: calc(11 * var(--u));
  margin-top: calc(-5.5 * var(--u));
  border-radius: 50%;
  background: #0b1a2e;
  box-shadow: 0 0 0 calc(3 * var(--u)) #e0a021;
}
/* the string: a quarter-circle that leaves the hole and loops out past the edge */
.ha-tag::after {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(-10 * var(--u));
  width: calc(25 * var(--u));
  height: calc(20 * var(--u));
  margin-top: calc(-20 * var(--u));
  border-top: calc(3 * var(--u)) solid var(--gold);
  border-right: calc(3 * var(--u)) solid var(--gold);
  border-radius: 0 100% 0 0;
  pointer-events: none;
}
.ha-tag__avatar {
  flex: none;
  width: calc(32 * var(--u));
  height: calc(32 * var(--u));
  margin-right: calc(8 * var(--u));
}
.ha-tag__avatar > svg { width: 100%; height: 100%; }
.ha-tag__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ha-tag__score {
  flex: none;
  margin-left: calc(10 * var(--u));
  padding: calc(4 * var(--u)) calc(10 * var(--u));
  border-radius: 999px;
  background: var(--pine);
  color: var(--snow);
  font-family: var(--font-display);
  font-size: calc(16 * var(--u));
  font-weight: 400;
  line-height: 1.1;
  white-space: nowrap;
}
.ha-tag--block { display: flex; width: 100%; }
/* "this is you" */
.ha-tag--me { border-color: #e0a021; background-color: #ffd166; background-image: linear-gradient(180deg, #ffe08a 0%, #ffc94a 100%); }
.ha-tag--me .ha-tag__score { background: var(--red); }
/* disconnected player */
.ha-tag--off { border-color: #7d8b9c; background-color: #c5ced8; background-image: none; color: #4a586b; }
.ha-tag--off .ha-tag__avatar { opacity: 0.5; }
.ha-tag--off .ha-tag__score { background: #5a6680; }
.ha-tag--sm { min-height: calc(36 * var(--u)); padding: calc(2 * var(--u)) calc(8 * var(--u)) calc(2 * var(--u)) calc(26 * var(--u)); border-width: calc(2 * var(--u)); border-radius: calc(18 * var(--u)) calc(10 * var(--u)) calc(10 * var(--u)) calc(18 * var(--u)); font-size: calc(15 * var(--u)); }
.ha-tag--sm::before { left: calc(8 * var(--u)); width: calc(9 * var(--u)); height: calc(9 * var(--u)); margin-top: calc(-4.5 * var(--u)); box-shadow: 0 0 0 calc(2 * var(--u)) #e0a021; }
.ha-tag--sm::after { left: calc(-8 * var(--u)); width: calc(21 * var(--u)); height: calc(16 * var(--u)); margin-top: calc(-16 * var(--u)); border-top-width: calc(2 * var(--u)); border-right-width: calc(2 * var(--u)); }
.ha-tag--sm .ha-tag__avatar { width: calc(24 * var(--u)); height: calc(24 * var(--u)); margin-right: calc(6 * var(--u)); }
.ha-tag--sm .ha-tag__score { font-size: calc(13 * var(--u)); padding: calc(3 * var(--u)) calc(8 * var(--u)); }
.ha-tag--lg { min-height: calc(64 * var(--u)); padding: calc(6 * var(--u)) calc(16 * var(--u)) calc(6 * var(--u)) calc(42 * var(--u)); border-width: calc(4 * var(--u)); border-radius: calc(32 * var(--u)) calc(16 * var(--u)) calc(16 * var(--u)) calc(32 * var(--u)); font-size: calc(26 * var(--u)); }
.ha-tag--lg::before { left: calc(13 * var(--u)); width: calc(15 * var(--u)); height: calc(15 * var(--u)); margin-top: calc(-7.5 * var(--u)); box-shadow: 0 0 0 calc(4 * var(--u)) #e0a021; }
.ha-tag--lg::after { left: calc(-14 * var(--u)); width: calc(36 * var(--u)); height: calc(28 * var(--u)); margin-top: calc(-28 * var(--u)); border-top-width: calc(4 * var(--u)); border-right-width: calc(4 * var(--u)); }
.ha-tag--lg .ha-tag__avatar { width: calc(46 * var(--u)); height: calc(46 * var(--u)); margin-right: calc(12 * var(--u)); }
.ha-tag--lg .ha-tag__score { font-size: calc(22 * var(--u)); padding: calc(5 * var(--u)) calc(14 * var(--u)); margin-left: calc(14 * var(--u)); }

/* --------------------------------------------------------------------------
   12. Pop-up trivia bubble - the signature element
   --------------------------------------------------------------------------
   <div class="ha-bubble ha-bubble--gold is-in">
     <div class="ha-bubble__badge">{HA.icon('film')}</div>
     <div class="ha-bubble__body">
       <span class="ha-bubble__kicker">Did you know?</span>   (optional)
       <span class="ha-bubble__text">The tarantula was real.</span>
     </div>
   </div>
   Solid fills, a fat white outline, a dark keyline and a hard shadow keep it
   legible over any film frame. Sized by --bu (= --u unless a size modifier
   is used). Add .is-in to pop it in, swap to .is-out to pop it away.        */
.ha-bubble {
  --bu: var(--u);
  --bub-bg: #ffd166;
  --bub-bg2: #ffc23d;
  --bub-ink: #10213a;
  --bub-line: #fffdf7;
  --bub-badge: #e63946;
  --bub-kicker: #c8102e;
  --bub-tilt: 0deg;
  position: relative;
  display: inline-block;
  min-width: calc(220 * var(--bu));
  max-width: calc(600 * var(--bu));
  padding: calc(26 * var(--bu)) calc(28 * var(--bu)) calc(22 * var(--bu)) calc(64 * var(--bu));
  border: calc(5 * var(--bu)) solid var(--bub-line);
  border-radius: calc(32 * var(--bu));
  background-color: var(--bub-bg);
  background-image: linear-gradient(180deg, var(--bub-bg) 0%, var(--bub-bg) 45%, var(--bub-bg2) 100%);
  color: var(--bub-ink);
  font-family: var(--font-body);
  font-size: calc(25 * var(--bu));
  font-weight: 900;
  line-height: 1.22;
  text-align: left;
  box-shadow:
    0 0 0 calc(2.5 * var(--bu)) rgba(6, 15, 29, 0.72),
    0 calc(9 * var(--bu)) 0 calc(2.5 * var(--bu)) rgba(6, 15, 29, 0.72),
    0 calc(22 * var(--bu)) calc(30 * var(--bu)) rgba(0, 0, 0, 0.5);
  transform: rotate(var(--bub-tilt));
  transform-origin: calc(54 * var(--bu)) 100%;
  z-index: var(--z-bubble);
}
/* snow-cap: shared rule above (.ha-snowcap::before, .ha-bubble::before);
   only the metrics that follow --bu are repeated here */
.ha-bubble::before {
  top: calc(-17 * var(--bu));
  left: calc(-7 * var(--bu));
  right: calc(-7 * var(--bu));
  height: calc(34 * var(--bu));
  border-radius: calc(16 * var(--bu)) calc(16 * var(--bu)) calc(9 * var(--bu)) calc(9 * var(--bu));
  background-size: calc(120 * var(--bu)) 100%;
}
/* tail: a rotated square whose top half hides inside the bubble; its fill
   paints over the bubble's own outline so the two shapes merge */
.ha-bubble::after {
  content: "";
  position: absolute;
  left: calc(40 * var(--bu));
  bottom: calc(-19 * var(--bu));
  width: calc(28 * var(--bu));
  height: calc(28 * var(--bu));
  border: calc(5 * var(--bu)) solid var(--bub-line);
  border-top-color: transparent;
  border-left-color: transparent;
  border-radius: 0 0 calc(8 * var(--bu)) 0;
  background: var(--bub-bg2);
  /* straight-down hard shadow, expressed in the tail's rotated space */
  box-shadow: calc(6.4 * var(--bu)) calc(6.4 * var(--bu)) 0 calc(1 * var(--bu)) rgba(6, 15, 29, 0.72);
  transform: rotate(45deg);
  pointer-events: none;
}
.ha-bubble__body { position: relative; display: block; z-index: 1; }
.ha-bubble__kicker {
  display: block;
  margin-bottom: calc(4 * var(--bu));
  font-family: var(--font-display);
  font-size: calc(16 * var(--bu));
  font-weight: 400;
  letter-spacing: 0.1em;
  line-height: 1.1;
  text-transform: uppercase;
  color: var(--bub-kicker);
}
.ha-bubble__text { display: block; overflow-wrap: break-word; word-wrap: break-word; }

/* icon in an ornament: a glossy bauble with a gold cap and loop that hangs
   off the top-left corner, over the snow */
.ha-bubble__badge {
  position: absolute;
  top: calc(-24 * var(--bu));
  left: calc(-28 * var(--bu));
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(76 * var(--bu));
  height: calc(76 * var(--bu));
  border: calc(5 * var(--bu)) solid var(--bub-line);
  border-radius: 50%;
  background-color: var(--bub-badge);
  background-image: radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.6) 0, rgba(255, 255, 255, 0) 42%);
  box-shadow:
    0 0 0 calc(2.5 * var(--bu)) rgba(6, 15, 29, 0.72),
    0 calc(6 * var(--bu)) 0 calc(2.5 * var(--bu)) rgba(6, 15, 29, 0.72);
  /* swings from its hanging loop, like a bauble on a branch */
  transform-origin: 50% calc(-22 * var(--bu));
  z-index: 3;
}
.ha-bubble__badge > svg { width: calc(46 * var(--bu)); height: calc(46 * var(--bu)); }
.ha-bubble__badge::before {
  content: "";
  position: absolute;
  top: calc(-15 * var(--bu));
  left: 50%;
  width: calc(22 * var(--bu));
  height: calc(13 * var(--bu));
  margin-left: calc(-11 * var(--bu));
  border: calc(2.5 * var(--bu)) solid #0b1a2e;
  border-radius: calc(5 * var(--bu)) calc(5 * var(--bu)) calc(2 * var(--bu)) calc(2 * var(--bu));
  background: linear-gradient(180deg, #ffe08a 0%, #e0a021 100%);
}
.ha-bubble__badge::after {
  content: "";
  position: absolute;
  top: calc(-27 * var(--bu));
  left: 50%;
  width: calc(15 * var(--bu));
  height: calc(15 * var(--bu));
  margin-left: calc(-7.5 * var(--bu));
  border: calc(3.5 * var(--bu)) solid #ffd166;
  border-bottom-color: transparent;
  border-radius: 50%;
}

/* colour variants (gold is the default) */
.ha-bubble--gold { --bub-bg: #ffd166; --bub-bg2: #ffc23d; --bub-ink: #10213a; --bub-badge: #e63946; --bub-kicker: #c8102e; }
.ha-bubble--red { --bub-bg: #e63946; --bub-bg2: #cf2437; --bub-ink: #ffffff; --bub-badge: #1b9455; --bub-kicker: #ffe08a; }
.ha-bubble--green { --bub-bg: #1fa35f; --bub-bg2: #16864c; --bub-ink: #ffffff; --bub-badge: #e63946; --bub-kicker: #ffe08a; }
.ha-bubble--ice { --bub-bg: #a6e4ff; --bub-bg2: #78d0f8; --bub-ink: #0b1a2e; --bub-badge: #ffc23d; --bub-kicker: #0b5f8a; }
.ha-bubble--snow { --bub-bg: #fffdf7; --bub-bg2: #e6f1f9; --bub-ink: #10213a; --bub-line: #e63946; --bub-badge: #1b9455; --bub-kicker: #c8102e; }
.ha-bubble--red,
.ha-bubble--green { text-shadow: 0 calc(2 * var(--bu)) 0 rgba(0, 0, 0, 0.25); }

/* size, tail and tilt modifiers */
.ha-bubble--sm { --bu: calc(var(--u) * 0.7); }
.ha-bubble--lg { --bu: calc(var(--u) * 1.3); }
.ha-bubble--block { display: block; max-width: none; }
.ha-bubble--tail-right { transform-origin: calc(100% - 54 * var(--bu)) 100%; }
.ha-bubble--tail-right::after { left: auto; right: calc(40 * var(--bu)); }
.ha-bubble--tail-center { transform-origin: 50% 100%; }
.ha-bubble--tail-center::after { left: 50%; margin-left: calc(-14 * var(--bu)); }
.ha-bubble--tail-none::after { display: none; }
.ha-bubble--nosnow::before { display: none; }
.ha-bubble--tilt-l { --bub-tilt: -2deg; }
.ha-bubble--tilt-r { --bub-tilt: 2deg; }

/* spring pop-in / pop-out, anchored at the tail */
.ha-bubble.is-in { animation: ha-bubble-in 0.62s both; }
.ha-bubble.is-in .ha-bubble__badge { animation: ha-badge-swing 0.9s 0.25s both; }
.ha-bubble.is-out { animation: ha-bubble-out 0.34s ease-in both; pointer-events: none; }

@keyframes ha-bubble-in {
  0% { transform: scale(0) rotate(-12deg); opacity: 0; }
  12% { opacity: 1; }
  50% { transform: scale(1.12) rotate(3deg); }
  72% { transform: scale(0.96) rotate(-1deg); }
  88% { transform: scale(1.02) rotate(var(--bub-tilt)); }
  100% { transform: scale(1) rotate(var(--bub-tilt)); opacity: 1; }
}
@keyframes ha-bubble-out {
  0% { transform: scale(1) rotate(var(--bub-tilt)); opacity: 1; }
  30% { transform: scale(1.1) rotate(var(--bub-tilt)); opacity: 1; }
  100% { transform: scale(0) rotate(8deg); opacity: 0; }
}
@keyframes ha-badge-swing {
  0% { transform: rotate(0); }
  25% { transform: rotate(-16deg); }
  50% { transform: rotate(11deg); }
  75% { transform: rotate(-5deg); }
  100% { transform: rotate(0); }
}

/* --------------------------------------------------------------------------
   13. String lights and pine garland
   --------------------------------------------------------------------------
   <div class="ha-lights"></div>   no children needed.
   The element paints the wire and unlit bulbs; ::before and ::after each
   paint the lit glow of every other bulb and fade in opposite phase, so the
   whole string twinkles with just two compositor-animated layers.           */
.ha-lights {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  /* taller than the 48u tile: 'round' may widen the tile to fit a whole number
     of repeats, and the auto height below grows with it to keep bulbs round */
  height: calc(62 * var(--u));
  pointer-events: none;
  z-index: var(--z-lights);
}
.ha-lights,
.ha-lights::before,
.ha-lights::after {
  background-repeat: round no-repeat;
  background-position: 0 0;
  background-size: calc(160 * var(--u)) auto;
}
.ha-lights { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 48'%3E%3Cpath d='M0 4Q20 18 40 4T80 4T120 4T160 4' fill='none' stroke='%23060f1d' stroke-width='5'/%3E%3Cpath d='M0 4Q20 18 40 4T80 4T120 4T160 4' fill='none' stroke='%2314693f' stroke-width='2.5'/%3E%3Cpath d='M20 17c6 0 8.5 6 8.5 11.5c0 6-4 10-8.5 10s-8.5-4-8.5-10c0-5.5 2.5-11.5 8.5-11.5z' fill='%237d1626' stroke='%23060f1d' stroke-width='2'/%3E%3Crect x='15.5' y='9.5' width='9' height='8.5' rx='2' fill='%230f5132' stroke='%23060f1d' stroke-width='2'/%3E%3Cpath d='M60 17c6 0 8.5 6 8.5 11.5c0 6-4 10-8.5 10s-8.5-4-8.5-10c0-5.5 2.5-11.5 8.5-11.5z' fill='%230e5c35' stroke='%23060f1d' stroke-width='2'/%3E%3Crect x='55.5' y='9.5' width='9' height='8.5' rx='2' fill='%230f5132' stroke='%23060f1d' stroke-width='2'/%3E%3Cpath d='M100 17c6 0 8.5 6 8.5 11.5c0 6-4 10-8.5 10s-8.5-4-8.5-10c0-5.5 2.5-11.5 8.5-11.5z' fill='%2394701f' stroke='%23060f1d' stroke-width='2'/%3E%3Crect x='95.5' y='9.5' width='9' height='8.5' rx='2' fill='%230f5132' stroke='%23060f1d' stroke-width='2'/%3E%3Cpath d='M140 17c6 0 8.5 6 8.5 11.5c0 6-4 10-8.5 10s-8.5-4-8.5-10c0-5.5 2.5-11.5 8.5-11.5z' fill='%231f628a' stroke='%23060f1d' stroke-width='2'/%3E%3Crect x='135.5' y='9.5' width='9' height='8.5' rx='2' fill='%230f5132' stroke='%23060f1d' stroke-width='2'/%3E%3C/svg%3E"); }
.ha-lights::before,
.ha-lights::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  animation: ha-twinkle 1.2s ease-in-out infinite alternate;
}
.ha-lights::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 48'%3E%3Cdefs%3E%3CradialGradient id='g0'%3E%3Cstop offset='0' stop-color='%23ff5263' stop-opacity='.75'/%3E%3Cstop offset='.45' stop-color='%23ff5263' stop-opacity='.35'/%3E%3Cstop offset='1' stop-color='%23ff5263' stop-opacity='0'/%3E%3C/radialGradient%3E%3CradialGradient id='g2'%3E%3Cstop offset='0' stop-color='%23ffe08a' stop-opacity='.75'/%3E%3Cstop offset='.45' stop-color='%23ffe08a' stop-opacity='.35'/%3E%3Cstop offset='1' stop-color='%23ffe08a' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Ccircle cx='20' cy='28' r='19' fill='url(%23g0)'/%3E%3Cpath d='M20 17c6 0 8.5 6 8.5 11.5c0 6-4 10-8.5 10s-8.5-4-8.5-10c0-5.5 2.5-11.5 8.5-11.5z' fill='%23ff5263' stroke='%23060f1d' stroke-width='2'/%3E%3Cellipse cx='17' cy='24.5' rx='2' ry='4' fill='%23fff' opacity='.8' transform='rotate(18 17 24.5)'/%3E%3Crect x='15.5' y='9.5' width='9' height='8.5' rx='2' fill='%230f5132' stroke='%23060f1d' stroke-width='2'/%3E%3Ccircle cx='100' cy='28' r='19' fill='url(%23g2)'/%3E%3Cpath d='M100 17c6 0 8.5 6 8.5 11.5c0 6-4 10-8.5 10s-8.5-4-8.5-10c0-5.5 2.5-11.5 8.5-11.5z' fill='%23ffe08a' stroke='%23060f1d' stroke-width='2'/%3E%3Cellipse cx='97' cy='24.5' rx='2' ry='4' fill='%23fff' opacity='.8' transform='rotate(18 97 24.5)'/%3E%3Crect x='95.5' y='9.5' width='9' height='8.5' rx='2' fill='%230f5132' stroke='%23060f1d' stroke-width='2'/%3E%3C/svg%3E"); }
.ha-lights::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 48'%3E%3Cdefs%3E%3CradialGradient id='g1'%3E%3Cstop offset='0' stop-color='%233fe08c' stop-opacity='.75'/%3E%3Cstop offset='.45' stop-color='%233fe08c' stop-opacity='.35'/%3E%3Cstop offset='1' stop-color='%233fe08c' stop-opacity='0'/%3E%3C/radialGradient%3E%3CradialGradient id='g3'%3E%3Cstop offset='0' stop-color='%237fd9ff' stop-opacity='.75'/%3E%3Cstop offset='.45' stop-color='%237fd9ff' stop-opacity='.35'/%3E%3Cstop offset='1' stop-color='%237fd9ff' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Ccircle cx='60' cy='28' r='19' fill='url(%23g1)'/%3E%3Cpath d='M60 17c6 0 8.5 6 8.5 11.5c0 6-4 10-8.5 10s-8.5-4-8.5-10c0-5.5 2.5-11.5 8.5-11.5z' fill='%233fe08c' stroke='%23060f1d' stroke-width='2'/%3E%3Cellipse cx='57' cy='24.5' rx='2' ry='4' fill='%23fff' opacity='.8' transform='rotate(18 57 24.5)'/%3E%3Crect x='55.5' y='9.5' width='9' height='8.5' rx='2' fill='%230f5132' stroke='%23060f1d' stroke-width='2'/%3E%3Ccircle cx='140' cy='28' r='19' fill='url(%23g3)'/%3E%3Cpath d='M140 17c6 0 8.5 6 8.5 11.5c0 6-4 10-8.5 10s-8.5-4-8.5-10c0-5.5 2.5-11.5 8.5-11.5z' fill='%237fd9ff' stroke='%23060f1d' stroke-width='2'/%3E%3Cellipse cx='137' cy='24.5' rx='2' ry='4' fill='%23fff' opacity='.8' transform='rotate(18 137 24.5)'/%3E%3Crect x='135.5' y='9.5' width='9' height='8.5' rx='2' fill='%230f5132' stroke='%23060f1d' stroke-width='2'/%3E%3C/svg%3E"); animation-delay: -1.2s; }
.ha-lights--inline { position: relative; }
.ha-lights--fixed { position: fixed; }
.ha-lights--sm { height: calc(44 * var(--u)); }
.ha-lights--sm,
.ha-lights--sm::before,
.ha-lights--sm::after { background-size: calc(113 * var(--u)) auto; }
/* steady glow, no blinking */
.ha-lights--steady::before,
.ha-lights--steady::after { animation: none; }

@keyframes ha-twinkle {
  0%, 35% { opacity: 1; }
  65%, 100% { opacity: 0.08; }
}

/* <div class="ha-garland"></div>  a pine bough divider with berries */
.ha-garland {
  width: 100%;
  height: calc(32 * var(--u));
  border: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 32'%3E%3Cpath d='M0 8L5 3L10 10L16 2L22 10L28 4L34 10L40 2L46 10L52 3L58 10L64 2L70 10L76 4L82 10L88 2L96 8V24L90 30L84 22L78 29L72 22L66 30L60 22L54 28L48 22L42 30L36 22L30 29L24 22L18 30L12 22L6 29L0 24Z' fill='%230f5132'/%3E%3Cpath d='M0 8L5 3L10 10L16 2L22 10L28 4L34 10L40 2L46 10L52 3L58 10L64 2L70 10L76 4L82 10L88 2L96 8M96 24L90 30L84 22L78 29L72 22L66 30L60 22L54 28L48 22L42 30L36 22L30 29L24 22L18 30L12 22L6 29L0 24' fill='none' stroke='%230a3a24' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M0 16L8 12L16 18L24 13L32 19L40 12L48 17L56 12L64 19L72 13L80 18L88 12L96 16' fill='none' stroke='%231f9d5c' stroke-width='4' stroke-linecap='butt' stroke-linejoin='round'/%3E%3Cpath d='M0 21L8 17L16 23L24 18L32 24L40 17L48 22L56 17L64 24L72 18L80 23L88 17L96 21' fill='none' stroke='%231a7a4c' stroke-width='2.5' stroke-linecap='butt' stroke-linejoin='round'/%3E%3Ccircle cx='22' cy='15' r='4.5' fill='%23e63946' stroke='%23060f1d' stroke-width='1.5'/%3E%3Ccircle cx='20.65' cy='13.425' r='1.3' fill='%23fff' opacity='.85'/%3E%3Ccircle cx='29' cy='19.5' r='3.6' fill='%23e63946' stroke='%23060f1d' stroke-width='1.5'/%3E%3Ccircle cx='27.92' cy='18.24' r='1.0' fill='%23fff' opacity='.85'/%3E%3Ccircle cx='70' cy='17' r='4.5' fill='%23e63946' stroke='%23060f1d' stroke-width='1.5'/%3E%3Ccircle cx='68.65' cy='15.425' r='1.3' fill='%23fff' opacity='.85'/%3E%3Ccircle cx='48' cy='15' r='4.2' fill='%23ffd166' stroke='%23060f1d' stroke-width='1.5'/%3E%3Ccircle cx='46.74' cy='13.53' r='1.2' fill='%23fff' opacity='.85'/%3E%3C/svg%3E");
  background-repeat: round no-repeat;
  background-position: 0 50%;
  background-size: calc(96 * var(--u)) calc(32 * var(--u));
}
.ha-garland--sm { height: calc(22 * var(--u)); background-size: calc(66 * var(--u)) calc(22 * var(--u)); }

/* --------------------------------------------------------------------------
   14. Room code
   --------------------------------------------------------------------------
   <div class="ha-code"><span class="ha-code__tile">B</span> x4 </div>
   Everything is in em, so set font-size (or use --sm / --lg / --xl) to scale. */
.ha-code {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: calc(44 * var(--u));
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
}
.ha-code__tile {
  --tile: var(--ans-0);
  --tile-edge: var(--ans-0-dark);
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 1.26em;
  height: 1.5em;
  margin: 0 0.085em 0.14em;
  border-radius: 0.3em;
  background: var(--tile);
  color: #ffffff;
  text-shadow: 0 0.06em 0 rgba(0, 0, 0, 0.28);
  text-transform: uppercase;
  box-shadow:
    inset 0 0.07em 0 rgba(255, 255, 255, 0.38),
    inset 0 -0.08em 0 rgba(0, 0, 0, 0.14),
    0 0.14em 0 var(--tile-edge),
    0 0.26em 0.3em rgba(0, 0, 0, 0.35);
  transform: rotate(-3deg);
}
.ha-code__tile:nth-child(4n + 2) { --tile: var(--ans-1); --tile-edge: var(--ans-1-dark); transform: rotate(2deg) translateY(0.04em); }
.ha-code__tile:nth-child(4n + 3) { --tile: var(--ans-2); --tile-edge: var(--ans-2-dark); color: #33210a; text-shadow: 0 0.04em 0 rgba(255, 255, 255, 0.5); transform: rotate(-1.5deg) translateY(-0.03em); }
.ha-code__tile:nth-child(4n + 4) { --tile: var(--ans-3); --tile-edge: var(--ans-3-dark); color: #06283d; text-shadow: 0 0.04em 0 rgba(255, 255, 255, 0.5); transform: rotate(3deg); }
.ha-code--sm { font-size: calc(22 * var(--u)); }
.ha-code--lg { font-size: calc(72 * var(--u)); }
.ha-code--xl { font-size: calc(120 * var(--u)); }
/* all tiles snow-white with ink letters, for busy backgrounds */
.ha-code--plain .ha-code__tile { --tile: var(--snow); --tile-edge: #a9bfd3; color: var(--ink); text-shadow: none; }

/* --------------------------------------------------------------------------
   15. Chips, badges and rank medals
   -------------------------------------------------------------------------- */
.ha-chip {
  display: inline-flex;
  flex: none;
  align-items: center;
  height: calc(28 * var(--u));
  padding: 0 calc(11 * var(--u));
  border-radius: 999px;
  background: #2a4370;
  color: var(--snow);
  font-family: var(--font-body);
  font-size: calc(13 * var(--u));
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
}
.ha-chip > .ha-icon { width: calc(18 * var(--u)); height: calc(18 * var(--u)); margin: 0 calc(5 * var(--u)) 0 calc(-4 * var(--u)); }
/* host crown */
.ha-chip--host { background: var(--gold); color: #4a2f00; box-shadow: 0 calc(2 * var(--u)) 0 #c98a10; }
/* streak flame */
.ha-chip--streak { background-color: #f2622e; background-image: linear-gradient(180deg, #ff9f43 0%, #e63946 100%); color: #ffffff; text-shadow: 0 calc(1 * var(--u)) 0 rgba(0, 0, 0, 0.3); box-shadow: 0 calc(2 * var(--u)) 0 #9c0f25; }
.ha-chip--good { background: var(--ans-1); box-shadow: 0 calc(2 * var(--u)) 0 var(--ans-1-dark); }
.ha-chip--bad { background: var(--red); box-shadow: 0 calc(2 * var(--u)) 0 var(--red-dark); }
.ha-chip--ice { background: var(--ans-3); color: #06283d; box-shadow: 0 calc(2 * var(--u)) 0 var(--ans-3-dark); }
.ha-chip--snow { background: var(--snow); color: var(--ink); box-shadow: 0 calc(2 * var(--u)) 0 #a9bfd3; }
.ha-chip--lg { height: calc(38 * var(--u)); padding: 0 calc(15 * var(--u)); font-size: calc(17 * var(--u)); }
.ha-chip--lg > .ha-icon { width: calc(24 * var(--u)); height: calc(24 * var(--u)); }

/* <span class="ha-medal" data-rank="1">1</span>  gold / silver / bronze coin,
   any other rank is a plain slate disc */
.ha-medal {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: calc(38 * var(--u));
  height: calc(38 * var(--u));
  border: calc(3 * var(--u)) solid #5a6f92;
  border-radius: 50%;
  background: #2a4370;
  color: var(--snow);
  font-family: var(--font-display);
  font-size: calc(19 * var(--u));
  font-weight: 400;
  line-height: 1;
  box-shadow: 0 calc(3 * var(--u)) 0 rgba(0, 0, 0, 0.3);
  vertical-align: middle;
}
.ha-medal[data-rank="1"] { border-color: #fff0b8; background-color: #ffd166; background-image: linear-gradient(160deg, #ffe9a3 0%, #ffc233 60%, #e0a021 100%); color: #4a2f00; box-shadow: 0 calc(3 * var(--u)) 0 #a86f00; }
.ha-medal[data-rank="2"] { border-color: #f4f8fb; background-color: #cdd7e1; background-image: linear-gradient(160deg, #f4f8fb 0%, #c3cfdb 60%, #9aa9b9 100%); color: #2b3a4f; box-shadow: 0 calc(3 * var(--u)) 0 #6b7a8c; }
.ha-medal[data-rank="3"] { border-color: #f6c79b; background-color: #d98b4a; background-image: linear-gradient(160deg, #f0ae74 0%, #d98b4a 60%, #b0662a 100%); color: #43200a; box-shadow: 0 calc(3 * var(--u)) 0 #7d4416; }
.ha-medal--sm { width: calc(28 * var(--u)); height: calc(28 * var(--u)); border-width: calc(2 * var(--u)); font-size: calc(14 * var(--u)); }
.ha-medal--lg { width: calc(60 * var(--u)); height: calc(60 * var(--u)); border-width: calc(4 * var(--u)); font-size: calc(30 * var(--u)); }

/* --------------------------------------------------------------------------
   16. Toast
   --------------------------------------------------------------------------
   HA.toast('Text') in fx.js builds this markup:
   <div class="ha-toasts"><div class="ha-toast ha-toast--good">..</div></div>  */
.ha-toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-b) + 20 * var(--u));
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 calc(16 * var(--u));
  pointer-events: none;
  z-index: var(--z-toast);
}
.ha-toasts--top { top: calc(var(--safe-t) + 20 * var(--u)); bottom: auto; }
.ha-toast {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin-top: calc(10 * var(--u));
  padding: calc(11 * var(--u)) calc(18 * var(--u));
  border: calc(3 * var(--u)) solid var(--snow);
  border-radius: calc(18 * var(--u));
  background: #10213a;
  color: var(--snow);
  font-family: var(--font-body);
  font-size: calc(16 * var(--u));
  font-weight: 900;
  line-height: 1.2;
  box-shadow: 0 calc(5 * var(--u)) 0 rgba(0, 0, 0, 0.4);
  animation: ha-toast-in 0.4s var(--ease-spring) both;
}
.ha-toast > .ha-icon { width: calc(24 * var(--u)); height: calc(24 * var(--u)); margin-right: calc(9 * var(--u)); }
.ha-toast--good { background: var(--ans-1); }
.ha-toast--bad { background: var(--red); }
.ha-toast--gold { background: var(--gold); color: #33210a; }
.ha-toast.is-out { animation: ha-toast-out 0.25s ease-in both; }

@keyframes ha-toast-in {
  from { transform: translateY(calc(30 * var(--u))) scale(0.8); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes ha-toast-out {
  from { transform: translateY(0) scale(1); opacity: 1; }
  to { transform: translateY(calc(16 * var(--u))) scale(0.9); opacity: 0; }
}

/* --------------------------------------------------------------------------
   17. Modal and bottom sheet
   --------------------------------------------------------------------------
   <div class="ha-modal is-open">            (+ .ha-modal--sheet for a sheet)
     <div class="ha-modal__card">
       <div class="ha-sheet__grip"></div>     (sheet only, optional)
       <h2 class="ha-modal__title">Settings</h2>
       <div class="ha-modal__body">..</div>
       <div class="ha-modal__actions"><button class="ha-btn">..</button></div>
     </div>
   </div>
   The scrim is a plain translucent fill (no backdrop-filter).               */
.ha-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 20 * var(--u)) calc(var(--safe-r) + 20 * var(--u)) calc(var(--safe-b) + 20 * var(--u)) calc(var(--safe-l) + 20 * var(--u));
  background: rgba(6, 15, 29, 0.86);
  z-index: var(--z-modal);
}
.ha-modal.is-open { display: flex; animation: ha-fade-in 0.18s ease-out both; }
.ha-modal__card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: calc(440 * var(--u));
  max-height: 100%;
  padding: calc(22 * var(--u));
  border: calc(4 * var(--u)) solid var(--snow);
  border-radius: calc(26 * var(--u));
  background-color: #14294a;
  background-image: linear-gradient(180deg, #1d3a66 0%, #14294a 100%);
  color: var(--snow);
  box-shadow: 0 calc(10 * var(--u)) 0 rgba(0, 0, 0, 0.4);
  animation: ha-pop-in 0.42s var(--ease-spring) both;
}
.ha-modal__title { margin: 0 0 calc(12 * var(--u)); font-family: var(--font-display); font-weight: 400; font-size: calc(26 * var(--u)); line-height: 1.1; text-align: center; }
.ha-modal__body { flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.ha-modal__actions { display: flex; flex: none; margin-top: calc(18 * var(--u)); padding-bottom: calc(6 * var(--u)); }
.ha-modal__actions > * { flex: 1 1 0; min-width: 0; }
.ha-modal__actions > * + * { margin-left: calc(12 * var(--u)); }

.ha-modal--sheet { align-items: flex-end; padding: calc(var(--safe-t) + 24 * var(--u)) 0 0; }
.ha-modal--sheet .ha-modal__card {
  max-width: calc(560 * var(--u));
  padding-bottom: calc(var(--safe-b) + 22 * var(--u));
  border-bottom: 0;
  border-radius: calc(28 * var(--u)) calc(28 * var(--u)) 0 0;
  box-shadow: none;
  animation: ha-sheet-in 0.32s var(--ease-out) both;
}
.ha-sheet__grip { flex: none; width: calc(48 * var(--u)); height: calc(6 * var(--u)); margin: calc(-8 * var(--u)) auto calc(14 * var(--u)); border-radius: 999px; background: rgba(255, 253, 247, 0.38); }

@keyframes ha-sheet-in {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   18. Ambient layers: starry sky, falling snow, confetti
   -------------------------------------------------------------------------- */

/* <div class="ha-sky"></div>  static stars behind everything */
.ha-sky {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
  opacity: 0.75;
  background-image:
    radial-gradient(circle, #ffffff 0, #ffffff 1px, rgba(255, 255, 255, 0) 2px),
    radial-gradient(circle, #ffffff 0, #ffffff 1.5px, rgba(255, 255, 255, 0) 2.5px),
    radial-gradient(circle, #ffe9a3 0, #ffe9a3 1px, rgba(255, 233, 163, 0) 2px),
    radial-gradient(circle, #cfeaff 0, #cfeaff 1px, rgba(207, 234, 255, 0) 2px);
  background-size: 190px 170px, 310px 290px, 270px 230px, 130px 210px;
  background-position: 20px 30px, 140px 90px, 60px 150px, 100px 10px;
  z-index: var(--z-sky);
}

/* HA.snow() in fx.js builds:  <div class="ha-snow"><i class="ha-snow__flake"></i>...</div>
   Each flake is a full-height column with a dot at the top, so the fall can
   be a pure percentage translate that needs no measuring and no resize code. */
.ha-snow {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: var(--z-snow);
}
.ha-snow__flake {
  position: absolute;
  top: 0;
  width: 6px;
  height: 100%;
  animation: ha-snow-a 12s linear infinite;
  will-change: transform;
}
.ha-snow__flake::before {
  content: "";
  display: block;
  width: 100%;
  padding-top: 100%;
  border-radius: 50%;
  background: #ffffff;
}
@keyframes ha-snow-a {
  0% { transform: translate3d(0, -6%, 0); }
  50% { transform: translate3d(26px, 49%, 0); }
  100% { transform: translate3d(-8px, 104%, 0); }
}
@keyframes ha-snow-b {
  0% { transform: translate3d(0, -6%, 0); }
  35% { transform: translate3d(-22px, 32%, 0); }
  70% { transform: translate3d(12px, 71%, 0); }
  100% { transform: translate3d(-14px, 104%, 0); }
}
@keyframes ha-snow-c {
  0% { transform: translate3d(0, -6%, 0); }
  100% { transform: translate3d(34px, 104%, 0); }
}

/* HA.confetti() builds:  <div class="ha-confetti"><i class="ha-confetti__piece"></i>...</div> */
.ha-confetti {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: var(--z-confetti);
}
.ha-confetti__piece {
  position: absolute;
  display: block;
  border-radius: 2px;
  will-change: transform, opacity;
}

/* --------------------------------------------------------------------------
   19. Waiting dots
   --------------------------------------------------------------------------
   <span class="ha-dots"><i></i><i></i><i></i></span>   three bouncing snowballs */
.ha-dots { display: inline-flex; align-items: flex-end; height: calc(22 * var(--u)); vertical-align: middle; }
.ha-dots > i {
  display: block;
  width: calc(11 * var(--u));
  height: calc(11 * var(--u));
  margin: 0 calc(3 * var(--u));
  border-radius: 50%;
  background: var(--snow);
  box-shadow: inset 0 calc(-2 * var(--u)) 0 var(--snow-shade);
  animation: ha-dot 0.9s ease-in-out infinite;
}
.ha-dots > i:nth-child(2) { animation-delay: 0.15s; }
.ha-dots > i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ha-dot {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(calc(-9 * var(--u))); }
}

/* --------------------------------------------------------------------------
   20. One-shot animation utilities
   --------------------------------------------------------------------------
   Add the class to play it; to replay, remove it, force a reflow
   (void el.offsetWidth) and add it again.                                   */
.ha-anim-pop { animation: ha-pop-in 0.45s var(--ease-spring) both; }
.ha-anim-pop-out { animation: ha-pop-out 0.25s ease-in both; }
.ha-anim-wobble { animation: ha-wobble 0.5s ease-in-out both; }
.ha-anim-shake { animation: ha-shake 0.45s both; }
.ha-anim-bounce { animation: ha-bounce 0.6s var(--ease-out) both; }
.ha-anim-drop { animation: ha-drop 0.55s var(--ease-spring) both; }
.ha-anim-fade { animation: ha-fade-in 0.3s ease-out both; }
/* looping */
.ha-anim-pulse { animation: ha-pulse 1.2s ease-in-out infinite; }
.ha-anim-float { animation: ha-float 3.2s ease-in-out infinite; }
.ha-anim-swing { animation: ha-swing 2.6s ease-in-out infinite; transform-origin: 50% 0; }

@keyframes ha-pop-in {
  0% { transform: scale(0.4); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes ha-pop-out {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.5); opacity: 0; }
}
@keyframes ha-wobble {
  0%, 100% { transform: rotate(0) scale(1); }
  20% { transform: rotate(-4deg) scale(1.04); }
  45% { transform: rotate(3deg) scale(1.04); }
  70% { transform: rotate(-2deg) scale(1.01); }
}
@keyframes ha-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(calc(-9 * var(--u))); }
  35% { transform: translateX(calc(8 * var(--u))); }
  55% { transform: translateX(calc(-6 * var(--u))); }
  75% { transform: translateX(calc(4 * var(--u))); }
}
@keyframes ha-bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(calc(-16 * var(--u))); }
  55% { transform: translateY(0); }
  72% { transform: translateY(calc(-6 * var(--u))); }
}
@keyframes ha-drop {
  0% { transform: translateY(calc(-60 * var(--u))) rotate(-6deg); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: translateY(0) rotate(0); opacity: 1; }
}
@keyframes ha-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes ha-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes ha-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(calc(-8 * var(--u))); }
}
@keyframes ha-swing {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

/* --------------------------------------------------------------------------
   21. Calm mode
   --------------------------------------------------------------------------
   Non-essential motion is switched off when the OS asks for reduced motion,
   or when a page puts .ha-calm on <html> (e.g. a low-power TV mode).
   State changes still show: bubbles and modals simply fade.                 */
@media (prefers-reduced-motion: reduce) {
  .ha-lights::before,
  .ha-lights::after,
  .ha-candy,
  .ha-candy__fill::before,
  .ha-dots > i,
  .ha-anim-pulse,
  .ha-anim-float,
  .ha-anim-swing,
  .ha-anim-wobble,
  .ha-anim-shake,
  .ha-anim-bounce,
  .ha-answer.is-correct,
  .ha-answer.is-wrong,
  .ha-input.is-error,
  .ha-bubble.is-in .ha-bubble__badge {
    animation: none !important;
  }
  .ha-snow,
  .ha-confetti { display: none !important; }
  .ha-bubble.is-in,
  .ha-anim-pop,
  .ha-anim-drop,
  .ha-modal__card,
  .ha-toast { animation: ha-fade-in 0.2s ease-out both !important; }
  .ha-bubble.is-out,
  .ha-anim-pop-out,
  .ha-toast.is-out { animation: ha-fade-out 0.2s ease-in both !important; }
  .ha-btn,
  .ha-answer,
  .ha-toggle__track::after { transition: none !important; }
}
.ha-calm .ha-lights::before,
.ha-calm .ha-lights::after,
.ha-calm .ha-candy,
.ha-calm .ha-candy__fill::before,
.ha-calm .ha-dots > i,
.ha-calm .ha-anim-pulse,
.ha-calm .ha-anim-float,
.ha-calm .ha-anim-swing,
.ha-calm .ha-anim-wobble,
.ha-calm .ha-anim-shake,
.ha-calm .ha-anim-bounce,
.ha-calm .ha-answer.is-correct,
.ha-calm .ha-answer.is-wrong,
.ha-calm .ha-input.is-error,
.ha-calm .ha-bubble.is-in .ha-bubble__badge {
  animation: none !important;
}
.ha-calm .ha-snow,
.ha-calm .ha-confetti { display: none !important; }
.ha-calm .ha-bubble.is-in,
.ha-calm .ha-anim-pop,
.ha-calm .ha-anim-drop,
.ha-calm .ha-modal__card,
.ha-calm .ha-toast { animation: ha-fade-in 0.2s ease-out both !important; }
.ha-calm .ha-bubble.is-out,
.ha-calm .ha-anim-pop-out,
.ha-calm .ha-toast.is-out { animation: ha-fade-out 0.2s ease-in both !important; }

@keyframes ha-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
