/* ===== Base =====
   Your hand on the left, the board in the middle, the opponent's hidden hand as a slim stack on the right; stacked on phones.
   Every size follows --stone-size, so the whole table fits the window. --time-scale stretches every animation in slow motion
   (1, or SLOW_MOTION_FACTOR in move.js), and --pace speeds up the turnovers of a long chain. */
:root {
  --stone-size: clamp(56px, min(calc((100vh - 240px) / 4.75), calc((100vw - 120px) / 8.2)), 136px);
  --gap: calc(var(--stone-size) * 0.13);
  --background: #162034;
  --panel: #212d45;
  --panel-raised: #2c3b59;
  --ink: #eef2fb;
  --muted: #9eadc8;
  --line: #3a4a6a;
  --accent: #f3c54a;
  --blue: #4aa3ff;
  --red: #ff6150;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  --font-display: 'Fredoka', 'Avenir Next Rounded', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
  --time-scale: 1;
  color-scheme: dark;
}
body.slow {
  --time-scale: 4;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: radial-gradient(ellipse at 50% -10%, #2b3d66 0%, var(--background) 60%) fixed var(--background);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  min-height: 100vh;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
h1,
h2,
h3,
button,
.run-line,
.name,
.points,
.hand-count,
#stone-info b,
#stone-info .level,
.card-label,
.name-tag,
.points-pop,
.piece-guide b {
  font-family: var(--font-display);
}
.page {
  max-width: 1300px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px
    max(14px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px;
  min-height: 100vh;
}

/* ===== Buttons ===== */
button {
  font-size: 16px;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  background: var(--panel-raised);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 #0e1422;
  transition: transform 0.06s;
}
button:hover {
  filter: brightness(1.12);
}
button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0e1422;
}
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
button.primary,
#slow-button[aria-pressed='true'] {
  background: var(--accent);
  color: #2a2410;
}
.text-button {
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 0;
  text-decoration: underline;
}

/* ===== Top bar: title, run ladder, buttons ===== */
.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
}
.title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}
h1 {
  font-weight: 700;
  font-size: 28px;
  margin: 0;
  letter-spacing: -0.01em;
}
.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
/* Twenty pips, the last one is the boss. */
.run-progress {
  flex: 1;
  min-width: 200px;
  max-width: 520px;
}
.ladder {
  display: flex;
  gap: 4px;
  align-items: center;
}
.ladder i {
  flex: 1;
  height: 10px;
  border-radius: 3px;
  background: rgba(10, 14, 26, 0.55);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}
.ladder i.won {
  background: linear-gradient(#ffe08a, #e0a92e);
}
.ladder i.current {
  background: var(--panel-raised);
  box-shadow: 0 0 0 2px var(--accent);
}
.ladder i.boss {
  flex: 1.8;
  background: #2a1838;
  box-shadow: inset 0 0 0 2px #7d4bb8;
}
.ladder i.boss.current {
  box-shadow:
    0 0 0 2px var(--accent),
    inset 0 0 0 2px #7d4bb8;
}
.ladder i.boss.won {
  background: linear-gradient(#e2b6ff, #8b4fd6);
}
.run-line {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* ===== Scores: you, the tug of war, the opponent ===== */
.scoreboard {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(40px, 1fr) minmax(0, max-content);
  gap: 14px;
  align-items: center;
  max-width: calc(var(--stone-size) * 7.6 + 60px);
  width: 100%;
  justify-self: center;
}
.player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px 12px;
  border-radius: 16px;
  background: rgba(33, 45, 69, 0.7);
  border: 2px solid var(--line);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.player.to-move {
  border-color: currentColor;
  box-shadow:
    0 0 0 4px color-mix(in srgb, currentColor 16%, transparent),
    0 0 22px color-mix(in srgb, currentColor 30%, transparent);
}
.player.opponent {
  flex-direction: row-reverse;
  text-align: right;
  padding-right: 5px;
}
.player .name {
  font-weight: 600;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player .points {
  font-weight: 700;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}
.player .spikes {
  font-size: 13px;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.you {
  color: var(--blue);
}
.opponent {
  color: var(--red);
}
.portrait {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 2px currentColor;
}
.tug-of-war {
  display: flex;
  height: 8px;
  border-radius: 99px;
  background: rgba(10, 14, 26, 0.5);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}
.tug-of-war div {
  transition: width 0.35s ease-out;
}
.tug-of-war .you {
  background: linear-gradient(90deg, #2f7fe0, var(--blue));
}
.tug-of-war .opponent {
  background: linear-gradient(90deg, var(--red), #d8402f);
  margin-left: auto;
}

/* ===== Table: the two hands around the board ===== */
.table {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: calc(var(--stone-size) * 0.3);
  justify-content: center;
  align-items: center;
  align-content: center;
  padding-bottom: 12px;
}
.centre {
  display: grid;
  gap: 8px;
}
.hand {
  display: grid;
  grid-template-columns: repeat(2, var(--stone-size));
  gap: var(--gap);
  align-content: center;
  min-height: calc(var(--stone-size) * 4 + var(--gap) * 3);
}
.hand:not(.active) .hand-stone {
  opacity: 0.55;
  filter: saturate(0.8);
}
.hand-stone {
  width: var(--stone-size);
  height: var(--stone-size);
  padding: 0;
  background: none;
  box-shadow: none;
  border-radius: 14px;
  transition:
    transform 0.15s,
    filter 0.15s,
    opacity 0.15s;
}
.hand-stone:hover {
  filter: brightness(1.1);
}
.hand-stone.selected {
  transform: translateY(-6px) scale(1.06);
  background: radial-gradient(circle, rgba(243, 197, 74, 0.4) 0%, rgba(243, 197, 74, 0) 70%);
}
.hand-stone:disabled {
  cursor: default;
}
.hand-stone:disabled:hover {
  filter: none;
}
.hidden-hand {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: calc(var(--stone-size) * 0.75);
}
.hidden-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.hidden-stone {
  width: calc(var(--stone-size) * 0.62);
  height: calc(var(--stone-size) * 0.62);
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.5));
}
.hidden-stone + .hidden-stone {
  margin-top: calc(var(--stone-size) * -0.34);
}
.hidden-stone:nth-child(odd) {
  transform: rotate(-4deg);
}
.hidden-stone:nth-child(even) {
  transform: rotate(3deg);
}
.hand-count {
  font-size: 14px;
  color: var(--red);
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
}
.portrait img,
.big-portrait img {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}
.hidden-stone svg,
.hand-stone svg,
.square svg.stone {
  width: 100%;
  height: 100%;
  display: block;
}
.hand-stone svg,
.square svg.stone {
  overflow: visible;
  filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.45));
}
#stone-info {
  min-height: 1.5em;
  max-width: calc(var(--stone-size) * 4.4);
  justify-self: center;
  text-align: center;
  font-size: 15px;
  color: var(--muted);
}
#stone-info b {
  font-weight: 600;
  color: var(--ink);
}
#stone-info .level {
  color: var(--accent);
  font-weight: 600;
}
#stone-info .status {
  font-family: var(--font-display);
  font-weight: 500;
}
#stone-info .status.opponent {
  color: var(--red);
}
#stone-info .status.you {
  color: var(--blue);
}

/* The coach line under the board: the tutorial's lessons, and a word on a rare stone the first time it shows up. */
.coach {
  max-width: calc(var(--stone-size) * 4.4);
  justify-self: center;
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 2px solid var(--accent);
  text-align: center;
  font-size: 15px;
  line-height: 1.45;
  animation: drop 0.25s ease-out;
}
.coach p {
  margin: 0;
}
.coach .take {
  color: var(--accent);
  font-weight: 700;
}
.coach .lose {
  color: var(--red);
  font-weight: 700;
}
.coach-buttons {
  display: flex;
  gap: 16px;
  align-items: center;
}
.coach-buttons:empty {
  display: none;
}

/* ===== Board ===== */
.board-frame {
  position: relative;
  justify-self: center;
}
.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--board-size), var(--stone-size));
  gap: var(--gap);
  padding: var(--gap);
  border-radius: 20px;
  background: var(--grain), linear-gradient(160deg, #5d6880 0%, #454f68 50%, #363f56 100%);
  background-blend-mode: overlay, normal;
  box-shadow:
    0 10px 0 #20283a,
    0 22px 40px rgba(0, 0, 0, 0.5),
    inset 0 2px 0 rgba(255, 255, 255, 0.18),
    inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}
.board::before {
  content: '';
  position: absolute;
  inset: -26px;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(243, 197, 74, 0.1), transparent);
  pointer-events: none;
}
.square {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 40%, rgba(30, 38, 58, 0.35), rgba(10, 14, 26, 0.6));
  box-shadow:
    inset 0 4px 10px rgba(0, 0, 0, 0.55),
    inset 0 -1px 0 rgba(255, 255, 255, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.1);
}
.square.playable {
  cursor: pointer;
}
.square.playable:hover {
  background: rgba(243, 197, 74, 0.16);
  box-shadow: inset 0 0 0 3px rgba(243, 197, 74, 0.55);
}
.square.last-move::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 22px;
  height: 4px;
  margin-left: -11px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  pointer-events: none;
}
/* The preview: a ghost of the selected stone, yellow rings on stones you would take, red on stones you would lose, faded spikes. */
.square .preview-stone {
  position: absolute;
  inset: 0;
  opacity: 0.72;
  pointer-events: none;
}
.square.would-lose::after,
.square.would-take::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 16px;
  border: 3px solid var(--accent);
  animation: pulse 0.9s ease-in-out infinite;
  pointer-events: none;
}
.square.would-lose::after {
  border-color: var(--red);
}
.square.preview .breaking {
  opacity: 0.3;
}

/* ===== A move: drop, shatter, turn over ===== */
.square.just-placed svg.stone {
  animation: drop calc(0.3s * var(--time-scale)) cubic-bezier(0.3, 1.5, 0.5, 1);
}
.board.thump {
  animation: thump calc(0.28s * var(--time-scale)) ease-out calc(0.12s * var(--time-scale));
}
.board.shake {
  animation: shake calc(0.4s * var(--time-scale)) ease-in-out;
}
.square:not(.preview) .breaking {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: shatter calc(0.45s * var(--time-scale)) ease-in forwards;
}
.flip-card {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  animation: turn calc(0.42s * var(--time-scale) * var(--pace, 1)) ease-in-out forwards;
}
.flip-card .front,
.flip-card .back-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.flip-card .back-face {
  transform: rotateY(180deg);
}
.square.turning-over::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 14px;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(rgba(255, 255, 255, 0.6), transparent 70%);
  animation: flash calc(0.3s * var(--time-scale)) ease-out calc(0.2s * var(--time-scale)) forwards;
}
/* Pops over the board: the name of the stone placed, and the points won or lost. */
.points-pop,
.name-tag {
  position: absolute;
  font-weight: 700;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 4;
  white-space: nowrap;
}
.points-pop {
  font-size: 26px;
  color: var(--accent);
  text-shadow:
    0 2px 0 #0e1422,
    0 0 10px rgba(0, 0, 0, 0.6);
  animation: rise calc(1.1s * var(--time-scale)) ease-out forwards;
}
.points-pop.loss {
  color: var(--red);
}
.name-tag {
  font-size: 15px;
  color: var(--ink);
  background: #0e1422;
  border: 2px solid currentColor;
  border-radius: 99px;
  padding: 1px 10px;
  animation: tagup calc(1.3s * var(--time-scale)) ease-out forwards;
}
.name-tag.you {
  border-color: var(--blue);
}
.name-tag.opponent {
  border-color: var(--red);
}

/* ===== Rare stones: poison, and one-off effects of a fight ===== */
.square.poisoned svg.stone {
  filter: drop-shadow(0 0 7px #7dff5a) drop-shadow(0 4px 3px rgba(0, 0, 0, 0.45));
}
.square.poisoned::before {
  content: '';
  position: absolute;
  inset: 18% 22% auto;
  height: 60%;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(circle at 30% 20%, #9dff6a 0 4px, transparent 5px),
    radial-gradient(circle at 70% 45%, #7de04a 0 3px, transparent 4px),
    radial-gradient(circle at 45% 75%, #9dff6a 0 3px, transparent 4px);
  animation: drip 1.6s ease-in infinite;
}
.poison-countdown {
  position: absolute;
  right: 4%;
  top: 4%;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #2d7a1f;
  border: 2px solid #9dff6a;
  color: #eaffde;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  z-index: 3;
  box-shadow: 0 0 10px #7dff5a;
}
.square.bitten::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 18px;
  pointer-events: none;
  background: radial-gradient(circle, rgba(125, 255, 90, 0.7), transparent 70%);
  animation: flash calc(0.5s * var(--time-scale)) ease-out forwards;
}
.square.shield-hit::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 18px;
  pointer-events: none;
  border: 4px solid #ffd34d;
  box-shadow: 0 0 18px #ffd34d;
  animation: flash calc(0.5s * var(--time-scale)) ease-out forwards;
}
.square.crowned::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 236, 140, 0.95), rgba(243, 197, 74, 0.4) 40%, transparent 70%);
  animation: flash calc(0.8s * var(--time-scale)) ease-out forwards;
}
.square.crumbling svg.stone {
  animation: crumble calc(0.5s * var(--time-scale)) ease-in-out;
}
.bee {
  position: absolute;
  width: 10px;
  height: 7px;
  margin: -3px 0 0 -5px;
  border-radius: 50%;
  z-index: 5;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, #ffd34d 0 3px, #1d1d1d 3px 5px);
  box-shadow: 0 -3px 0 -1px rgba(255, 255, 255, 0.8);
  animation: bee calc(1s * var(--time-scale)) ease-in-out forwards;
}

/* ===== Cards between matches: the next opponent, rewards, the end of a run ===== */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 14, 26, 0.72);
  backdrop-filter: blur(3px);
  z-index: 10;
  padding: 16px;
  overflow: auto;
}
#rules-modal {
  z-index: 11;
}
.card {
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 22px 24px;
  border-radius: 18px;
  text-align: center;
  display: grid;
  gap: 12px;
  width: min(520px, 100%);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: drop 0.3s ease-out;
}
.card h2 {
  font-size: 28px;
  margin: 0;
}
.card p {
  margin: 0;
  color: var(--muted);
}
.card .card-label {
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.card .card-label.quiet {
  color: var(--muted);
}
.card .big-portrait {
  width: 132px;
  height: 132px;
  justify-self: center;
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    0 0 0 4px var(--red),
    0 10px 24px rgba(0, 0, 0, 0.5);
}
.card .big-portrait.boss {
  box-shadow:
    0 0 0 4px #9b5de5,
    0 0 40px rgba(155, 93, 229, 0.6);
}
.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.choice {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 12px 8px;
  background: var(--panel-raised);
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}
.choice svg {
  width: 76px;
  height: 76px;
  overflow: visible;
}
.choices.difficulties {
  grid-template-columns: repeat(2, 1fr);
}
.choice .difficulty {
  font-size: 19px;
}
.choice .difficulty-detail {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 13px;
  color: var(--muted);
}
.choice .pips {
  color: var(--red);
  letter-spacing: 2px;
  font-size: 12px;
}
.choice .swap {
  display: flex;
  align-items: center;
  gap: 2px;
}
.choice .swap svg {
  width: 56px;
  height: 56px;
}
/* A long list of choices, like every stone of a run: smaller tiles. */
.choices.compact {
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  max-height: 52vh;
  overflow-y: auto;
}
.choices.compact .choice {
  padding: 8px 4px;
  font-size: 12px;
}
.choices.compact .swap svg {
  width: 50px;
  height: 50px;
}
.hand-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.hand-row svg {
  width: 52px;
  height: 52px;
  overflow: visible;
}
/* The two buttons at the foot of a card: the quiet one on the left, the main one on the right. */
.card-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
}
.card.wide {
  width: min(1040px, 100%);
}
/* Your whole collection on its own wide card: big stones with their names, the ones in your deck lit,
   the rest dimmed. */
.collection {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
  max-height: 64vh;
  overflow-y: auto;
  padding: 6px;
}
.owned {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 10px 4px 8px;
  background: none;
  box-shadow: none;
  border-radius: 14px;
  opacity: 0.38;
  filter: saturate(0.6);
  transition:
    opacity 0.12s,
    transform 0.12s;
}
.owned svg {
  width: 84px;
  height: 84px;
  overflow: visible;
}
.owned-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}
.owned.in-deck {
  opacity: 1;
  filter: none;
  background: rgba(243, 197, 74, 0.16);
  box-shadow: inset 0 0 0 2px rgba(243, 197, 74, 0.6);
}
.owned:hover {
  transform: translateY(-2px);
}
.deck-count {
  font-variant-numeric: tabular-nums;
}
/* A stone you got after the last match wears a badge: New or Up. */
.deck-stone {
  position: relative;
}
.badge {
  position: absolute;
  top: -6px;
  right: -8px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--accent);
  color: #2a2410;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 0 2px 0 #0e1422;
}
.owned .badge {
  top: 2px;
  right: 6px;
}

/* The card after a win: a big Victory, then the new stone, shining. */
.card h2.victory {
  font-size: 40px;
  color: var(--accent);
  text-shadow: 0 4px 0 #6b4f08;
  animation: drop 0.45s ease-out;
}
.gift {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 14px;
  border-radius: 16px;
  background: radial-gradient(circle at 50% 38%, rgba(243, 197, 74, 0.32), var(--panel-raised) 62%);
  box-shadow: inset 0 0 0 2px rgba(243, 197, 74, 0.55);
}
.gift-stone {
  position: relative;
  width: 132px;
  height: 132px;
}
.gift-stone::before {
  content: '';
  position: absolute;
  inset: -26px;
  background: repeating-conic-gradient(rgba(255, 236, 160, 0.3) 0 12deg, transparent 12deg 30deg);
  border-radius: 50%;
  mask: radial-gradient(circle, #000 35%, transparent 70%);
  animation: spin 9s linear infinite;
}
.gift-stone svg {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: visible;
  animation: drop 0.5s ease-out;
}
.gift .gift-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}
.gift .gift-where {
  color: var(--ink);
}
.card .primary:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

/* The card before a match: the opponent's stones, a panel for each rare stone you have not met yet, your deck. */
.their-deck svg {
  width: 46px;
  height: 46px;
}
.meeting {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
  background: var(--panel-raised);
}
.meeting p b {
  color: var(--ink);
}
.demo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.demo-arrow {
  font-size: 22px;
  color: var(--accent);
}
.mini-board {
  display: grid;
  grid-template-columns: repeat(var(--board-size), clamp(34px, 11vw, 56px));
  gap: 5px;
  padding: 5px;
  border-radius: 10px;
  background: linear-gradient(160deg, #5d6880 0%, #363f56 100%);
}
.mini-board .square {
  border-radius: 8px;
}
.mini-board .square.placed {
  box-shadow: inset 0 0 0 2px var(--accent);
}
.mini-board .square svg.stone {
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}
.mini-board .poison-countdown {
  width: 16px;
  height: 16px;
  font-size: 10px;
  border-width: 1px;
}
.demo-caption {
  font-size: 14px;
}
.worst-move b {
  color: var(--ink);
}
.worst-move .text-button {
  margin-left: 6px;
  font-size: 14px;
}

/* ===== Rules ===== */
.card.rules {
  text-align: left;
  width: min(760px, 100%);
  line-height: 1.5;
}
.rules h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
  margin: 8px 0 0;
}
.rules ul {
  margin: 0;
  padding-left: 20px;
}
.rules li {
  margin: 4px 0;
}
.rules .rules-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rules-footer-links {
  display: flex;
  gap: 18px;
}
.piece-guide {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.piece-guide div {
  display: grid;
  grid-template-columns: 52px 52px 1fr;
  gap: 8px;
  align-items: center;
  background: var(--panel-raised);
  border-radius: 12px;
  padding: 8px;
}
.piece-guide svg {
  width: 100%;
  height: auto;
  overflow: visible;
}
.piece-guide p {
  grid-column: 3; /* the king has one picture, his words still go in the wide column */
}
.piece-guide b {
  font-weight: 600;
  display: block;
}
.piece-guide span {
  font-size: 13px;
  color: var(--muted);
}
.record {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ===== Keyframes ===== */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes thump {
  0%,
  100% {
    transform: none;
  }
  35% {
    transform: translateY(3px) scale(0.995);
  }
}
@keyframes shake {
  0%,
  100% {
    transform: none;
  }
  20% {
    transform: translateX(-5px) rotate(-0.4deg);
  }
  40% {
    transform: translateX(5px) rotate(0.4deg);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(2px);
  }
}
@keyframes drop {
  0% {
    transform: scale(1.35);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes shatter {
  0% {
    transform: none;
    opacity: 1;
  }
  35% {
    transform: scale(1.25);
    opacity: 1;
  }
  100% {
    transform: translateY(-6px) scale(0.2) rotate(40deg);
    opacity: 0;
  }
}
@keyframes turn {
  0% {
    transform: perspective(500px) rotateY(0);
  }
  50% {
    transform: perspective(500px) rotateY(90deg) scale(1.1);
  }
  100% {
    transform: perspective(500px) rotateY(180deg);
  }
}
@keyframes flash {
  0% {
    opacity: 1;
    transform: scale(0.4);
  }
  100% {
    opacity: 0;
    transform: scale(1.5);
  }
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}
@keyframes rise {
  0% {
    opacity: 0;
    margin-top: 10px;
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    margin-top: -40px;
  }
}
@keyframes tagup {
  0% {
    opacity: 0;
    margin-top: 0;
  }
  15% {
    opacity: 1;
    margin-top: -8px;
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    margin-top: -22px;
  }
}
@keyframes drip {
  0% {
    opacity: 0;
    transform: translateY(-4px);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(14px);
  }
}
@keyframes crumble {
  0%,
  100% {
    transform: none;
  }
  20% {
    transform: translateX(-4%) rotate(-4deg);
  }
  40% {
    transform: translateX(4%) rotate(4deg);
  }
  60% {
    transform: translateX(-3%) rotate(-2deg);
  }
  80% {
    transform: translateX(2%);
  }
}
@keyframes bee {
  0% {
    transform: translate(0, 0) scale(0.4);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  55% {
    transform: translate(var(--bee-x), var(--bee-y)) scale(1);
  }
  100% {
    transform: translate(0, 0) scale(0.4);
    opacity: 0;
  }
}

/* ===== Reduced motion, and phones ===== */
@media (prefers-reduced-motion: reduce) {
  .square:not(.preview) .breaking {
    animation: none;
    opacity: 0;
  }
  .flip-card {
    animation: none;
    transform: rotateY(180deg);
  }
  .board.thump,
  .board.shake,
  .square.just-placed svg.stone,
  .square.turning-over::after,
  .square.would-take::after,
  .points-pop,
  .name-tag,
  .card,
  .card h2.victory,
  .gift-stone::before,
  .gift-stone svg {
    animation: none;
  }
}
@media (max-width: 760px) {
  :root {
    --stone-size: calc((100vw - 60px) / 4.5);
  }
  .table {
    grid-template-columns: 1fr;
  }
  .hand {
    grid-template-columns: repeat(4, var(--stone-size));
    min-height: 0;
    justify-content: center;
  }
  .hidden-hand {
    order: -1;
    width: auto;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .hidden-stack {
    flex-direction: row;
  }
  .hidden-stone {
    width: calc(var(--stone-size) * 0.42);
    height: calc(var(--stone-size) * 0.42);
  }
  .hidden-stone + .hidden-stone {
    margin: 0 0 0 calc(var(--stone-size) * -0.1);
  }
  .player .points {
    font-size: 24px;
  }
  .portrait {
    width: 34px;
    height: 34px;
  }
  h1 {
    font-size: 23px;
  }
  button {
    font-size: 14px;
    padding: 8px 11px;
  }
  .player .name {
    font-size: 15px;
  }
}
