/* Page shell + DOM UI: look A "Polished space" (D-054; LOOK_AND_HUD §5).
   Lilita One (display, always capitals) for the wordmark, buttons, titles and big numbers; the system
   font for names, labels and body text. Indigo glass panels, chunky glossy buttons with a lip.
   GREEN (--g, swapped to the colorblind color by ui/settings.ts) means you and your friends, RED
   everyone else; green buttons follow --g too. */
:root {
  --sys: -apple-system, 'SF Pro Display', 'SF Pro Text', system-ui, 'Segoe UI', Roboto, sans-serif;
  --display: 'Lilita One', var(--sys);
  --bg: #09081c;
  --bg-top: #141133;
  --bg-mid: #0e0c27;
  --ink: #f4f2ff;
  --dim: rgba(222, 218, 255, 0.64);
  --faint: rgba(222, 218, 255, 0.56);
  --line: rgba(255, 255, 255, 0.09);
  --line2: rgba(255, 255, 255, 0.14);
  --g: 52, 236, 124;
  --green: rgb(var(--g));
  --g-text: #7dffae;
  --red: #ff4466;
  --red-text: #ff8fa2;
  --gold: #ffc94d;
  --stroke: rgba(6, 5, 20, 0.85);
  /* Green button faces, derived from --g so colorblind mode recolors them (fallbacks first). */
  --g-hi: color-mix(in srgb, rgb(var(--g)) 72%, #fff);
  --g-lo: color-mix(in srgb, rgb(var(--g)) 82%, #000);
  --g-lip: color-mix(in srgb, rgb(var(--g)) 42%, #000);
  --g-shadow: color-mix(in srgb, rgb(var(--g)) 34%, #000);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  /* Content never closer to the screen edge than this, even without safe-area insets (browser). */
  --sat: max(var(--safe-top), 12px);
  --sab: max(var(--safe-bottom), 10px);
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sys);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* Fixed body: iOS Safari can't scroll or rubber-band the page, and its size follows the visible
   viewport as the toolbar shows/hides (100vh would be the toolbar-hidden height). */
body {
  position: fixed;
  inset: 0;
}

/* Portrait play area: full screen on phones and tablets (any orientation), a centered 9:16 column
   only on wide desktop windows (mouse/trackpad); a phone turned sideways must not get a sliver. */
#app {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
}
@media (min-aspect-ratio: 4/5) and (hover: hover) and (pointer: fine) {
  #app {
    max-width: calc(100vh * 9 / 16);
    max-width: calc(100dvh * 9 / 16);
  }
}

#game-container {
  position: absolute;
  inset: 0;
  touch-action: none;
}
#game-container canvas {
  display: block;
  touch-action: none;
  outline: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Overlay root lets touches fall through to the game except on its own interactive children. */
#ui-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  touch-action: none;
}
#ui-root > * {
  pointer-events: auto;
}

.hidden {
  display: none !important;
}

button {
  font-family: inherit;
  color: inherit;
  -webkit-user-select: none;
  user-select: none;
  cursor: pointer;
  margin: 0;
}
button:disabled {
  cursor: default;
}
button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(var(--g), 0.75);
  outline-offset: 2px;
}

/* ---------- shared pieces ---------- */
.screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.screen > .col {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  padding: var(--sat) calc(20px + var(--safe-right)) var(--sab) calc(20px + var(--safe-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  scrollbar-width: none;
}
.screen > .col::-webkit-scrollbar {
  display: none;
}
.screen > .col > * {
  flex: none;
}

/* Glass panel: indigo gradient, hairline border, inner top highlight, deep shadow, backdrop blur. */
.glass {
  background: linear-gradient(180deg, rgba(36, 31, 82, 0.7), rgba(18, 15, 44, 0.78));
  border: 1px solid var(--line);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 18px 40px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
}
.caps {
  font: 800 11px/1 var(--sys);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}
.ico {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: none;
  color: rgba(236, 234, 255, 0.88);
}
.icon-btn svg {
  width: 22px;
  height: 22px;
}
.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}
.dot.g {
  background: var(--green);
  box-shadow: 0 0 8px rgba(var(--g), 0.8);
}
.dot.r {
  background: var(--red);
  box-shadow: 0 0 8px rgba(255, 68, 102, 0.7);
}

/* Chunky glossy buttons: gradient face, a lip under it, inner top highlight, gloss band. */
.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  padding: 0 18px;
  border: 0;
  border-radius: 18px;
  font: 400 20px/1 var(--display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
  flex: none;
  transition: transform 0.08s;
}
.btn > * {
  position: relative;
}
.btn:active:not(:disabled) {
  transform: translateY(2px);
}
.btn svg {
  flex: none;
}
.btn-primary {
  height: 62px;
  font-size: 25px;
  background: linear-gradient(180deg, #5bf597 0%, #2fe077 48%, #1bc460 100%);
  background: linear-gradient(180deg, var(--g-hi) 0%, rgb(var(--g)) 48%, var(--g-lo) 100%);
  box-shadow:
    0 5px 0 var(--g-lip),
    0 10px 24px rgba(var(--g), 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    inset 0 -2px 0 rgba(0, 60, 20, 0.22);
  text-shadow: 0 2px 0 var(--g-shadow);
}
.btn-primary::after {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  top: 4px;
  height: 44%;
  border-radius: 14px 14px 30px 30px / 14px 14px 12px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.btn-primary:active:not(:disabled) {
  box-shadow:
    0 3px 0 var(--g-lip),
    0 8px 20px rgba(var(--g), 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
}
.btn-primary svg {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 1.5px 0 var(--g-shadow));
}
.btn-secondary {
  height: 52px;
  color: rgba(236, 234, 255, 0.9);
  background: linear-gradient(180deg, #3d3796 0%, #2c2770 100%);
  box-shadow:
    0 4px 0 #19164a,
    0 8px 18px rgba(0, 0, 0, 0.35),
    inset 0 1.5px 0 rgba(255, 255, 255, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  text-shadow: 0 2px 0 rgba(10, 8, 40, 0.7);
}
.btn-secondary:active:not(:disabled) {
  box-shadow:
    0 2px 0 #19164a,
    0 6px 14px rgba(0, 0, 0, 0.35),
    inset 0 1.5px 0 rgba(255, 255, 255, 0.18);
}
.btn-secondary svg {
  width: 21px;
  height: 21px;
  color: rgba(236, 234, 255, 0.82);
}
.btn:disabled {
  opacity: 0.6;
}
.soon {
  position: absolute;
  right: -6px;
  top: -9px;
  transform: rotate(5deg);
  font: 800 10px/1 var(--sys);
  letter-spacing: 0.12em;
  color: #2a1a00;
  text-shadow: none;
  background: linear-gradient(180deg, #ffd978, #ffb627);
  border-radius: 7px;
  padding: 4px 7px 3px;
  box-shadow:
    0 1.5px 0 #a86a00,
    0 4px 10px rgba(0, 0, 0, 0.35);
}
.txt-btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  background: none;
  border: 0;
  font: 700 15px/1 var(--sys);
  color: var(--dim);
}

/* ---------- wordmark (ui/wordmark.ts sets the sizes) ---------- */
.wm {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  line-height: 1;
}
.wm span {
  display: block;
  white-space: nowrap;
}
.wm-lead {
  letter-spacing: 0.2em;
  margin-right: -0.2em;
  color: #d9d4ff;
  text-shadow:
    0 2px 0 #2a2466,
    0 3px 0 #1c184a,
    0 6px 12px rgba(0, 0, 0, 0.5);
  margin-bottom: 0.06em;
}
/* The last word: the element's own text is the dark extrusion with an outline and a soft green glow;
   ::after lays the white-to-GREEN face on top (same box, same text from data-t). */
.wm-last {
  position: relative;
  letter-spacing: 0.01em;
  line-height: 0.98;
  padding: 0 7px 0.08em;
  color: #0b5c30;
  color: var(--g-shadow);
  -webkit-text-stroke: 0.1em #06331b;
  -webkit-text-stroke: 0.1em color-mix(in srgb, rgb(var(--g)) 18%, #000);
  text-shadow:
    0 2px 0 #06331b,
    0 4px 0 #052a16,
    0 5px 0 #042110,
    0 12px 22px rgba(0, 0, 0, 0.6),
    0 0 34px rgba(var(--g), 0.34);
}
.wm-last::after {
  content: attr(data-t);
  position: absolute;
  inset: 0;
  padding: inherit;
  -webkit-text-stroke: 0;
  text-shadow: none;
  color: #fff;
  background: linear-gradient(180deg, #fff 0%, #fff 34%, #d4ffe4 58%, #7cf4ac 100%);
  background: linear-gradient(
    180deg,
    #fff 0%,
    #fff 34%,
    color-mix(in srgb, rgb(var(--g)) 22%, #fff) 58%,
    color-mix(in srgb, rgb(var(--g)) 62%, #fff) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- home ---------- */
.home {
  background:
    /* Extra veil behind the brand, hero snake and tagline band, and under the legend: the attract
       world is backdrop and must never compete with the text (mock A keeps it dim). */
    radial-gradient(
      100% 30% at 50% 24%,
      rgba(10, 8, 28, 0.78) 0%,
      rgba(10, 8, 28, 0.5) 60%,
      rgba(10, 8, 28, 0) 100%
    ),
    linear-gradient(
      180deg,
      rgba(10, 8, 28, 0.42),
      rgba(10, 8, 28, 0.55) 50%,
      rgba(7, 6, 20, 0.7) 82%,
      rgba(7, 6, 20, 0.9)
    );
}
.home .topbar {
  width: 100%;
  height: 44px;
  margin-top: 4px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.home .brand {
  width: 100%;
  margin-top: 6px;
  padding-bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.home .hero {
  display: block;
  width: calc(100% + 40px);
  height: 104px;
  margin: -6px -20px 0;
  pointer-events: none;
}
.home .tagline {
  margin-top: 4px;
  font: 800 12px/1 var(--sys);
  letter-spacing: 0.3em;
  margin-right: -0.3em;
  color: rgba(214, 208, 255, 0.66);
  text-transform: uppercase;
}
/* The card floats in the space between the brand and the legend. */
.home .card {
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
  margin-top: auto;
  margin-bottom: auto;
  padding: 18px 20px 18px;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
}
.home .lbl-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 4px 9px;
}
.home .cnt {
  font: 700 11px/1 var(--sys);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.field {
  position: relative;
  height: 56px;
  box-sizing: border-box;
  border-radius: 17px;
  background: rgba(6, 5, 20, 0.62);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    0 1px 0 rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  padding: 0 6px 0 18px;
  gap: 8px;
}
.field:focus-within {
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1.5px rgba(var(--g), 0.6),
    0 0 0 3px rgba(var(--g), 0.12);
}
.field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: none;
  background: none;
  font: 700 19px/1 var(--sys);
  letter-spacing: 0.01em;
  color: var(--ink);
  caret-color: var(--green);
  user-select: text;
  -webkit-user-select: text;
}
.field input::placeholder {
  color: rgba(225, 220, 255, 0.4);
}
.field .dice {
  width: 44px;
  height: 44px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: rgba(236, 234, 255, 0.78);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09);
}
.field .dice svg {
  width: 21px;
  height: 21px;
}
.field .dice:active {
  transform: rotate(-12deg) scale(0.94);
}
.home .play {
  margin-top: 16px;
}
.home .party {
  margin-top: 16px;
}
/* PARTY stays fully readable while disabled: the SOON tag already says why. */
.home .party:disabled {
  opacity: 1;
}
.home .how {
  margin-top: 18px;
  text-align: center;
  font: 600 12.5px/1.55 var(--sys);
  color: rgba(214, 208, 255, 0.62);
}
.home .how b {
  color: rgba(244, 242, 255, 0.88);
  font-weight: 800;
}
.home .legend {
  padding-top: 16px;
  padding-bottom: 6px;
  text-align: center;
  font: 600 12px/1.6 var(--sys);
  color: rgba(214, 208, 255, 0.6);
  white-space: nowrap;
}
.home .legend .dot {
  margin-right: 6px;
  vertical-align: 0.5px;
}
.home .legend .sep {
  margin: 0 9px;
  color: rgba(214, 208, 255, 0.32);
}
.home .legend b {
  font-weight: 800;
}
.home .legend b.g {
  color: var(--g-text);
}
.home .legend b.r {
  color: var(--red-text);
}
/* Short phones (SE, mini): smaller hero, no tagline, a tighter card. */
@media (max-height: 740px) {
  .home .topbar {
    margin-top: 2px;
    height: 44px;
    margin-bottom: -18px;
  }
  .home .brand {
    margin-top: 0;
  }
  .home .hero {
    height: 70px;
    margin-top: -4px;
  }
  .home .tagline {
    display: none;
  }
  .home .brand {
    padding-bottom: 10px;
  }
  .home .card {
    padding: 14px 16px;
    border-radius: 24px;
  }
  .home .field {
    height: 50px;
  }
  .home .play {
    margin-top: 12px;
    height: 56px;
    font-size: 23px;
  }
  .home .party {
    margin-top: 14px;
    height: 48px;
  }
  .home .how {
    margin-top: 12px;
    font-size: 12px;
    line-height: 1.5;
  }
  .home .legend {
    padding-top: 10px;
  }
}
/* Phone held sideways: brand on the left, the card on the right. */
@media (orientation: landscape) and (max-height: 500px) {
  .home > .col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    grid-template-rows: 1fr auto;
    column-gap: 24px;
    align-items: center;
    justify-items: center;
    padding-top: max(var(--safe-top), 8px);
    padding-bottom: max(var(--safe-bottom), 8px);
  }
  .home .topbar {
    position: absolute;
    top: max(var(--safe-top), 8px);
    right: calc(12px + var(--safe-right));
    width: auto;
    margin: 0;
  }
  .home .brand {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
  }
  .home .hero {
    width: 100%;
    margin: -2px 0 0;
  }
  .home .tagline {
    display: block;
    font-size: 11px;
  }
  .home .card {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin: 0;
    padding: 12px 16px 12px;
    border-radius: 22px;
  }
  .home .lbl-row {
    margin-bottom: 6px;
  }
  .home .field {
    height: 46px;
  }
  .home .play {
    margin-top: 10px;
    height: 52px;
    font-size: 22px;
  }
  .home .party {
    margin-top: 12px;
    height: 44px;
    font-size: 18px;
  }
  .home .how {
    margin-top: 10px;
    font-size: 11.5px;
    line-height: 1.45;
  }
  .home .legend {
    grid-column: 1;
    grid-row: 2;
    margin: 0;
    padding: 0 0 4px;
    font-size: 11.5px;
  }
}

/* ---------- death ---------- */
.death {
  background: radial-gradient(
    110% 62% at 50% 48%,
    rgba(14, 10, 34, 0.42) 0%,
    rgba(10, 7, 26, 0.66) 62%,
    rgba(40, 8, 22, 0.82) 100%
  );
}
.death > .col {
  justify-content: safe center;
}
.death .card {
  width: 100%;
  max-width: 400px;
  box-sizing: border-box;
  padding: 22px 20px 20px;
  border-radius: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.death .killer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  box-sizing: border-box;
  padding: 7px 14px;
  border-radius: 20px;
  background: rgba(6, 5, 20, 0.5);
  box-shadow: inset 0 0 0 1px rgba(255, 68, 102, 0.28);
  font: 700 13.5px/1.2 var(--sys);
  color: var(--dim);
  white-space: nowrap;
}
.death .killer.friend {
  box-shadow: inset 0 0 0 1px rgba(var(--g), 0.3);
}
.death .killer .dot {
  margin-left: 2px;
}
.death .killer b {
  color: var(--red-text);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.death .killer.friend b {
  color: var(--g-text);
}
.death .killer .sub {
  color: var(--faint);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.death .line {
  font: 700 14px/1.3 var(--sys);
  color: var(--dim);
}
.death .title {
  margin-top: 10px;
  font: 400 58px/1 var(--display);
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: #fff;
  background: linear-gradient(180deg, #fff 0%, #fff 40%, #ffc2cd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #8a1430) drop-shadow(0 10px 18px rgba(0, 0, 0, 0.5))
    drop-shadow(0 0 22px rgba(255, 68, 102, 0.28));
  padding: 0 4px 3px;
}
.death .hr {
  align-self: stretch;
  height: 1px;
  margin: 16px 6px 16px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.13), transparent);
}
.death .len {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.death .len-v {
  margin-top: 4px;
  font: 400 58px/1.02 var(--display);
  letter-spacing: 0.01em;
  color: var(--g-text);
  text-shadow:
    0 3px 0 var(--g-shadow),
    0 0 24px rgba(var(--g), 0.32);
  font-variant-numeric: tabular-nums;
}
.death .len-sub {
  margin-top: 6px;
  min-height: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.death .new-best {
  font: 800 10px/1 var(--sys);
  letter-spacing: 0.14em;
  color: #2a1a00;
  background: linear-gradient(180deg, #ffd978, #ffb627);
  border-radius: 7px;
  padding: 4px 8px 3px;
  box-shadow: 0 1.5px 0 #a86a00;
}
.death .best {
  font: 700 12.5px/1 var(--sys);
  color: var(--dim);
}
.death .best b {
  color: var(--gold);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.death .tiles {
  align-self: stretch;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 22px;
}
.death .tile {
  border-radius: 16px;
  padding: 12px 4px 10px;
  background: rgba(6, 5, 20, 0.5);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    inset 0 2px 5px rgba(0, 0, 0, 0.35);
  min-width: 0;
}
.death .tile .v {
  font: 400 27px/1.1 var(--display);
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.death .tile .k {
  margin-top: 4px;
  font: 800 9.5px/1.2 var(--sys);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}
.death .actions {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.death .actions svg {
  width: 23px;
  height: 23px;
}
.death .home-btn svg {
  width: 20px;
  height: 20px;
}
/* PLAY AGAIN during the respawn wait: dark green glass that fills up, then the glossy face. */
.again .track {
  display: none;
}
.again .secs {
  font: 400 19px/1 var(--display);
  letter-spacing: 0.02em;
  color: var(--g-text);
  text-transform: none;
}
.btn-primary.waiting {
  opacity: 1;
  color: rgba(244, 242, 255, 0.78);
  background: linear-gradient(180deg, rgba(30, 64, 52, 0.92), rgba(14, 38, 30, 0.95));
  box-shadow:
    0 5px 0 #06261a,
    inset 0 0 0 1.5px rgba(var(--g), 0.45),
    inset 0 2px 0 rgba(160, 255, 200, 0.18);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.btn-primary.waiting::after {
  display: none;
}
.btn-primary.waiting svg {
  filter: none;
}
.again.waiting .track {
  display: block;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}
.again .track i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, rgba(var(--g), 0.34), rgba(var(--g), 0.2));
  transform-origin: left center;
  transform: scaleX(0);
}
.again .track i.run {
  animation: fill-bar var(--wait, 3s) linear forwards;
}
@keyframes fill-bar {
  to {
    transform: scaleX(1);
  }
}
@media (max-height: 700px) {
  .death .card {
    padding: 16px 18px 18px;
  }
  .death .title {
    margin-top: 6px;
  }
  .death .hr {
    margin: 10px 6px;
  }
  .death .len-v {
    font-size: 48px;
  }
  .death .tiles {
    margin: 12px 0 16px;
  }
  .death .tile {
    padding: 9px 4px 8px;
  }
  .death .tile .v {
    font-size: 24px;
  }
  .death .again {
    height: 56px;
  }
  .death .home-btn {
    height: 48px;
  }
  .death .actions {
    gap: 14px;
  }
}
/* Phone held sideways: the card turns into two columns (numbers left, buttons right). */
@media (orientation: landscape) and (max-height: 500px) {
  .death .card {
    max-width: 640px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      'pill pill'
      'title title'
      'len acts'
      'tiles acts';
    column-gap: 22px;
    padding: 14px 20px 16px;
    align-items: center;
  }
  .death .killer,
  .death .line {
    grid-area: pill;
    justify-self: center;
  }
  .death .title {
    grid-area: title;
    justify-self: center;
    margin-top: 4px;
  }
  .death .hr {
    display: none;
  }
  .death .len {
    grid-area: len;
    margin-top: 8px;
  }
  .death .len-v {
    font-size: 42px;
  }
  .death .tiles {
    grid-area: tiles;
    margin: 10px 0 0;
  }
  .death .tile {
    padding: 8px 4px 7px;
  }
  .death .tile .v {
    font-size: 21px;
  }
  .death .actions {
    grid-area: acts;
    align-self: center;
  }
}

/* ---------- connecting / error / reconnect card ---------- */
.netcover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(110% 70% at 50% 50%, rgba(14, 10, 34, 0.6), rgba(7, 6, 20, 0.84));
  z-index: 5;
}
.netcard {
  width: 320px;
  max-width: calc(100% - 40px);
  box-sizing: border-box;
  padding: 26px 22px 24px;
  border-radius: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}
.netcard .title {
  font: 400 24px/1.1 var(--display);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 2px 0 rgba(10, 8, 40, 0.8);
}
.netcard .body {
  font: 600 14px/1.4 var(--sys);
  color: var(--dim);
}
.netcard .acts {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}
.netcard .btn-primary {
  height: 56px;
  font-size: 22px;
}
.netcard .btn-secondary {
  height: 48px;
  font-size: 18px;
}
.netcard .txt-btn {
  margin: -4px 0 -12px;
}
.spinner {
  width: 34px;
  height: 34px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--green);
  border-right-color: var(--green);
  filter: drop-shadow(0 0 6px rgba(var(--g), 0.5));
  animation: net-spin 0.9s linear infinite;
  margin-bottom: 4px;
}
@keyframes net-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 3s;
  }
}

/* ---------- settings sheet ---------- */
.sheet {
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 55%, var(--bg) 100%);
  z-index: 4;
}
.sheet > .col {
  padding-left: calc(16px + var(--safe-left));
  padding-right: calc(16px + var(--safe-right));
  align-items: stretch;
}
.sheet > .col > * {
  width: 100%;
  max-width: 520px;
  align-self: center;
}
.sheet .nav {
  height: 48px;
  margin-top: 4px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
}
.sheet .nav .back {
  border: 1px solid var(--line);
  color: var(--ink);
}
.sheet .nav .title {
  text-align: center;
  font: 400 24px/1 var(--display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 2px 0 rgba(10, 8, 40, 0.8);
}
.sheet .group-label {
  margin: 24px 0 8px;
  padding: 0 16px;
  box-sizing: border-box;
}
.sheet .group {
  border-radius: 20px;
  overflow: hidden;
}
.row {
  min-height: 56px;
  box-sizing: border-box;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  color: var(--ink);
}
.row + .row {
  border-top: 1px solid var(--line);
}
.row .txt {
  flex: 1;
  min-width: 0;
}
.row .lbl {
  font: 700 15.5px/1.25 var(--sys);
  color: var(--ink);
}
.row .sub {
  margin-top: 3px;
  font: 500 12.5px/1.3 var(--sys);
  color: var(--dim);
}
.row .val {
  font: 700 15px/1 var(--sys);
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.toggle {
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  border-radius: 16px;
  background: rgba(6, 5, 20, 0.6);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: background 0.15s;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  box-sizing: border-box;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff, #dcd8f5);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s;
}
.row[aria-checked='true'] .toggle {
  background: var(--green);
  box-shadow: 0 0 12px rgba(var(--g), 0.35);
}
.row[aria-checked='true'] .toggle::after {
  transform: translateX(20px);
}

/* ---------- Drop + Boost (bottom-left) ---------- */
.btns {
  position: absolute;
  left: calc(22px + var(--safe-left));
  bottom: calc(14px + var(--sab));
  width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  touch-action: none;
}
/* The gap between the two buttons passes touches through to the game (joystick), only the buttons catch. */
#ui-root > .btns {
  pointer-events: none;
}
.btns .gbtn {
  pointer-events: auto;
}
.gbtn {
  position: relative;
  border: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  touch-action: none;
  color: #fff;
  font-family: var(--display);
  /* transform only: an animated box-shadow repaints the button every frame of the press (D-057). */
  transition: transform 0.08s;
  will-change: transform;
}
.dropwrap {
  position: relative;
  width: 68px;
  height: 68px;
}
.drop-cap {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  transform: translateX(-50%);
  max-width: 124px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 700 11.5px/1.2 var(--sys);
  color: var(--dim);
  text-shadow:
    0 0 2px var(--stroke),
    0 0 3px var(--stroke),
    0 1px 4px var(--stroke);
  pointer-events: none;
}
.drop-cap b {
  color: var(--g-text);
  font-weight: 800;
}
/* fill-mode both: the finished fade stays in getAnimations(), so buttons.ts can replay it on every
   target change (without it, only the first change faded). */
.drop-cap.swap {
  animation: cap-in 0.15s ease-out both;
}
@keyframes cap-in {
  from {
    opacity: 0;
  }
}
/* Drop: a solid chunky GREEN button (follows --g, so colorblind mode recolors it). */
.drop {
  width: 68px;
  height: 68px;
  box-sizing: border-box;
  border-radius: 20px;
  background: linear-gradient(180deg, #5bf597 0%, #2fe077 50%, #1bc460 100%);
  background: linear-gradient(180deg, var(--g-hi) 0%, rgb(var(--g)) 50%, var(--g-lo) 100%);
  box-shadow:
    0 5px 0 var(--g-lip),
    0 10px 22px rgba(0, 0, 0, 0.4),
    0 0 18px rgba(var(--g), 0.25),
    inset 0 2px 0 rgba(255, 255, 255, 0.5);
  text-shadow: 0 1.5px 0 var(--g-shadow);
  gap: 0;
  overflow: hidden;
}
.drop.held {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 var(--g-lip),
    0 6px 14px rgba(0, 0, 0, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.5);
}
.drop.cooling {
  filter: saturate(0.55) brightness(0.8);
}
/* Cooldown: dark wedge that empties clockwise from 12 o'clock as --p goes 1 → 0. */
.drop .cd {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: conic-gradient(transparent calc((1 - var(--p, 0)) * 1turn), rgba(4, 20, 12, 0.6) 0);
  pointer-events: none;
}
.drop svg {
  position: relative;
  width: 24px;
  height: 20px;
  color: #fff;
  filter: drop-shadow(0 1.5px 0 var(--g-shadow));
}
.drop .lbl {
  position: relative;
  margin-top: 2px;
  font: 400 16px/1 var(--display);
  letter-spacing: 0.05em;
}
.drop .pct {
  position: relative;
  font: 400 12.5px/1.05 var(--display);
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.88);
}
/* Boost: an 84 pt chunky orange disc with a white bolt. */
.boost {
  width: 84px;
  height: 84px;
  box-sizing: border-box;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #ffd36b 0%, #ffae2e 45%, #f2801a 100%);
  box-shadow:
    0 5px 0 #a84c06,
    0 12px 26px rgba(255, 150, 40, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 6px rgba(150, 60, 0, 0.35);
  gap: 2px;
}
.boost svg {
  width: 28px;
  height: 30px;
  margin-top: 2px;
}
.boost .lbl {
  font: 400 14px/1 var(--display);
  letter-spacing: 0.1em;
  margin-right: -0.1em;
  text-shadow: 0 1.5px 0 rgba(140, 60, 0, 0.9);
}
.boost.held,
.boost.on {
  transform: translateY(3px);
  box-shadow:
    0 2px 0 #a84c06,
    0 0 26px rgba(255, 170, 50, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 6px rgba(150, 60, 0, 0.35);
}
.boost.on {
  background: radial-gradient(circle at 50% 30%, #ffe08a 0%, #ffbb3c 45%, #f78c22 100%);
}
/* Too small to boost (MIN_BOOST_MASS): the same disc, faded. */
.boost.weak {
  opacity: 0.5;
}
.drop *,
.boost * {
  pointer-events: none;
}
@media (pointer: fine) {
  .btns {
    opacity: 0.92;
  }
}
/* Phone held sideways: too short for the stacked pair under the leaderboard, so they sit side by side. */
@media (orientation: landscape) and (max-height: 500px) {
  .btns {
    width: auto;
    flex-direction: row-reverse;
    align-items: flex-end;
    gap: 18px;
  }
}
