/* Cozy Cards — game styles. Builds on /assets/brand.css tokens. */
:root {
  --deck: var(--yellow);
  --deck-soft: var(--yellow-soft);
  --deck-ink: #000;
  --p1: var(--pink);
  --p2: var(--blue);
  --card-r: 26px;
  --card-bd: 3px solid #000;
  --pad-x: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
}
html, body { overflow-x: hidden; }
body { background: var(--beige); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
svg { width: 24px; height: 24px; flex: none; fill: none; }

/* ---------- app shell ---------- */
.app {
  max-width: 1040px; margin: 0 auto;
  padding: env(safe-area-inset-top) var(--pad-x) 0;
  min-height: 100dvh; display: flex; flex-direction: column;
}
.top .site-header { padding-top: 10px; }
.top .site-header .back { min-height: 44px; } /* brand pill is 41px tall; nudge it to a full thumb-sized target */
.view { display: flex; flex-direction: column; gap: 22px; padding-bottom: max(40px, env(safe-area-inset-bottom)); }
html.is-playing { overflow: hidden; overscroll-behavior: none; }
body.is-playing { overflow: hidden; overscroll-behavior: none; position: fixed; inset: 0; width: 100%; touch-action: manipulation; }
body.is-playing .app { height: 100dvh; min-height: 0; overflow: hidden; }
body.is-playing .top .site-header { padding-bottom: 8px; }

/* small reusable buttons */
.icon-btn, .pill-btn, .ctl {
  appearance: none; cursor: pointer; border: var(--bd); background: var(--paper);
  box-shadow: 2px 2px 0 #000; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; min-height: 48px; min-width: 48px; border-radius: 999px; font-weight: 700; font-size: 15px;
  transition: transform .12s var(--ease-bounce), box-shadow .12s, background .15s;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; color: #000;
}
.pill-btn { padding: 0 16px 0 10px; }
.icon-btn:active, .pill-btn:active, .ctl:active { transform: translate(2px, 2px); box-shadow: none; }
.icon-btn:focus-visible, .pill-btn:focus-visible, .ctl:focus-visible, .turn:focus-visible,
.deck-tile:focus-visible, .seg-btn:focus-visible, .fav-heart:focus-visible, .card-heart:focus-visible {
  outline: 3px solid var(--blue-hover); outline-offset: 3px;
}
.icon-btn[aria-pressed="true"] { background: var(--yellow); }
.btn-ico { width: 20px; height: 20px; }
.btn-ico { fill: currentColor; }
.sound-toggle svg { fill: #000; }

/* ---------- HOME ---------- */
.hero {
  position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px;
  padding-top: 4px;
}
.hero h1 { font-size: clamp(46px, 13vw, 88px); margin: 8px 0 12px; letter-spacing: -.035em; }
.hero .hl {
  display: inline-block; background: var(--pink); border: var(--bd); border-radius: 18px;
  padding: 0 .16em .06em; transform: rotate(-3deg); box-shadow: var(--shadow); margin-left: .04em;
}
.lede { font-size: 17px; max-width: 34em; }
.hero-art {
  width: clamp(104px, 28vw, 300px); height: auto; align-self: start; margin-top: 8px;
  transform: rotate(6deg); filter: drop-shadow(4px 5px 0 rgba(0,0,0,.12));
  animation: bob 5s ease-in-out infinite;
}
@keyframes bob { 50% { transform: rotate(3deg) translateY(-6px); } }
.hero-art-btn {
  appearance: none; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; align-self: start;
  touch-action: manipulation; border-radius: 16px; min-width: 48px; min-height: 48px; -webkit-user-select: none; user-select: none;
}
.hero-art-btn:focus-visible { outline: 3px solid var(--blue-hover); outline-offset: 4px; }
.hero-art-btn.spin .hero-art { animation: hero-spin .8s var(--ease-bounce); }
@keyframes hero-spin { 0% { transform: rotate(6deg); } 35% { transform: rotate(-16deg) scale(1.14); } 65% { transform: rotate(18deg) scale(.96); } 100% { transform: rotate(6deg); } }
@media (max-width: 520px) {
  .hero { grid-template-columns: 1fr 104px; }
  .hero-copy { display: contents; }
  .hero .kicker { grid-column: 1; grid-row: 1; }
  .hero h1 { grid-column: 1; grid-row: 2; }
  .hero-art-btn { grid-column: 2; grid-row: 1 / span 2; }
  .hero-art { margin-top: 0; }
  .lede { grid-column: 1 / -1; }
}

.players { display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.names { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.amp { font-weight: 800; font-size: 22px; }
@media (max-width: 359px) { .names { grid-template-columns: 1fr; gap: 6px; } .amp { justify-self: center; font-size: 18px; line-height: 1; } }
.name-field {
  position: relative; display: flex; align-items: center; min-width: 0;
  border: var(--bd); border-radius: 999px; background: var(--beige); padding-left: 12px; min-height: 52px;
}
.name-field:focus-within { background: #fff; outline: 3px solid var(--blue-hover); outline-offset: 2px; }
.name-field .dot { width: 16px; height: 16px; border-radius: 50%; border: var(--bd); flex: none; }
.p1 .dot { background: var(--p1); }
.p2 .dot { background: var(--p2); }
.name-field input {
  appearance: none; border: 0; background: transparent; outline: none; min-width: 0; width: 100%;
  font: 700 17px var(--font); padding: 12px 12px 12px 8px; color: #000;
}
.name-field input::placeholder { color: #8a817a; font-weight: 600; }
.seg {
  display: grid; grid-template-columns: 1fr 1fr; border: var(--bd); border-radius: 999px; padding: 4px;
  background: var(--beige); gap: 4px;
}
.seg-btn {
  appearance: none; border: 2px solid transparent; background: transparent; border-radius: 999px;
  min-height: 44px; font-weight: 700; font-size: 15px; cursor: pointer; touch-action: manipulation; color: #000;
  transition: background .2s, box-shadow .2s;
}
.seg-btn[aria-checked="true"] { background: var(--yellow); border-color: #000; box-shadow: 2px 2px 0 #000; }
.seg-note { font-size: 14px; margin-top: -4px; }

/* mode toggle: Couple vs Co-worker. Big, chunky, impossible to miss. */
.mode-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.mode-btn {
  appearance: none; cursor: pointer; display: flex; align-items: center; gap: 10px; text-align: left;
  min-height: 72px; padding: 10px 12px; border: var(--bd); border-radius: var(--r); background: #fff; color: #000;
  box-shadow: var(--shadow); font: inherit; touch-action: manipulation; -webkit-user-select: none; user-select: none;
  transition: transform .14s var(--ease-bounce), box-shadow .14s, background .2s;
}
.mode-btn img { width: 42px; height: 42px; flex: none; filter: drop-shadow(2px 2px 0 #000); transition: transform .3s var(--ease-bounce); }
.mode-txt { display: flex; flex-direction: column; min-width: 0; }
.mode-btn b { font-size: 17px; font-weight: 800; line-height: 1.15; letter-spacing: -.01em; }
.mode-btn small { font-size: 13px; font-weight: 700; color: var(--muted); line-height: 1.25; }
.mode-btn[aria-checked="true"] { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #000; }
.mode-btn[data-mode="couple"][aria-checked="true"] { background: var(--pink); }
.mode-btn[data-mode="team"][aria-checked="true"] { background: var(--yellow); }
.mode-btn[aria-checked="true"] small { color: #000; }
.mode-btn[aria-checked="true"] img { transform: rotate(-10deg) scale(1.08); }
.mode-btn[aria-checked="false"]:active { transform: translate(4px, 4px); box-shadow: none; }
@media (hover: hover) { .mode-btn[aria-checked="false"]:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 #000; } }
.mode-btn:focus-visible { outline: 3px solid var(--blue-hover); outline-offset: 3px; }
.mode-btn.pop { animation: bump .4s var(--ease-bounce); }
@media (max-width: 479px) {
  .mode-btn { flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 10px 6px; }
  .mode-txt { align-items: center; }
  .mode-btn img { width: 36px; height: 36px; }
  .mode-btn b { font-size: 16px; }
}
.intro .mode-toggle { max-width: 420px; margin-top: 4px; }

/* co-worker roster: 2-8 name pills */
.team-box { display: flex; flex-direction: column; gap: 12px; }
.team-names { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 560px) { .team-names { grid-template-columns: 1fr 1fr; } }
.team-field { padding-right: 4px; }
.team-field .dot { background: var(--pc); }
.rm-player {
  appearance: none; flex: none; cursor: pointer; width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0;
  background: transparent; color: #000; font-size: 26px; font-weight: 700; line-height: 1; display: grid; place-items: center;
  touch-action: manipulation;
}
.rm-player span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: var(--bd); background: #fff; font-size: 20px; padding-bottom: 2px; }
.rm-player:active span { background: var(--orange-soft); transform: scale(.92); }
.rm-player:focus-visible { outline: 3px solid var(--blue-hover); outline-offset: -2px; }
.team-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.add-player { min-height: 48px; padding: 8px 18px 8px 14px; font-size: 16px; box-shadow: 3px 3px 0 #000; }
.add-player .plus { font-size: 22px; line-height: 1; font-weight: 800; }
.team-count { font-size: 14px; font-weight: 700; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-size: 30px; }

.deck-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .deck-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 960px) { .deck-grid { grid-template-columns: 1fr 1fr 1fr; } }
.deck-tile {
  --c: var(--yellow);
  position: relative; appearance: none; cursor: pointer; text-align: left; color: var(--tile-ink, #000);
  display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto auto auto; column-gap: 14px; row-gap: 4px;
  align-items: center; padding: 16px 16px 16px 14px; border: var(--bd); border-radius: var(--r);
  background: var(--c); box-shadow: var(--shadow); font: inherit; overflow: hidden;
  transition: transform .14s var(--ease-bounce), box-shadow .14s; touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
.deck-tile:active { transform: translate(4px, 4px) rotate(-.5deg); box-shadow: 0 0 0 #000; }
@media (hover: hover) { .deck-tile:hover { transform: translate(-2px, -2px) rotate(-.6deg); box-shadow: 6px 6px 0 #000; } }
.deck-tile .tile-icon {
  grid-row: 1 / span 3; width: 64px; height: 64px; filter: drop-shadow(3px 3px 0 #000);
  transition: transform .3s var(--ease-bounce); pointer-events: none;
}
.deck-tile:active .tile-icon { transform: rotate(-14deg) scale(1.1); }
@media (hover: hover) { .deck-tile:hover .tile-icon { transform: rotate(-8deg) scale(1.06); } }
.deck-grid.pop-in .deck-tile { animation: tile-in .55s var(--ease-bounce) both; }
.deck-grid.pop-in .deck-tile:nth-child(2) { animation-delay: .05s; }
.deck-grid.pop-in .deck-tile:nth-child(3) { animation-delay: .1s; }
.deck-grid.pop-in .deck-tile:nth-child(4) { animation-delay: .15s; }
.deck-grid.pop-in .deck-tile:nth-child(5) { animation-delay: .2s; }
.deck-grid.pop-in .deck-tile:nth-child(6) { animation-delay: .25s; }
.deck-grid.pop-in .deck-tile:nth-child(7) { animation-delay: .3s; }
@keyframes tile-in { from { opacity: 0; transform: translateY(22px) rotate(-2deg) scale(.96); } }
.deck-tile h3 { font-size: 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.deck-tile .tile-blurb { font-size: 15px; line-height: 1.35; }
.deck-tile .tile-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; margin-top: 4px; }
.tile-bar { flex: 1; max-width: 120px; height: 10px; border: var(--bd); border-radius: 99px; background: rgba(255,255,255,.6); overflow: hidden; }
.tile-bar span { display: block; height: 100%; background: #000; border-radius: 99px; }
.tile-done {
  flex: none; transform: rotate(4deg); letter-spacing: .06em; line-height: 1.4; background: var(--paper); color: #000;
  border: var(--bd); border-radius: 8px; padding: 2px 10px 2px 8px; font-size: 12px; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase; box-shadow: 2px 2px 0 #000;
}
.deck-tile.grab { background: linear-gradient(rgba(255,255,255,.72), rgba(255,255,255,.72)), #fff url("/assets/static-confetti.png") 30% 40% / 300% auto; }
.deck-tile.favtile { background: var(--pink-soft); }
.deck-tile.favtile.empty { background: #fff; }

.rules { display: flex; flex-direction: column; gap: 12px; }
.rule-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .rule-list { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); } }
.rule-list li { background: #fff; border: var(--bd); border-radius: var(--r-sm); padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; }
.rule-list li b { display: block; font-size: 16px; }
.rule-list li span { font-size: 14px; color: var(--muted); }
.rule-num {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: var(--bd); display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
}
.fine { font-size: 14px; }

/* ---------- PLAY ---------- */
.view-play { flex: 1; min-height: 0; gap: 10px; padding-bottom: 0; width: 100%; max-width: 600px; margin: 0 auto; }
.play-bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; }
@media (max-width: 429px) { #to-decks { padding: 0; } #to-decks span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }
.turn {
  appearance: none; cursor: pointer; justify-self: center; display: inline-flex; align-items: center; gap: 8px;
  min-height: 48px; max-width: 100%; min-width: 0; padding: 0 12px 0 10px; border: var(--bd); border-radius: 999px;
  background: #fff; box-shadow: 2px 2px 0 #000; font-size: 15px; touch-action: manipulation; color: #000;
  transition: transform .12s var(--ease-bounce), box-shadow .12s;
}
.turn:active { transform: translate(2px, 2px); box-shadow: none; }
.turn-dot { width: 18px; height: 18px; border-radius: 50%; border: var(--bd); background: var(--pc, var(--p1)); flex: none; transition: background .25s; }
.turn-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.turn svg { width: 20px; height: 20px; }
.turn.bump { animation: bump .45s var(--ease-bounce); }
@keyframes bump { 40% { transform: scale(1.08) rotate(-2deg); } }

.progress-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.progress-row img { width: 32px; height: 32px; }
.play-name { font-weight: 800; font-size: 14px; }
.progress { height: 12px; border: var(--bd); border-radius: 99px; background: #fff; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--deck); border-right: var(--bd); transition: width .4s var(--ease-bounce); }
.play-count { font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.stage {
  position: relative; flex: 1; min-height: 220px; container-type: size;
  --cw: min(78vw, 300px);
}
@supports (width: 1cqw) { .stage { --cw: min(90cqw, 76cqh, 390px); --ch: min(calc(var(--cw) * 1.4), 96cqh); } }
.pile-card, .card3d {
  position: absolute; inset: 0; margin: auto; width: var(--cw); height: var(--ch, calc(var(--cw) * 1.4));
}
.pile-card {
  border: var(--card-bd); border-radius: var(--card-r); background: var(--deck);
  background-image: radial-gradient(circle at 105% 105%, var(--beige) 0 34%, transparent 34.5%);
  transition: transform .35s var(--ease-bounce), opacity .25s;
}
.pile-card:nth-child(1) { transform: rotate(-5deg) translate(-6px, 6px); }
.pile-card:nth-child(2) { transform: rotate(4deg) translate(6px, 4px); }
.pile-card:nth-child(3) { transform: rotate(-1.5deg) translate(0, 3px); }
.pile.dealing .pile-card { animation: deal-in .5s var(--ease-bounce) both; }
.pile.dealing .pile-card:nth-child(2) { animation-delay: .07s; }
.pile.dealing .pile-card:nth-child(3) { animation-delay: .14s; }
@keyframes deal-in { from { transform: translate(60px, 75vh) rotate(28deg); } }
.card3d.deal { animation: deal .62s var(--ease-bounce) .2s both; }
@keyframes deal { from { transform: translate(-40px, 80vh) rotate(-22deg); } }
.pile.shuffling .pile-card:nth-child(1) { animation: shuf1 .6s ease-in-out; }
.pile.shuffling .pile-card:nth-child(2) { animation: shuf2 .6s ease-in-out; }
@keyframes shuf1 { 30% { transform: rotate(-12deg) translate(-70px, -6px); } 60% { transform: rotate(6deg) translate(30px, 0); } }
@keyframes shuf2 { 30% { transform: rotate(12deg) translate(70px, -6px); } 60% { transform: rotate(-6deg) translate(-30px, 0); } }

.card3d {
  perspective: 1600px; touch-action: none; cursor: grab; z-index: 2;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.card3d.dragging { cursor: grabbing; }
.card3d.enter { animation: enter .42s var(--ease-bounce) both; }
@keyframes enter { from { transform: translateY(14px) rotate(-3deg) scale(.96); } }
.card3d.enter-left { animation: enter-left .42s var(--ease-bounce) both; }
@keyframes enter-left { from { transform: translateX(-110%) rotate(-14deg); } }
.card3d:focus-visible { outline: none; }
.card3d:focus-visible .face { outline: 3px solid var(--blue-hover); outline-offset: 4px; }
.flipper {
  position: absolute; inset: 0; transform-style: preserve-3d; -webkit-transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.3, 1.35, .45, 1);
}
.card3d.flipped .flipper { transform: rotateY(180deg); }
.card3d.lift .flipper { animation: lift .7s ease-out; }
@keyframes lift { 45% { scale: 1.08; } }
.face {
  position: absolute; inset: 0; border: var(--card-bd); border-radius: var(--card-r);
  backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: var(--shadow-lg);
  overflow: hidden; transform: rotateY(0deg);
}
/* Belt and braces for the flip: swap which face is visible right as the card passes edge-on (~85ms into the
   .7s bouncy flip). Keeps the hidden side's buttons out of tap/Tab reach, and stops engines that ignore
   backface-visibility (some WebViews, software rendering) from showing the front mirrored while face-down. */
.face-front { visibility: hidden; transition: visibility 0s .085s; }
.card3d.flipped .face-front { visibility: visible; }
.card3d.flipped .face-back { visibility: hidden; transition: visibility 0s .085s; }

/* card back: deck color with the beige blobs from the printed deck */
.face-back { background: var(--deck); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4%; color: var(--deck-ink); }
.face-back::before, .face-back::after { content: ""; position: absolute; background: var(--beige); border: var(--card-bd); }
.face-back::before { width: 78%; aspect-ratio: 1; border-radius: 50%; right: -30%; bottom: -24%; }
.face-back::after { width: 120%; height: 22%; left: -20%; top: -6%; transform: rotate(-24deg); }
.face-back > * { position: relative; z-index: 1; }
.back-icon { width: 46%; aspect-ratio: 1; filter: drop-shadow(5px 5px 0 #000); pointer-events: none; }
.back-name { font-weight: 800; font-size: calc(var(--cw) * .1); letter-spacing: -.03em; text-align: center; line-height: 1; padding: 0 8%; }
.back-who {
  display: flex; max-width: 84%; min-width: 0; background: #000; color: #fff; border-radius: 99px;
  padding: 4px 12px; font-weight: 800; font-size: 15px; line-height: 1.25; transform: rotate(-3deg); margin-bottom: -1%;
}
.bw-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bw-rest { flex: none; white-space: nowrap; }
.back-tap {
  font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; background: #fff; color: #000;
  border: var(--bd); border-radius: 99px; padding: 4px 12px;
}
.back-logo { position: absolute; bottom: 5%; left: 7%; background: #fff; border: var(--bd); border-radius: 99px; padding: 6px 12px; }
.back-logo img { height: 15px; width: auto; }

/* card front: white card, stairs in the corner, wordmark at the bottom */
.face-front::after {
  content: ""; position: absolute; inset: -10% -60%; pointer-events: none; z-index: 4; opacity: 0;
  background: linear-gradient(105deg, transparent 40%, var(--deck) 50%, transparent 60%); mix-blend-mode: multiply;
}
.card3d.lift .face-front::after { animation: sheen .9s .32s ease-out; }
@keyframes sheen { 0% { transform: translateX(-60%); opacity: .45; } 100% { transform: translateX(60%); opacity: .45; } }
.stamp {
  position: absolute; top: 5%; z-index: 3; pointer-events: none; padding: 4px 14px; border: 4px solid currentColor;
  border-radius: 14px; font-weight: 900; font-size: calc(var(--cw) * .11); letter-spacing: .03em; text-transform: uppercase;
  background: #fff; line-height: 1.1; box-shadow: 3px 3px 0 currentColor;
}
.stamp-done { left: 7%; color: var(--blue-hover); opacity: var(--done, 0); transform: rotate(-14deg) scale(calc(.7 + var(--done, 0) * .3)); }
.stamp-skip { right: 7%; color: var(--orange-hover); opacity: var(--skip, 0); transform: rotate(14deg) scale(calc(.7 + var(--skip, 0) * .3)); }
.face-front {
  background: #fff; transform: rotateY(180deg); display: flex; flex-direction: column;
  padding: calc(var(--cw) * .065) calc(var(--cw) * .07) calc(var(--cw) * .05);
}
.front-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.front-tags { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; flex: 1; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; border: var(--bd); border-radius: 99px;
  padding: 3px 10px; font-size: 12px; font-weight: 800; letter-spacing: .04em; white-space: nowrap; background: #fff;
  max-width: 100%; min-width: 0;
}
.tag .tl { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tag .tdot { flex: none; }
.tag .tdot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #000; background: var(--pc, var(--p1)); }
.tag.both .tdot { background: linear-gradient(90deg, var(--p1) 50%, var(--p2) 50%); }
.tag.tag-mech { background: var(--deck-soft); }
.stairs { width: calc(var(--cw) * .2); height: auto; aspect-ratio: 116 / 96; flex: none; fill: var(--deck); }
.prompt {
  flex: 1; min-height: 0; display: flex; align-items: center; overflow: hidden;
  font-weight: 700; letter-spacing: -.02em; line-height: 1.14; font-size: 26px;
  padding: 6px 0; text-wrap: pretty;
}
.prompt p { width: 100%; }
.front-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.front-foot .wm { height: calc(var(--cw) * .062); min-height: 14px; width: auto; }
.front-foot .no { display: flex; font-size: 12px; font-weight: 700; color: var(--muted); margin-left: auto; margin-right: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 0; }
.front-foot .no .dn { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.front-foot .no .nn { flex: none; }
.card3d.foot-stack .front-foot .no { flex-direction: column; align-items: flex-end; line-height: 1.2; text-align: right; }
.card3d.foot-stack .front-foot .no .sep { display: none; }
.card-heart {
  appearance: none; border: var(--bd); background: #fff; border-radius: 50%; width: 48px; height: 48px;
  display: grid; place-items: center; cursor: pointer; touch-action: manipulation; padding: 0; flex: none;
  transition: transform .15s var(--ease-bounce), background .2s;
}
.card-heart svg { width: 24px; height: 24px; }
.card-heart svg, .ctl-heart svg { fill: transparent; transition: fill .2s; }
.card-heart.on { background: var(--pink-soft); }
.card-heart.on svg, .ctl-heart[aria-pressed="true"] svg { fill: var(--pink-hover); }
.ctl-heart[aria-pressed="true"] { background: var(--pink-soft); }
.card-heart.pop, .ctl-heart.pop { animation: heartpop .5s var(--ease-bounce); }
@keyframes heartpop { 35% { transform: scale(1.35) rotate(-8deg); } }
/* mechanics area (timer / count / tally) */
.mech { display: flex; align-items: center; gap: 12px; padding: 8px 0 10px; }
.ring { position: relative; width: calc(var(--cw) * .27); min-width: 72px; aspect-ratio: 1; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .trk { stroke: var(--beige); }
.ring .bar { stroke: var(--deck); transition: stroke-dashoffset .25s linear; }
.ring .num {
  position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800;
  font-size: calc(var(--cw) * .085); font-variant-numeric: tabular-nums; letter-spacing: -.03em;
}
.ring.urgent .num { animation: tick .5s ease-out; color: var(--orange-hover); }
@keyframes tick { 30% { transform: scale(1.25); } }
.mech-btns { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.mbtn {
  appearance: none; cursor: pointer; border: var(--bd); border-radius: 999px; background: var(--deck); color: var(--deck-ink);
  min-height: 48px; padding: 0 14px; font-weight: 800; font-size: 16px; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; box-shadow: 3px 3px 0 #000; touch-action: manipulation;
  transition: transform .12s var(--ease-bounce), box-shadow .12s;
}
.mbtn svg { width: 18px; height: 18px; }
.mbtn svg { fill: currentColor; }
.mbtn:active { transform: translate(3px, 3px); box-shadow: none; }
.mbtn.ghost { background: #fff; color: #000; }
.mbtn:focus-visible { outline: 3px solid var(--blue-hover); outline-offset: 2px; }
.tally-row { display: flex; gap: 8px; align-items: center; }
.tally-row .mbtn { flex: 1; }
.tally-num {
  min-width: 48px; height: 48px; border-radius: 50%; border: var(--bd); display: grid; place-items: center;
  font-weight: 800; font-size: 20px; background: var(--deck-soft); font-variant-numeric: tabular-nums;
}
.tally-num.bump { animation: bump .35s var(--ease-bounce); }
.mech-msg { font-weight: 800; font-size: 15px; }
.card3d.ding .face.face-front { animation: ding .6s var(--ease-bounce); }
@keyframes ding { 20% { transform: rotateY(180deg) rotate(-3deg); } 50% { transform: rotateY(180deg) rotate(3deg); } 80% { transform: rotateY(180deg) rotate(-1deg); } }

.card3d.compact .mech-msg { display: none; }
.card3d.compact .back-icon { width: 36%; }
.card3d.compact .face-back { gap: 3%; padding-bottom: 8%; }
.card3d.compact .back-who { font-size: 13px; }
.card3d.compact .back-tap { font-size: 12px; padding: 3px 10px; }
.card3d.compact .front-tags .tag-mech.redundant, .card3d.tags-wrap .front-tags .tag-mech.redundant { display: none; }
.card3d.compact .ring { min-width: 62px; }
.card3d.compact .mech { padding: 4px 0 6px; gap: 10px; }
.card3d.compact .face-front { padding: 14px 14px 10px; }
.card3d.compact .card-heart { width: 44px; height: 44px; }
.card3d.compact .mbtn { padding: 0 10px; font-size: 15px; }

/* fly-away */
.card3d.fly { transition: transform .45s cubic-bezier(.5, 0, .75, 0), opacity .45s; opacity: 0; pointer-events: none; }
.card3d.snap { transition: transform .45s var(--ease-bounce); }

/* 3-2-1 overlay */
.countdown {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; pointer-events: none;
}
.countdown span {
  display: grid; place-items: center; width: calc(var(--cw) * .62); aspect-ratio: 1; border-radius: 50%;
  background: var(--deck); color: var(--deck-ink); border: var(--card-bd); box-shadow: var(--shadow-lg);
  font-weight: 800; font-size: calc(var(--cw) * .3); letter-spacing: -.04em; animation: cd .8s var(--ease-bounce) both;
}
.countdown span.go { font-size: calc(var(--cw) * .17); background: var(--yellow); color: #000; }
@keyframes cd { 0% { transform: scale(.3) rotate(-20deg); opacity: 0; } 25% { transform: scale(1.06); opacity: 1; } 80% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }

.hint { text-align: center; font-size: 14px; font-weight: 700; color: var(--muted); min-height: 21px; transition: opacity .2s; }
.controls {
  display: grid; grid-template-columns: 52px 52px minmax(0, 1fr) 52px; gap: 10px; align-items: center;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  width: 100%; max-width: 460px; margin: 0 auto;
}
.ctl { width: 52px; height: 52px; padding: 0; }
.ctl[disabled] { opacity: .4; pointer-events: none; }
.btn-main { background: var(--deck); color: var(--deck-ink); min-height: 56px; padding: 10px 16px; }
.btn-main span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 359px) { .controls { gap: 8px; grid-template-columns: 50px 50px minmax(0, 1fr) 50px; } .ctl { width: 50px; height: 50px; } .btn-main { padding: 10px 12px; font-size: 16px; } }
.keys { display: none; text-align: center; font-size: 13px; padding-bottom: 14px; margin-top: -6px; }
@media (hover: hover) and (pointer: fine) and (min-height: 700px) { .keys { display: block; } .controls { padding-bottom: 6px; } }
@media (min-width: 700px) and (min-height: 700px) { .view-play { gap: 14px; } .stage { min-height: 380px; } }
@media (max-height: 640px) and (orientation: portrait) {
  body.is-playing .top .site-header { padding-top: 6px; padding-bottom: 4px; }
  .view-play { gap: 8px; }
  .hint { display: none; }
  .stage { min-height: 200px; }
}
/* phone in landscape: card on the left, everything else stacked on the right */
@media (orientation: landscape) and (max-height: 540px) {
  body.is-playing .app {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    grid-template-rows: auto auto auto 1fr auto; column-gap: 20px; row-gap: 8px;
    grid-template-areas: "stage top" "stage bar" "stage prog" "stage hint" "stage ctl";
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.is-playing .top { grid-area: top; }
  body.is-playing .top .site-header { padding: 6px 0 0; }
  .view-play { display: contents; }
  .play-bar { grid-area: bar; }
  .progress-row { grid-area: prog; }
  .stage { grid-area: stage; min-height: 0; margin: 8px 0; }
  .hint { grid-area: hint; align-self: center; }
  .controls { grid-area: ctl; padding-bottom: max(10px, env(safe-area-inset-bottom)); max-width: none; }
  .keys { display: none !important; }
  #to-decks { padding: 0; }
  #to-decks span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

/* ---------- FAVORITES ---------- */
.favs-head { display: flex; align-items: center; gap: 14px; }
.favs-head h1 { font-size: clamp(34px, 9vw, 52px); }
.favs-sub { margin-top: -10px; }
.fav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
@media (min-width: 720px) { .fav-list { grid-template-columns: 1fr 1fr; } }
.fav-item {
  position: relative; background: #fff; border: var(--bd); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 14px 14px 14px 20px; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; overflow: hidden;
  transition: transform .3s var(--ease-bounce), opacity .3s;
}
.fav-item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 10px; background: var(--c); border-right: var(--bd); }
.fav-item .fav-deck { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.fav-item .fav-deck img { width: 28px; height: 28px; }
.fav-item p { grid-column: 1; font-weight: 700; font-size: 18px; line-height: 1.25; letter-spacing: -.01em; }
.fav-heart {
  grid-column: 2; grid-row: 1 / span 2; align-self: start; appearance: none; width: 48px; height: 48px; border-radius: 50%;
  border: var(--bd); background: var(--pink-soft); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.fav-heart svg { fill: var(--pink-hover); }
.fav-item.gone { opacity: 0; transform: scale(.9) rotate(-2deg); }
.fav-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 32px 20px; box-shadow: var(--shadow); }
.fav-empty h2 { font-size: 26px; }

/* ---------- END OF DECK ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; overflow-y: auto; overscroll-behavior: contain;
  padding: max(20px, env(safe-area-inset-top)) var(--pad-x) max(20px, env(safe-area-inset-bottom));
  background: rgba(240, 234, 229, .9); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fade .3s ease both;
}
@keyframes fade { from { opacity: 0; } }
.cert {
  position: relative; z-index: 2; width: 100%; max-width: 420px; margin: auto; background: #fff; border: var(--card-bd);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 28px 22px 22px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  animation: certin .6s var(--ease-bounce) both .1s;
  background-image: repeating-linear-gradient(45deg, transparent 0 14px, rgba(0,0,0,.025) 14px 15px);
}
.cert::before { content: ""; position: absolute; inset: 8px; border: 1.5px dashed #000; border-radius: calc(var(--r-lg) - 8px); pointer-events: none; opacity: .35; }
@keyframes spin-in { from { transform: rotate(-200deg) scale(0); } }
@keyframes certin { from { transform: translateY(40px) scale(.9) rotate(-3deg); opacity: 0; } }
.cert-seal-wrap { position: relative; display: grid; place-items: center; width: 160px; height: 112px; }
.spark { position: absolute; width: 30px; height: 30px; animation: twinkle 1.8s ease-in-out infinite; }
.spark.s1 { left: 6px; top: 8px; fill: var(--yellow); }
.spark.s2 { right: 10px; top: 0; width: 22px; height: 22px; fill: var(--pink); animation-delay: .6s; }
.spark.s3 { right: 18px; bottom: 4px; width: 26px; height: 26px; fill: var(--blue); animation-delay: 1.1s; }
@keyframes twinkle { 50% { transform: scale(.6) rotate(45deg); opacity: .7; } }
.cert-logo { height: 20px; width: auto; margin-top: -4px; }
.cert h2 { font-size: 38px; }
.cert-body { font-size: 17px; max-width: 28em; }
.cert-body b { white-space: nowrap; }
.cert-seal {
  width: 84px; height: 84px; display: grid; place-items: center;
  filter: drop-shadow(4px 4px 0 #000); transform: rotate(-8deg); position: relative; animation: spin-in .8s var(--ease-bounce) both .35s;
}
.cert-seal img { width: 84px; height: 84px; }
.cert-stats { font-size: 14px; font-weight: 700; color: var(--muted); }
.cert-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: 6px; }
.cert-row { display: flex; gap: 10px; }
.cert-row .btn { flex: 1; min-width: 0; padding: 12px 10px; }
.cert-body b { background: var(--deck-soft); border-radius: 6px; padding: 0 4px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.confetti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border: 1.5px solid #000; border-radius: 2px;
  animation: fall var(--d, 3s) cubic-bezier(.3, .4, .6, 1) var(--delay, 0s) forwards;
}
.confetti i.round { border-radius: 50%; width: 12px; height: 12px; }
@keyframes fall {
  0% { transform: translate3d(0, 0, 0) rotate(0); opacity: 1; }
  100% { transform: translate3d(var(--dx, 0), 110dvh, 0) rotate(var(--rot, 540deg)); opacity: 1; }
}
.burst { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; z-index: 6; }
.burst i {
  position: absolute; width: 9px; height: 9px; border: 1.5px solid #000; border-radius: 2px;
  animation: pop .8s cubic-bezier(.2, .8, .3, 1) forwards;
}
@keyframes pop { to { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; } }
.hearts { position: fixed; width: 0; height: 0; z-index: 61; pointer-events: none; }
.hearts svg {
  position: absolute; left: -12px; top: -12px; width: 24px; height: 24px; fill: var(--pink-hover);
  animation: rise 1.1s cubic-bezier(.2, .7, .3, 1) var(--dl, 0ms) both;
}
@keyframes rise {
  0% { transform: translate(0, 0) scale(.3); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(var(--x), -130px) scale(var(--s, 1)); opacity: 0; }
}
#done-save .btn-ico { fill: none; }

/* ---------- INTRO ---------- */
html.intro-open, html.intro-open body { overflow: hidden; }
.intro {
  position: fixed; inset: 0; z-index: 55; display: flex; overflow-y: auto; overscroll-behavior: contain;
  padding: max(24px, env(safe-area-inset-top)) var(--pad-x) max(24px, env(safe-area-inset-bottom));
  background: var(--beige);
  background-image: radial-gradient(circle at 8% 10%, var(--yellow-soft) 0 16vmax, transparent 16.2vmax),
    radial-gradient(circle at 96% 92%, var(--pink-soft) 0 20vmax, transparent 20.2vmax);
}
.intro-inner { margin: auto; width: 100%; max-width: 560px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.intro-fan { position: relative; width: 250px; height: 200px; margin-bottom: 4px; animation: bob 5s ease-in-out 1.2s infinite; }
.ifan {
  position: absolute; left: 50%; top: 12px; width: 120px; height: 168px; margin-left: -60px; overflow: hidden;
  border: 3px solid #000; border-radius: 18px; box-shadow: var(--shadow); display: grid; place-items: center;
  transform-origin: 50% 115%; transform: translateX(var(--tx)) rotate(var(--rot));
  animation: fan-in .8s var(--ease-bounce) both;
}
.ifan::after {
  content: ""; position: absolute; width: 74%; aspect-ratio: 1; border-radius: 50%; background: var(--beige);
  border: 3px solid #000; right: -30%; bottom: -24%;
}
.ifan img { width: 62%; position: relative; z-index: 1; filter: drop-shadow(3px 3px 0 #000); }
.ifan-1 { background: var(--blue); --rot: -17deg; --tx: -56px; --ox: -70vw; --oy: -10vh; --orot: -60deg; animation-delay: .1s; }
.ifan-2 { background: var(--orange); --rot: 0deg; --tx: 0px; --ox: 0px; --oy: -80vh; --orot: 10deg; animation-delay: .22s; z-index: 1; }
.ifan-3 { background: var(--yellow); --rot: 17deg; --tx: 56px; --ox: 70vw; --oy: -10vh; --orot: 60deg; animation-delay: .34s; z-index: 2; }
@keyframes fan-in { from { transform: translateY(70px) rotate(0deg) scale(.8); opacity: 0; } }
.ispark { position: absolute; z-index: 3; stroke: #000; animation: twinkle 1.8s ease-in-out infinite; }
.ispark.is1 { width: 34px; height: 34px; left: 4px; top: 0; fill: var(--yellow); }
.ispark.is2 { width: 26px; height: 26px; right: 6px; top: 26px; fill: var(--pink); animation-delay: .7s; }
.intro-kicker { opacity: .8; }
.intro-h { font-size: clamp(54px, 16vw, 84px); letter-spacing: -.035em; }
.intro .hl {
  display: inline-block; background: var(--pink); border: var(--bd); border-radius: 18px;
  padding: 0 .16em .06em; transform: rotate(-3deg); box-shadow: var(--shadow); margin-left: .04em;
}
.intro-line { font-size: 17px; max-width: 25em; margin-top: 6px; }
.intro-h { white-space: nowrap; }
.intro-line q { font-weight: 700; }
.intro-go { min-width: 230px; min-height: 58px; font-size: 19px; margin-top: 8px; animation: nudge 3s ease-in-out 1.6s infinite; }
@keyframes nudge { 0%, 82%, 100% { rotate: 0deg; } 86% { rotate: -4deg; } 91% { rotate: 4deg; } 96% { rotate: -2deg; } }
.intro-fine { font-size: 13px; font-weight: 800; letter-spacing: .06em; color: var(--muted); }
.intro.leaving { pointer-events: none; animation: intro-out .3s ease .42s forwards; }
.intro.leaving .intro-fan { animation: none; }
.intro.leaving .ifan { animation: deal-out .55s cubic-bezier(.5, 0, .75, 0) forwards; }
.intro.leaving .ifan-2 { animation-delay: .06s; }
.intro.leaving .ifan-3 { animation-delay: .12s; }
.intro.leaving .intro-inner > :not(.intro-fan) { opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; }
@keyframes deal-out { to { transform: translate(var(--ox), var(--oy)) rotate(var(--orot)); } }
@keyframes intro-out { to { opacity: 0; } }
@media (max-height: 640px) {
  .intro-inner { gap: 10px; }
  .intro-fan { width: 210px; height: 150px; }
  .ifan { width: 90px; height: 126px; margin-left: -45px; top: 8px; }
  .ifan-1 { --tx: -44px; } .ifan-3 { --tx: 44px; }
  .intro-line { font-size: 15px; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); z-index: 60;
  transform: translate(-50%, -24px); border: 2px solid #000; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  background: var(--yellow); color: #000; font-weight: 800; font-size: 15px; padding: 10px 18px; border-radius: 99px;
  transition: transform .3s var(--ease-bounce), opacity .2s; width: max-content; max-width: min(calc(100vw - 32px), 420px);
  text-align: center; line-height: 1.25;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .face-front, .card3d.flipped .face-back { transition-delay: 0s !important; }
  .hero-art { animation: none; }
  .confetti, .burst, .hearts { display: none; }
  .intro-go { animation: none; }
}
