:root {
  --dusk: #2F2B5E; --lavender: #5A4E95; --sky-low: #9C86C4; --horizon: #E9B8C9;
  --night: #272250; --back: #3B3577;
  --cream: #FFF6E6; --kraft: #E6CFA6; --kraft-ink: #5B3E22; --ink: #2B2552; --soft: #CFC4F0; --gold: #FFE6A8;
  --peony: #F4978E; --mum: #F9C74F; --willow: #8FD3B0; --comet: #8EC1F5; --halo: #C9B1F0;
  --peony-ink: #A83A31;
  --ui: 'Fredoka', ui-rounded, system-ui, sans-serif;
  --crayon: 'Caveat Brush', 'Comic Sans MS', cursive;
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .28  0 0 0 0 .2  0 0 0 .16 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --paper-shadow: 2px 3px 0 rgba(20, 12, 52, .32), 0 6px 14px rgba(20, 12, 52, .18);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: linear-gradient(var(--dusk) 0%, var(--lavender) 48%, var(--sky-low) 80%, var(--horizon) 100%) fixed var(--dusk);
  color: var(--cream); font-family: var(--ui); font-weight: 500;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px dashed var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ---------- paper primitives ---------- */
.paper-card {
  background: var(--grain), var(--cream); color: var(--ink);
  box-shadow: var(--paper-shadow);
  border-radius: 3px 5px 2px 6px / 5px 2px 6px 3px;
}
.btn {
  --bg: var(--cream);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  border: 0; cursor: pointer; padding: .7em 1.2em; min-height: 44px;
  background: var(--grain), var(--bg); color: var(--ink);
  font-weight: 600; font-size: 1.05rem;
  border-radius: 2px 4px 3px 5px / 4px 2px 5px 3px;
  box-shadow: 2px 3px 0 rgba(20, 12, 52, .38);
  transform: rotate(-.4deg);
  transition: transform .12s, box-shadow .12s;
}
.btn:hover:not(:disabled) { transform: rotate(-.4deg) translateY(-1px); box-shadow: 3px 5px 0 rgba(20, 12, 52, .38); }
.btn:active:not(:disabled) { transform: rotate(-.4deg) translateY(1px); box-shadow: 1px 1px 0 rgba(20, 12, 52, .38); }
.btn:disabled { cursor: not-allowed; filter: saturate(.35); opacity: .55; }
.btn.mum { --bg: var(--mum); } .btn.halo { --bg: var(--halo); } .btn.cream { --bg: var(--cream); }
.btn.small { min-height: 36px; padding: .4em .9em; font-size: .95rem; }
.btn.big { font-size: 1.2rem; padding: .8em 1.6em; }
.chip {
  border: 0; cursor: pointer; min-width: 44px; min-height: 44px; padding: .3em .8em;
  background: var(--grain), var(--cream); color: var(--ink); font-weight: 600;
  border-radius: 3px 5px 2px 4px; box-shadow: 1px 2px 0 rgba(20, 12, 52, .3);
}
.chip.on { background: var(--grain), var(--mum); box-shadow: inset 0 0 0 2px var(--ink), 1px 2px 0 rgba(20, 12, 52, .3); }
.chip:disabled { opacity: .3; cursor: not-allowed; }
.chip.round { border-radius: 50% 46% 52% 48%; width: 48px; height: 48px; padding: 0; display: grid; place-items: center; }
.chip.num { font-family: var(--crayon); font-size: 1.7rem; }
.avatar {
  display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none;
  border-radius: 50% 46% 52% 48%; background: var(--c); color: var(--ink);
  font-size: .85rem; font-weight: 600; box-shadow: 1px 1px 0 rgba(20, 12, 52, .3);
}
.badge { font-size: .72rem; padding: .1em .5em; border-radius: 2px; background: rgba(43, 37, 82, .12); color: var(--ink); }
.badge.away { background: #F2C4BE; } .badge.host { background: #FFF0C7; }
.logo { display: block; height: auto; overflow: visible; }

/* ---------- cards ---------- */
.card {
  --cw: 80px;
  position: relative; display: block; flex: none; padding: 0; border: 0; background: none;
  width: var(--cw); aspect-ratio: 114 / 156; transform: rotate(var(--rot, 0deg));
}
.card > svg:first-child { width: 100%; height: 100%; display: block; overflow: visible; }
.card .ring { position: absolute; inset: -6%; width: 112%; height: 112%; pointer-events: none; }
.card .pin {
  position: absolute; left: 50%; top: -5%; width: 9%; height: 16%; translate: -50% 0;
  background: #D9A66B; border-radius: 2px; box-shadow: 0 1px 1px rgba(0, 0, 0, .3);
  background-image: linear-gradient(transparent 45%, #A87440 45% 55%, transparent 55%);
}
.card.pre { visibility: hidden; }
.card.pinged { animation: ping 1.8s ease-out; }
@keyframes ping {
  0% { filter: none; }
  20% { transform: rotate(var(--rot)) translateY(-10px); filter: drop-shadow(0 0 10px #FFE08A); }
  60% { filter: drop-shadow(0 0 10px #FFE08A); }
  100% { transform: rotate(var(--rot)); filter: none; }
}

/* ---------- home ---------- */
.home { min-height: 100dvh; display: grid; place-items: center; padding: 32px 16px; position: relative; overflow: hidden; }
.home-sky { position: absolute; inset: 0; pointer-events: none; }
.home-burst { position: absolute; width: 340px; opacity: .9; }
.home-burst.b0 { left: -40px; top: 30px; } .home-burst.b1 { right: -20px; top: 90px; width: 300px; } .home-burst.b2 { left: 12%; bottom: -60px; width: 380px; }
.home-card { position: relative; width: min(760px, 100%); padding: 28px clamp(18px, 4vw, 44px) 26px; }
.home-logo { margin: 0 auto; width: min(460px, 100%); }
.tagline { text-align: center; font-family: var(--crayon); font-size: 1.5rem; color: #5E4E96; margin: 4px 0 20px; }
.field { display: flex; flex-direction: column; gap: 4px; max-width: 320px; margin: 0 auto 22px; }
.field span { font-size: .95rem; color: #5B4E8A; }
input {
  font: inherit; font-size: 1.1rem; color: var(--ink); min-height: 44px; padding: .45em .7em; width: 100%;
  background: #FFFDF7; border: 2px solid #CDBFE6; border-radius: 3px 5px 2px 4px;
}
input:focus { outline: none; border-color: var(--ink); }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.choice { background: var(--grain), #F3EAFB; padding: 16px 18px 18px; border-radius: 2px 4px 3px 5px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.choice:nth-child(2) { background: var(--grain), #FFF1D6; }
.choice h2 { margin: 0; font-size: 1.3rem; }
.choice p { margin: 0; color: #5B4E8A; font-size: .95rem; }
.chips { display: flex; gap: 8px; align-items: center; }
.chips:not(.plain)::after { content: 'computer players'; font-size: .9rem; color: #5B4E8A; margin-left: 4px; }
.levels { display: flex; flex-direction: column; gap: 4px; }
.level-blurb { margin: 0; font-family: var(--crayon); font-size: 1.15rem !important; color: #5E4E96 !important; min-height: 2.6em; }
.join { display: flex; gap: 8px; width: 100%; }
.join input { text-transform: uppercase; letter-spacing: .2em; max-width: 120px; }
.form-error { background: #FBE0DC; color: var(--peony-ink); padding: .6em .9em; border-radius: 3px; text-align: center; }
.howto { margin-top: 18px; color: var(--ink); }
.howto summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.howto ul { margin: 8px 0 0; padding-left: 1.2em; line-height: 1.5; max-width: 68ch; }
.howto li { margin-bottom: 6px; }
.loading { min-height: 100dvh; display: grid; place-items: center; font-family: var(--crayon); font-size: 1.8rem; color: var(--gold); }

/* ---------- lobby ---------- */
.lobby { min-height: 100dvh; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.lobby-top { width: min(760px, 100%); display: flex; justify-content: space-between; align-items: center; }
.lobby-top .brand { width: 220px; }
.lobby-card { width: min(760px, 100%); padding: 24px clamp(16px, 4vw, 36px); }
.lobby-card h1 { margin: 0 0 6px; font-size: 1.6rem; }
.lobby-card h2 { font-size: 1.15rem; margin: 22px 0 8px; } .lobby-card h2 small { font-weight: 500; color: #6B5E9E; }
.code { font-family: var(--crayon); letter-spacing: .12em; background: #FFF0C7; padding: 0 .35em; border-radius: 2px; color: var(--ink); }
.invite { display: flex; gap: 8px; }
.seats { list-style: none; padding: 18px 0 4px; margin: 0; display: flex; flex-wrap: wrap; gap: 18px 14px; position: relative; }
.seats::before { content: ''; position: absolute; left: -10px; right: -10px; top: 0; height: 18px; border-bottom: 2px solid #CDB894; border-radius: 0 0 50% 50% / 0 0 100% 100%; }
.seat { position: relative; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--grain), #F3EAFB; border-radius: 2px 4px 3px 5px; box-shadow: 1px 2px 0 rgba(20, 12, 52, .25); }
.seat:nth-child(even) { transform: rotate(1deg); } .seat:nth-child(odd) { transform: rotate(-1deg); }
.seat .pin { position: absolute; top: -14px; left: 50%; width: 8px; height: 20px; background: #D9A66B; border-radius: 2px; translate: -50% 0; }
.seat .x { border: 0; background: none; cursor: pointer; min-width: 32px; min-height: 32px; color: var(--peony-ink); font-size: 1rem; }
.host-controls { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; align-items: center; }
.waiting, .note { font-family: var(--crayon); font-size: 1.35rem; color: #5E4E96; margin: 18px 0 0; }

/* ---------- game layout ---------- */
.game {
  display: grid; height: 100dvh; overflow: hidden;
  grid-template-columns: minmax(0, 1fr) 272px;
  grid-template-rows: auto auto minmax(200px, 1fr) auto;
  grid-template-areas: "top panel" "line panel" "sky panel" "ground panel";
}
.topbar { grid-area: top; display: flex; align-items: center; gap: 16px; padding: 10px 18px 4px; min-width: 0; }
.topbar .brand { width: 190px; flex: none; }
.turnbar {
  display: flex; align-items: center; gap: 10px; padding: 6px 16px 6px 8px; min-height: 44px; margin: 0 auto;
  background: var(--grain), var(--cream); color: var(--ink); border-radius: 2px 4px 3px 5px; box-shadow: 2px 3px 0 rgba(20, 12, 52, .32);
  max-width: 100%; min-width: 0;
}
.turnbar .lantern { width: 34px; height: 34px; flex: none; }
.turnbar strong { font-size: 1.15rem; white-space: nowrap; }
.turnbar span { font-family: var(--crayon); font-size: 1.25rem; color: #6B5E9E; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turnbar.mine { background: var(--grain), #FFF0C7; animation: glow 2.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 2px 3px 0 rgba(20, 12, 52, .32), 0 0 22px rgba(255, 210, 120, .55); } }
.meta { display: flex; align-items: center; gap: 8px; flex: none; }
.meta .code { font-size: 1.2rem; padding: .05em .4em; }
.icon { border: 0; background: rgba(255, 246, 230, .12); color: var(--cream); cursor: pointer; min-height: 36px; padding: .3em .7em; border-radius: 3px; font-size: .9rem; }
.icon:hover { background: rgba(255, 246, 230, .22); }
.only-mobile { display: none !important; }

/* teammates */
.line { grid-area: line; display: flex; flex-wrap: wrap; justify-content: space-around; gap: 10px 28px; padding: 10px 20px 0; min-width: 0; }
.mate { --cw: clamp(48px, 4.9vw, 78px); position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding-top: 12px; }
.mate .string { position: absolute; left: -16px; right: -16px; top: 0; height: 18px; border-bottom: 2px solid #EADCC2; border-radius: 0 0 50% 50% / 0 0 100% 100%; pointer-events: none; }
.mate .cards { display: flex; gap: 8px; }
.mate .card { --cw: inherit; width: var(--cw); transition: transform .15s; }
.mate .card[data-act]:hover { transform: rotate(var(--rot)) translateY(-4px); cursor: pointer; }
.mate .card.preview { filter: drop-shadow(0 0 7px #FFE08A); transform: rotate(var(--rot)) translateY(-6px); }
.mate.p5 .card { --cw: 60px; }
.tag {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding: 4px 10px 4px 5px; min-height: 34px;
  background: var(--grain), #EDE3F7; color: var(--ink); border-radius: 2px 4px 3px 5px; box-shadow: 1px 2px 0 rgba(20, 12, 52, .3);
}
.tag.turn { background: var(--grain), var(--cream); box-shadow: 1px 2px 0 rgba(20, 12, 52, .3), 0 0 16px rgba(255, 220, 140, .6); }
.tag .nm { font-weight: 600; }
.tag .status { font-family: var(--crayon); font-size: 1.1rem; color: #7A5A12; }
.mini { border: 0; background: var(--mum); color: var(--ink); cursor: pointer; border-radius: 2px; font-size: .8rem; padding: .25em .6em; min-height: 28px; }
.game.p5 .mate { --cw: clamp(44px, 3.9vw, 64px); }

/* sky */
.sky { grid-area: sky; position: relative; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; }
.hills { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 46%; }
.slots { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); height: 100%; padding: 0 12px; }
.slot { display: flex; flex-direction: column; align-items: center; min-height: 0; }
.burst-wrap { position: relative; flex: 1; width: 100%; min-height: 0; display: grid; place-items: center; }
.burst { width: 100%; height: 100%; max-width: 280px; overflow: visible; }
.burst.pre { opacity: 0; }
.burst.bloom .burst-g { transform-origin: 0 0; animation: bloom 1.1s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes bloom { 0% { transform: scale(.08); opacity: 0; } 35% { opacity: 1; } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
.wait, .done { position: absolute; font-family: var(--crayon); font-size: 1.15rem; color: var(--soft); opacity: .85; text-align: center; }
.done { bottom: 4px; color: var(--gold); }
.launch { --cw: clamp(44px, 4.4vw, 74px); display: flex; align-items: flex-end; gap: 4px; padding-bottom: 14px; position: relative; }
.tube { width: calc(var(--cw) * .42); height: auto; margin-bottom: 18px; }
.tube.shake { animation: shake .45s linear 2; }
@keyframes shake { 25% { translate: -3px 0; } 75% { translate: 3px 0; } }
.stack { position: relative; width: var(--cw); aspect-ratio: 114 / 156; }
.stackcard { --cw: inherit; position: absolute; inset: 0; width: 100%; }
.stackcard:nth-last-child(2) { translate: -4px 3px; } .stackcard:nth-last-child(3) { translate: -8px 6px; }

/* ground */
.ground {
  grid-area: ground; position: relative; display: grid; grid-template-columns: auto auto minmax(250px, 300px);
  justify-content: center; align-items: center; gap: 12px 28px; padding: 12px 20px 16px; background: var(--night);
}
.hand-label { font-family: var(--crayon); font-size: 1.9rem; color: var(--gold); transform: rotate(-8deg); line-height: 1; text-align: right; }
.hand-label small { display: block; font-size: 1.2rem; color: var(--soft); }
.hand { --cw: clamp(74px, 7.6vw, 116px); display: flex; gap: 14px; padding-top: 18px; }
.hand .card { cursor: pointer; transition: transform .15s; }
.hand .card:disabled { cursor: default; }
.hand .card:not(:disabled):hover { transform: rotate(var(--rot)) translateY(-6px); }
.hand .card.selected { transform: rotate(var(--rot)) translateY(-18px); filter: drop-shadow(0 10px 8px rgba(0, 0, 0, .35)); }
.actions { display: flex; flex-direction: column; gap: 9px; }
.btn.act { justify-content: space-between; width: 100%; }
.btn.act small { font-family: var(--crayon); font-size: 1.15rem; font-weight: 400; opacity: .8; }
.help { margin: 0; font-family: var(--crayon); font-size: 1.15rem; color: var(--soft); }

/* side panel */
.panel {
  grid-area: panel; display: flex; flex-direction: column; gap: 4px; margin: 12px 12px 12px 0; padding: 14px 16px; min-height: 0;
  background: var(--grain), var(--kraft); color: var(--kraft-ink); border-radius: 3px 5px 2px 6px; box-shadow: var(--paper-shadow);
}
.panel h3 { margin: 0 0 6px; font-family: var(--crayon); font-weight: 400; font-size: 1.55rem; display: flex; justify-content: space-between; align-items: baseline; }
.panel h3 small { font-size: 1.15rem; opacity: .75; }
.tokens { display: flex; flex-direction: column; }
.tk { padding: 6px 0 10px; border-bottom: 2px dashed rgba(91, 62, 34, .3); }
.lanterns { display: grid; grid-template-columns: repeat(4, 1fr); justify-items: center; }
.lantern { width: 46px; height: 46px; overflow: visible; }
.crackers { display: flex; justify-content: space-around; }
.cracker { width: 30px; height: 60px; overflow: visible; }
.cr.just-burnt { animation: burn 1s ease-out; }
@keyframes burn { 0%, 30% { filter: brightness(1.8) drop-shadow(0 0 8px #FFB060); } 100% { filter: none; } }
.deck-tk { display: flex; align-items: center; justify-content: space-between; }
.deck-tk h3 { flex-direction: column; margin: 0; }
.box { min-width: 76px; padding: 8px 10px; text-align: center; font-family: var(--crayon); font-size: 2rem; color: var(--kraft-ink); background: var(--grain), #C99A64; border-radius: 2px; box-shadow: 2px 3px 0 rgba(60, 35, 10, .35); position: relative; }
.box::before { content: ''; position: absolute; left: 8px; right: 8px; top: 6px; bottom: 6px; background: var(--cream); z-index: 0; border-radius: 1px; }
.box { isolation: isolate; } .box::before { z-index: -1; }
.drawer-body { display: flex; flex-direction: column; min-height: 0; flex: 1; gap: 4px; }
.scrap { padding: 8px 0 10px; border-bottom: 2px dashed rgba(91, 62, 34, .3); }
.scrap-row { display: flex; align-items: center; gap: 0; margin-bottom: 4px; }
.scrap-row .glyph { margin-right: 6px; flex: none; }
.card.tiny { --cw: 34px; } .card.tiny + .card.tiny { margin-left: -8px; }
.empty { margin: 0; font-family: var(--crayon); font-size: 1.15rem; opacity: .7; }
.log { flex: 1; min-height: 120px; display: flex; flex-direction: column; padding-top: 8px; }
.log ol {
  list-style: none; margin: 0; padding: 8px 10px 8px 34px; flex: 1; min-height: 0; overflow-y: auto;
  font-family: var(--crayon); font-size: 1.12rem; line-height: 30px; color: #3D3466;
  background: #FBF6EA repeating-linear-gradient(transparent 0 29px, #B9CBE6 29px 30px);
  background-attachment: local;
  border-left: 0; box-shadow: inset 24px 0 0 -22.8px #F2A7A0, 1px 2px 0 rgba(60, 35, 10, .2);
  border-radius: 2px;
}
.log li.bad { color: #857C9C; } .log li.end { color: var(--peony-ink); }

/* hint sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(18, 14, 40, .45); z-index: 20; }
.sheet {
  position: fixed; z-index: 21; left: 50%; bottom: 16px; translate: -50% 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto;
  padding: 18px 20px 16px; background: var(--grain), var(--kraft); color: var(--kraft-ink);
  border-radius: 3px 5px 2px 6px; box-shadow: var(--paper-shadow); animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sheet h2 { margin: 0; color: var(--ink); font-size: 1.3rem; }
.sheet header small { font-family: var(--crayon); font-size: 1.2rem; }
.who { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip.name { display: inline-flex; align-items: center; gap: 6px; }
.preview-cards { --cw: clamp(58px, 17vw, 84px); display: flex; justify-content: center; gap: 12px; margin: 18px 0 6px; }
.preview-cards .miss { opacity: .45; }
.say { text-align: center; margin: 4px 0 10px; font-family: var(--crayon); font-size: 1.6rem; color: #5E3FA0; min-height: 1.4em; }
.pick { display: flex; flex-direction: column; gap: 10px; }
.pick-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pick-row > span { width: 64px; font-weight: 600; font-size: .95rem; }
.sheet footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* end card */
.end-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(18, 14, 40, .5); animation: fade .4s; }
@keyframes fade { from { opacity: 0; } }
.end-card { width: min(480px, 100%); padding: 26px 28px 22px; text-align: center; }
.end-card h2 { margin: 0; font-size: 1.7rem; }
.end-card .score { font-family: var(--crayon); font-size: 4.4rem; line-height: 1; margin: 10px 0 0; color: #5E3FA0; }
.end-card .score small { font-size: 1.6rem; color: #6B5E9E; }
.end-stacks { display: flex; justify-content: center; gap: 16px; margin: 14px 0 18px; }
.end-stacks span { display: flex; align-items: center; gap: 4px; font-family: var(--crayon); font-size: 1.5rem; }
.end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.end-actions .waiting { width: 100%; margin: 0 0 6px; }

/* motion layer */
.fly { position: fixed; z-index: 40; pointer-events: none; }
.fly .card { --cw: 100%; width: 100%; height: 100%; transform: none; }
.fly .card.grey { filter: grayscale(1) brightness(.85); }
.rocket { position: fixed; z-index: 39; width: 26px; pointer-events: none; }
.rocket svg { width: 100%; height: auto; display: block; }
.pop { position: fixed; z-index: 41; pointer-events: none; translate: -50% -50%; }
.pop.word { font-family: 'Bagel Fat One', var(--ui); font-size: 2rem; -webkit-text-stroke: 6px var(--cream); paint-order: stroke fill; animation: word 1.3s ease-out forwards; }
.pop.word.s0 { color: var(--peony); } .pop.word.s1 { color: var(--mum); } .pop.word.s2 { color: var(--willow); } .pop.word.s3 { color: var(--comet); } .pop.word.s4 { color: var(--halo); }
@keyframes word { 0% { transform: scale(.3) rotate(-14deg); opacity: 0; } 25% { transform: scale(1.1) rotate(-8deg); opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(-30px) rotate(-6deg); opacity: 0; } }
.pop.smoke { width: 150px; text-align: center; animation: smoke 1.7s ease-out forwards; }
.pop.smoke svg { width: 100%; height: auto; display: block; }
.pop.smoke b { display: block; font-family: var(--crayon); font-weight: 400; font-size: 2.4rem; color: var(--cream); margin-top: -12px; text-shadow: 0 2px 0 rgba(20, 12, 52, .4); }
@keyframes smoke { 0% { transform: translateY(10px) scale(.4); opacity: 0; } 20% { transform: translateY(-20px) scale(1); opacity: 1; } 75% { opacity: 1; } 100% { transform: translateY(-60px) scale(1.15); opacity: 0; } }

.toasts { position: fixed; z-index: 50; top: 70px; left: 50%; translate: -50% 0; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(520px, calc(100vw - 32px)); }
.toast { background: var(--grain), #FFF0C7; color: var(--ink); padding: 8px 16px; font-family: var(--crayon); font-size: 1.35rem; border-radius: 2px 4px 3px 5px; box-shadow: 2px 3px 0 rgba(20, 12, 52, .32); transform: rotate(-1deg); animation: up .25s ease-out; transition: opacity .4s, transform .4s; text-align: center; }
.toast.error { background: var(--grain), #FBE0DC; color: var(--peony-ink); }
.toast.out { opacity: 0; transform: translateY(-10px); }
.conn { position: fixed; z-index: 60; bottom: 16px; left: 50%; translate: -50% 0; background: var(--peony); color: var(--ink); padding: 6px 14px; border-radius: 3px; font-weight: 600; box-shadow: 2px 3px 0 rgba(20, 12, 52, .32); }

/* ---------- phones & narrow screens ---------- */
@media (max-width: 860px) {
  .game {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(150px, 1fr) auto;
    grid-template-areas: "top" "panel" "line" "sky" "ground";
    height: auto; min-height: 100dvh; overflow: visible;
  }
  .only-mobile { display: inline-flex !important; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px 0; }
  .topbar .brand { width: 104px; }
  .meta { gap: 4px; }
  .icon { font-size: .78rem; padding: .3em .55em; min-height: 34px; }
  .turnbar { order: 3; width: 100%; margin: 0; }
  .meta { margin-left: auto; }
  .meta .code { display: none; }
  .panel { margin: 8px 12px 0; padding: 6px 12px; }
  .tokens { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
  .tk { border: 0; padding: 0; display: flex; align-items: center; gap: 6px; }
  .tk h3 { display: none; }
  .lanterns { display: flex; gap: 0; }
  .lantern { width: 24px; height: 28px; }
  .cracker { width: 16px; height: 32px; }
  .crackers { gap: 4px; }
  .box { min-width: 0; font-size: 1.3rem; padding: 2px 10px; }
  .drawer-body { display: none; }
  .panel.open .drawer-body {
    display: flex; position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; top: 18dvh; padding: 16px; overflow-y: auto;
    background: var(--grain), var(--kraft); box-shadow: 0 -6px 20px rgba(20, 12, 52, .4); border-radius: 6px 6px 0 0;
  }
  .drawer-close { align-self: flex-end; }
  .line { flex-direction: column; flex-wrap: nowrap; gap: 0; padding: 4px 12px 0; }
  .mate { --cw: min(15vw, 62px); display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 6px; padding: 12px 0 6px; }
  .game.p5 .mate { --cw: min(15vw, 56px); }
  .mate .cards { order: 2; gap: 6px; }
  .mate .tag { order: 1; flex-direction: column; justify-content: center; gap: 2px; padding: 4px; background: none; box-shadow: none; color: var(--cream); text-align: center; }
  .mate .tag.turn { background: rgba(255, 240, 199, .16); }
  .mate .tag .status { color: var(--gold); font-size: 1rem; }
  .mate .badge { background: rgba(255, 246, 230, .16); color: var(--cream); }
  .slots { padding: 0 4px; }
  .launch { --cw: min(13vw, 54px); padding-bottom: 10px; }
  .tube { display: none; }
  .wait { display: none; }
  .ground { grid-template-columns: 1fr; justify-items: center; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); gap: 8px; }
  .hand-label { display: none; }
  .hand { --cw: min(21vw, 92px); gap: 8px; padding-top: 16px; }
  .actions { flex-direction: row; flex-wrap: wrap; width: 100%; gap: 8px; }
  .btn.act { flex: 1 1 0; flex-direction: column; gap: 0; padding: .4em .5em; min-height: 52px; font-size: .95rem; }
  .btn.act small { font-size: .95rem; }
  .help { width: 100%; text-align: center; }
  .sheet { bottom: 0; width: 100vw; border-radius: 8px 8px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .choices { grid-template-columns: 1fr; }
  .toasts { top: auto; bottom: 120px; }
}
@media (max-width: 380px) {
  .mate { grid-template-columns: 60px 1fr; }
  .actions .btn.act small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

.back-to-playroom { position: absolute; z-index: 2; top: 16px; left: 16px; color: var(--cream); font-weight: 600; text-decoration: none; padding: 8px 12px; border-radius: 3px; background: rgba(255, 246, 230, .12); }
.back-to-playroom:hover { background: rgba(255, 246, 230, .22); }

/* suit tags in the log, toasts and hint preview */
.ctag { white-space: nowrap; font-weight: 400; }
.ctag .glyph { display: inline-block; vertical-align: -3px; margin-right: 3px; }
.ctag.s0 { color: #A83A31; } .ctag.s1 { color: #8A5800; } .ctag.s2 { color: #24734F; } .ctag.s3 { color: #24578F; } .ctag.s4 { color: #5E3FA0; }
.log li.bad .ctag { opacity: .85; }
.toast .ctag .glyph { vertical-align: -4px; }

/* about / how to play (static text for readers and search engines) */
.about { width: min(760px, calc(100% - 32px)); margin: 0 auto 48px; padding: 26px clamp(18px, 4vw, 40px); color: var(--ink);
  background: var(--grain), var(--cream); border-radius: 3px 5px 2px 6px / 5px 2px 6px 3px; box-shadow: var(--paper-shadow); line-height: 1.6; }
.about h2 { font-size: 1.25rem; margin: 1.4em 0 .4em; } .about h2:first-child { margin-top: 0; }
.about p, .about li, .about dd { max-width: 68ch; }
.about dt { font-weight: 600; margin-top: .8em; } .about dd { margin: .2em 0 0; }
.about a { color: #5E3FA0; font-weight: 600; }
.about .more { margin-top: 1.6em; }

/* Reserve the first screen for the app so the text below never shifts. */
#app { min-height: 100dvh; }
