/*
 * Sequa: lanterns at night. In order: colors, the sky, shared controls, the
 * home screens, then the game table (layout, board, lanterns, strings, hand,
 * overlays) and reduced motion.
 */

/* ---------- Colors and type ---------- */

/*
 * Two typefaces, both under the SIL Open Font License (public/fonts): Shippori
 * Mincho for titles and Zen Maru Gothic for everything else. Only their Latin
 * letters are bundled; anything else (the suits, say) falls back to the system.
 */
@font-face {
  font-family: "Shippori Mincho";
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/shippori-mincho-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

@font-face {
  font-family: "Shippori Mincho";
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/shippori-mincho-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

@font-face {
  font-family: "Zen Maru Gothic";
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/zen-maru-gothic-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

@font-face {
  font-family: "Zen Maru Gothic";
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/zen-maru-gothic-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

@font-face {
  font-family: "Zen Maru Gothic";
  font-weight: 900;
  font-display: swap;
  src: url("/fonts/zen-maru-gothic-latin-900-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}

:root {
  color-scheme: dark;
  --night: #070b1f;
  --text: #eef1fb;
  --ivory: #f4e9cf;
  --muted: #a9b2d2;
  --gold: #ffcf6b;
  --red: #ff9a9a;
  --ink: #1b2240;
  --ink-red: #d3263f;
  --ui: "Zen Maru Gothic", ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --rounded: "Zen Maru Gothic", ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  --display: "Shippori Mincho", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --serif: var(--display);
  /* Paper's fine grain, for the cards: a little noise, warm brown and faint. */
  --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.42 0 0 0 0 0.32 0 0 0 0 0.18 0 0 0 0.1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  /* Brass, to match the lanterns: a rim of it around every panel and button, brightest at the top left. */
  --rim: linear-gradient(150deg, rgba(248, 226, 170, 0.78), rgba(201, 154, 82, 0.32) 42%, rgba(120, 88, 40, 0.55));
  --glass: linear-gradient(160deg, rgba(40, 48, 112, 0.6), rgba(14, 18, 52, 0.7));
}

/* Team colors, after the Okabe–Ito palette (blue against orange reads with common color blindness).
   Kept in step with TEAMS in board3d.ts. */
.team-0 {
  --c: #4aa8f0;
  --c-light: #d4ecff;
  --c-deep: #1d6aa1;
}

.team-1 {
  --c: #f5891f;
  --c-light: #ffe0bd;
  --c-deep: #ad5808;
}

.team-2 {
  --c: #d67fb0;
  --c-light: #ffdcef;
  --c-deep: #8e3a6b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

/* Read aloud and reachable by keyboard, but not drawn. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

html {
  background: var(--night);
}

html,
body {
  margin: 0;
  color: var(--text);
  font: 500 16px/1.45 var(--ui);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

body.at-table {
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

main {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

h1 {
  margin: 0;
  font: 700 1.95rem/1.1 var(--display);
  letter-spacing: 0.01em;
  color: var(--ivory);
  text-shadow: 0 0 18px rgba(255, 196, 100, 0.45);
}

h2 {
  margin: 0 0 8px;
  font: 600 1.15rem/1.25 var(--display);
  letter-spacing: 0.02em;
  color: var(--ivory);
}

p {
  margin: 0;
}

/* ---------- The sky ---------- */

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  /* Shown until the painting loads. */
  background: linear-gradient(180deg, #0a0f33 0%, #1d1a55 55%, #2b2766 62%, #0b1030 100%);
}

/*
 * The painting, sized to cover the screen at its own shape (--ar is its
 * width over height), so overlays placed in percent stay on their spot.
 * Upright screens see a slice of it, centered on --fx (the moon).
 */
.backdrop {
  --ar: 1.75;
  --fx: 0.5;
  --cover-w: max(100vw, calc(100vh * var(--ar)));
  --cover-h: max(100vh, calc(100vw / var(--ar)));
  position: absolute;
  width: var(--cover-w);
  height: var(--cover-h);
  left: clamp(calc(100vw - var(--cover-w)), calc(50vw - var(--fx) * var(--cover-w)), 0px);
  top: calc((100vh - var(--cover-h)) / 2);
}

/* The painting itself never moves: only the light, mist, petals and lanterns over it do. */
@media (max-aspect-ratio: 1/1) {
  .backdrop {
    --fx: 0.6;
  }
}

.backdrop .painting {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.backdrop > span {
  position: absolute;
  left: var(--x);
  top: var(--y);
}

.moonglow {
  width: 9%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(235, 238, 255, 0.45) 0%, rgba(200, 205, 255, 0.15) 35%, transparent 68%);
  animation: moonglow 9s ease-in-out infinite;
}

@keyframes moonglow {
  50% {
    opacity: 0.6;
    transform: translate(-50%, -50%) scale(1.08);
  }
}

/* Lantern light in the painting, flickering. */
.flicker {
  width: var(--s);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 200, 120, 0.55) 0%, rgba(255, 160, 80, 0.2) 35%, transparent 70%);
  animation: flicker var(--dur) ease-in-out var(--delay) infinite;
}

@keyframes flicker {
  0%,
  100% {
    opacity: 0.75;
  }
  20% {
    opacity: 1;
  }
  35% {
    opacity: 0.55;
  }
  55% {
    opacity: 0.95;
  }
  70% {
    opacity: 0.7;
  }
}

.backdrop .star {
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
  animation: twinkle var(--dur) ease-in-out var(--delay) infinite;
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.15;
  }
  50% {
    opacity: 1;
  }
}

/* Light glinting on the water. */
.glint {
  width: var(--w);
  height: 2px;
  border-radius: 2px;
  opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(235, 225, 255, 0.9), transparent);
  animation: glint var(--dur) ease-in-out var(--delay) infinite;
}

.glint.warm {
  background: linear-gradient(90deg, transparent, rgba(255, 196, 120, 0.95), transparent);
}

.glint.faint {
  --peak: 0.4;
}

@keyframes glint {
  0%,
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scaleX(0.6);
  }
  50% {
    opacity: var(--peak, 0.85);
    transform: translate(calc(-50% + var(--shift, 6px)), -50%) scaleX(1);
  }
}

/* Mist drifting along the far shore. */
.mist {
  width: 90%;
  height: 10%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(190, 180, 235, 0.22), transparent 70%);
  animation: mist 60s ease-in-out infinite alternate;
}

.mist.later {
  width: 80%;
  animation-duration: 75s;
  animation-direction: alternate-reverse;
}

@keyframes mist {
  to {
    transform: translateX(25%);
  }
}

/* Blossom petals falling from the top corners, turning as they go. */
.petals {
  position: absolute;
  inset: 0;
}

.petal {
  position: absolute;
  left: var(--x);
  top: -4%;
  width: var(--size);
  height: calc(var(--size) * 0.75);
  opacity: 0;
  animation: fall var(--fall) linear var(--delay) infinite;
}

.petal::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 0 100% 0 100%;
  background: linear-gradient(135deg, #ffe3ee, #f49cc0);
  animation: flutter var(--spin) ease-in-out infinite;
}

@keyframes fall {
  0% {
    opacity: 0;
    transform: translate(0, 0);
  }
  6% {
    opacity: 0.9;
  }
  50% {
    transform: translate(calc(var(--drift) * 0.5), 55vh);
  }
  90% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translate(var(--drift), 112vh);
  }
}

@keyframes flutter {
  0% {
    transform: rotate(0deg) rotateX(0deg);
  }
  50% {
    transform: rotate(180deg) rotateX(65deg);
  }
  100% {
    transform: rotate(360deg) rotateX(0deg);
  }
}

/* ---------- Shared controls ---------- */

/* Buttons are dark glass with a brass rim; they press in under a finger. */
:where(button) {
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(44, 52, 116, 0.74), rgba(18, 22, 60, 0.82)) padding-box,
    var(--rim) border-box;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 12px rgba(0, 0, 0, 0.25);
  transition:
    transform 120ms ease,
    filter 150ms ease,
    box-shadow 150ms ease;
}

:where(button:hover) {
  filter: brightness(1.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 14px rgba(246, 210, 140, 0.2),
    0 4px 12px rgba(0, 0, 0, 0.25);
}

:where(button:active) {
  transform: scale(0.97);
  filter: brightness(0.92);
}

:where(button, summary, input):focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* The main button on a screen is polished brass, lettered dark. */
button.primary {
  color: #2a1a04;
  background:
    linear-gradient(180deg, #fbe7b3 0%, #f0c56f 42%, #d6a048 58%, #e9b960 100%) padding-box,
    linear-gradient(180deg, #fff3cf, #8a6227) border-box;
  text-shadow: 0 1px 0 rgba(255, 244, 214, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    inset 0 -2px 5px rgba(120, 74, 20, 0.35),
    0 0 18px rgba(255, 186, 72, 0.3),
    0 4px 12px rgba(0, 0, 0, 0.3);
}

button.primary:hover {
  filter: brightness(1.06);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

button.link {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0 4px;
  min-height: 0;
  font-weight: 500;
  color: var(--muted);
  justify-self: start;
}

button.link:hover {
  color: var(--text);
  box-shadow: none;
}

input {
  font: inherit;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(201, 154, 82, 0.42);
  background: rgba(6, 9, 30, 0.6);
  color: var(--text);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
}

input:focus {
  border-color: rgba(248, 226, 170, 0.85);
}

.card,
.glass {
  background:
    var(--glass) padding-box,
    var(--rim) border-box;
  border: 1px solid transparent;
  border-radius: 18px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 30px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
}

.card {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.top .me {
  display: flex;
  align-items: center;
  gap: 10px;
}

.muted,
.hint {
  color: var(--muted);
}

.error {
  color: var(--red);
}

.error:empty {
  display: none;
}

.eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.icon {
  display: inline-block;
}

.spark-icon {
  fill: currentColor;
}

.gust-icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Home, sign-up and joining ---------- */

.join input {
  flex: 1;
  min-width: 0;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 600;
}

.join input::placeholder {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}

.code {
  font: 800 2rem/1 var(--rounded);
  letter-spacing: 0.2em;
  user-select: all;
}

.wordmark {
  font-size: 2.3rem;
}

/* Sign-up: a lantern, the name, and one question. */
.welcome {
  margin-top: max(10vh, 32px);
  justify-items: center;
  gap: 12px;
  padding: 30px 22px 18px;
  text-align: center;
}

.welcome .wordmark {
  font-size: 2.8rem;
}

.welcome-lantern {
  height: 84px;
  display: grid;
  place-items: end center;
}

.welcome-lantern .lantern.mini {
  --w: 50px;
}

.welcome-lantern .lantern.mini .halo {
  width: 300%;
}

.tagline {
  margin: -4px 0 10px;
  color: var(--muted);
}

.welcome label {
  font-weight: 700;
}

.welcome input,
.welcome .primary {
  width: 100%;
}

.welcome .link {
  justify-self: center;
}

.invited {
  margin: -6px 0 2px;
  color: var(--gold);
  font-weight: 700;
}

/* On an iPhone in the browser: three numbered steps to the Home Screen, and the invite code to bring along. */
.install {
  margin-top: max(3vh, 12px);
}

.install h2 {
  font-size: 1.2rem;
  line-height: 1.3;
  color: var(--ivory);
}

.install > .muted {
  margin: -4px 0 4px;
}

.install-steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  width: 100%;
  display: grid;
  gap: 12px;
  text-align: left;
}

.install-steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  column-gap: 12px;
  align-items: center;
}

.install-steps li::before {
  content: counter(step);
  grid-row: span 2;
  align-self: start;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #2a1a04;
  background: linear-gradient(180deg, #fbe7b3, #e2ae55);
  box-shadow: 0 0 12px rgba(255, 186, 72, 0.3);
}

.install-steps .line-icon {
  width: 20px;
  height: 20px;
  vertical-align: -4px;
  color: var(--gold);
}

.install-steps small {
  color: var(--muted);
  font-size: 0.8rem;
}

.install-code {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px 12px 12px;
  border-radius: 14px;
  background: rgba(6, 9, 30, 0.45);
  border: 1px solid rgba(201, 154, 82, 0.35);
}

.install .note {
  margin-top: 2px;
}

/* No games yet: the invite-code field leads, since most first games are someone else's invite. */
.first-game {
  display: grid;
  gap: 10px;
}

.join-inline {
  display: grid;
  gap: 6px;
}

.top .me .avatar {
  width: 30px;
  height: 30px;
  font-size: 0.85rem;
}

.me-name {
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  color: var(--ivory);
}

/* "Your turn" alerts: a slim nudge while they're off; nothing once they're on. */
.push-box:empty {
  display: none;
}

.push-box.nudge {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 14px;
  padding: 12px 14px 12px 16px;
  border-radius: 16px;
  background:
    linear-gradient(160deg, rgba(64, 52, 40, 0.55), rgba(24, 22, 52, 0.7)) padding-box,
    var(--rim) border-box;
  border: 1px solid transparent;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.push-box.nudge > :not(.nudge-text, button) {
  grid-column: 1 / -1;
}

.push-box.nudge .hint:empty {
  display: none;
}

.nudge-text {
  display: grid;
  gap: 2px;
}

.nudge-text small {
  color: var(--muted);
  font-size: 0.8rem;
}

.push-box.nudge button.primary {
  min-height: 38px;
  padding: 6px 16px;
}

.home-section {
  display: grid;
  gap: 2px;
}

.games {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.games-note {
  padding: 14px 16px;
  font-size: 0.92rem;
}

/* A game: who's in it, and whose turn. The ones waiting on you glow. */
.game-card {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  text-align: left;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.game-card.yours {
  background:
    linear-gradient(160deg, rgba(74, 62, 64, 0.8), rgba(28, 26, 64, 0.86)) padding-box,
    linear-gradient(150deg, rgba(255, 232, 170, 0.95), rgba(214, 160, 72, 0.55) 45%, rgba(150, 104, 40, 0.8)) border-box;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 26px rgba(255, 186, 80, 0.22),
    0 6px 16px rgba(0, 0, 0, 0.3);
}

.game-card.over {
  opacity: 0.72;
}

.faces {
  display: flex;
  align-items: center;
}

.faces .avatar {
  width: 36px;
  height: 36px;
  font-size: 0.95rem;
}

.faces .avatar + .avatar {
  margin-left: -7px;
}

.game-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.game-text b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-text small {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.game-status {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
}

.game-status.yours {
  color: #2a1a04;
  background: linear-gradient(180deg, #fbe7b3 0%, #f0c56f 45%, #d9a24a 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 0 14px rgba(255, 190, 80, 0.45);
  animation: your-turn-glow 2.6s ease-in-out infinite;
}

.game-status.waiting {
  letter-spacing: 0.14em;
  color: var(--ivory);
}

.faces .avatar.open {
  color: var(--muted);
  background: #232857;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

@keyframes your-turn-glow {
  50% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.6),
      0 0 22px rgba(255, 196, 90, 0.75);
  }
}

/* Starting a game: each way to play, pictured as its lanterns. */
.start {
  gap: 4px;
}

.start h2 {
  margin: 0;
}

.modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.mode {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 3px;
  padding: 12px 6px 10px;
  border-radius: 14px;
}

.mode b {
  font-size: 1rem;
}

.mode small {
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--muted);
  text-align: center;
}

.mode-lanterns {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 30px;
  margin-bottom: 4px;
}

.mode-lanterns .lantern.mini {
  --w: 14px;
}

.mode-lanterns.n4 .lantern:nth-child(2) {
  margin-right: 8px;
}

.practice-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  text-align: left;
}

.practice-card .avatar {
  width: 40px;
  height: 40px;
  font-size: 1.05rem;
}

.practice-text {
  display: grid;
  gap: 2px;
}

.practice-text small {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
}

.link.how {
  justify-self: center;
  margin: 2px 0 8px;
}

/* ---------- Family: everyone you've played with, and your record together ---------- */

/* A relative's face: warm paper and brass, not a team color (teams change from game to game). */
.avatar.kin {
  --c: #e8c98a;
  --c-light: #fff3d6;
  --c-deep: #9c7434;
}

.kin-card {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 16px;
  text-align: left;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.kin-card .avatar {
  width: 36px;
  height: 36px;
  font-size: 0.95rem;
}

.kin-card .chevron {
  color: var(--muted);
  font-size: 1.4rem;
}

/* Your last few results together, oldest to newest: a lit lantern for a win, a dark one for a loss, half for a draw. */
.recent {
  display: flex;
  align-items: center;
  gap: 5px;
}

.recent .mark {
  width: 9px;
  height: 12px;
  border-radius: 45% 45% 40% 40%;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(201, 154, 82, 0.5);
}

.recent .mark.won {
  background: radial-gradient(circle at 50% 60%, #fff4cf, #ffc04a 55%, #d9861c);
  box-shadow:
    inset 0 0 0 1px rgba(255, 236, 190, 0.6),
    0 0 8px rgba(255, 184, 74, 0.7);
}

.recent .mark.draw {
  background: linear-gradient(90deg, #f3c160 50%, rgba(255, 255, 255, 0.1) 50%);
}

/* A record as a scoreboard: "You 3 – 2 Grandma", the numbers large. */
.score {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 4px 10px;
}

.score .side {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.score .who {
  font-weight: 700;
  color: var(--text);
}

.score b {
  font: 700 1.7rem/1 var(--display);
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 196, 84, 0.4);
}

.score .dash,
.score .sep {
  color: var(--muted);
}

.score .draws {
  flex-basis: 100%;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.banner-score {
  margin: 2px 0 4px;
}

.banner-score .score b {
  font-size: 1.45rem;
}

.kin-record {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 14px 12px 12px;
  border-radius: 18px;
  text-align: center;
  background: rgba(6, 9, 30, 0.35);
  box-shadow: inset 0 0 0 1px rgba(201, 154, 82, 0.25);
}

.kin-record .score b {
  font-size: 2.3rem;
}

.kin-record .recent .mark {
  width: 12px;
  height: 16px;
}

.recent-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.recent-row small {
  font-size: 0.76rem;
  letter-spacing: 0.04em;
}

.more-games {
  justify-self: center;
  width: 100%;
  min-height: 40px;
  font-size: 0.88rem;
}

.kin-record p {
  margin: 0;
  font-size: 0.88rem;
}

.kin-sheet .modes {
  margin-top: 6px;
}

.kin-sheet .mode {
  padding: 12px 6px;
}

.kin-sheet > .sheet-body > .link {
  justify-self: center;
}

/* Who's playing a new game: family, each with a toggle (in 2 v 2, partner or opponent). */
.pick-lead {
  margin: 0;
}

.pick-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.pick {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.pick:last-child {
  border-bottom: 0;
}

.pick .avatar {
  width: 34px;
  height: 34px;
}

.chips {
  display: flex;
  gap: 6px;
}

button.chip {
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
}

button.chip.on {
  color: #2a1a04;
  background:
    linear-gradient(180deg, #fbe7b3 0%, #f0c56f 45%, #d9a24a 100%) padding-box,
    linear-gradient(180deg, #fff3cf, #8a6227) border-box;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 0 12px rgba(255, 190, 80, 0.35);
}

.pick-foot {
  display: grid;
  gap: 10px;
  position: sticky;
  bottom: 0;
  padding-top: 12px;
  border-top: 1px solid rgba(201, 154, 82, 0.25);
}

.pick-summary {
  display: grid;
  gap: 2px;
  margin: 0;
}

.pick-summary small {
  color: var(--muted);
  font-size: 0.82rem;
}

/* ---------- The game table ---------- */

/* Upright phones: players across the top, the board, then the hand along the bottom. */
main.table {
  --tilt: 22deg;
  /* Where the board sits in its space: 0 top, 1 bottom. Upright, it sits low, near the hand. */
  --board-align: 0.82;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "side" "stage" "prompt" "hand";
}

.table > .side {
  grid-area: side;
}

.table > .stage {
  grid-area: stage;
}

.table > .prompt {
  grid-area: prompt;
}

.table > .hand-panel {
  grid-area: hand;
}

.side {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 0;
}

.side .topbar {
  display: contents;
}

.side .back {
  order: 0;
}

.side .seats {
  order: 1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
}

.side .menu {
  order: 3;
}

/* Online games add the reactions button beside the menu. */
.side.social {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

.side .react {
  order: 2;
}

/* Over the board, so a reaction's bubble can spill onto it. */
.side {
  position: relative;
  z-index: 30;
}

.round {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 999px;
  font-size: 1.4rem;
  line-height: 1;
}

.line-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-icon.menu {
  stroke-width: 3.2;
}

.seat {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 14px;
  background:
    var(--glass) padding-box,
    var(--rim) border-box;
  border: 1px solid transparent;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  transition: box-shadow 300ms ease;
}

/* Whose turn it is: the rim takes their team's light. */
.seat.active {
  background:
    var(--glass) padding-box,
    linear-gradient(150deg, color-mix(in srgb, var(--c) 75%, white), color-mix(in srgb, var(--c) 45%, transparent)) border-box;
  box-shadow:
    0 0 22px color-mix(in srgb, var(--c) 45%, transparent),
    0 6px 18px rgba(0, 0, 0, 0.3);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 900 0.95rem/1 var(--rounded);
  color: #0b1030;
  background: radial-gradient(circle at 35% 30%, var(--c-light), var(--c) 62%, var(--c-deep));
  /* A brass ring, like the lanterns'. */
  box-shadow:
    0 0 0 2px #d9b46a,
    0 0 0 3px rgba(80, 56, 20, 0.6),
    0 0 14px color-mix(in srgb, var(--c) 55%, transparent);
}

/* Team shapes (Settings): a badge on each avatar and lantern, for telling teams apart without color. */
.team-shape {
  display: none;
}

.avatar {
  position: relative;
}

.shapes .avatar .team-shape {
  display: block;
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 15px;
  height: 15px;
  fill: #fff4dc;
  stroke: rgba(10, 13, 38, 0.95);
  stroke-width: 2.6;
  stroke-linejoin: round;
  paint-order: stroke;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}

.shape-badge {
  display: none;
}

.shapes .lantern .shape-badge {
  display: block;
  position: absolute;
  right: -34%;
  bottom: 4%;
  width: 52%;
  aspect-ratio: 1;
}

.shapes .lantern .shape-badge .team-shape {
  display: block;
  width: 100%;
  height: 100%;
  fill: #fff4dc;
  stroke: rgba(10, 13, 38, 0.95);
  stroke-width: 2.6;
  stroke-linejoin: round;
  paint-order: stroke;
}

.seat.open .avatar {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.who {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.who b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
}

.who .detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--muted);
}

.who .detail:empty {
  display: none;
}

.pill {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--ivory);
  background: rgba(201, 154, 82, 0.16);
  border: 1px solid rgba(248, 226, 170, 0.42);
}

.pill::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 8px var(--c);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

@keyframes pulse-dot {
  50% {
    opacity: 0.35;
  }
}

.seat .lantern.mini {
  display: none;
}

/* Wide screens and sideways phones: players on the left, the hand on the right. */
@media (min-aspect-ratio: 4/3) {
  main.table {
    --tilt: 34deg;
    --board-align: 0.5;
    /* The prompt sits over the bottom of the stage; boards keep this much clear. */
    --board-bottom: 54px;
    column-gap: 14px;
    grid-template-columns: clamp(150px, 21vw, 270px) minmax(0, 1fr) clamp(128px, 17vw, 230px);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "side stage hand";
  }

  /* Over the stage, in one row, so the board never resizes when buttons come and go. */
  .table > .prompt {
    grid-area: stage;
    align-self: end;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding-bottom: 4px;
    pointer-events: none;
  }

  .table > .prompt > * {
    pointer-events: auto;
  }

  .hand-title {
    padding-right: 34px;
    white-space: nowrap;
  }

  .side {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .side .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .side .topbar .react {
    margin-left: auto;
    margin-right: 8px;
  }

  .react-body {
    right: auto;
    left: 0;
  }

  .seat .bubble {
    left: calc(100% + 12px);
    top: 50%;
    translate: 0 -50%;
    transform-origin: 0 50%;
  }

  .seat .bubble::before {
    left: -6px;
    top: 50%;
    translate: 0 -50%;
    border: 7px solid transparent;
    border-left: 0;
    border-right-color: #fff8e4;
  }

  .side .seats {
    grid-auto-flow: row;
    gap: 10px;
  }

  .seat {
    padding: 10px 12px;
    gap: 10px;
    border-radius: 16px;
  }

  .avatar {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }

  .who b {
    font-size: 1rem;
  }

  .seat .lantern.mini {
    display: inline-block;
  }

  .table .hand-panel {
    height: auto;
  }

  .table .hand-title {
    display: flex;
  }
}

/* Big screens: the panels grow with the window, so they don't shrink to a corner. */
@media (min-aspect-ratio: 4/3) and (min-height: 720px) {
  main.table {
    --board-bottom: 68px;
    column-gap: 22px;
    padding: 18px 22px;
    grid-template-columns: clamp(230px, 18vw, 360px) minmax(0, 1fr) clamp(210px, 14vw, 300px);
  }

  .side,
  .side .seats {
    gap: 14px;
  }

  .seat {
    padding: 14px 16px;
    gap: 14px;
    border-radius: 20px;
  }

  .avatar {
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
  }

  .who b {
    font-size: 1.25rem;
  }

  .who .detail,
  .pill {
    font-size: 0.95rem;
  }

  .seat .lantern.mini {
    --w: 22px;
  }

  .round,
  .menu summary {
    min-width: 48px;
    min-height: 48px;
  }

  .table .hand-title {
    font-size: 1.15rem;
  }

  .prompt-text {
    padding: 10px 22px;
    font-size: 1.1rem;
  }
}

@media (min-aspect-ratio: 4/3) and (max-height: 480px) {
  .side,
  .side .seats {
    gap: 6px;
  }

  .seat {
    padding: 6px 8px;
  }

  .avatar {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
  }
}

.menu {
  position: relative;
}

.menu summary {
  list-style: none;
  display: grid;
  place-items: center;
  min-width: 40px;
  min-height: 40px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.2rem;
  background:
    linear-gradient(180deg, rgba(44, 52, 116, 0.74), rgba(18, 22, 60, 0.82)) padding-box,
    var(--rim) border-box;
  border: 1px solid transparent;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition:
    transform 120ms ease,
    filter 150ms ease;
}

.menu summary:hover {
  filter: brightness(1.14);
}

.menu summary:active {
  transform: scale(0.95);
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu-body {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  gap: 6px;
  padding: 8px;
  min-width: 180px;
}

.menu-body button {
  text-align: left;
}

/* The gear on the home screen. */
.round.settings {
  width: 40px;
}

/* ---------- Reactions and nudges ---------- */

.react-body {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  right: 0;
  width: max-content;
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 6px;
  padding: 8px;
}

.react-body button {
  min-height: 38px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
}

.line-icon.chat {
  stroke-width: 1.9;
}

/* Someone else with the game open right now: a small green light on their avatar. */
.seat.here .avatar::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #5fe08a;
  box-shadow:
    0 0 0 2px #0e1236,
    0 0 8px rgba(95, 224, 138, 0.9);
}

/* A reaction: a paper speech bubble under its seat (beside it when sideways), for a few seconds. */
.seat .bubble {
  position: absolute;
  z-index: 70;
  left: 50%;
  top: calc(100% + 10px);
  width: max-content;
  max-width: 170px;
  padding: 7px 13px;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 800;
  color: #2a1a04;
  background: linear-gradient(180deg, #fff8e4, #f4e0b2);
  box-shadow:
    0 0 0 1px rgba(150, 110, 50, 0.45),
    0 0 20px rgba(255, 200, 110, 0.35),
    0 8px 18px rgba(0, 0, 0, 0.45);
  translate: -50% 0;
  transform-origin: 50% 0;
  pointer-events: none;
  animation: bubble-life 3.8s ease-out var(--age, 0ms) both;
}

.seat .bubble::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -6px;
  translate: -50% 0;
  border: 7px solid transparent;
  border-top: 0;
  border-bottom-color: #fff8e4;
}

@keyframes bubble-life {
  0% {
    opacity: 0;
    scale: 0.6;
  }
  7% {
    opacity: 1;
    scale: 1.07;
  }
  12% {
    scale: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes bubble-calm {
  0%,
  100% {
    opacity: 0;
  }
  6%,
  85% {
    opacity: 1;
  }
}

.prompt-buttons .nudge {
  min-height: 36px;
  padding: 6px 16px;
}

/* ---------- The board ---------- */

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
}

.scene {
  perspective: calc(var(--tile, 30px) * 22);
  transform: translateY(var(--shift, 0px));
}

.plane {
  display: grid;
  grid-template-columns: repeat(10, var(--tile, 30px));
  grid-auto-rows: var(--tile, 30px);
  gap: calc(var(--tile, 30px) * 0.13);
  padding: calc(var(--tile, 30px) * 0.18);
  border-radius: calc(var(--tile, 30px) * 0.34);
  transform: rotateX(var(--tilt));
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.12), rgba(160, 170, 255, 0.05));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.14),
    0 calc(var(--tile, 30px) * 0.5) calc(var(--tile, 30px) * 1.4) rgba(0, 0, 0, 0.5);
}

.plane.waiting {
  opacity: 0.45;
}

/* The 3D board fills the stage; the overlays sit on top of it. */
.stage canvas.board3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
  transition: opacity 300ms ease;
}

.tile {
  position: relative;
  width: var(--tile, 30px);
  height: var(--tile, 30px);
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: calc(var(--tile, 30px) * 0.18);
  display: grid;
  place-items: center;
  color: var(--ink);
  cursor: pointer;
  /* A thick block of frosted glass: lit top face, a solid edge below, a soft shadow. */
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.97) 0%, rgba(238, 242, 253, 0.9) 45%, rgba(212, 220, 245, 0.84) 100%);
  box-shadow:
    inset 0 calc(var(--tile, 30px) * 0.03) 0 #ffffff,
    inset 0 0 0 calc(var(--tile, 30px) * 0.015) rgba(255, 255, 255, 0.55),
    inset 0 calc(var(--tile, 30px) * -0.06) calc(var(--tile, 30px) * 0.1) rgba(118, 132, 198, 0.28),
    0 calc(var(--tile, 30px) * 0.11) 0 rgba(170, 182, 230, 0.92),
    0 calc(var(--tile, 30px) * 0.2) calc(var(--tile, 30px) * 0.22) rgba(3, 5, 24, 0.55);
  transition: opacity 200ms ease;
}

/* A lit tile glows in its team's color; a new one lights as its lantern touches down. */
.tile .glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    circle at 50% 30%,
    #ffffff 0%,
    color-mix(in srgb, var(--c-light, #ffffff) 88%, white) 40%,
    color-mix(in srgb, var(--c, #ffffff) 45%, white) 100%
  );
  box-shadow:
    inset 0 0 calc(var(--tile, 30px) * 0.25) color-mix(in srgb, var(--c, #ffffff) 40%, transparent),
    0 0 calc(var(--tile, 30px) * 0.7) color-mix(in srgb, var(--c, #ffffff) 60%, transparent);
}

.tile.lit .glow {
  opacity: 1;
}

.tile.landing .glow {
  animation: tile-land 900ms ease-out var(--land, 0ms) both;
}

@keyframes tile-land {
  0% {
    opacity: 0;
  }
  35%,
  100% {
    opacity: 1;
  }
}

/* "7♥" on one line, as big as the tile allows. */
.tile .face {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--tile, 30px) * 0.01);
  pointer-events: none;
}

.tile .face b {
  font: 800 calc(var(--tile, 30px) * 0.37) / 1 var(--rounded);
  letter-spacing: -0.05em;
}

.tile .face i {
  font-style: normal;
  font-size: calc(var(--tile, 30px) * 0.34);
  line-height: 1;
}

.tile.red {
  color: var(--ink-red);
}

/* Free corners glow gold: they count for everyone. */
.tile.corner {
  background: radial-gradient(circle at 50% 42%, #fffdf2 0%, #ffeab4 48%, #f7c55e 100%);
  box-shadow:
    inset 0 calc(var(--tile, 30px) * 0.03) 0 #ffffff,
    inset 0 calc(var(--tile, 30px) * -0.06) calc(var(--tile, 30px) * 0.1) rgba(200, 130, 20, 0.35),
    0 calc(var(--tile, 30px) * 0.11) 0 #d9a441,
    0 0 calc(var(--tile, 30px) * 0.8) rgba(255, 196, 84, 0.75);
}

.tile .face .star {
  font-size: calc(var(--tile, 30px) * 0.62);
  color: #ffb81c;
  text-shadow:
    0 0 calc(var(--tile, 30px) * 0.18) rgba(255, 236, 160, 0.95),
    0 calc(var(--tile, 30px) * 0.02) 0 #c97f00;
}

/* The latest move: a ring that stays until the next one. */
.tile.last::before {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: inherit;
  box-shadow: 0 0 0 calc(var(--tile, 30px) * 0.035) color-mix(in srgb, var(--c, #ffffff) 75%, white);
  pointer-events: none;
}

/* Where the chosen card can go, the five a choice would light, and the tile waiting on the player. */
.tile.target::after,
.tile.chosen::after,
.tile.pending::after {
  content: "";
  position: absolute;
  inset: calc(var(--tile, 30px) * -0.05);
  border-radius: calc(var(--tile, 30px) * 0.21);
  pointer-events: none;
}

.tile.target::after {
  box-shadow:
    0 0 0 calc(var(--tile, 30px) * 0.05) var(--gold),
    0 0 calc(var(--tile, 30px) * 0.45) calc(var(--tile, 30px) * 0.06) rgba(255, 196, 84, 0.85);
  animation: target-glow 1.5s ease-in-out infinite;
}

.plane.many .tile.target::after {
  animation: none;
  box-shadow: 0 0 0 calc(var(--tile, 30px) * 0.04) rgba(255, 207, 107, 0.9);
}

.tile.chosen::after {
  animation: none;
  box-shadow:
    0 0 0 calc(var(--tile, 30px) * 0.05) #fff6d8,
    0 0 calc(var(--tile, 30px) * 0.45) rgba(255, 236, 170, 0.85);
}

.tile.pending::after {
  box-shadow:
    0 0 0 calc(var(--tile, 30px) * 0.06) #ffffff,
    0 0 calc(var(--tile, 30px) * 0.5) rgba(255, 255, 255, 0.85);
}

.plane.choosing .tile:not(.target, .pending, .corner, .chosen) {
  opacity: 0.62;
}

/* While choosing where to play, lanterns fade so every tile shows. */
.lanterns.choosing .lantern:not(.target, .preview, .igniting, .out, .chosen) {
  opacity: 0.35;
}

/* A tile where the player's Spark would finish a string or stop one. */
.tile.spot::after {
  content: "✦";
  position: absolute;
  inset: calc(var(--tile, 30px) * -0.05);
  display: grid;
  place-items: start end;
  padding: 0 calc(var(--tile, 30px) * 0.06);
  border-radius: calc(var(--tile, 30px) * 0.21);
  font-size: calc(var(--tile, 30px) * 0.3);
  line-height: 1.2;
  color: #fff6d8;
  text-shadow: 0 0 calc(var(--tile, 30px) * 0.12) #ffc040;
  pointer-events: none;
  box-shadow:
    0 0 0 calc(var(--tile, 30px) * 0.05) #fff0b8,
    0 0 calc(var(--tile, 30px) * 0.45) rgba(255, 220, 140, 0.9);
  animation: target-glow 1.1s ease-in-out infinite;
}

/* A Gust's best targets: lanterns in an opponent's row of four. */
.lantern.threat .paper {
  outline-color: #ff7a50;
  animation: target-glow 0.9s ease-in-out infinite;
}

/* A Spark in hand with a key tile waiting. */
.pcard.spark.keyed {
  box-shadow:
    0 0 0 2px #fff0b8,
    0 0 20px 4px rgba(255, 214, 120, 0.6),
    0 10px 18px rgba(0, 0, 0, 0.3);
  animation: keyed 1.4s ease-in-out infinite;
}

.pcard.spark.keyed.selected {
  animation: none;
}

@keyframes keyed {
  50% {
    box-shadow:
      0 0 0 2px #fff0b8,
      0 0 30px 8px rgba(255, 214, 120, 0.85),
      0 10px 18px rgba(0, 0, 0, 0.3);
  }
}

/* At the start of a turn, a soft glow on every tile a card in hand can light. */
.tile.hint::after {
  content: "";
  position: absolute;
  inset: calc(var(--tile, 30px) * -0.04);
  border-radius: calc(var(--tile, 30px) * 0.21);
  pointer-events: none;
  box-shadow:
    0 0 0 calc(var(--tile, 30px) * 0.03) rgba(255, 217, 138, 0.75),
    0 0 calc(var(--tile, 30px) * 0.3) rgba(255, 196, 84, 0.45);
  animation: target-glow 2.4s ease-in-out infinite;
}

.lantern {
  transition: opacity 200ms ease;
}

@keyframes target-glow {
  50% {
    opacity: 0.55;
  }
}

/* ---------- Lanterns ---------- */

.lanterns {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Anchored at its bottom center, (--x, --y); --w is its width. */
.lantern {
  position: absolute;
  left: var(--x, 0px);
  top: var(--y, 0px);
  width: var(--w, 20px);
  height: calc(var(--w, 20px) * 1.45);
  margin: calc(var(--w, 20px) * -1.45) 0 0 calc(var(--w, 20px) * -0.5);
  pointer-events: none;
}

.lanterns.gusting .lantern.target {
  pointer-events: auto;
  cursor: pointer;
}

.lantern .halo {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 320%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--c) 42%, transparent) 0%,
    color-mix(in srgb, var(--c) 16%, transparent) 34%,
    transparent 66%
  );
  animation: halo 3.4s ease-in-out var(--phase, 0s) infinite;
}

.lantern .rig {
  position: absolute;
  inset: 0;
  animation: bob 4.8s ease-in-out var(--phase, 0s) infinite;
}

.lantern .hook {
  position: absolute;
  top: 0;
  left: 50%;
  width: 22%;
  height: 10%;
  transform: translateX(-50%);
  border: calc(var(--w, 20px) * 0.035) solid #4a3720;
  border-bottom: 0;
  border-radius: 50% 50% 0 0;
}

.lantern .paper {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 14%;
  bottom: 13%;
  overflow: hidden;
  border-radius: 48% / 30%;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.3) 0%, transparent 24%, rgba(255, 255, 255, 0.18) 42%, transparent 60%, rgba(0, 0, 0, 0.3) 100%),
    repeating-linear-gradient(180deg, transparent 0 14%, rgba(0, 0, 0, 0.12) 14% 16%),
    radial-gradient(ellipse 62% 58% at 50% 52%, #fffdf2 0%, var(--c-light) 28%, var(--c) 70%, var(--c-deep) 100%);
  box-shadow: 0 0 calc(var(--w, 20px) * 0.4) calc(var(--w, 20px) * 0.06) color-mix(in srgb, var(--c) 70%, transparent);
}

/* Dark paper, shown while the lantern lights up or goes out. */
.lantern .paper::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #3a3f5e, #1a1e36);
  opacity: 0;
}

.lantern .cap {
  position: absolute;
  left: 22%;
  right: 22%;
  height: 10%;
  border-radius: calc(var(--w, 20px) * 0.06);
  background: linear-gradient(180deg, #7a5d3b, #2f2113);
}

.lantern .cap.top {
  top: 8%;
}

.lantern .cap.bottom {
  bottom: 7%;
}

.lantern .tassel {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 7%;
  height: 9%;
  transform: translateX(-50%);
  border-radius: 0 0 40% 40%;
  background: linear-gradient(var(--c-deep), color-mix(in srgb, var(--c-deep) 60%, black));
}

.lantern.mini {
  --w: 16px;
  position: relative;
  left: auto;
  top: auto;
  margin: 0;
  display: inline-block;
  flex: none;
  vertical-align: middle;
}

.lantern.mini .halo {
  width: 220%;
}

/* The menus' lanterns: a render of the board's own temple lantern (art/ui/renders.py), its halo behind
   the lit windows. */
.lantern .lantern-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

/* Behind dark bronze, the halo has to carry the light: stronger than the paper lantern's, centred on the windows. */
.lantern.art .halo {
  top: 62%;
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--c) 60%, transparent) 0%,
    color-mix(in srgb, var(--c) 24%, transparent) 36%,
    transparent 66%
  );
}

.lantern.strung .halo {
  width: 380%;
}

/* Gust: lanterns that can be blown out, and the one about to be. */
.lantern.target .paper {
  outline: calc(var(--w, 20px) * 0.07) solid rgba(255, 255, 255, 0.9);
  outline-offset: calc(var(--w, 20px) * 0.05);
}

.lantern.pending .rig {
  animation: shiver 0.45s ease-in-out infinite;
}

/* Spark: a pale lantern where it would go. */
.lantern.preview {
  opacity: 0.6;
}

.lantern.preview .halo {
  animation-duration: 1s;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6%);
  }
}

@keyframes halo {
  0%,
  100% {
    opacity: 0.92;
  }
  40% {
    opacity: 1;
  }
  55% {
    opacity: 0.78;
  }
  70% {
    opacity: 0.97;
  }
}

@keyframes shiver {
  25% {
    transform: rotate(7deg);
  }
  75% {
    transform: rotate(-7deg);
  }
}

/*
 * A new lantern drifts down onto its tile, swaying like it's floating; its
 * light swells as it touches down and throws a few sparks. Keep the length
 * in step with DRIFT_MS in table.ts.
 */
.lantern.igniting {
  animation: drift-down 1900ms cubic-bezier(0.25, 0.6, 0.35, 1) var(--delay, 0ms) both;
}

.lantern.igniting .halo {
  animation: halo-drift 1900ms ease-out var(--delay, 0ms) both;
}

@keyframes drift-down {
  0% {
    opacity: 0;
    transform: translate(-10%, -330%) rotate(-8deg);
  }
  14% {
    opacity: 1;
  }
  38% {
    transform: translate(9%, -190%) rotate(6deg);
  }
  62% {
    transform: translate(-5%, -85%) rotate(-4deg);
  }
  82% {
    transform: translate(2%, -6%) rotate(1.5deg);
  }
  90% {
    transform: translate(0, 2%) rotate(0deg);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes halo-drift {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }
  20% {
    opacity: 0.75;
    transform: translate(-50%, -50%) scale(0.9);
  }
  80% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1);
  }
  88% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.35);
  }
  100% {
    opacity: 0.92;
    transform: translate(-50%, -50%) scale(1);
  }
}

.lantern .spark {
  position: absolute;
  left: var(--sx);
  top: 62%;
  width: 9%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff6d0;
  box-shadow: 0 0 calc(var(--w, 20px) * 0.12) calc(var(--w, 20px) * 0.04) var(--c-light);
  opacity: 0;
  animation: spark 1100ms ease-out calc(var(--delay, 0ms) + var(--sd, 0ms)) both;
}

@keyframes spark {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(1);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(var(--w, 20px) * var(--drift, 0)), calc(var(--w, 20px) * -1.2)) scale(0.4);
  }
}

/* Blown out: the lantern lurches in the wind, goes dark and falls away in a wisp of smoke. */
.lantern.out {
  animation: blow-out 1000ms ease-in forwards;
}

.lantern.out .paper::after {
  animation: go-dark 700ms ease-in 120ms forwards;
}

.lantern.out .halo {
  animation: halo-out 600ms ease-in 80ms forwards;
}

@keyframes blow-out {
  0% {
    transform: none;
    opacity: 1;
  }
  20% {
    transform: rotate(16deg) translateX(10%);
  }
  40% {
    transform: rotate(-10deg);
  }
  60% {
    transform: rotate(5deg);
    opacity: 1;
  }
  100% {
    transform: translateY(28%) rotate(2deg) scale(0.7);
    opacity: 0;
  }
}

@keyframes go-dark {
  0% {
    opacity: 0;
  }
  30% {
    opacity: 0.7;
  }
  42% {
    opacity: 0.3;
  }
  100% {
    opacity: 1;
  }
}

@keyframes halo-out {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }
}

.lantern .smoke {
  position: absolute;
  left: 25%;
  top: -5%;
  width: 50%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(215, 222, 240, 0.55), transparent 70%);
  opacity: 0;
  animation: smoke 1400ms ease-out 350ms forwards;
}

@keyframes smoke {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.6);
  }
  30% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translateY(-150%) scale(2.4);
  }
}

/* ---------- Strings of lights ---------- */

/* Drawn over the lanterns, so a finished row reads at a glance. */
.strings {
  position: absolute;
  inset: 0;
  z-index: 40;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.strings path {
  fill: none;
}

.strings .wire {
  stroke: rgba(70, 48, 22, 0.9);
  stroke-width: calc(var(--tile, 30px) * 0.04);
}

.strings .glow,
.strings .bulbs {
  stroke-linecap: round;
  stroke-dasharray: 0 calc(var(--tile, 30px) * 0.3);
}

.strings .glow {
  stroke: rgba(255, 214, 130, 0.45);
  stroke-width: calc(var(--tile, 30px) * 0.3);
}

.strings .bulbs {
  stroke: #fff6d8;
  stroke-width: calc(var(--tile, 30px) * 0.12);
}

.string.new .wire {
  stroke-dasharray: var(--len);
  stroke-dashoffset: var(--len);
  animation: draw 900ms ease-out var(--delay, 0ms) forwards;
}

.string.new .glow,
.string.new .bulbs {
  opacity: 0;
  animation: fade-in 600ms ease-out calc(var(--delay, 0ms) + 650ms) forwards;
}

/* The five a choice would light: a dotted string that marches along. */
.string.choice .wire {
  stroke: rgba(255, 250, 235, 0.95);
  stroke-dasharray: calc(var(--tile, 30px) * 0.14) calc(var(--tile, 30px) * 0.1);
  animation: march 0.9s linear infinite;
}

.string.choice .glow {
  stroke: rgba(255, 255, 255, 0.3);
}

.string.choice .bulbs {
  opacity: 0.85;
}

@keyframes march {
  to {
    stroke-dashoffset: calc(var(--tile, 30px) * -0.48);
  }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes fade-in {
  to {
    opacity: 1;
  }
}

/* ---------- The hand ---------- */

.hand-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  /* Upright: just tall enough for seven cards side by side across the screen. */
  height: calc(min(150px, (100vw - 64px) / 7 / 0.72) + 34px);
  padding: 10px;
}

.hand-title {
  display: none;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
}

.hand-title .lantern.mini {
  --w: 14px;
}

/* The deck new cards are drawn from: two card backs and how many are left. Upright, it sits at the start of the row of cards. */
.deck {
  position: absolute;
  z-index: 2;
  left: 12px;
  bottom: 16px;
  width: 26px;
  height: 36px;
}

.hand {
  margin-left: 40px;
}

/* A card's back: midnight lacquer, a fine gold lattice, a lit lantern-moon at its heart, a gold edge. */
.deck-card {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  border: 1px solid rgba(246, 210, 130, 0.75);
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 210, 130, 0.9) 0 11%, rgba(255, 205, 120, 0.18) 12% 26%, transparent 27%),
    repeating-linear-gradient(45deg, rgba(246, 210, 130, 0.13) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(-45deg, rgba(246, 210, 130, 0.13) 0 1px, transparent 1px 5px),
    linear-gradient(160deg, #2e3274, #15183c);
  box-shadow:
    inset 0 0 0 2px #15183c,
    inset 0 0 0 3px rgba(246, 210, 130, 0.45),
    0 3px 8px rgba(0, 0, 0, 0.45);
}

.deck-card + .deck-card {
  transform: translate(-3px, -3px);
}

/* How many cards are left, on a little tag at the deck's corner. */
.deck-count {
  position: absolute;
  right: -8px;
  bottom: -7px;
  min-width: 20px;
  padding: 1px 4px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
  color: #2b1800;
  background: linear-gradient(180deg, #ffdc8f, #f2ac3a);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

@media (min-aspect-ratio: 4/3) {
  .deck {
    top: 6px;
    right: 14px;
    left: auto;
    bottom: auto;
    width: 22px;
    height: 30px;
  }

  .hand {
    margin-left: 0;
  }
}

/* A played card on its way to the board. */
.hand.flight {
  position: fixed;
  z-index: 100;
  margin: 0;
  pointer-events: none;
}

.hand.flight .pcard {
  transition: none;
}

.hand {
  grid-row: 2;
  position: relative;
  min-height: 0;
}

.suit-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

/*
 * A card: warm paper with a fine grain, a gilded line just inside its edge.
 * In a row it leans into a gentle fan (--rot); it can be dragged onto the
 * board, so the browser mustn't take the drag for a scroll.
 */
.pcard {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: var(--ch);
  min-height: 0;
  padding: 0;
  border-radius: calc(var(--cw) * 0.08);
  color: var(--ink);
  background:
    var(--paper-grain),
    radial-gradient(130% 95% at 30% 12%, #fffdf7 0%, #f8f1e1 55%, #eee1c4 100%);
  border: 1px solid rgba(110, 80, 36, 0.5);
  box-shadow:
    inset 0 0 0 calc(var(--cw) * 0.04) rgba(255, 252, 244, 0.85),
    inset 0 0 0 calc(var(--cw) * 0.04 + 1.2px) rgba(196, 152, 78, 0.65),
    0 2px 4px rgba(0, 0, 0, 0.25),
    0 10px 18px rgba(0, 0, 0, 0.3);
  transform: translate(var(--cx, 0px), var(--cy, 0px)) rotate(var(--rot, 0deg));
  transform-origin: 50% 100%;
  touch-action: none;
  transition:
    transform 240ms cubic-bezier(0.2, 0.9, 0.3, 1),
    box-shadow 240ms ease,
    opacity 200ms ease;
}

.pcard.red {
  color: #c41e3a;
}

/* Lifted off the hand by a drag: the card left behind waits, faded; the one in hand glows. */
.pcard.lifted {
  opacity: 0.3;
}

.pcard.held {
  box-shadow:
    0 0 0 2px var(--gold),
    0 0 26px 6px rgba(255, 196, 84, 0.5),
    0 18px 30px rgba(0, 0, 0, 0.5);
}

.hand.flight.dragging {
  will-change: transform;
}

.pcard .face {
  position: absolute;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.pcard .rank {
  font: 800 1em/1 var(--rounded);
  letter-spacing: -0.04em;
}

.pcard .suit {
  line-height: 1;
}

/* Stacked, in a side panel: "A ♠" across the part of each card that shows. */
.hand.stack .pcard .face {
  left: 10%;
  right: 10%;
  top: 4%;
  height: 56%;
  justify-content: space-between;
  font-size: calc(var(--ch) * 0.44);
}

/* In a row, along the bottom: the rank over the suit. */
.hand.row .pcard .face {
  inset: 6% 0;
  flex-direction: column;
  justify-content: center;
  gap: 4%;
  font-size: calc(var(--cw) * 0.42);
}

.hand.row .pcard .suit {
  font-size: 1.05em;
}

.pcard.jack .rank {
  font: 700 0.42em/1 var(--ui);
  letter-spacing: 0.02em;
}

.pcard.jack .suit .icon {
  display: block;
  width: 0.9em;
  height: 0.9em;
}

/* The Spark: a card of night sky with a gold spark glowing on it. */
.pcard.spark {
  color: #ffd27a;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 214, 130, 0.32) 0%, transparent 46%),
    radial-gradient(130% 100% at 50% 18%, #363c86 0%, #1b1e50 60%, #0f1234 100%);
  border-color: rgba(246, 210, 130, 0.85);
  box-shadow:
    inset 0 0 0 calc(var(--cw) * 0.04) rgba(20, 22, 60, 0.9),
    inset 0 0 0 calc(var(--cw) * 0.04 + 1.2px) rgba(246, 210, 130, 0.7),
    0 2px 4px rgba(0, 0, 0, 0.25),
    0 10px 18px rgba(0, 0, 0, 0.3);
}

.pcard.spark .rank {
  color: var(--ivory);
}

.pcard.spark .spark-icon {
  filter: drop-shadow(0 0 4px rgba(255, 200, 100, 0.85));
}

/* The Gust: pale silver-blue paper, the wind drawn in deep blue. */
.pcard.gust {
  color: #2c4a7d;
  background:
    var(--paper-grain),
    radial-gradient(130% 100% at 40% 15%, #f5f9ff 0%, #d9e5f7 60%, #bcd0ec 100%);
  box-shadow:
    inset 0 0 0 calc(var(--cw) * 0.04) rgba(248, 251, 255, 0.85),
    inset 0 0 0 calc(var(--cw) * 0.04 + 1.2px) rgba(120, 150, 200, 0.6),
    0 2px 4px rgba(0, 0, 0, 0.25),
    0 10px 18px rgba(0, 0, 0, 0.3);
}

/* The chosen card lifts out of the hand, stands straight, and glows gold. */
.pcard.selected {
  z-index: 30 !important;
  transform: translate(calc(var(--cx, 0px) + var(--pop-x, 0px)), calc(var(--cy, 0px) + var(--pop-y, 0px))) rotate(0deg);
  box-shadow:
    0 0 0 2px var(--gold),
    0 0 26px 6px rgba(255, 196, 84, 0.55),
    0 12px 24px rgba(0, 0, 0, 0.45);
}

.pcard.dead {
  opacity: 0.6;
}

.pcard.dead::after {
  content: "dead";
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  font: 700 calc(var(--cw) * 0.085) / 1 var(--ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #737a98;
}

.hand.stack .pcard.dead::after {
  top: 32%;
  bottom: auto;
  transform: translate(-50%, -50%);
}

.pcard.waiting {
  cursor: default;
}

/* ---------- Prompt and overlays ---------- */

.prompt {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  min-height: 40px;
  text-align: center;
}

.prompt-text {
  padding: 7px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ivory);
  background:
    linear-gradient(180deg, rgba(20, 24, 62, 0.78), rgba(10, 13, 38, 0.82)) padding-box,
    var(--rim) border-box;
  border: 1px solid transparent;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.prompt-text:empty,
.prompt-buttons:empty,
.note:empty {
  display: none;
}

/* Your turn: the prompt glows once, warm. */
.prompt-text.fresh {
  animation: prompt-glow 1.4s ease-out;
}

@keyframes prompt-glow {
  25% {
    box-shadow:
      0 0 0 1px rgba(248, 226, 170, 0.6),
      0 0 26px rgba(255, 196, 100, 0.55),
      0 6px 18px rgba(0, 0, 0, 0.3);
  }
}

.prompt-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.note {
  font-size: 0.85rem;
  color: var(--muted);
}

.recap {
  position: absolute;
  top: 4px;
  left: 50%;
  z-index: 40;
  transform: translateX(-50%);
  display: grid;
  gap: 4px;
  width: max-content;
  max-width: min(92%, 420px);
  padding: 12px 16px;
  font-size: 0.9rem;
}

.invite,
.banner {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 50;
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  gap: 8px;
  max-width: min(92%, 380px);
  padding: 18px 22px;
  text-align: center;
}

.invite .code {
  color: var(--gold);
  font-size: 2.2rem;
  letter-spacing: 0.18em;
  text-shadow: 0 0 18px rgba(255, 196, 84, 0.45);
}

.invite .row,
.banner .row {
  justify-content: center;
}

/* ---------- First-game tips ---------- */

/* A guide lantern's note, rising in once the moves have landed: upright, over
   the sky above the board; sideways, in the column under the players. */
.table > .coach {
  grid-area: stage;
  align-self: start;
  justify-self: center;
  z-index: 45;
  width: min(100%, 420px);
  margin-top: 2px;
  --rise: -12px;
}

.coach {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 12px 16px 12px 14px;
  box-shadow:
    0 0 0 1px rgba(255, 214, 140, 0.12),
    0 0 34px rgba(255, 186, 90, 0.16),
    0 14px 34px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  animation: coach-in 560ms cubic-bezier(0.2, 0.9, 0.3, 1) var(--tip-delay, 0ms) both;
}

.coach.closing {
  animation: coach-out 180ms ease-in both;
}

.coach .lantern.mini {
  --w: 22px;
  margin-top: 3px;
}

.coach-light {
  --c: #ffc46a;
  --c-light: #fff3d6;
  --c-deep: #b8731c;
}

.coach-body {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.coach-title {
  font: 700 1.05rem/1.3 var(--display);
  color: var(--ivory);
}

.coach-text {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
}

.coach-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 7px;
}

.coach-buttons .primary {
  min-height: 34px;
  padding: 5px 18px;
  font-size: 0.88rem;
}

.coach-buttons .link {
  font-size: 0.85rem;
}

@media (min-aspect-ratio: 4/3) {
  .table > .coach {
    grid-area: side;
    align-self: end;
    justify-self: stretch;
    width: auto;
    margin: 0;
    --rise: 12px;
  }
}

/* Upright with little height (a small phone, or a browser's toolbars): a compact note, so the board stays clear. */
@media (max-aspect-ratio: 4/3) and (max-height: 760px) {
  .table > .coach {
    gap: 10px;
    padding: 8px 12px 9px 11px;
  }

  .coach .lantern.mini {
    --w: 16px;
  }

  .coach-body {
    gap: 1px;
  }

  .coach-title {
    font-size: 0.95rem;
  }

  .coach-text {
    font-size: 0.82rem;
    line-height: 1.38;
  }

  .coach-buttons {
    margin-top: 5px;
  }

  .coach-buttons .primary {
    min-height: 30px;
    padding: 3px 14px;
    font-size: 0.8rem;
  }

  .coach-buttons .link {
    font-size: 0.78rem;
  }
}

/* Sideways phones: a narrow column and little height, so smaller type and no lantern. */
@media (min-aspect-ratio: 4/3) and (max-height: 480px) {
  .table > .coach {
    grid-template-columns: minmax(0, 1fr);
    padding: 9px 11px;
  }

  .coach .lantern.mini {
    display: none;
  }

  .coach-title {
    font-size: 0.92rem;
  }

  .coach-text {
    font-size: 0.8rem;
    line-height: 1.35;
  }

  .coach-buttons {
    margin-top: 4px;
    gap: 4px 10px;
  }

  .coach-buttons .primary {
    min-height: 30px;
    padding: 3px 14px;
    font-size: 0.8rem;
  }

  .coach-buttons .link {
    font-size: 0.78rem;
  }
}

@keyframes coach-in {
  from {
    opacity: 0;
    transform: translateY(var(--rise, -12px)) scale(0.97);
  }
}

@keyframes coach-out {
  to {
    opacity: 0;
    transform: translateY(calc(var(--rise, -12px) * 0.6)) scale(0.98);
  }
}

/* The card a tip is about: a soft gold ring that breathes. */
.pcard.coached::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: calc(var(--cw) * 0.08 + 3px);
  box-shadow:
    0 0 0 2px rgba(255, 240, 200, 0.95),
    0 0 26px 6px rgba(255, 196, 100, 0.6);
  opacity: 0;
  pointer-events: none;
  animation: coached 1.6s ease-in-out var(--tip-delay, 0ms) infinite;
}

.pcard.coached.selected::before {
  animation: none;
}

@keyframes coached {
  50% {
    opacity: 1;
  }
}

.banner {
  min-width: min(86%, 320px);
  gap: 10px;
  /* After the winning lantern lands and its string lights. */
  animation: banner-in 700ms cubic-bezier(0.2, 0.9, 0.3, 1) 2.6s both;
}

.banner-title {
  font: 700 2.2rem/1.1 var(--display);
  color: var(--ivory);
}

.banner.won .banner-title {
  color: var(--gold);
  text-shadow: 0 0 22px rgba(255, 196, 84, 0.55);
}

.banner .link {
  justify-self: center;
}

@keyframes banner-in {
  from {
    opacity: 0;
    transform: translate(-50%, -42%) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

/* A win: a gust of blossom petals across the screen (hanafubuki, a "blossom blizzard"). */
.fx {
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  pointer-events: none;
}

.gust-petal {
  position: absolute;
  left: 0;
  top: var(--y);
  width: var(--size);
  height: calc(var(--size) * 0.75);
  opacity: 0;
  animation: blow var(--dur) cubic-bezier(0.3, 0.15, 0.45, 1) var(--delay) forwards;
}

.gust-petal::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 0 100% 0 100%;
  background: linear-gradient(135deg, #fff2f6, #f6a3c4);
  box-shadow: 0 0 calc(var(--size) * 0.7) rgba(255, 205, 225, 0.4);
  animation: flutter var(--spin) ease-in-out infinite;
}

@keyframes blow {
  0% {
    opacity: 0;
    transform: translate(-8vw, 0);
  }
  10% {
    opacity: 1;
  }
  55% {
    transform: translate(52vw, var(--lift));
  }
  85% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate(110vw, var(--land));
  }
}

/* ---------- Sheets: Settings and How to play ---------- */

/* Up from the bottom on phones; a card in the middle on bigger screens. */
dialog.sheet {
  display: flex;
  flex-direction: column;
  width: min(100%, 480px);
  max-width: 100%;
  max-height: min(90dvh, 780px);
  margin: auto auto 0;
  padding: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(30, 36, 88, 0.97), rgba(12, 15, 44, 0.98)) padding-box,
    var(--rim) border-box;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  box-shadow:
    0 0 0 1px rgba(255, 214, 140, 0.08),
    0 -12px 44px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  animation: sheet-up 420ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

dialog.sheet:not([open]) {
  display: none;
}

dialog.sheet::backdrop {
  background: rgba(4, 6, 22, 0.58);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

dialog.sheet.closing {
  animation: sheet-down 190ms ease-in forwards;
}

@media (min-width: 640px) and (min-height: 560px) {
  dialog.sheet {
    margin: auto;
    border-bottom: 1px solid transparent;
    border-radius: 24px;
    box-shadow:
      0 0 0 1px rgba(255, 214, 140, 0.08),
      0 24px 60px rgba(0, 0, 0, 0.6);
    animation-name: sheet-in;
  }

  dialog.sheet.closing {
    animation-name: sheet-out;
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes sheet-down {
  to {
    transform: translateY(100%);
  }
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
}

@keyframes sheet-out {
  to {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 6px 22px;
}

.sheet-head h2 {
  margin: 0;
  font: 700 1.5rem/1.2 var(--display);
  text-shadow: 0 0 16px rgba(255, 196, 100, 0.3);
}

.sheet-head .close .line-icon {
  width: 20px;
  height: 20px;
}

.sheet-body {
  display: grid;
  gap: 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 22px max(22px, calc(14px + env(safe-area-inset-bottom)));
}

/* Settings */

.setting-group {
  display: grid;
}

.setting-group h3 {
  margin: 0 0 4px;
  font: 700 0.74rem/1.2 var(--ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}

.setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.setting-group > .setting:last-child {
  border-bottom: 0;
}

.setting.disabled {
  cursor: default;
}

.setting.disabled .setting-text {
  opacity: 0.55;
}

.setting-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  text-align: left;
}

.setting-text b {
  font-weight: 700;
  font-size: 0.98rem;
}

.setting-text small {
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--muted);
}

.setting-text small:empty {
  display: none;
}

/* A row that opens something: the whole row is the button. */
.setting.link-row {
  width: 100%;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--text);
  font-weight: inherit;
  padding: 10px 0;
}

.setting.link-row:active {
  transform: none;
  filter: brightness(1.2);
}

.chevron {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--gold);
}

.setting.alerts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  gap: 6px;
  cursor: default;
}

/* An on/off switch: dark glass when off, polished brass when on. */
.switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 31px;
  min-height: 0;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
  transition: background 200ms ease, border-color 200ms ease;
}

.switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #d5d9e8);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
  transition: transform 220ms cubic-bezier(0.3, 0.7, 0.4, 1);
}

.switch[aria-checked="true"] {
  background: linear-gradient(180deg, #f6d68c, #cf9640);
  border-color: rgba(255, 236, 190, 0.85);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 0 12px rgba(255, 190, 80, 0.35);
}

.switch[aria-checked="true"] .knob {
  transform: translateX(21px);
  background: radial-gradient(circle at 35% 30%, #fffdf6, #f3e3bf);
}

.switch:disabled {
  opacity: 0.45;
}

/* A sound's switch with its volume underneath, as one row. */
.setting-pair {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.setting-group > .setting-pair:last-child {
  border-bottom: 0;
}

.setting-pair > .setting {
  border-bottom: 0;
  padding-bottom: 4px;
}

/* A volume: ten lights between − and +, lit in brass like a switch that's on. */
.volume {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  transition: opacity 200ms ease;
}

.volume.off {
  opacity: 0.38;
}

.volume .step {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
}

.volume .step .line-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2.6;
}

.volume .step:disabled {
  opacity: 0.35;
}

.volume.off .step:disabled {
  opacity: 1;
}

/* As tall as the buttons, so it's as easy to hit; the lights sit in the middle. */
.volume-bar {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  align-items: center;
  gap: 4px;
  height: 44px;
  padding: 0 6px;
  border-radius: 12px;
  cursor: pointer;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.volume.off .volume-bar {
  cursor: default;
}

.volume-bar:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.volume-bar .light {
  height: 16px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.volume-bar .light.lit {
  background: linear-gradient(180deg, #f6d68c, #cf9640);
  border-color: rgba(255, 236, 190, 0.85);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 0 9px rgba(255, 190, 80, 0.32);
}

.about {
  display: grid;
  gap: 6px;
  padding-top: 4px;
  font-size: 0.8rem;
  line-height: 1.45;
  text-align: center;
}

.about a {
  color: var(--ivory);
}

/* How to play */

.rules-intro {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ivory);
}

.rule {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}

.rule.text-only {
  grid-template-columns: minmax(0, 1fr);
}

.rule-text {
  display: grid;
  gap: 6px;
}

.rule-text h3 {
  margin: 0;
  font: 700 1.05rem/1.3 var(--display);
  color: var(--ivory);
}

.rule-text p {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}

.rules-art {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 64px;
}

.rules-art.five {
  position: relative;
  gap: 0;
  justify-content: space-between;
}

.rules-art.five .lantern.mini {
  --w: 15px;
}

.rules-art.five .wire {
  position: absolute;
  left: 4%;
  right: 4%;
  top: calc(50% - 12px);
  height: 8px;
  border-top: 1.5px solid rgba(255, 226, 160, 0.7);
  border-radius: 50%;
}

.mini-card,
.mini-tile {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 7px;
}

.mini-card {
  width: 40px;
  height: 56px;
  color: var(--ink);
  background:
    var(--paper-grain),
    radial-gradient(130% 95% at 30% 12%, #fffdf7 0%, #f8f1e1 55%, #eee1c4 100%);
  border: 1px solid rgba(110, 80, 36, 0.5);
  box-shadow:
    inset 0 0 0 2px rgba(255, 252, 244, 0.85),
    inset 0 0 0 3px rgba(196, 152, 78, 0.6),
    0 4px 10px rgba(0, 0, 0, 0.35);
}

.mini-card .face,
.mini-tile .face {
  display: grid;
  justify-items: center;
  font: 800 0.95rem/1 var(--ui);
}

.mini-card .face.red,
.mini-tile .face.red {
  color: #c41e3a;
}

.mini-card .suit-icon,
.mini-tile .suit-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.mini-card.spark,
.mini-card.gust {
  width: 52px;
  height: 72px;
  gap: 2px;
  align-content: center;
  font: 700 0.72rem/1 var(--ui);
}

.mini-card.spark {
  color: #ffd27a;
  background: radial-gradient(130% 100% at 50% 18%, #363c86 0%, #1b1e50 60%, #0f1234 100%);
  border-color: rgba(246, 210, 130, 0.85);
  box-shadow:
    inset 0 0 0 2px rgba(20, 22, 60, 0.9),
    inset 0 0 0 3px rgba(246, 210, 130, 0.7),
    0 4px 10px rgba(0, 0, 0, 0.35);
}

.mini-card.spark b {
  color: var(--ivory);
}

.mini-card.gust {
  color: #2c4a7d;
  background:
    var(--paper-grain),
    radial-gradient(130% 100% at 40% 15%, #f5f9ff 0%, #d9e5f7 60%, #bcd0ec 100%);
}

.mini-card .icon {
  width: 26px;
  height: 26px;
}

.mini-tile {
  width: 44px;
  height: 44px;
  color: #141a2e;
  background: linear-gradient(160deg, rgba(196, 186, 212, 0.95), rgba(150, 140, 172, 0.95));
  border: 1px solid rgba(240, 232, 248, 0.6);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 4px 10px rgba(0, 0, 0, 0.35);
}

.mini-tile.lit {
  background: linear-gradient(160deg, rgba(150, 196, 236, 0.95), rgba(84, 140, 200, 0.95));
  box-shadow:
    inset 0 0 12px rgba(212, 236, 255, 0.7),
    0 0 16px rgba(74, 168, 240, 0.45),
    0 4px 10px rgba(0, 0, 0, 0.35);
}

/* Hanging just over its tile, as in the game. */
.mini-tile.lit .lantern.mini {
  position: absolute;
  --w: 14px;
  left: 50%;
  top: -17px;
  margin-left: -7px;
}

.mini-tile.lit {
  margin-top: 12px;
}

.mini-tile.corner {
  background: linear-gradient(160deg, #fbecc4, #e7c27c);
  box-shadow:
    inset 0 0 10px rgba(255, 250, 230, 0.8),
    0 0 18px rgba(255, 196, 84, 0.5),
    0 4px 10px rgba(0, 0, 0, 0.35);
}

.mini-tile .icon.star {
  width: 26px;
  height: 26px;
  fill: #ffd34d;
  stroke: #b47a16;
  stroke-width: 1.2;
  stroke-linejoin: round;
}

.rules-art .arrow {
  font-size: 1.4rem;
  color: var(--gold);
}

.rules-art.pair {
  gap: 4px;
}

.rules-art.pair .mini-card {
  width: 34px;
  height: 48px;
}

.rules-art.pair .mini-tile {
  width: 38px;
  height: 38px;
}

/* ---------- Reduced motion ---------- */

/* `calm` is set on <html> from the device's setting, or the player's own choice in Settings. */
.calm .backdrop,
.calm .backdrop > span,
.calm .lantern .rig,
.calm .lantern .halo,
.calm .tile.target::after,
.calm .string.choice .wire,
.calm .pill::after,
.calm .pcard.spark.keyed,
.calm .prompt-text.fresh,
.calm .game-status.yours {
  animation: none !important;
}

.calm .sky .petals,
.calm .glint,
.calm .fx {
  display: none;
}

.calm .lantern.igniting,
.calm .lantern.igniting *,
.calm .lantern.out,
.calm .lantern.out *,
.calm .tile.landing .glow,
.calm .string.new *,
.calm .banner {
  animation-duration: 1ms !important;
}

.calm .lantern.igniting,
.calm .lantern.igniting *,
.calm .lantern.out,
.calm .lantern.out *,
.calm .tile.landing .glow,
.calm .string.new * {
  animation-delay: 0ms !important;
}

.calm .pcard {
  transition: none;
}

/* Tips still wait for the moves to land, then simply appear; the card they point at holds a steady ring. */
.calm .coach,
.calm .coach.closing {
  animation-duration: 1ms !important;
}

.calm .pcard.coached::before {
  animation: none;
  opacity: 1;
}

.calm .seat .bubble {
  animation-name: bubble-calm;
}

.calm dialog.sheet,
.calm .switch,
.calm .switch .knob,
.calm .volume,
.calm .volume-bar .light {
  animation: none;
  transition: none;
}
