/* MAPLE MANCALA — a Btown Games production */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bark: #33200f;
  --bark-2: #241608;
  --plank: #b07a3f;
  --plank-deep: #8f5a25;
  --carve: #4a2c13;
  --amber: #e8a13c;
  --amber-hot: #ffc966;
  --candy: #d47f1f;
  --cream: #f6ead2;
  --cream-dim: #d9c6a2;
  --leaf: #c9502f;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
  background: var(--bark);
  color: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#app { position: fixed; inset: 0; overflow: hidden; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hidden { display: none !important; }

button { font-family: inherit; border: none; cursor: pointer; }

/* ---------------------------------------------------------------- menu */

#menu {
  align-items: center;
  justify-content: space-between;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(232, 161, 60, 0.14), transparent 60%),
    var(--bark);
  padding: calc(env(safe-area-inset-top, 0px) + 5vh) 24px 0;
  text-align: center;
}

.menu-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 420px;
  margin: auto;
}

#logo { line-height: 1.02; margin-bottom: 4px; }
#logo .l-maple {
  display: block;
  font-size: clamp(26px, 4.6vh, 40px);
  font-weight: 800;
  letter-spacing: 0.28em;
  color: var(--leaf);
}
#logo .l-mancala {
  display: block;
  font-size: clamp(44px, 8.2vh, 76px);
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, var(--amber-hot), var(--candy));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

#tagline {
  font-size: clamp(13px, 1.9vh, 16px);
  color: var(--cream-dim);
  line-height: 1.45;
  margin-bottom: 6px;
}

.big-btn {
  width: 100%;
  padding: 16px 20px;
  border-radius: 16px;
  font-size: clamp(17px, 2.4vh, 21px);
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #3a2005;
  background: linear-gradient(180deg, var(--amber-hot), var(--amber));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    0 5px 0 #9c6414,
    0 8px 18px rgba(0, 0, 0, 0.35);
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #9c6414; }

.mode-sub {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--cream-dim);
  margin: -8px 0 2px;
}

.wood-btn {
  width: 100%;
  padding: 13px 18px;
  border-radius: 14px;
  font-size: clamp(15px, 2.1vh, 18px);
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--cream);
  background: linear-gradient(180deg, var(--plank), var(--plank-deep));
  box-shadow:
    inset 0 2px 0 rgba(255, 224, 170, 0.3),
    0 4px 0 var(--carve),
    0 6px 14px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.wood-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--carve); }
.btn-sub { font-size: 11px; font-weight: 700; color: rgba(246, 234, 210, 0.75); letter-spacing: 0.04em; }

#howto {
  font-size: clamp(12px, 1.7vh, 14px);
  color: var(--cream-dim);
  line-height: 1.5;
  max-width: 340px;
  margin-top: 6px;
}
#howto b { color: var(--amber); }

#credit, #credit-go {
  padding: 14px 0 calc(env(safe-area-inset-bottom, 0px) + 14px);
  font-size: 12px;
  color: var(--cream-dim);
  text-align: center;
}
#credit a, #credit-go a { color: var(--amber); text-decoration: none; font-weight: 700; }

/* ---------------------------------------------------------------- game */

#game { padding: calc(env(safe-area-inset-top, 0px) + 6px) 10px calc(env(safe-area-inset-bottom, 0px) + 10px); }

#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 8px;
}
#menuBtn, #mute {
  flex: 0 0 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 18px;
  color: var(--cream);
  background: rgba(246, 234, 210, 0.1);
}
#toast {
  flex: 1;
  text-align: center;
  font-size: clamp(13px, 1.9vh, 16px);
  font-weight: 800;
  color: var(--amber-hot);
  min-height: 20px;
}
#toast.pop { animation: tpop 0.25s ease-out; }
@keyframes tpop {
  0% { transform: scale(0.75); }
  60% { transform: scale(1.07); }
  100% { transform: scale(1); }
}
.mode-pass.turn-north #toast { transform: rotate(180deg); }
.mode-pass.turn-north #toast.pop { animation-name: tpop-flip; }
@keyframes tpop-flip {
  0% { transform: rotate(180deg) scale(0.75); }
  60% { transform: rotate(180deg) scale(1.07); }
  100% { transform: rotate(180deg) scale(1); }
}

/* First-visit action cue. It sits above the board, so it never covers a pit. */
#previewHint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: min(100%, 420px);
  margin: 0 auto 7px;
  padding: 7px 9px 7px 12px;
  border: 1px solid rgba(255, 201, 102, 0.45);
  border-radius: 12px;
  color: var(--cream);
  background: rgba(74, 44, 19, 0.9);
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
}
#previewHint button {
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--bark-2);
  background: var(--amber-hot);
  font-size: 10px;
  font-weight: 900;
}

/* A compact race readout. Thirteen is a visible marker, not a win rule. */
#race {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 7px;
  width: min(100%, 420px);
  margin: 0 auto 8px;
  color: var(--cream-dim);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.race-side {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 6px;
  min-width: 0;
}
.race-right { text-align: right; }
.race-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.race-count { color: var(--cream); }
.race-track {
  grid-column: 1 / -1;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(246, 234, 210, 0.13);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}
.race-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--candy), var(--amber-hot));
}
.race-left .race-track i { margin-left: auto; }
.race-mark {
  padding-bottom: 1px;
  color: rgba(246, 234, 210, 0.55);
  font-size: 8px;
  white-space: nowrap;
}

/* -------------------------------------------------------------- board */
/* The maple plank: warm wood with faint grain streaks, carved edge. */

#board {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 440px;
  width: 100%;
  margin: 0 auto 14px;
  padding: 12px;
  border-radius: 26px;
  background:
    repeating-linear-gradient(94deg,
      rgba(74, 44, 19, 0.10) 0 2px, transparent 2px 26px,
      rgba(74, 44, 19, 0.16) 26px 27px, transparent 27px 61px),
    linear-gradient(180deg, #c08a4c, var(--plank) 30%, var(--plank-deep));
  /* a thick slab: lit top face, solid wood side, soft ground shadow */
  box-shadow:
    inset 0 0 0 3px rgba(74, 44, 19, 0.55),
    inset 0 10px 20px rgba(255, 224, 170, 0.3),
    inset 0 -10px 22px rgba(36, 22, 8, 0.45),
    0 9px 0 -2px #6b4020,
    0 14px 0 -3px #452709,
    0 26px 34px rgba(0, 0, 0, 0.6);
  transform: perspective(1100px) rotateX(3.5deg);
  min-height: 0;
}

#pitgrid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 6px 14vw;
  align-items: center;
  justify-items: center;
  min-height: 0;
  position: relative;
  container-type: size; /* lets the buckets size themselves to fit 6 rows */
}
/* faint maple leaf carved down the spine of the plank */
#pitgrid::before {
  content: '🍁';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 42px;
  opacity: 0.18;
  filter: grayscale(35%);
  pointer-events: none;
}

/* ------------------------------------------------------------ buckets */
/* Each pit is a sap bucket carved into the plank: dark inside, worn rim. */

.pit {
  position: relative;
  width: min(24vw, 96px, calc(16.6cqh - 9px));
  height: min(24vw, 96px, calc(16.6cqh - 9px));
  border-radius: 50%;
  /* a carved bowl lit from above: near wall in shadow, far wall catching light */
  background:
    radial-gradient(circle at 50% 20%, rgba(0, 0, 0, 0.55), transparent 62%),
    radial-gradient(circle at 50% 72%, #2f1b0a 0 40%, #241204 62%, #4a2c13 84%, #7a4e24 100%);
  box-shadow:
    inset 0 14px 16px -4px rgba(0, 0, 0, 0.9),
    inset 0 -10px 14px -6px rgba(255, 205, 140, 0.3),
    inset 0 0 0 3px rgba(58, 33, 12, 0.9),
    0 2px 2px rgba(255, 224, 170, 0.4),
    0 -2px 3px rgba(30, 17, 5, 0.75);
  border: none;
  touch-action: none;
}
.pit.pop { animation: pitpop 0.22s ease-out; }
@keyframes pitpop {
  0% { transform: scale(1); }
  45% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.pit.lift { animation: lift 0.3s ease-out; }
@keyframes lift {
  0% { transform: scale(1); }
  40% { transform: scale(0.92); }
  100% { transform: scale(1); }
}
.pit.flash { animation: flash 0.42s ease-in-out; }
@keyframes flash {
  0%, 100% { filter: none; }
  50% { filter: brightness(1.9) drop-shadow(0 0 14px rgba(255, 201, 102, 0.9)); }
}

/* whose side is live: their buckets get a warm rim */
body:not(.turn-north) .pit.south,
.turn-north .pit.north {
  box-shadow:
    inset 0 14px 16px -4px rgba(0, 0, 0, 0.9),
    inset 0 -10px 14px -6px rgba(255, 205, 140, 0.3),
    inset 0 0 0 3px rgba(232, 161, 60, 0.8),
    0 2px 2px rgba(255, 224, 170, 0.4),
    0 0 14px rgba(232, 161, 60, 0.3);
}

/* landing preview: pulsing amber ring on the pit the last drop hits */
.pit.land, .store.land {
  outline: 3px solid var(--amber-hot);
  outline-offset: 3px;
  animation: landpulse 0.9s ease-in-out infinite;
}
@keyframes landpulse {
  0%, 100% { outline-color: rgba(255, 201, 102, 1); }
  50% { outline-color: rgba(255, 201, 102, 0.35); }
}

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

/* maple-candy drops: glossy amber beads */
.drop {
  position: absolute;
  width: 21%;
  height: 21%;
  border-radius: 50% 50% 50% 44%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 32% 26%, #ffe9b8 0 12%, #f0a944 36%, var(--candy) 60%, #6f3608 100%);
  box-shadow:
    0 4px 5px -1px rgba(0, 0, 0, 0.65),
    inset -2px -3px 4px rgba(80, 35, 4, 0.6),
    inset 2px 3px 3px rgba(255, 236, 190, 0.5);
}
.drop::after {
  content: '';
  position: absolute;
  left: 20%;
  top: 12%;
  width: 32%;
  height: 24%;
  border-radius: 50%;
  transform: rotate(-20deg);
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
}
/* no two candies pour quite alike */
.drop:nth-child(3n) { border-radius: 54% 46% 52% 48% / 48% 54% 46% 52%; }
.drop:nth-child(4n + 1) { border-radius: 47% 53% 45% 55% / 55% 46% 54% 45%; }
.drop.pop { animation: droppop 0.3s ease-out; }
@keyframes droppop {
  0% { transform: translate(-50%, -180%) scale(1.25); opacity: 0.35; }
  55% { transform: translate(-50%, -42%) scale(1.08, 0.9); opacity: 1; }
  78% { transform: translate(-50%, -54%) scale(0.96, 1.05); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

.pit .count {
  position: absolute;
  right: -4px;
  bottom: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: linear-gradient(180deg, #5c3717, var(--carve));
  color: var(--cream);
  font-size: 12px;
  font-weight: 900;
  line-height: 22px;
  text-align: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 224, 170, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.pit.empty .count { opacity: 0.55; }

/* ------------------------------------------------------------- stores */
/* The big buckets — one per player, parked at that player's end. */

.store {
  flex: 0 0 clamp(58px, 10dvh, 84px);
  border-radius: 20px;
  /* a long carved trough, same light as the buckets */
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 45%),
    radial-gradient(140% 200% at 50% 90%, #2f1b0a 0 45%, #241204 68%, #4a2c13 88%, #7a4e24 100%);
  box-shadow:
    inset 0 14px 18px -6px rgba(0, 0, 0, 0.9),
    inset 0 -9px 14px -7px rgba(255, 205, 140, 0.28),
    inset 0 0 0 3px rgba(58, 33, 12, 0.9),
    0 2px 2px rgba(255, 224, 170, 0.35),
    0 -2px 3px rgba(30, 17, 5, 0.7);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.25s;
}
.store.active {
  box-shadow:
    inset 0 14px 18px -6px rgba(0, 0, 0, 0.9),
    inset 0 -9px 14px -7px rgba(255, 205, 140, 0.28),
    inset 0 0 0 3px rgba(232, 161, 60, 0.85),
    0 2px 2px rgba(255, 224, 170, 0.35),
    0 0 18px rgba(232, 161, 60, 0.4);
}
.store-inner {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 0 18px;
}
.mode-pass #storeN .store-inner { transform: rotate(180deg); }
.store-name {
  font-size: clamp(13px, 1.9dvh, 16px);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--cream-dim);
}
.store.active .store-name { color: var(--amber-hot); }
.store-count {
  font-size: clamp(28px, 5dvh, 42px);
  font-weight: 900;
  color: var(--cream);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}
.store-count.pop { animation: tpop 0.25s ease-out; }
.store-tag {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--amber);
  text-transform: uppercase;
  min-width: 64px;
}

/* ------------------------------------------------------- moment effects */

#gameFx {
  position: fixed;
  inset: 0;
  z-index: 24;
  overflow: hidden;
  pointer-events: none;
}
.capture-drop {
  position: fixed;
  width: 13px;
  height: 13px;
  border-radius: 50% 50% 50% 44%;
  background: radial-gradient(circle at 32% 26%, #fff0c8 0 14%, #f0a944 38%, var(--candy) 66%, #6f3608 100%);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.55);
  will-change: transform, opacity;
}

#momentBanner {
  position: fixed;
  left: 50%;
  z-index: 25;
  max-width: calc(100vw - 32px);
  padding: 10px 19px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  color: var(--bark-2);
  background: linear-gradient(180deg, #ffe19b, var(--amber));
  box-shadow: 0 5px 0 #8f5c13, 0 10px 26px rgba(36, 22, 8, 0.5);
  font-size: clamp(18px, 5vw, 25px);
  font-weight: 950;
  letter-spacing: 0.06em;
  text-align: center;
  white-space: nowrap;
}
#momentBanner.capture {
  top: 47%;
  animation: captureBanner 0.9s cubic-bezier(0.3, 1.45, 0.5, 1) forwards;
}
#momentBanner.again {
  top: 18%;
  font-size: clamp(15px, 4.4vw, 21px);
  animation: goAgainPop 1.05s cubic-bezier(0.3, 1.5, 0.5, 1) forwards;
}
#momentBanner.again.chain-2 { filter: brightness(1.08); }
#momentBanner.again.chain-3 {
  padding-inline: 24px;
  filter: brightness(1.16) drop-shadow(0 0 10px rgba(255, 201, 102, 0.5));
}
.mode-pass.turn-north #momentBanner { --banner-turn: 180deg; }
@keyframes captureBanner {
  0% { transform: translate(-50%, -50%) rotate(var(--banner-turn, 0deg)) scale(0.45); opacity: 0; }
  18%, 72% { transform: translate(-50%, -50%) rotate(var(--banner-turn, 0deg)) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -62%) rotate(var(--banner-turn, 0deg)) scale(0.94); opacity: 0; }
}
@keyframes goAgainPop {
  0% { transform: translateX(-50%) rotate(var(--banner-turn, 0deg)) scale(0.3); opacity: 0; }
  18% { transform: translateX(-50%) rotate(var(--banner-turn, 0deg)) scale(1.12); opacity: 1; }
  30%, 75% { transform: translateX(-50%) rotate(var(--banner-turn, 0deg)) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -10px) rotate(var(--banner-turn, 0deg)) scale(0.92); opacity: 0; }
}

/* ------------------------------------------------------------- result */

#result {
  align-items: center;
  justify-content: center;
  background: rgba(20, 11, 3, 0.55);
  backdrop-filter: blur(3px);
  padding: 24px;
}
#result .menu-inner { position: relative; z-index: 1; }
#res-card {
  width: 100%;
  max-width: 380px;
  padding: 26px 22px;
  border-radius: 24px;
  text-align: center;
  background:
    repeating-linear-gradient(94deg,
      rgba(74, 44, 19, 0.10) 0 2px, transparent 2px 30px),
    linear-gradient(180deg, var(--plank), var(--plank-deep));
  box-shadow:
    inset 0 0 0 3px rgba(74, 44, 19, 0.55),
    inset 0 8px 16px rgba(255, 224, 170, 0.25),
    0 8px 0 -2px #6b4020,
    0 13px 0 -3px #452709,
    0 24px 48px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#res-card.celebrate { animation: resultRise 0.45s cubic-bezier(0.3, 1.35, 0.5, 1); }
@keyframes resultRise {
  from { transform: translateY(24px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
#res-title {
  font-size: clamp(26px, 4.4vh, 34px);
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--cream);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}
#res-score {
  font-size: clamp(38px, 6.5vh, 54px);
  font-weight: 900;
  color: var(--amber-hot);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}
#res-line { font-size: 14px; color: var(--cream); opacity: 0.9; line-height: 1.45; }
#brief-cta {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--cream);
  text-decoration: none;
  background: rgba(36, 22, 8, 0.35);
  border-radius: 12px;
  padding: 10px;
}
#brief-cta strong { color: var(--amber-hot); }

/* ---------------------------------------------------------- leaderboard */

#lb {
  width: 100%;
  background: rgba(36, 22, 8, 0.35);
  border: 2px solid rgba(74, 44, 19, 0.55);
  border-radius: 14px;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
#lb .chip-btn {
  padding: 6px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--cream);
  background: linear-gradient(180deg, var(--plank), var(--plank-deep));
  border: 0;
  border-radius: 10px;
  box-shadow: 0 2px 0 var(--carve);
  cursor: pointer;
}
#lb .chip-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--carve); }
.lb-tabs { display: flex; gap: 8px; }
.lb-tabs .chip-btn { opacity: 0.65; }
.lb-tabs .chip-btn.sel {
  opacity: 1;
  color: var(--bark-2);
  background: linear-gradient(180deg, var(--amber-hot), var(--amber));
}
.lb-status {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--cream-dim);
  text-align: center;
  min-height: 15px;
}
#lbList {
  list-style: none;
  width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
#lbList li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--cream);
  padding: 3px 8px;
  border-radius: 8px;
}
#lbList li.me { background: rgba(232, 161, 60, 0.22); color: var(--amber-hot); }
#lbList .rank { width: 26px; text-align: center; }
#lbList .nm {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#lbList .sc { font-variant-numeric: tabular-nums; white-space: nowrap; }
.lb-form { display: flex; gap: 8px; width: 100%; }
.lb-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  color: var(--cream);
  background: rgba(20, 11, 3, 0.45);
  border: 2px solid rgba(74, 44, 19, 0.75);
  border-radius: 10px;
  outline: none;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  user-select: text;
}
.lb-form input:focus { border-color: var(--amber); }

#mapleFlourish {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.flourish-leaf {
  position: absolute;
  left: var(--leaf-x);
  top: 42%;
  font-size: var(--leaf-size);
  opacity: 0;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.35));
  animation: mapleGust 1.45s ease-out var(--leaf-delay) forwards;
}
@keyframes mapleGust {
  0% { transform: translate(-50%, 22vh) rotate(0deg) scale(0.35); opacity: 0; }
  18% { opacity: 0.95; }
  100% { transform: translate(calc(-50% + var(--leaf-drift)), -52vh) rotate(var(--leaf-spin)) scale(1); opacity: 0; }
}

/* ------------------------------------------------------------ online play */

.online-label {
  margin: 2px 0 -8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.11em;
  color: var(--cream-dim);
  text-transform: uppercase;
}
#onlineRow {
  display: flex;
  gap: 10px;
  width: 100%;
}
.online-btn {
  min-width: 0;
  padding: 11px 8px;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  font-size: clamp(11px, 3.1vw, 14px);
}
.online-btn .btn-sub { font-size: 10px; }
.rejoin-btn {
  padding: 10px 14px;
  font-size: 13px;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 11, 3, 0.76);
  backdrop-filter: blur(3px);
}
.op-card {
  width: min(92vw, 340px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 18px;
  background:
    repeating-linear-gradient(94deg,
      rgba(74, 44, 19, 0.10) 0 2px, transparent 2px 30px),
    linear-gradient(180deg, var(--plank), var(--plank-deep));
  border: 3px solid var(--carve);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color: var(--cream);
  text-align: center;
}
.op-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.07em;
}
.op-label {
  margin-bottom: -6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--cream);
  text-align: left;
}
.op-card input {
  width: 100%;
  padding: 12px;
  border: 2px solid rgba(246, 234, 210, 0.35);
  border-radius: 12px;
  outline: none;
  color: var(--cream);
  background: var(--bark-2);
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}
.op-card input:focus { border-color: var(--amber-hot); }
#opCode {
  font-size: 24px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
}
.op-error {
  font-size: 13px;
  font-weight: 700;
  color: #ffd0b8;
}
.op-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 4px;
}
.op-btns .wood-btn {
  width: auto;
  padding: 12px 18px;
  font-size: 14px;
}
.op-btns .big-btn {
  width: auto;
  padding: 12px 22px;
  font-size: 16px;
}
#lobbyCode {
  padding: 6px 0;
  color: var(--amber-hot);
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  text-shadow: 0 3px 0 var(--carve);
  animation: lobbyPulse 1.6s ease-in-out infinite;
}
@keyframes lobbyPulse {
  50% { opacity: 0.75; }
}
#lobbyHint {
  color: var(--cream);
  font-size: 13px;
  line-height: 1.45;
}

@media (max-height: 760px) {
  #menu { padding-top: calc(env(safe-area-inset-top, 0px) + 2vh); }
  .menu-inner { gap: 9px; }
  #tagline { margin-bottom: 0; }
  #howto { margin-top: 1px; line-height: 1.35; }
  .online-label { margin-bottom: -5px; }
  #previewHint { padding-block: 5px; margin-bottom: 5px; }
  #race { margin-bottom: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  #lobbyCode,
  .pit.pop,
  .pit.lift,
  .pit.flash,
  .drop.pop,
  .store-count.pop,
  #toast.pop,
  #res-card.celebrate,
  .flourish-leaf {
    animation: none !important;
  }
  .pit.land, .store.land { animation: none !important; }
  #momentBanner.capture,
  #momentBanner.again {
    animation: none !important;
    transform: translate(-50%, -50%) rotate(var(--banner-turn, 0deg));
    opacity: 1;
  }
}
