:root {
  --bg: #1b1430;
  --bg-2: #2a1f4a;
  --card: #fffaf2;
  --ink: #1b1430;
  --muted: #6d6585;
  --line: #e9e1d4;
  --accent: #ff5d73;
  --accent-ink: #ffffff;
  --accent-2: #ffc94d;
  --ok: #2bb673;
  --radius: 22px;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, .55);
  --font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #4b2f86 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #7a2450 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

.app {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(max(20px, env(safe-area-inset-top)) + 36px) 16px max(24px, env(safe-area-inset-bottom));
}
.screen { width: 100%; max-width: 440px; animation: rise .35s ease both; }
#screen-lobby { max-width: 900px; }
#screen-game { max-width: 640px; }
#screen-words { max-width: 520px; }
#screen-mime { max-width: 480px; }
#screen-done { max-width: 520px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Language ---------- */
.lang-switch {
  position: absolute; z-index: 2; top: max(12px, env(safe-area-inset-top)); right: 12px;
  display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, .12);
}
.lang-switch button {
  font: inherit; font-weight: 700; font-size: .8rem; letter-spacing: .04em; color: #cfc4ec;
  background: none; border: 0; border-radius: 999px; padding: 5px 10px; cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { background: var(--card); color: var(--ink); }

/* ---------- Brand ---------- */
.brand { text-align: center; color: #fff; margin-bottom: 22px; }
.brand h1 { font-size: clamp(2.6rem, 11vw, 3.6rem); font-weight: 800; letter-spacing: -.03em; margin: 6px 0 2px; }
.logo {
  width: 72px; height: 72px; margin: 0 auto; display: grid; place-items: center;
  font-size: 40px; border-radius: 24px; background: var(--accent-2);
  transform: rotate(-6deg); box-shadow: 0 10px 0 -2px #d99a12;
}
.logo.big { width: 96px; height: 96px; font-size: 54px; margin-bottom: 12px; }

/* ---------- Card ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.center { text-align: center; }
h2 { margin: 0; font-size: 1.4rem; letter-spacing: -.01em; }

/* ---------- Form ---------- */
.home-form { display: grid; gap: 14px; }
.home-form .card > .field:last-child { margin-bottom: 0; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 6px; color: var(--muted); }
input {
  width: 100%; font: inherit; font-size: 1.1rem; color: var(--ink);
  padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line); background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(255, 93, 115, .18); }
.code-input { text-transform: uppercase; letter-spacing: .45em; font-weight: 800; font-size: 1.6rem; text-align: center; padding-left: calc(16px + .45em); }
.code-input::placeholder { color: #d6cfc2; }

.join-block { display: grid; gap: 4px; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .9rem; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 2px; background: var(--line); border-radius: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; font: inherit; font-weight: 800; font-size: 1.1rem;
  padding: 15px 18px; border-radius: 16px; border: 0; cursor: pointer;
  transition: transform .08s, box-shadow .15s, opacity .15s, background .15s;
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 0 -1px #c93a50; }
.btn-primary:active { box-shadow: 0 3px 0 -1px #c93a50; }
.btn-ghost { background: transparent; color: var(--ink); border: 2px solid var(--ink); }
.btn-ghost:hover { background: var(--ink); color: #fff; }
.btn-small { width: auto; font-size: .95rem; padding: 10px 16px; border-radius: 12px; }
.btn-link { background: none; color: var(--muted); font-weight: 600; font-size: .95rem; padding: 10px; margin-top: 8px; text-decoration: underline; }
.btn-block { width: 100%; }

/* ---------- Lobby ---------- */
.lobby { display: grid; gap: 16px; }
@media (min-width: 760px) {
  .lobby.is-host { grid-template-columns: 340px 1fr; align-items: start; }
}

.share { text-align: center; }
.eyebrow { margin: 0 0 4px; text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; font-weight: 700; color: var(--muted); }
.room-code {
  font: inherit; font-weight: 800; font-size: clamp(2.8rem, 14vw, 4rem); letter-spacing: .14em;
  color: var(--ink); background: none; border: 0; cursor: pointer; padding: 0 0 0 .14em; line-height: 1.1;
}
.qr { display: block; width: min(240px, 70vw); aspect-ratio: 1; margin: 14px auto 10px; border-radius: 14px; background: #fff; padding: 6px; border: 2px solid var(--line); }
.hint { color: var(--muted); font-size: .95rem; margin: 8px 0 12px; }
.hint a { color: var(--ink); font-weight: 700; word-break: break-all; }

.players-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.pill { background: var(--ink); color: #fff; font-weight: 700; font-size: .85rem; padding: 4px 10px; border-radius: 999px; }

.player-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.player {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
  animation: pop .25s ease both;
}
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
.player.me { border-color: var(--ink); }
.player.offline { opacity: .5; }
.avatar {
  flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 1.05rem;
}
.player-name { flex: 1; font-weight: 700; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--accent-2); color: var(--ink); }
.tag.you { background: var(--line); }
.tag.off { background: #eee; color: var(--muted); }
.kick { border: 0; background: none; color: var(--muted); font-size: 1.3rem; line-height: 1; padding: 4px 8px; cursor: pointer; border-radius: 8px; }
.kick:hover { background: #ffe3e7; color: var(--accent); }
.player.empty { border-style: dashed; color: #b9b0a2; justify-content: center; font-weight: 600; background: transparent; animation: none; }

.waiting { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-weight: 600; text-align: center; margin: 4px 0 0; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite both; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* Player on mobile: compact code */
.lobby:not(.is-host) .share { padding: 14px 22px; }
.lobby:not(.is-host) .room-code { font-size: 2.2rem; }

/* ---------- Teams ---------- */
/* Team palette, up to 8 teams. Very bright solids, so dark text (--ink) on top, not white.
   Anything carrying .team-N or data-team="N" gets that team's colours:
   --tc solid / --tc-dark (raised edges, strong borders) / --tc-soft (backgrounds) / --tc-line (borders) */
.team-0, [data-team="0"] { --tc: #2ee672; --tc-dark: #12a94b; --tc-soft: #dcfce8; --tc-line: #86ebad; } /* green */
.team-1, [data-team="1"] { --tc: #ff9220; --tc-dark: #d96a00; --tc-soft: #fff0dc; --tc-line: #ffc380; } /* orange */
.team-2, [data-team="2"] { --tc: #4db8ff; --tc-dark: #1481d1; --tc-soft: #e0f2ff; --tc-line: #9cd6ff; } /* blue */
.team-3, [data-team="3"] { --tc: #ff7ac3; --tc-dark: #d63d94; --tc-soft: #ffe6f4; --tc-line: #ffb3dc; } /* pink */
.team-4, [data-team="4"] { --tc: #b18cff; --tc-dark: #7a4fe0; --tc-soft: #efe8ff; --tc-line: #d2bfff; } /* purple */
.team-5, [data-team="5"] { --tc: #ffd93b; --tc-dark: #c9a200; --tc-soft: #fff8d6; --tc-line: #ffe98a; } /* yellow */
.team-6, [data-team="6"] { --tc: #2fd9c8; --tc-dark: #0f9e90; --tc-soft: #dcf9f5; --tc-line: #8ce9df; } /* teal */
.team-7, [data-team="7"] { --tc: #ff6b5e; --tc-dark: #d13a2c; --tc-soft: #ffe5e2; --tc-line: #ffb0a8; } /* red */
/* Each team is a drop zone with its own padding; the negative margin realigns it with the card */
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0 -10px 10px; }
.team { min-width: 0; padding: 10px 10px 14px; border-radius: 20px; outline: 2px dashed transparent; outline-offset: -2px; transition: outline-color .12s, background .12s; }
.team .player-list { margin-bottom: 0; }
.team.drop-target { outline-color: var(--tc); background: var(--tc-soft); }
/* pan-y: vertical scrolling stays with the browser, the horizontal drag to another team is ours */
.player.draggable { cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.player.dragging { opacity: .3; }
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 10; margin: 0; pointer-events: none; list-style: none;
  box-shadow: var(--shadow);
  /* position tracked through --x / --y (set from JS) so the animation keeps control of the rotation */
  transform: translate(var(--x, 0), var(--y, 0)) rotate(-2deg) scale(1.04);
  animation: wiggle .32s ease-in-out infinite;
}
@keyframes wiggle {
  0%, 100% { transform: translate(var(--x, 0), var(--y, 0)) rotate(-4deg) scale(1.04); }
  50% { transform: translate(var(--x, 0), var(--y, 0)) rotate(4deg) scale(1.04); }
}
.is-dragging, .is-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.team h3 {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 0 12px; padding: 9px 12px; border-radius: 12px; color: var(--ink); font-size: 1rem; font-weight: 800;
}
.team h3 { background: var(--tc); box-shadow: 0 4px 0 -1px var(--tc-dark); }
.team-count { font-size: .85rem; opacity: .85; }
.player[data-team] { border-color: var(--tc-line); }
.player[data-team] .avatar { background: var(--tc); color: var(--ink); }
.player[data-team].me { border-color: var(--tc-dark); background: var(--tc-soft); }
.player.compact { gap: 8px; padding: 7px 8px; min-width: 0; }
.player.compact .avatar { width: 28px; height: 28px; border-radius: 9px; font-size: .85rem; }
.player.compact .player-name { font-size: .95rem; }
.my-team { margin: 0 0 16px; padding: 10px 14px; border-radius: 12px; text-align: center; font-weight: 800; color: var(--ink); }
.my-team { background: var(--tc); box-shadow: 0 4px 0 -1px var(--tc-dark); }
.my-team.flash { animation: flash .5s ease both; }
@keyframes flash { 0% { transform: scale(.94); opacity: .4; } 60% { transform: scale(1.03); } }
.pill.draft { margin-left: auto; margin-right: 8px; background: var(--accent-2); color: var(--ink); }

/* ---------- Game settings ---------- */
.settings { margin: 18px 0; padding-top: 16px; border-top: 2px solid var(--line); }
.settings h3, .progress-title { margin: 0 0 10px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 16px; background: var(--line); }
.segment {
  display: grid; gap: 1px; padding: 9px 4px; border: 0; border-radius: 12px; background: none;
  font: inherit; color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.segment strong { font-size: 1rem; font-weight: 800; }
.segment small { font-size: .78rem; font-weight: 600; }
.segment[aria-checked="true"], .segment[aria-selected="true"] { background: var(--ink); color: #fff; }
.segment:disabled { cursor: default; }
.settings .hint { margin-bottom: 0; }
.settings .hint + h3 { margin-top: 18px; }
.host-only .hint { margin-top: 10px; }

/* ---------- Preparation: entering words ---------- */
.team-pill { color: var(--ink); }
.team-pill { background: var(--tc); }
.word-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 14px 0; }
.word-form .btn { height: 100%; }
.word-list { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; counter-reset: word; }
.word {
  counter-increment: word; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 9px 8px 9px 12px;
  background: #fff; border: 2px solid var(--line); border-radius: 14px; animation: pop .25s ease both;
}
.word::before { content: counter(word); flex: none; width: 1.4em; font-weight: 800; color: var(--muted); }
.word[data-team] { border-color: var(--tc-line); }
.word-text { flex: 1; min-width: 0; font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.word-by { flex: none; max-width: 35%; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.word-by.wide { max-width: none; }
.word-warn { display: block; font-size: .78rem; font-weight: 600; color: var(--accent); }
.word.empty { border-style: dashed; background: transparent; color: #b9b0a2; font-weight: 600; animation: none; padding-top: 12px; padding-bottom: 12px; }
.word.empty::before { content: none; }
.word.pending { border-style: dashed; }
.word.dropped { opacity: .5; background: transparent; }
.word.dropped .word-text { text-decoration: line-through; }
.thumb {
  flex: none; width: 42px; height: 38px; border: 2px solid var(--line); border-radius: 12px; background: #fff;
  font-size: 1.15rem; line-height: 1; cursor: pointer; filter: grayscale(1); opacity: .55;
  transition: transform .08s, filter .15s, opacity .15s, background .15s, border-color .15s;
}
.thumb:active { transform: scale(.92); }
.thumb[aria-pressed="true"] { filter: none; opacity: 1; }
.thumb.up[aria-pressed="true"] { background: #4fe08a; border-color: #12a94b; } /* thumbs up: green */
.thumb.down[aria-pressed="true"] { background: #ff7b6e; border-color: #c93a2c; } /* thumbs down: red */
#words-actions { margin-bottom: 20px; }
#words-actions .hint { margin: 10px 0 0; }
.words-done { margin: 14px 0; padding: 10px 14px; border-radius: 12px; text-align: center; font-weight: 800; background: var(--line); }

.progress { display: grid; grid-template-columns: 8.5em 1fr 5.5em; align-items: center; gap: 10px; margin-bottom: 8px; font-weight: 700; font-size: .9rem; }
.progress-bar { height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; border-radius: 999px; transition: width .3s ease; }
.progress .progress-bar i { background: var(--tc); }
.progress-count { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; white-space: nowrap; }

/* ---------- Miming ---------- */
/* Countdown: digits + a gauge that empties; red for the last 10 seconds */
.timer { display: grid; justify-items: center; gap: 6px; margin: 14px 0 4px; }
.timer strong { font-size: clamp(2.2rem, 11vw, 3rem); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.timer-bar { width: 100%; height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.timer-bar i { display: block; height: 100%; width: 100%; border-radius: 999px; background: var(--ink); }
/* Waiting for the mimer to look at their word: the clock is shown greyed out, at full time */
.timer.waiting strong { color: var(--muted); }
.timer.waiting .timer-bar i { background: var(--muted); }
.timer small { font-size: .85rem; font-weight: 600; color: var(--muted); }
.timer.urgent strong { color: var(--accent); }
.timer.urgent .timer-bar i { background: var(--accent); }
.time-up .mime-title { color: var(--accent); }
.word.not-found .result-time { color: var(--muted); }
#continue-block .btn:disabled { opacity: .6; }

.mime-title { margin: 18px 0 4px; font-size: clamp(1.5rem, 6.5vw, 2rem); font-weight: 800; line-height: 1.15; letter-spacing: -.02em; overflow-wrap: anywhere; }
#screen-mime .hint { margin-top: 6px; }
/* Hold button: the word only appears while it is pressed */
.secret {
  display: grid; place-content: center; gap: 6px; width: 100%; min-height: 150px; margin: 18px 0 14px; padding: 18px;
  border: 3px dashed var(--ink); border-radius: 20px; background: var(--line); color: var(--ink);
  font: inherit; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .08s, background .12s;
}
.secret strong { font-size: 1.3rem; font-weight: 800; overflow-wrap: anywhere; }
.secret small { font-size: .9rem; font-weight: 600; color: var(--muted); }
.secret.revealed { border-style: solid; transform: scale(.98); }
.secret.revealed strong { font-size: clamp(1.7rem, 8vw, 2.4rem); line-height: 1.1; }
.secret.revealed small { color: var(--ink); font-size: .88rem; line-height: 1.3; } /* the word's definition */
.secret.revealed { background: var(--tc); } /* colour of the team that wrote the word */
#mime-next { margin-bottom: 0; }
/* Long-press button: a darker gauge advances from left to right while it is held.
   Its progress (--p, from 0 to 1) is driven from JS, frame by frame: it is useful feedback that must not
   disappear when the phone asks for reduced motion (transitions switched off). */
.btn-hold {
  position: relative; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.hold-fill {
  position: absolute; inset: 0; pointer-events: none; background: rgba(27, 20, 48, .32);
  transform: scaleX(var(--p, 0)); transform-origin: 0 50%;
}
.btn-hold > span { position: relative; }
.btn-hold.holding { transform: translateY(2px); }
.hold-hint { font-size: .85rem; margin-top: 10px; }
#btn-abandon { margin-top: 4px; }
/* the ghost button's hover inversion would hide the gauge and sticks on touch screens */
#btn-abandon:hover { background: transparent; color: var(--ink); }

/* ---------- Game over: the times ---------- */
.results-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.result-team {
  position: relative; display: grid; justify-items: center; gap: 2px; padding: 14px 8px 12px; border-radius: 18px;
  color: var(--ink); text-align: center;
}
.result-team { background: var(--tc); box-shadow: 0 5px 0 -1px var(--tc-dark); }
/* Three teams or more: boxes wrap, with smaller digits */
.results-teams.many { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 14px 10px; }
.results-teams.many .result-team strong { font-size: clamp(1.5rem, 7vw, 2rem); }
.result-team-name { font-weight: 800; font-size: .95rem; }
.result-team strong { font-size: clamp(2rem, 10vw, 2.6rem); font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.result-team small { font-size: .82rem; font-weight: 600; }
.result-fastest {
  position: absolute; top: -10px; right: -6px; padding: 3px 9px; border-radius: 999px; transform: rotate(6deg);
  background: var(--ink); color: #fff; font-size: .72rem; font-weight: 700;
}
.results-tabs { margin-bottom: 12px; }
.results-tabs .segment { padding: 10px 4px; }
#screen-done .player-list, #screen-done .word-list { margin-bottom: 0; }
.done-actions { display: grid; gap: 10px; margin-top: 20px; padding-top: 18px; border-top: 2px solid var(--line); }
.done-actions .hint { margin: 8px 0 0; }
.result-time { flex: none; min-width: 2.6em; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- "It's your turn to mime!": glowing screen border ---------- */
/* The edges of the screen light up in the team colour and pulse softly twice, while the message pops in the
   middle. Nothing covers the page itself: a full-screen flash proved too harsh.
   Without animation (reduced motion), the border and message simply show, static, for the same duration. */
.your-turn {
  position: fixed; z-index: 19; inset: 0; display: grid; place-items: center; padding: 24px; pointer-events: none;
  text-align: center; color: var(--ink); animation: turn-border 2.2s ease-in-out both;
}
.your-turn { --turn: var(--tc); box-shadow: inset 0 0 0 8px var(--turn), inset 0 0 46px 14px var(--turn); }
.your-turn strong {
  max-width: 11em; padding: 16px 22px; border: 4px solid var(--ink); border-radius: 24px; background: var(--turn);
  box-shadow: 0 8px 0 -2px var(--ink), var(--shadow);
  font-size: clamp(1.7rem, 8vw, 2.3rem); font-weight: 800; line-height: 1.05; letter-spacing: -.02em;
  animation: turn-pop 2.2s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes turn-border {
  0% { opacity: 0; }
  14% { opacity: 1; }
  34% { opacity: .55; }
  54%, 84% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes turn-pop {
  0% { transform: scale(.3) rotate(-8deg); }
  14% { transform: scale(1.08) rotate(2deg); }
  24%, 84% { transform: scale(1) rotate(-2deg); }
  100% { transform: scale(.9) rotate(-2deg); }
}

/* ---------- Celebration for the mimer ---------- */
.celebrate { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 24px; pointer-events: none; overflow: hidden; }
.celebrate-card {
  display: grid; justify-items: center; gap: 6px; max-width: 320px; padding: 22px 26px; text-align: center;
  background: var(--accent-2); color: var(--ink); border: 4px solid var(--ink); border-radius: 28px;
  box-shadow: 0 10px 0 -2px var(--ink), var(--shadow); transform: rotate(-3deg);
  animation: celebrate-pop 3s cubic-bezier(.2, 1.4, .4, 1) both;
}
.celebrate-card strong { font-size: clamp(1.6rem, 7.5vw, 2.1rem); font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.celebrate-emoji { font-size: 3.4rem; line-height: 1; animation: celebrate-wobble .5s ease-in-out 6 alternate; }
/* Pops in with a bounce, stays, then fades out */
@keyframes celebrate-pop {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  10% { transform: scale(1.18) rotate(4deg); opacity: 1; }
  16% { transform: scale(.95) rotate(-5deg); }
  22%, 86% { transform: scale(1) rotate(-3deg); opacity: 1; }
  100% { transform: scale(.8) rotate(-3deg) translateY(30px); opacity: 0; }
}
/* Sad trombone: same card, greyed, and the trumpet droops instead of dancing */
.sad .celebrate-card { background: #e9e4f2; animation-name: sad-pop; animation-timing-function: ease-out; }
.sad .celebrate-emoji { transform: rotate(38deg); animation: sad-droop 2.2s ease-in both; }
@keyframes sad-pop {
  0% { opacity: 0; transform: translateY(-18px); }
  10%, 82% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(26px); }
}
@keyframes sad-droop { 0%, 15% { transform: rotate(-20deg); } 100% { transform: rotate(38deg); } }
@keyframes celebrate-wobble { from { transform: rotate(-14deg) scale(1); } to { transform: rotate(14deg) scale(1.15); } }
.confetti {
  position: absolute; left: 50%; top: 50%; width: 10px; height: 16px; margin: -8px 0 0 -5px; border-radius: 3px; opacity: 0;
  animation: confetti-burst 1.9s cubic-bezier(.1, .7, .3, 1) both;
}
.confetti:nth-child(3n) { width: 12px; height: 12px; border-radius: 50%; }
@keyframes confetti-burst {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 160px)) rotate(var(--spin)); opacity: 0; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100% - 32px); text-align: center; border: 2px solid rgba(255,255,255,.12);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--accent); }

/* ---------- Duck (easter egg, pure CSS) ---------- */
/* Background lane: negative z-index = behind the cards, hidden overflow = no horizontal scrolling */
.duck-lane {
  position: fixed; z-index: -1; left: 0; right: 0; bottom: env(safe-area-inset-bottom);
  height: 84px; overflow: hidden; pointer-events: none; /* tall enough for the hat */
}
/* Still and off-screen until eggs.js gives it the .play class (one crossing, then back to rest);
   with no animation (reduced motion) it simply stays hidden */
.duck { position: absolute; left: -80px; bottom: 4px; width: 66px; height: 54px; }
.duck.play { animation: duck-cross 28s linear both; }
.duck.play.rtl { animation-name: duck-cross-back; }
.duck:not(.play) * { animation: none; }
.duck-body {
  position: absolute; left: 6px; bottom: 11px; width: 44px; height: 28px;
  background: #ff7ab8; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  transform-origin: 50% 100%; animation: duck-waddle .28s ease-in-out infinite alternate;
}
.duck-body::before { /* tail */
  content: ""; position: absolute; left: -7px; top: 1px; width: 15px; height: 12px;
  background: inherit; border-radius: 90% 10% 60% 20%; transform: rotate(18deg);
}
.duck-body::after { /* wing */
  content: ""; position: absolute; left: 9px; top: 9px; width: 23px; height: 13px;
  background: #f04f9c; border-radius: 50% 50% 50% 50% / 35% 35% 65% 65%;
}
.duck-head { position: absolute; left: 29px; top: -15px; width: 23px; height: 23px; border-radius: 50%; background: #ff7ab8; }
.duck-hat { /* rainbow top hat: six stripes from a hard-stop gradient */
  position: absolute; left: 2px; top: -12px; width: 15px; height: 15px; border-radius: 3px 3px 0 0;
  background: linear-gradient(#e40303 0 16.67%, #ff8c00 0 33.33%, #ffed00 0 50%, #00a63e 0 66.67%, #2b6bff 0 83.33%, #a23bd6 0);
  transform: rotate(-10deg); transform-origin: 50% 100%;
}
.duck-hat::after { /* hat brim */
  content: ""; position: absolute; left: -5px; bottom: -2px; width: 25px; height: 4px; border-radius: 2px; background: #fff;
}
.duck-head::before { /* eye */
  content: ""; position: absolute; left: 13px; top: 7px; width: 4px; height: 4px; border-radius: 50%; background: var(--ink);
}
.duck-head::after { /* beak */
  content: ""; position: absolute; left: 20px; top: 10px; width: 12px; height: 7px;
  background: #ff8a1f; border-radius: 2px 8px 8px 2px;
}
.duck-leg {
  position: absolute; left: 24px; bottom: 0; width: 4px; height: 14px; border-radius: 2px; background: #ff8a1f;
  transform-origin: 50% 0; animation: duck-step .28s ease-in-out infinite alternate;
}
.duck-leg + .duck-leg { left: 32px; animation-delay: -.28s; } /* legs in opposite phase */
.duck-leg::after { /* webbed foot */
  content: ""; position: absolute; left: 0; bottom: 0; width: 10px; height: 4px; background: inherit; border-radius: 2px 5px 2px 2px;
}
/* One crossing: left to right, or (.rtl) right to left, flipped */
@keyframes duck-cross {
  from { transform: translateX(0); }
  to { transform: translateX(calc(100vw + 100px)); }
}
@keyframes duck-cross-back {
  from { transform: translateX(calc(100vw + 100px)) scaleX(-1); }
  to { transform: translateX(0) scaleX(-1); }
}
@keyframes duck-waddle { from { transform: rotate(-4deg); } to { transform: rotate(4deg) translateY(-2px); } }
@keyframes duck-step { from { transform: rotate(26deg); } to { transform: rotate(-26deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
