:root {
  color-scheme: light;
  --paper: #f7f3ea;
  --table: #ece4d4;
  --ink: #201b16;
  --muted: #71685d;
  --line: #d6cabb;
  --card: #fffaf1;
  --accent: #2f6f5f;
  --danger: #b95645;
  --heal: #6f8d45;
  --shield: #547493;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

button,
input {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

.app,
.game {
  min-height: 100vh;
}

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 390px);
  gap: 16px;
  padding: 16px;
}

.lobby {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.lobby-card {
  width: min(100%, 520px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf3;
}

.intro {
  max-width: 38rem;
  color: var(--muted);
  line-height: 1.45;
}

.join-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

/* Signing in stays optional, but it is worth offering first: it saves your statistics
   and carries your name between devices. So the block sits above the join form as a
   real call to action — a guest still scrolls past it and plays. */
.account-panel {
  display: grid;
  gap: 12px;
  margin-top: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

/* Signed in there is nothing to sell, so the same block collapses to one line:
   who you are on the left, the way out on the right. */
.account-panel.signed-in {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.account-title {
  margin: 0;
  font-weight: 800;
}

.account-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.account-login {
  width: 100%;
}

/* The signed-in player's own history, under the lobby form. Never rendered for a
   guest, so the lobby keeps its original height when nobody has signed in. */
.account-history {
  margin-top: 16px;
}

.account-empty {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.history-list,
.leaderboard-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.history-row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  font-size: 0.85rem;
}

.history-row.won {
  border-color: var(--accent);
}

.history-code {
  font-weight: 800;
  letter-spacing: 0.08em;
}

.history-outcome {
  font-weight: 700;
  color: var(--accent);
}

.history-detail {
  color: var(--muted);
  text-align: right;
}

/* All-time board on the host screen, below the waiting-room grid. */
.leaderboard {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 2ch 1fr auto auto;
  gap: 14px;
  align-items: baseline;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
}

.leaderboard-rank {
  color: var(--muted);
  font-weight: 800;
}

.leaderboard-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-record,
.leaderboard-sips {
  color: var(--muted);
  font-size: 0.85rem;
}

input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.form-actions,
.actionbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.board,
.phone,
.waiting-room {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf3;
}

.waiting-room {
  display: grid;
  grid-column: 1 / -1;
  grid-template-rows: auto auto 1fr;
  min-height: calc(100vh - 32px);
  overflow: hidden;
}

.board {
  display: grid;
  grid-template-rows: auto minmax(430px, 1fr) auto auto;
  min-width: 0;
  overflow: hidden;
}

.topbar,
.waiting-header,
.actionbar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.actionbar {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.waiting-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.waiting-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #f3eadb;
}

.waiting-copy p {
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.waiting-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 24px;
  padding: 24px;
}

.waiting-players {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.waiting-player,
.waiting-actions {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.waiting-player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.waiting-player.me {
  outline: 3px solid #e0b65f;
}

.waiting-player h3,
.waiting-player p {
  margin: 0;
}

.waiting-player p,
.waiting-actions p {
  color: var(--muted);
}

.waiting-actions {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
}

/* Both halves of the identity sit at label size: the board is for watching the
   table, and a title that reads across the room steals attention the game needs. */
.board-identity {
  display: flex;
  align-items: baseline;
  min-width: 0;
  gap: 10px;
}

.board-wordmark,
.board-code {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.board-wordmark {
  text-transform: uppercase;
}

.board-code {
  letter-spacing: 0.14em;
}

.turn-status {
  display: grid;
  min-width: 0;
  gap: 1px;
  text-align: right;
}

.turn-status strong {
  font-size: 1.1rem;
  line-height: 1.15;
}

.turn-status span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 5vw, 4.6rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
}

.view-links {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.view-links a {
  display: grid;
  min-width: 58px;
  min-height: 34px;
  place-items: center;
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
}

.view-links a.active {
  background: var(--ink);
  color: #fff;
}

.arena {
  position: relative;
  display: grid;
  min-height: 430px;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(32, 27, 22, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(32, 27, 22, 0.05) 1px, transparent 1px),
    var(--table);
  background-size: 52px 52px;
}

.table-center {
  display: grid;
  width: min(42vw, 330px);
  min-width: 220px;
  min-height: 140px;
  place-items: center;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 243, 0.82);
  text-align: center;
}

.table-center p {
  margin: 0;
  color: var(--muted);
}

.event-log {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fffaf3;
}

.event-log-header {
  display: grid;
  align-content: start;
  gap: 2px;
}

.event-log-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 290px);
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.event-log-list > p {
  margin: 0;
  color: var(--muted);
}

.event-log-item {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 118px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.event-log-item strong {
  display: block;
  color: var(--ink);
  font-size: 0.88rem;
}

.event-log-item p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.25;
}

.event-log-item ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.event-log-item li,
.event-log-item small,
.event-target {
  color: var(--danger);
  font-size: 0.74rem;
  font-weight: 900;
}

.event-target {
  color: var(--accent);
}

.players {
  position: absolute;
  inset: 18px;
}

/* Seat coordinates come from seatPosition() in boardLayout.js via --seat-x/--seat-y,
   so any roster size gets a ring with no overlap — the old eight nth-child positions
   left seat one unplaced on the host board and stacked player nine onto player one. */
.player {
  position: absolute;
  left: var(--seat-x, 50%);
  top: var(--seat-y, 50%);
  width: clamp(150px, 12vw, 190px);
  min-height: 128px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf3;
  transform: translate(-50%, -50%);
  transition: transform 160ms ease, outline-color 160ms ease, opacity 160ms ease;
}

.player.active {
  outline: 3px solid #e0b65f;
  /* Must compose with the centring translate or the card jumps off its seat. */
  transform: translate(-50%, calc(-50% - 3px));
}

.player.defeated {
  opacity: 0.42;
}

.avatar {
  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 8px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #f2eadf;
  font-weight: 900;
}

.player h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.hp-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hp-track {
  flex: 1;
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: #eadfcc;
}

.hp-fill {
  width: var(--hp);
  height: 100%;
  border-radius: inherit;
  background: var(--danger);
}

.player small {
  display: block;
  min-height: 18px;
  margin-top: 8px;
  color: var(--muted);
}

/* The row hugs the card's own top edge instead of bleeding 54px past both sides —
   the old inset overlay painted minions across neighbouring seats. z-index keeps the
   tokens above their own card's corner; they can no longer reach anyone else's. */
.minions {
  position: absolute;
  top: -30px;
  right: 0;
  left: 0;
  z-index: 5;
  display: flex;
  gap: 4px;
  justify-content: center;
  pointer-events: none;
}

.minion-token {
  display: grid;
  width: 30%;
  max-width: 58px;
  min-height: 56px;
  place-items: center;
  padding: 4px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: #fffaf3;
  color: var(--muted);
  box-shadow: 0 10px 24px rgba(32, 27, 22, 0.18);
  text-align: center;
}

.minion-token strong {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: #f3eadb;
  color: var(--ink);
  font-size: 0.66rem;
}

.minion-token em {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.52rem;
  font-weight: 800;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.minion-token b {
  color: var(--danger);
  font-size: 0.64rem;
}

/* ── The stacked hand (Organic design system, scoped to the phone) ──────────
   Tokens and layout come from the "Stacked Card Hand" handoff: cream ground,
   terracotta + sage accents, Caprasimo display over Figtree body, pill
   controls, and a vertically stacked pile of card rows that expand in place. */
.phone {
  --o-n100: #f9f4ed;
  --o-n200: #eee7db;
  --o-n300: #dcd3c4;
  --o-n700: #645c50;
  --o-n800: #474238;
  --o-accent: #c67139;
  --o-accent-100: #fff2eb;
  --o-accent-600: #b2622d;
  --o-accent-700: #8c491a;
  --o-accent-800: #643312;
  --o-sage: #7a8a5e;
  --o-sage-100: #f0fae1;
  --o-sage-800: #3d472b;
  --o-sage-900: #272e1b;
  --o-shadow-sm: 0 1px 2px rgba(46, 43, 37, 0.14);
  --o-shadow-md: 0 3px 10px rgba(46, 43, 37, 0.16);
  --o-shadow-lg: 0 12px 32px rgba(46, 43, 37, 0.22);
  --o-heading: "Caprasimo", Georgia, serif;
  --o-body: "Figtree", Inter, system-ui, sans-serif;
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  overflow: hidden;
  background: #f5ead8;
  color: #201e1d;
  font-family: var(--o-body);
}

.turn-header {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--o-n300);
  border-radius: 0 0 28px 28px;
  background: var(--o-n100);
}

.turn-title-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.turn-title {
  display: flex;
  flex-direction: column;
}

.turn-kicker {
  color: var(--o-accent-700);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.turn-name {
  font-family: var(--o-heading);
  font-weight: 400;
  font-size: 30px;
  line-height: 1;
}

.turn-mana {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.mana-pips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  max-width: 96px;
}

.mana-pip {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: var(--o-sage);
  box-shadow: var(--o-shadow-sm);
}

.mana-pip.spent {
  background: var(--o-n300);
  box-shadow: none;
}

.mana-count {
  color: var(--o-n800);
  font-size: 14px;
}

.turn-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.turn-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--o-n200);
  color: var(--o-n800);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.turn-chip.outline {
  border: 1px solid var(--o-accent);
  background: transparent;
  color: var(--o-accent);
}

.turn-chip.sage {
  background: var(--o-sage-100);
  color: var(--o-sage-800);
}

.turn-chip.accent {
  background: var(--o-accent-100);
  color: var(--o-accent-800);
}

.turn-log {
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--o-sage-100);
  color: var(--o-sage-900);
  font-size: 13px;
  line-height: 1.35;
}

.phone .hand {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 20px 10px;
  scrollbar-width: none;
}

.phone .hand::-webkit-scrollbar {
  display: none;
}

.hand-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
}

.hand-title {
  font-family: var(--o-heading);
  font-weight: 400;
  font-size: 15px;
}

.hand-hint {
  color: var(--o-n700);
  font-size: 13px;
}

.hand-card {
  position: relative;
  padding: 14px 16px;
  border: 1px solid var(--o-n300);
  border-radius: 28px;
  background: var(--o-n100);
  box-shadow: var(--o-shadow-md);
  cursor: pointer;
  transform: rotate(var(--tilt, 0deg));
  transition: margin 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.25s, box-shadow 0.25s, opacity 0.2s;
}

.hand-card + .hand-card {
  margin-top: -10px;
}

.hand-card.expanded {
  margin-top: 12px;
  margin-bottom: 12px;
  transform: rotate(0deg);
  box-shadow: var(--o-shadow-lg);
}

.hand-card.blocked {
  opacity: 0.66;
}

.hand-card:focus-visible {
  outline: 2px solid var(--o-accent);
  outline-offset: 2px;
}

.hand-card-row {
  display: flex;
  align-items: center;
  gap: 13px;
}

.hand-card-row .art {
  flex: none;
  width: 42px;
  height: 58px;
  border: 0;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(32, 30, 29, 0.12);
}

.hand-card-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.hand-card-name {
  font-family: var(--o-heading);
  font-weight: 400;
  font-size: 18px;
  line-height: 1.15;
}

.hand-card-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--o-n700);
  font-size: 13px;
}

.hand-card-cost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--o-sage);
  color: #fff;
  font-family: var(--o-heading);
  font-size: 14px;
}

.hand-card-cost.blocked {
  background: var(--o-n300);
  color: var(--o-n700);
}

.hand-card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--o-n300);
}

.hand-card-effect {
  margin: 0;
  color: var(--o-n800);
  font-size: 16px;
  line-height: 1.45;
}

.hand-card-tags {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hand-card-costlabel {
  color: var(--o-n700);
  font-size: 13px;
}

.hand-card-actions {
  display: flex;
  gap: 10px;
}

.hand-empty {
  padding: 28px 18px;
  border-radius: 28px;
  background: var(--o-n200);
  color: var(--o-n800);
  text-align: center;
  font-size: 15px;
  line-height: 1.5;
}

.played-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 26px;
}

.o-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #201e1d;
  font-family: var(--o-heading);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
}

.o-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.o-btn:focus-visible {
  outline: 2px solid var(--o-accent);
  outline-offset: 2px;
}

.o-btn.primary {
  background: var(--o-accent);
  color: #f5ead8;
}

.o-btn.primary:not(:disabled):hover {
  background: var(--o-accent-600);
}

.o-btn.ghost {
  color: var(--o-accent);
}

.o-btn.ghost:hover {
  background: rgba(198, 113, 57, 0.1);
}

.hand-card-actions .o-btn.ghost {
  flex: 1;
  height: 46px;
}

.hand-card-actions .o-btn.cta {
  flex: 1.6;
  height: 46px;
}

.turn-footer {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 20px 24px;
  border-top: 1px solid var(--o-n300);
  border-radius: 28px 28px 0 0;
  background: var(--o-n100);
}

.o-btn.end-turn {
  height: 52px;
  font-size: 17px;
}

.turn-foot-hint {
  color: var(--o-n700);
  text-align: center;
  font-size: 12px;
}

.art {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #efe2cb;
  background-position: center;
  background-size: cover;
}

.art::before,
.art::after,
.effect::before,
.effect::after {
  content: "";
  position: absolute;
  display: block;
}

.art-beer::before {
  left: 45px;
  top: 18px;
  width: 34px;
  height: 46px;
  border: 4px solid #c79d45;
  border-radius: 4px 4px 8px 8px;
  background: linear-gradient(#fff 0 20%, #e9b44c 20%);
}

.art-beer::after {
  left: 78px;
  top: 30px;
  width: 18px;
  height: 22px;
  border: 4px solid #c79d45;
  border-left: 0;
  border-radius: 0 12px 12px 0;
}

.art-cocktail::before,
.art-pineapple::before,
.art-berry::before {
  left: 41px;
  top: 14px;
  width: 54px;
  height: 38px;
  clip-path: polygon(0 0, 100% 0, 62% 100%, 38% 100%);
  background: #d56f62;
}

.art-cocktail::after,
.art-pineapple::after,
.art-berry::after {
  left: 65px;
  top: 52px;
  width: 6px;
  height: 26px;
  background: #6d5142;
  box-shadow: -14px 26px 0 2px #6d5142, 14px 26px 0 2px #6d5142;
}

.art-bubbles::before {
  left: 30px;
  top: 18px;
  width: 20px;
  height: 20px;
  border: 4px solid #6fa7b7;
  border-radius: 50%;
  box-shadow: 32px 18px 0 -2px #efe2cb, 32px 18px 0 2px #6fa7b7, 60px -4px 0 -3px #efe2cb, 60px -4px 0 1px #6fa7b7;
}

.art-cucumber::before {
  left: 34px;
  top: 20px;
  width: 72px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 50%, #edf4cc 0 8px, transparent 9px), #7b9d5a;
}

.art-coffee::before {
  left: 38px;
  top: 22px;
  width: 56px;
  height: 38px;
  border-radius: 0 0 16px 16px;
  background: linear-gradient(#2d221c 0 62%, #d8c6ae 62%);
}

.art-shot::before,
.art-kombucha::before,
.art-lemon::before,
.art-drop::before,
.art-ice::before {
  left: 47px;
  top: 13px;
  width: 42px;
  height: 58px;
  border: 4px solid #6fa7b7;
  border-radius: 8px 8px 14px 14px;
  background: linear-gradient(transparent 0 35%, #afd7df 35%);
}

.art-lemon::after {
  left: 70px;
  top: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50% 0 50% 50%;
  background: #e6c94e;
  transform: rotate(-25deg);
}

.art-drop::after {
  left: 61px;
  top: 20px;
  width: 26px;
  height: 34px;
  border-radius: 50% 50% 50% 0;
  background: #6fa7b7;
  transform: rotate(-45deg);
}

.art::before,
.art::after {
  display: none;
}

.art-beer {
  background-image: url("./assets/cards/beer.png");
}

.art-cocktail {
  background-image: url("./assets/cards/cocktail.png");
}

.art-bubbles {
  background-image: url("./assets/cards/bubbles.png");
}

.art-pineapple {
  background-image: url("./assets/cards/pineapple.png");
}

.art-cucumber {
  background-image: url("./assets/cards/cucumber.png");
}

.art-coffee {
  background-image: url("./assets/cards/coffee.png");
}

.art-berry {
  background-image: url("./assets/cards/berry.png");
}

.art-ice {
  background-image: url("./assets/cards/ice.png");
}

.art-shot {
  background-image: url("./assets/cards/shot.png");
}

.art-kombucha {
  background-image: url("./assets/cards/kombucha.png");
}

.art-lemon {
  background-image: url("./assets/cards/lemon.png");
}

.art-drop {
  background-image: url("./assets/cards/drop.png");
}

.art-kapsyl {
  background-image: url("./assets/cards/kapsyl.png");
}

.art-kaktus {
  background-image: url("./assets/cards/kaktus.png");
}

.art-happyhour {
  background-image: url("./assets/cards/happyhour.png");
}

.art-talt {
  background-image: url("./assets/cards/talt.png");
}

.target-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 27, 22, 0.42);
}

.target-dialog {
  width: min(620px, 94vw);
  max-height: min(78vh, 520px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf3;
  box-shadow: 0 22px 58px rgba(32, 27, 22, 0.28);
}

.target-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.target-dialog-header h3 {
  margin: 0;
}

.target-list {
  padding: 0;
}

.target-buttons {
  display: grid;
  gap: 8px;
}

.target-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 0 14px;
  text-align: left;
}

.target-button span {
  color: var(--muted);
  font-size: 0.78rem;
}

.primary-button,
.plain-button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.plain-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.ability-layer {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.card-play-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 50;
  display: grid;
  grid-template-columns: 150px minmax(220px, 1fr);
  gap: 20px;
  align-items: center;
  width: min(680px, 82vw);
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fffaf3;
  box-shadow: 0 30px 90px rgba(32, 27, 22, 0.36);
  transform: translate(-50%, -50%);
  animation: cardPlaySlam 1700ms cubic-bezier(.2, .9, .2, 1) forwards;
}

.played-card-visual {
  display: grid;
  grid-template-rows: 96px auto auto;
  min-height: 220px;
  padding: 10px;
  border: 1px solid #cdbda9;
  border-radius: 8px;
  background: var(--card);
  text-align: center;
  transform: rotate(-4deg);
}

.played-card-visual .art {
  width: 100%;
  height: 96px;
}

.played-card-visual strong {
  align-self: end;
  margin-top: 10px;
  color: var(--ink);
  font-size: 1rem;
}

.played-card-visual small {
  width: fit-content;
  margin: 8px auto 0;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-weight: 900;
}

.played-card-copy span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: uppercase;
}

.played-card-copy h2 {
  margin: 6px 0;
  font-size: clamp(2.1rem, 5vw, 4.8rem);
  line-height: 0.92;
}

.played-card-copy p {
  margin: 0;
  color: var(--danger);
  font-size: 1.35rem;
  font-weight: 900;
}

.card-spark {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 45;
  width: 18px;
  height: 18px;
  border: 2px solid var(--danger);
  border-radius: 3px;
  background: #fffaf3;
  animation: cardSpark 1000ms ease-out var(--delay) forwards;
  transform: rotate(var(--spin));
}

.board-alert {
  position: absolute;
  left: 50%;
  top: 24px;
  z-index: 20;
  display: grid;
  min-width: min(560px, 86%);
  padding: 20px 24px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fffaf3;
  box-shadow: 0 22px 58px rgba(32, 27, 22, 0.26);
  text-align: center;
  transform: translateX(-50%);
  animation: alertPop 260ms ease-out;
}

.board-alert strong {
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 0.95;
}

.board-alert span {
  color: var(--danger);
  font-size: clamp(1.2rem, 2.4vw, 2rem);
  font-weight: 900;
}

.board-alert-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.board-alert-list span {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  text-align: left;
}

.board-alert-list b {
  color: var(--ink);
}

.effect {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 92px;
  height: 92px;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: #fffaf3;
  transform: translate(-50%, -50%);
  animation: burst 720ms ease-out forwards;
}

.effect.damage {
  color: var(--danger);
}

.effect.heal {
  color: var(--heal);
}

.effect.shield {
  color: var(--shield);
}

.ko-spark {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 30;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 2px solid var(--danger);
  border-radius: 50%;
  background: #fffaf3;
  color: var(--danger);
  font-size: 2rem;
  font-weight: 1000;
  transform: translate(-50%, -50%) rotate(var(--r));
  animation: koSpark 1200ms ease-out forwards;
}

.drink-alert,
.death-screen {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 27, 22, 0.58);
}

.drink-alert > div,
.death-screen > div {
  width: min(620px, 92vw);
  padding: 28px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fffaf3;
  text-align: center;
  box-shadow: 0 28px 70px rgba(32, 27, 22, 0.34);
  animation: alertPop 240ms ease-out;
}

.drink-alert h2,
.death-screen h2 {
  margin: 0 0 12px;
  font-size: clamp(3.2rem, 12vw, 7rem);
  line-height: 0.88;
}

.death-screen {
  z-index: 500;
  background: var(--ink);
  color: #fffaf3;
}

.death-screen > div {
  border-color: #fffaf3;
  background: var(--ink);
}

.death-screen p {
  color: #f3eadb;
}

/* The winner's phone reuses the death-screen shell with celebration colors. */
.death-screen.winner {
  background: #b8862e;
}

.death-screen.winner > div {
  border-color: #201b16;
  background: #fff3c8;
  color: var(--ink);
}

.death-screen.winner p {
  color: #6b5638;
}

/* ── Winner celebration ─────────────────────────────────────────────────────
   The mascot is deliberately NOT a card: no CARD_ART entry, no .art-* rule —
   the card-art tests pin those lists exactly. */
.winner-chicken {
  display: block;
  width: min(260px, 60vw);
  height: min(163px, 38vw);
  margin: 0 auto 10px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background-image: url("./assets/cards/kyckling.png");
  background-position: center;
  background-size: cover;
  box-shadow: 0 14px 34px rgba(32, 27, 22, 0.25);
}

/* Above the card-play banner (z 50), which removes itself moments later. */
.winner-screen {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 27, 22, 0.35);
}

.winner-card {
  width: min(560px, 92%);
  padding: 26px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fff3c8;
  text-align: center;
  box-shadow: 0 28px 70px rgba(32, 27, 22, 0.4);
  animation: alertPop 240ms ease-out;
}

.winner-card h2 {
  margin: 0 0 8px;
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  line-height: 0.92;
}

.winner-card p {
  margin: 0;
  color: #6b5638;
}

.firework {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffd75e;
  filter: hue-rotate(var(--hue, 0deg));
  opacity: 0;
  animation: fireworkPop 1200ms ease-out var(--delay, 0ms) forwards;
}

@keyframes fireworkPop {
  0% {
    opacity: 0;
    box-shadow: 0 0 0 0 rgba(255, 190, 80, 0);
    transform: scale(0.4);
  }
  12% {
    opacity: 1;
  }
  45% {
    opacity: 1;
    box-shadow:
      0 -34px 0 -2px #ffb14e, 24px -24px 0 -3px #ff7b6b, 34px 0 0 -2px #ffd75e,
      24px 24px 0 -3px #8fd177, 0 34px 0 -2px #6fb3d9, -24px 24px 0 -3px #ff7b6b,
      -34px 0 0 -2px #ffd75e, -24px -24px 0 -3px #8fd177;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    box-shadow:
      0 -52px 0 -4px rgba(255, 177, 78, 0), 38px -38px 0 -5px rgba(255, 123, 107, 0),
      52px 0 0 -4px rgba(255, 215, 94, 0), 38px 38px 0 -5px rgba(143, 209, 119, 0),
      0 52px 0 -4px rgba(111, 179, 217, 0), -38px 38px 0 -5px rgba(255, 123, 107, 0),
      -52px 0 0 -4px rgba(255, 215, 94, 0), -38px -38px 0 -5px rgba(143, 209, 119, 0);
    transform: scale(1.25);
  }
}

body.view-board .game {
  grid-template-columns: 1fr;
}

body.view-board .phone {
  display: none;
}

/* The stacked hand is portrait-first: header and footer pin, the pile scrolls,
   and the whole thing fills the phone's viewport. */
body.view-hand {
  background: #f5ead8;
}

body.view-hand .game {
  display: block;
  width: 100%;
  min-height: 100dvh;
  padding: 0;
  margin: 0;
}

body.view-hand .board,
body.view-hand .waiting-room {
  display: none;
}

body.view-hand .phone {
  position: static;
  height: 100dvh;
  max-height: none;
  border: 0;
  border-radius: 0;
}

@media (min-width: 520px) {
  body.view-hand .phone {
    max-width: 430px;
    margin: 0 auto;
    border-left: 1px solid #dcd3c4;
    border-right: 1px solid #dcd3c4;
  }
}

@keyframes burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  42% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.45);
  }
}

@keyframes cardPlaySlam {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.55) rotate(-6deg);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(1deg);
  }
  72% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -55%) scale(0.92) rotate(2deg);
  }
}

@keyframes cardSpark {
  0% {
    opacity: 0;
    transform: rotate(var(--spin)) scale(0.4);
  }
  35% {
    opacity: 1;
    transform: rotate(calc(var(--spin) + 90deg)) scale(1.15);
  }
  100% {
    opacity: 0;
    transform: translateY(-70px) rotate(calc(var(--spin) + 210deg)) scale(0.2);
  }
}

@keyframes alertPop {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.drink-alert > div,
.death-screen > div {
  animation-name: alertPopCentered;
}

@keyframes alertPopCentered {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes koSpark {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--r)) scale(0.35);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(var(--r)) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -90%) rotate(var(--r)) scale(1.6);
  }
}

@media (max-width: 960px) {
  .game {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .phone {
    position: relative;
    top: 0;
    max-height: none;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .turn-status {
    text-align: left;
  }

  .view-links {
    width: 100%;
  }

  .view-links a {
    flex: 1;
  }

  .waiting-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .lobby-card {
    padding: 18px;
  }

  .form-actions,
  .waiting-copy,
  .actionbar {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 2.45rem;
  }

  .arena {
    min-height: 440px;
  }

  .players {
    inset: 10px;
  }

  .player {
    width: 132px;
    min-height: 118px;
    padding: 10px;
  }
}
