/* BTOWN CRIBBAGE — a Btown Games production.
 * Green-mountain felt below, a parchment Long Trail map for the board. */

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

:root {
  --pine: #123524;        /* darkest green — chrome, borders, text on gold */
  --pine-2: #1b4a31;
  --felt: #226b40;        /* the table */
  --felt-glow: #2e8149;
  --cream: #f6efdc;
  --cream-dim: #d9ccae;
  --sun: #f2a24a;         /* fleet gold */
  --maple: #b5542a;       /* card backs, and YOUR pegs */
  --maple-deep: #8f3d1f;
  --champ: #1d6b3f;       /* Champ's pegs */
  --parchment: #efe3c4;   /* the trail map */
  --trail: #c9a36c;
  --card-red: #c0392b;
  --card-black: #1d2733;
  --card-w: clamp(52px, 15vw, 74px);
}

html, body {
  height: 100%;
  overscroll-behavior: none;
  background: var(--pine);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -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; }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- screens */

.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(env(safe-area-inset-bottom, 0px) + 10px);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(242, 162, 74, 0.14), transparent 55%),
    radial-gradient(100% 100% at 50% 110%, var(--felt-glow), transparent 70%),
    linear-gradient(180deg, var(--pine) 0%, var(--pine-2) 55%, var(--felt) 100%);
}

.menu-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.4vh;
  width: 100%;
  max-width: 420px;
  flex: 1;
  justify-content: center;
  min-height: 0;
}

/* wordmark */
#logo { text-align: center; user-select: none; }
.l-btown {
  display: block;
  font-size: clamp(20px, 3.4vh, 30px);
  font-weight: 900;
  letter-spacing: 0.55em;
  margin-left: 0.55em;
  color: var(--sun);
  text-shadow: 0 2px 0 rgba(18, 53, 36, 0.9);
}
.l-cribbage { display: block; margin-top: 0.5vh; }
.l-cribbage i {
  display: inline-block;
  font-style: normal;
  font-weight: 900;
  font-size: clamp(34px, min(9vh, 11.5vw), 76px);
  line-height: 1;
  color: var(--cream);
  -webkit-text-stroke: 2.5px var(--pine);
  text-shadow: 0 5px 0 var(--pine), 0 8px 18px rgba(0, 0, 0, 0.4);
  animation: peg-bob 2.6s ease-in-out infinite;
}
.l-cribbage i:nth-child(odd) { color: #ffd9a0; }
.l-cribbage i:nth-child(2) { animation-delay: 0.1s; }
.l-cribbage i:nth-child(3) { animation-delay: 0.2s; }
.l-cribbage i:nth-child(4) { animation-delay: 0.3s; }
.l-cribbage i:nth-child(5) { animation-delay: 0.4s; }
.l-cribbage i:nth-child(6) { animation-delay: 0.5s; }
.l-cribbage i:nth-child(7) { animation-delay: 0.6s; }
.l-cribbage i:nth-child(8) { animation-delay: 0.7s; }
@keyframes peg-bob {
  0%, 100% { transform: translateY(0) rotate(-1.2deg); }
  50% { transform: translateY(-7px) rotate(1.2deg); }
}
.l-sub {
  display: block;
  margin-top: 1.2vh;
  font-size: clamp(12px, 1.8vh, 15px);
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--cream-dim);
  text-shadow: 0 1px 3px rgba(18, 53, 36, 0.9);
}

#tagline {
  text-align: center;
  color: var(--cream);
  font-size: clamp(13px, 2vh, 16px);
  font-weight: 600;
  line-height: 1.45;
  text-shadow: 0 1px 4px rgba(18, 53, 36, 0.8);
}

.big-btn {
  font-size: clamp(17px, 2.6vh, 22px);
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--pine);
  background: linear-gradient(180deg, #ffc24e, var(--sun));
  border: 3px solid var(--pine);
  border-radius: 16px;
  padding: 14px 30px;
  box-shadow: 0 5px 0 var(--pine), 0 10px 22px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.06s ease;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--pine); }
.big-btn.small { font-size: clamp(14px, 2.1vh, 17px); padding: 11px 22px; border-radius: 13px; }
.big-btn:disabled { opacity: 0.45; filter: saturate(0.4); }

.mode-btn {
  font-size: clamp(14px, 2.2vh, 18px);
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--cream);
  background: rgba(246, 239, 220, 0.08);
  border: 2.5px solid rgba(246, 239, 220, 0.35);
  border-radius: 14px;
  padding: 12px 26px;
  cursor: pointer;
  touch-action: manipulation;
}
.mode-btn:active { background: rgba(246, 239, 220, 0.2); }

#howto { text-align: center; display: flex; flex-direction: column; gap: 7px; }
.howto-line { font-size: 12px; color: var(--cream-dim); font-weight: 600; }
#howto .key {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--cream);
  border: 1.5px solid rgba(246, 239, 220, 0.4);
  border-radius: 8px;
  padding: 3px 9px;
  margin-right: 7px;
  background: rgba(18, 53, 36, 0.5);
}

#credit, #credit-go {
  flex: none;
  text-align: center;
  font-size: 12px;
  color: var(--cream-dim);
  text-shadow: 0 1px 3px rgba(18, 53, 36, 0.9);
  padding-bottom: 4px;
}
#credit a, #credit-go a { color: var(--sun); font-weight: 700; text-decoration: none; }
#credit a:active, #credit-go a:active { text-decoration: underline; }

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

#onlineModes {
  width: 100%;
  max-width: 390px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}
.online-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--cream-dim);
  text-shadow: 0 1px 3px rgba(18, 53, 36, 0.8);
}
#onlineRow {
  display: flex;
  gap: 9px;
  width: 100%;
}
.online-btn {
  flex: 1;
  min-width: 0;
  padding: 9px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.online-name {
  font-size: clamp(11px, 3.2vw, 14px);
  font-weight: 900;
  white-space: nowrap;
}
.online-blurb {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--cream-dim);
}
#rejoinBtn { margin-top: 2px; padding: 8px 13px; }

.op-card {
  width: min(92vw, 350px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px 18px;
  background: linear-gradient(180deg, rgba(27, 74, 49, 0.99), rgba(18, 53, 36, 0.99));
  border: 3px solid var(--pine);
  border-radius: 20px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.5);
  color: var(--cream);
  text-align: center;
}
.op-title {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.op-label {
  margin-bottom: -6px;
  color: var(--cream-dim);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-align: left;
}
.op-card input {
  width: 100%;
  padding: 12px;
  border: 2px solid rgba(246, 239, 220, 0.3);
  border-radius: 12px;
  outline: none;
  background: rgba(10, 30, 19, 0.7);
  color: var(--cream);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}
.op-card input:focus { border-color: var(--sun); }
#opCode {
  font-size: 24px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
}
.op-error {
  color: #ffb09c;
  font-size: 13px;
  font-weight: 700;
}
.op-btns {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}
.op-btns .big-btn { padding: 11px 20px; font-size: 16px; }
#lobbyCode {
  padding: 6px 0;
  color: var(--sun);
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  text-shadow: 0 3px 0 var(--pine);
  animation: lobbyPulse 1.6s ease-in-out infinite;
}
@keyframes lobbyPulse {
  50% { opacity: 0.75; }
}
#lobbyHint { color: var(--cream-dim); font-size: 13px; line-height: 1.4; }

/* ---------------------------------------------------------------- handoff */

.handoff-card {
  width: min(92vw, 380px);
  background: linear-gradient(180deg, rgba(27, 74, 49, 0.97), rgba(18, 53, 36, 0.97));
  border: 2.5px solid rgba(246, 239, 220, 0.25);
  border-radius: 22px;
  padding: 30px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.handoff-emoji { font-size: 46px; }
#handoffTitle {
  font-size: clamp(20px, 3.4vh, 26px);
  font-weight: 900;
  color: var(--cream);
}
.handoff-sub { font-size: 13px; color: var(--cream-dim); font-style: italic; }

/* ---------------------------------------------------------------- table */

#game {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 0 calc(env(safe-area-inset-bottom, 0px) + 6px);
  background:
    radial-gradient(130% 90% at 50% 30%, var(--felt) 0%, var(--pine-2) 78%, var(--pine) 100%);
}

#topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
}
#homeBtn {
  flex: none;
  font-size: 17px;
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 2px solid rgba(246, 239, 220, 0.25);
  background: rgba(18, 53, 36, 0.55);
  cursor: pointer;
  touch-action: manipulation;
}
#mute {
  flex: none;
  font-size: 17px;
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 2px solid rgba(246, 239, 220, 0.25);
  background: rgba(18, 53, 36, 0.55);
  color: var(--cream);
  cursor: pointer;
  touch-action: manipulation;
}
#homeBtn:focus-visible,
#mute:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 2px;
}

#players {
  flex: 1;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.player-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(18, 53, 36, 0.55);
  border: 2px solid rgba(246, 239, 220, 0.18);
  color: var(--cream);
  font-size: 13px;
  font-weight: 800;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.player-chip .dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(246, 239, 220, 0.8);
}
.player-chip .dot.p0 { background: var(--maple); }
.player-chip .dot.p1 { background: var(--champ); }
.player-chip .score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 24px;
  padding: 0 5px;
  border-radius: 7px;
  background: rgba(246, 239, 220, 0.14);
  font-size: 13px;
  font-weight: 900;
}
.player-chip .crib-tag { font-size: 12px; }
.player-chip.active {
  border-color: var(--sun);
  box-shadow: 0 0 0 2px rgba(242, 162, 74, 0.35), 0 0 18px rgba(242, 162, 74, 0.35);
}

/* ----------------------------------------------------- the trail board */

#board {
  position: relative;
  z-index: 2;
  flex: none;
  margin: 4px 8px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 2.5px solid rgba(18, 53, 36, 0.85);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 0 30px rgba(181, 84, 42, 0.12);
  background:
    radial-gradient(120% 120% at 50% -10%, #f7eed3, var(--parchment) 60%, #e6d5ab);
}
#board svg { display: block; width: 100%; height: auto; }

.peg { transition: transform 0.7s cubic-bezier(0.5, 1.4, 0.4, 1); }
#board.instant-pegs .peg { transition: none; }
.peg circle { stroke: rgba(18, 53, 36, 0.75); stroke-width: 1.1; }
.peg.p0 circle { fill: var(--maple); }
.peg.p1 circle { fill: var(--champ); }
.peg.back circle { opacity: 0.55; r: 3.1; }

#board.summit-result {
  box-shadow:
    0 0 0 3px rgba(242, 162, 74, 0.8),
    0 0 34px rgba(242, 162, 74, 0.75),
    inset 0 0 34px rgba(255, 194, 78, 0.35);
}
#board.summit-celebrate {
  animation: summit-board 1.1s ease-in-out 2;
}
#board.summit-result::after {
  content: "121 • SUMMIT!";
  position: absolute;
  top: 7px;
  right: 9px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--pine);
  color: var(--sun);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
#board.skunk-win::after { content: "🦨 SKUNK • 121!"; }
#board.summit-celebrate.winner-p0 .peg.p0.front,
#board.summit-celebrate.winner-p1 .peg.p1.front {
  animation: summit-peg 0.62s ease-in-out 3;
}
@keyframes summit-board {
  50% { filter: saturate(1.18) brightness(1.08); }
}
@keyframes summit-peg {
  50% { filter: drop-shadow(0 0 6px #fff3b5); }
}

/* ---------------------------------------------------------- mid-table */

#table {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 0;
  padding: 4px 10px 0;
}

#tableRow {
  display: flex;
  align-items: center;
  gap: clamp(12px, 5vw, 30px);
  min-height: calc(var(--card-w) * 1.4);
}

#deckArea { display: flex; align-items: center; gap: 10px; }
#deckPile {
  position: relative;
  width: calc(var(--card-w) * 0.82);
  aspect-ratio: 5 / 7;
  cursor: pointer;
  touch-action: manipulation;
}
.cardback {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  background:
    radial-gradient(circle at 50% 42%, rgba(246, 239, 220, 0.16) 0 26%, transparent 27%),
    linear-gradient(160deg, var(--maple), var(--maple-deep));
  border: 2.5px solid var(--cream);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--card-w) * 0.34);
}
.cardback.under { z-index: -1; }
.cardback.under span { display: none; }
.cardback.u1 { transform: translate(3px, 3px); }
.cardback.u2 { transform: translate(6px, 6px); }
#deckPile.cuttable .cardback:first-child { animation: beckon 1.4s ease-in-out infinite; }
@keyframes beckon {
  0%, 100% { transform: translateY(0); box-shadow: 0 3px 10px rgba(0,0,0,0.4); }
  50% { transform: translateY(-7px); box-shadow: 0 10px 18px rgba(0,0,0,0.45), 0 0 16px rgba(242,162,74,0.5); }
}

#starterSlot { width: calc(var(--card-w) * 0.82); aspect-ratio: 5 / 7; position: relative; }
#starterSlot .card { position: absolute; inset: 0; width: 100%; cursor: default; }
#starterSlot .card.flip-in { animation: flip-in 0.45s ease-out; }
@keyframes flip-in {
  0% { transform: rotateY(90deg) scale(1.15); }
  100% { transform: rotateY(0); }
}

#playArea {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: calc(var(--card-w) * 2.4);
}
#countBadge {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--cream-dim);
}
#countBadge b {
  display: inline-block;
  margin-left: 5px;
  font-size: 19px;
  color: var(--cream);
  min-width: 30px;
  text-align: center;
}
#countBadge.hot b { color: var(--sun); }
#pile {
  display: flex;
  align-items: center;
  min-height: calc(var(--card-w) * 1.05);
}
#pile .card { width: calc(var(--card-w) * 0.75); cursor: default; }
#pile .card + .card { margin-left: calc(var(--card-w) * -0.34); }
#pile .card:last-child.slap { animation: slap 0.24s cubic-bezier(0.2, 1.4, 0.4, 1); }
#pile .card.spent { opacity: 0.35; filter: saturate(0.5); }
@keyframes slap {
  0% { transform: scale(1.25) rotate(-7deg) translateY(-16px); }
  100% { transform: scale(1) rotate(0) translateY(0); }
}

#msg {
  min-height: 2.6em;
  padding: 0 14px;
  text-align: center;
  font-size: clamp(13px, 2vh, 16px);
  font-weight: 700;
  line-height: 1.3;
  color: var(--cream);
  text-shadow: 0 1px 4px rgba(18, 53, 36, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
}

#actionRow { display: flex; gap: 10px; align-items: center; min-height: 46px; }

.chip-btn {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--cream);
  background: rgba(246, 239, 220, 0.1);
  border: 2px solid rgba(246, 239, 220, 0.3);
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  touch-action: manipulation;
}
.chip-btn:active { background: rgba(246, 239, 220, 0.22); }

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

#handArea {
  position: relative;
  z-index: 2;
  flex: none;
  padding-top: 16px; /* headroom for lifted cards */
}
#handLabel {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--cream-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
}
#hand {
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 16px 18px 10px;
  min-height: calc(var(--card-w) * 1.4 + 30px);
}
#hand::-webkit-scrollbar { display: none; }
#hand::before, #hand::after { content: ""; margin: auto; }

.card {
  flex: none;
  width: var(--card-w);
  aspect-ratio: 5 / 7;
  border-radius: 10px;
  background: linear-gradient(170deg, #ffffff, #f2ecd9);
  border: 2px solid #cfc5a8;
  box-shadow: -3px 3px 8px rgba(0, 0, 0, 0.35);
  position: relative;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#hand .card + .card { margin-left: calc(var(--card-w) * -0.40); }
#hand .card { transform: translateY(6px); }
#hand .card.playable {
  transform: translateY(-8px);
  box-shadow: -3px 6px 12px rgba(0, 0, 0, 0.4), 0 0 14px rgba(242, 162, 74, 0.55);
  border-color: var(--sun);
  z-index: 1;
}
#hand .card.picked {
  transform: translateY(-16px);
  box-shadow: -3px 8px 14px rgba(0, 0, 0, 0.45), 0 0 16px rgba(181, 84, 42, 0.8);
  border-color: var(--maple);
  /* no z-index bump: it would cover the next card's tap strip */
}
#hand .card.dim { opacity: 0.55; }
#hand .card.deal-in { animation: deal-in 0.3s ease-out backwards; }
@keyframes deal-in {
  from { transform: translateY(60px) rotate(6deg); opacity: 0; }
}
#hand .card.nope { animation: nope 0.3s ease; }
@keyframes nope {
  25% { transform: translateY(6px) translateX(-5px) rotate(-3deg); }
  75% { transform: translateY(6px) translateX(5px) rotate(3deg); }
}
.card.red { color: var(--card-red); }
.card.black { color: var(--card-black); }

.card .corner {
  position: absolute;
  top: 5px; left: 6px;
  font-size: calc(var(--card-w) * 0.24);
  font-weight: 900;
  line-height: 1.02;
  text-align: center;
}
.card .corner.flip {
  top: auto; left: auto;
  bottom: 5px; right: 6px;
  transform: rotate(180deg);
}
.card .pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--card-w) * 0.5);
}
#pile .card .corner { font-size: calc(var(--card-w) * 0.2); }
#pile .card .pip { font-size: calc(var(--card-w) * 0.38); }

/* ------------------------------------------------------------- callout */

#callout {
  position: absolute;
  top: 42%;
  left: 0; right: 0;
  z-index: 45;
  text-align: center;
  pointer-events: none;
  animation: callout 1.05s ease forwards;
}
#callout .co-label {
  display: inline-block;
  font-size: clamp(22px, 4.2vh, 32px);
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--cream);
  text-shadow: 0 3px 0 var(--pine), 0 6px 20px rgba(0, 0, 0, 0.5);
  transform: rotate(-2deg);
}
#callout.tier-quiet .co-label {
  font-size: clamp(18px, 3.2vh, 25px);
  color: var(--cream-dim);
  transform: none;
}
#callout.tier-big .co-label {
  font-size: clamp(27px, 5.2vh, 40px);
  color: #ffd28c;
  text-shadow: 0 3px 0 var(--maple-deep), 0 7px 24px rgba(0, 0, 0, 0.55);
}
#callout.tier-summit .co-label {
  font-size: clamp(32px, 6.2vh, 48px);
  color: #fff0a8;
  text-shadow:
    0 3px 0 var(--maple-deep),
    0 0 18px rgba(242, 162, 74, 0.8),
    0 9px 28px rgba(0, 0, 0, 0.58);
}
#callout .co-pts {
  display: block;
  margin-top: 4px;
  font-size: clamp(15px, 2.4vh, 20px);
  font-weight: 900;
  color: var(--sun);
  text-shadow: 0 2px 0 var(--pine);
}
#callout.for-p1 .co-pts { color: #8fd6a8; }
@keyframes callout {
  0% { opacity: 0; transform: scale(0.6); }
  16% { opacity: 1; transform: scale(1.08); }
  28% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: scale(1); }
}

.score-flight {
  position: absolute;
  z-index: 44;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 30px;
  padding: 0 8px;
  border: 2px solid var(--cream);
  border-radius: 999px;
  background: var(--maple);
  color: white;
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.38);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: score-flight 0.78s cubic-bezier(0.3, 0.7, 0.35, 1) forwards;
}
.score-flight.p1 { background: var(--champ); }
@keyframes score-flight {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.75); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  78% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--fly-x)), calc(-50% + var(--fly-y))) scale(0.62);
  }
}

/* ------------------------------------------------------------ the show */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(10, 30, 19, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.show-card {
  width: min(94vw, 400px);
  max-height: 86%;
  background:
    radial-gradient(120% 120% at 50% -10%, #f7eed3, var(--parchment) 60%, #e8d8b0);
  border: 3px solid var(--pine);
  border-radius: 20px;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
#showTitle {
  font-size: clamp(17px, 2.8vh, 22px);
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--pine);
  text-align: center;
}
#showCards { display: flex; gap: 5px; }
#showCards .card { width: calc(var(--card-w) * 0.72); cursor: default; box-shadow: 0 2px 6px rgba(0,0,0,0.25); }
#showCards .card.starter-card { outline: 3px solid var(--sun); outline-offset: -1px; }
#showCards .card.combo-card {
  z-index: 2;
  border-color: var(--maple);
  box-shadow: 0 0 0 3px var(--sun), 0 7px 16px rgba(18, 53, 36, 0.35);
  transform: translateY(-7px);
}
#showCards .card.combo-dim { opacity: 0.38; filter: saturate(0.45); }
#showItems {
  width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}
.show-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 5px 10px;
  border-radius: 9px;
  background: rgba(18, 53, 36, 0.07);
  font-size: 14px;
  font-weight: 700;
  color: var(--pine);
  animation: item-in 0.3s ease-out backwards;
}
@keyframes item-in {
  from { opacity: 0; transform: translateX(-14px); }
}
.show-item .si-cards { font-weight: 600; opacity: 0.75; font-size: 12px; letter-spacing: 0.03em; }
.show-item .si-pts { font-weight: 900; color: var(--maple-deep); white-space: nowrap; }
.show-item.zero { justify-content: center; font-style: italic; opacity: 0.8; }
#showTotal {
  font-size: clamp(19px, 3vh, 25px);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--pine);
  animation: item-in 0.3s ease-out backwards;
}
#showTotal b { color: var(--maple-deep); font-size: 1.15em; }

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

#gameover {
  background: linear-gradient(180deg, rgba(10, 24, 15, 0.12) 0 27%, rgba(10, 24, 15, 0.82) 47%);
}
#gameover .menu-inner {
  justify-content: flex-end;
  padding-top: min(25vh, 190px);
}
#go-card {
  width: min(92vw, 400px);
  background: linear-gradient(180deg, rgba(27, 74, 49, 0.97), rgba(18, 53, 36, 0.97));
  border: 2.5px solid rgba(246, 239, 220, 0.22);
  border-radius: 22px;
  padding: 24px 20px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}
#go-title {
  font-size: clamp(24px, 4.2vh, 34px);
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--sun);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  transform: rotate(-2deg);
}
#go-line {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--cream);
}
#go-score {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--cream-dim);
}
#go-btns { display: flex; gap: 10px; align-items: center; }
#go-btns .big-btn { padding: 11px 26px; font-size: 17px; }

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

#lb {
  width: 100%;
  background: rgba(10, 24, 15, 0.35);
  border: 2px solid rgba(246, 239, 220, 0.18);
  border-radius: 14px;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.lb-tabs { display: flex; gap: 8px; }
.lb-tabs .chip-btn { opacity: 0.65; padding: 7px 12px; }
.lb-tabs .chip-btn.sel {
  opacity: 1;
  background: var(--sun);
  border-color: var(--sun);
  color: var(--pine);
}
.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%;
  max-height: 30vh;
  overflow-y: auto;
  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(242, 162, 74, 0.2); color: var(--sun); }
#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 .chip-btn { padding: 7px 12px; }
.lb-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  color: var(--cream);
  background: rgba(246, 239, 220, 0.1);
  border: 2px solid rgba(246, 239, 220, 0.3);
  border-radius: 10px;
  outline: none;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  user-select: text;
  -webkit-user-select: text;
}
.lb-form input:focus { border-color: var(--sun); }
.lb-rename { padding: 6px 10px; font-size: 11px; opacity: 0.75; }

#brief-cta {
  display: block;
  text-align: center;
  text-decoration: none;
  color: var(--cream);
  font-size: 13px;
  line-height: 1.5;
  background: linear-gradient(180deg, rgba(242, 162, 74, 0.22), rgba(242, 162, 74, 0.12));
  border: 2px solid rgba(242, 162, 74, 0.55);
  border-radius: 14px;
  padding: 10px 18px;
  width: 100%;
}
#brief-cta strong { color: #ffd9a0; font-size: 14px; }
#brief-cta:active { background: rgba(242, 162, 74, 0.3); }

#leaves {
  position: absolute;
  inset: 0;
  z-index: 22;
  overflow: hidden;
  pointer-events: none;
}
.leaf {
  position: absolute;
  top: -22px;
  width: 13px;
  height: 17px;
  border-radius: 80% 15% 75% 20%;
  background: var(--maple);
  box-shadow: inset -2px -2px 0 rgba(80, 35, 18, 0.22);
  animation: leaf-fall 1.8s ease-in forwards;
}
.leaf.gold { background: var(--sun); }
.leaf.green { background: #68a15e; }
@keyframes leaf-fall {
  0% { opacity: 0; transform: translate3d(0, -12px, 0) rotate(0); }
  12% { opacity: 0.92; }
  100% { opacity: 0; transform: translate3d(var(--drift), 105vh, 0) rotate(540deg); }
}

/* ------------------------------------------------------ reduced motion */

@media (prefers-reduced-motion: reduce) {
  .peg { transition: none; }
  .l-cribbage i,
  #deckPile.cuttable .cardback:first-child,
  #board.summit-celebrate,
  #board.winner-p0 .peg.p0.front,
  #board.winner-p1 .peg.p1.front,
  .leaf,
  .score-flight,
  #pile .card:last-child.slap,
  #starterSlot .card.flip-in,
  #hand .card.nope {
    animation: none;
  }
  #hand .card.deal-in,
  #showCards .card,
  .show-item,
  #showTotal { animation: none; }
  #callout { animation-name: callout-reduced; }
}

@keyframes callout-reduced {
  0%, 90% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------------------------------------------------------------- desktop */

@media (min-width: 700px) {
  :root { --card-w: 84px; }
  #board { max-width: 560px; margin-left: auto; margin-right: auto; }
  #hand { justify-content: center; }
}
