/* Wingspan · BoardBazi
   Phone first: a stacked portrait table; body.lay-desktop switches to a three-column table.
   Colours follow the box: parchment cards, forest green, wheat gold and wetland blue. */

:root {
  --bg: #1d2a22;
  --bg-2: #24352b;
  --panel: #f6efdf;
  --panel-2: #ece2cb;
  --ink: #2b2a22;
  --ink-2: #6b6552;
  --line: rgba(60, 50, 30, .18);
  --gold: #d9a13b;
  --gold-2: #b98326;
  --green: #4f8a3c;
  --forest: #2f6b3a;
  --grass: #c9a52c;
  --water: #2f6fb0;
  --red: #b5452f;
  --pink: #c75a8a;
  --brown: #a6773d;
  --radius: 12px;
  --app-h: 100vh;
  --bar-h: 40px;
  --font: Vazirmatn, "Vazir", Tahoma, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  font-size: 15px;
  line-height: 1.5;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
body.busy { cursor: progress; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #fffaf0; color: var(--ink);
  text-decoration: none; font-weight: 600; white-space: nowrap;
  transition: transform .08s, background .15s, opacity .15s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; }
.btn-gold { background: linear-gradient(180deg, #e8b84f, var(--gold-2)); border-color: #9b6c1d; color: #2a1d05; }
.btn-ghost { background: transparent; }
.btn-danger { background: #f4dbd4; border-color: #d9a093; color: #7a2412; }
.btn-lg { min-height: 50px; font-size: 17px; width: 100%; }
.btn-sm { min-height: 34px; padding: 4px 10px; font-size: 13px; }
.btn-xs { min-height: 28px; min-width: 28px; padding: 2px 8px; font-size: 13px; }
.icon-btn { background: transparent; border: 0; color: #fff; font-size: 22px; width: 40px; height: 40px; }

.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); font-weight: 600; }
.tag-off { background: #f2d6cf; color: #8b2e1a; }

/* ---------------- splash ---------------- */
.splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: radial-gradient(circle at 50% 35%, #33503d, var(--bg)); transition: opacity .45s; }
.splash.gone { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; color: #f6efdf; }
.splash-logo { width: 96px; height: 96px; object-fit: contain; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .4)); animation: float 2.4s ease-in-out infinite; }
.splash-title { font-size: 30px; letter-spacing: .3em; font-weight: 300; margin: 10px 0 18px; }
.splash-bar { width: 220px; height: 6px; background: rgba(255, 255, 255, .15); border-radius: 6px; overflow: hidden; margin: 0 auto; }
.splash-fill { height: 100%; width: 0; background: var(--gold); transition: width .2s; }
.splash-text { margin-top: 10px; font-size: 13px; opacity: .8; }
@keyframes float { 50% { transform: translateY(-8px); } }

/* ---------------- BoardBazi bar ---------------- */
.bb-bar {
  position: fixed; inset-inline: 0; top: 0; z-index: 30;
  height: calc(var(--bar-h) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
  padding-inline: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: rgba(14, 18, 29, .92); border-bottom: 1px solid rgba(255, 255, 255, .08); color: #f8fafc;
  backdrop-filter: blur(6px);
}
.bb-bar a { color: inherit; text-decoration: none; }
.bb-brand { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; min-width: 0; }
.bb-mark { width: 24px; height: 24px; border-radius: 6px; background: linear-gradient(135deg, #6366f1, #06b6d4); display: grid; place-items: center; color: #fff; flex: none; }
.bb-chip { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; }
.bb-initial { width: 24px; height: 24px; border-radius: 50%; background: #334155; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.bb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.bb-level { font-size: 12px; color: #94a3b8; white-space: nowrap; }
.bb-xp { width: 48px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .15); overflow: hidden; flex: none; }
.bb-xp-fill { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #06b6d4); }
.bb-signin { font-size: 13px; color: #cbd5e1 !important; }
body.with-bar .view-intro { padding-top: calc(var(--bar-h) + env(safe-area-inset-top) + 12px); }
@media (max-width: 380px) { .bb-word { display: none; } }

/* ---------------- intro / home / lobby ---------------- */
.app { min-height: var(--app-h); }
.view-intro { position: relative; min-height: var(--app-h); display: flex; align-items: center; justify-content: center; padding: 16px; overflow: hidden; }
.intro-hero { position: fixed; inset: 0; background: url(img/ui/hero.webp) center / cover no-repeat; filter: saturate(1.05); }
.intro-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20, 30, 22, .25), rgba(20, 30, 22, .7)); }
@media (orientation: portrait) { .intro-hero { background-image: url(img/ui/hero-tall.webp); } }
.intro-card {
  position: relative; z-index: 1; width: 100%; max-width: 440px;
  background: rgba(246, 239, 223, .96); border-radius: 18px; padding: 22px 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35); display: flex; flex-direction: column; gap: 12px;
}
.intro-box { width: 92px; align-self: center; border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); margin-top: -4px; }
.intro-title { margin: 0; text-align: center; font-size: 30px; color: var(--forest); letter-spacing: .02em; }
.intro-sub { margin: -8px 0 0; text-align: center; color: var(--ink-2); font-size: 14px; }
.intro-text { margin: 0; color: var(--ink); font-size: 14.5px; text-align: justify; }
.intro-hint { background: #fff3cf; border-radius: 8px; padding: 8px 10px; margin: 0; font-size: 14px; }
.intro-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.intro-link { text-align: center; color: var(--forest); text-decoration: none; font-size: 14px; }
.intro-note { margin: 0; text-align: center; font-size: 12px; color: var(--ink-2); }
.lang-switch { display: flex; gap: 4px; justify-content: flex-end; }
.lang-switch button { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 2px 10px; font-size: 13px; }
.lang-switch button.on { background: var(--forest); color: #fff; border-color: var(--forest); }
.dev-login { border-top: 1px dashed var(--line); padding-top: 10px; font-size: 13px; }
.dev-login .row { display: flex; gap: 6px; margin-top: 4px; }
.dev-login input, .join-form input { flex: 1; min-width: 0; min-height: 40px; border-radius: 10px; border: 1px solid var(--line); padding: 6px 10px; font: inherit; background: #fff; }
.home-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.home-hello { color: var(--ink-2); font-size: 13px; }
.home-name { font-size: 22px; font-weight: 700; }
.home-tools { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.home-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.home-stats:empty { display: none; }
.home-stats div { background: var(--panel-2); border-radius: 10px; padding: 8px; text-align: center; }
.home-stats b { display: block; font-size: 20px; }
.home-stats span { font-size: 12px; color: var(--ink-2); }
.divider { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.join-form { display: flex; gap: 8px; }
.join-form input { text-transform: uppercase; letter-spacing: .2em; text-align: center; font-weight: 700; }

.lobby-top { display: flex; align-items: center; gap: 10px; }
.chip { background: var(--panel-2); border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.lobby-code { flex: 1; font-size: 28px; font-weight: 800; letter-spacing: .25em; color: var(--forest); }
.lobby-help { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.lobby-count { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.lobby-seats { display: flex; flex-direction: column; gap: 6px; }
.seat { display: flex; align-items: center; gap: 8px; background: #fffaf0; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; min-height: 44px; }
.seat-empty { border-style: dashed; background: transparent; color: var(--ink-2); }
.seat-dot, .pc-dot { width: 12px; height: 12px; border-radius: 50%; background: #ccc; flex: none; display: inline-block; }
.seat-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-name small { color: var(--ink-2); font-weight: 400; }
.lobby-settings { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle > span:first-child { flex: 1; display: flex; flex-direction: column; }
.toggle small, .seg-row small { color: var(--ink-2); font-size: 12px; }
.toggle input { display: none; }
.toggle-ui { width: 46px; height: 26px; border-radius: 26px; background: #cfc6b1; position: relative; transition: background .2s; flex: none; }
.toggle-ui::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: inset-inline-start .2s; }
.toggle input:checked + .toggle-ui { background: var(--green); }
.toggle input:checked + .toggle-ui::after { inset-inline-start: 23px; }
.toggle input:disabled + .toggle-ui { opacity: .5; }
.seg-row { display: flex; flex-direction: column; gap: 4px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 6px; font-size: 13px; font-weight: 600; }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button.on { background: var(--forest); color: #fff; }
.lobby-actions { display: flex; gap: 8px; }
.lobby-actions .btn { flex: 1; }

/* ---------------- game: frame ---------------- */
.view-game {
  height: var(--app-h); display: flex; flex-direction: column; overflow: hidden;
  background: radial-gradient(circle at 50% 0, #2d4535, var(--bg) 70%);
  padding-bottom: env(safe-area-inset-bottom);
}
.g-top {
  display: flex; align-items: center; gap: 8px; padding: calc(4px + env(safe-area-inset-top)) 8px 4px;
  color: #f6efdf; min-height: 44px; flex: none;
}
.g-round { display: flex; flex-direction: column; line-height: 1.15; font-size: 13px; font-weight: 700; white-space: nowrap; }
.g-round small { font-weight: 400; opacity: .8; font-size: 11.5px; }
.g-status { flex: 1; text-align: center; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.my-turn .g-status { color: #ffd77a; }
.g-timer { font-variant-numeric: tabular-nums; font-size: 13px; background: rgba(0, 0, 0, .25); padding: 2px 8px; border-radius: 8px; }
.g-timer.urgent { background: var(--red); animation: pulse 1s infinite; }
.g-conn { width: 8px; height: 8px; border-radius: 50%; background: #5bd06a; flex: none; }
.g-conn.lost { background: #e0533b; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.g-players { display: flex; gap: 6px; padding: 0 8px 6px; overflow-x: auto; flex: none; scrollbar-width: none; }
.g-players::-webkit-scrollbar { display: none; }
.pchip {
  flex: 1 0 auto; min-width: 92px; max-width: 170px; display: flex; flex-direction: column; gap: 1px;
  padding: 4px 8px; border-radius: 10px; border: 2px solid transparent; background: rgba(246, 239, 223, .1); color: #f6efdf; text-align: start;
}
.pchip.viewing { background: rgba(246, 239, 223, .22); }
.pchip.active { border-color: var(--pc); box-shadow: 0 0 0 2px rgba(0, 0, 0, .2), 0 0 14px color-mix(in srgb, var(--pc) 60%, transparent); }
.pchip.deciding { border-style: dashed; border-color: var(--pc); }
.pchip.removed { opacity: .6; }
.pc-top { display: flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; min-width: 0; }
.pc-top .pc-dot { background: var(--pc); width: 10px; height: 10px; }
.pc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-first { width: 16px; height: 16px; object-fit: contain; }
.pc-stats { display: flex; gap: 8px; font-size: 11.5px; align-items: center; opacity: .95; }
.pc-stats b { font-size: 14px; color: #ffd77a; }
.pc-stats span { display: inline-flex; align-items: center; gap: 2px; }
.pc-cubes { display: flex; gap: 2px; height: 5px; }
.pc-cubes i { width: 7px; height: 5px; border-radius: 1px; background: var(--pc); opacity: .9; }

.g-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; }
.g-center { display: flex; flex-direction: column; gap: 6px; padding: 0 8px 8px; }

/* ---------------- shared table ---------------- */
.g-table { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; padding: 0 8px 6px; align-items: stretch; }
.tbl-block { background: rgba(246, 239, 223, .1); border-radius: 10px; padding: 4px 6px; min-width: 0; }
.tbl-block h3 { margin: 0 0 2px; font-size: 10.5px; color: rgba(246, 239, 223, .75); font-weight: 600; }
.feeder .dice { display: grid; grid-template-columns: repeat(3, 26px); gap: 3px; }
.dice-out { display: flex; gap: 2px; margin-top: 3px; }
.die {
  width: 26px; height: 26px; border-radius: 6px; background: #fbf6ea; border: 1px solid #d8ccb0;
  display: grid; place-items: center; padding: 2px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .08);
}
.die .fi { width: 100%; height: 100%; }
.die-split { display: grid; grid-template-columns: 1fr 1fr; width: 100%; height: 100%; }
.die-split .fi { width: 100%; height: 100%; }
.die.pick { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 0 10px rgba(217, 161, 59, .8); animation: bob 1.2s ease-in-out infinite; }
.die-ghost { width: 8px; height: 8px; border-radius: 2px; background: rgba(246, 239, 223, .25); border: 0; box-shadow: none; padding: 0; }
@keyframes bob { 50% { transform: translateY(-2px); } }

.tray { display: flex; gap: 4px; align-items: flex-start; }
.card {
  position: relative; display: block; padding: 0; border: 0; background: transparent; border-radius: 6px;
  aspect-ratio: 520 / 790; flex: none;
}
.card .bird-img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; display: block; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); background: #e9e0c9; }
.card-empty { background: rgba(246, 239, 223, .08); border: 1px dashed rgba(246, 239, 223, .25); }
.tray .card { width: 46px; }
.deck-n { position: absolute; bottom: 2px; inset-inline: 0; text-align: center; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; }
.card.pick .bird-img { box-shadow: 0 0 0 2px var(--gold), 0 0 12px rgba(217, 161, 59, .9); }
.card.chosen .bird-img { box-shadow: 0 0 0 3px #4cc06a, 0 0 12px rgba(76, 192, 106, .9); transform: translateY(-4px); }

.goals { display: grid; grid-template-columns: repeat(2, 30px); gap: 3px; }
.goal { position: relative; padding: 0; border: 0; background: transparent; width: 30px; height: 30px; border-radius: 5px; }
.goal img { width: 100%; height: 100%; border-radius: 5px; display: block; opacity: .9; }
.goal.current img { box-shadow: 0 0 0 2px var(--gold); opacity: 1; }
.goal.done img { filter: saturate(.4); opacity: .6; }
.goal-r { position: absolute; top: -3px; inset-inline-start: -3px; background: #2b2a22; color: #fff; font-size: 9px; border-radius: 50%; width: 13px; height: 13px; display: grid; place-items: center; }
.goal-pts, .goal-now { position: absolute; bottom: -3px; inset-inline-end: -3px; font-size: 9.5px; font-weight: 800; border-radius: 6px; padding: 0 3px; }
.goal-pts { background: var(--green); color: #fff; }
.goal-now { background: var(--gold); color: #2a1d05; }

/* ---------------- actions ---------------- */
.g-viewing { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #f6efdf; font-weight: 700; padding: 2px 2px; }
.g-actions { display: grid; grid-template-columns: 1.25fr 1fr 1fr 1fr; gap: 5px; }
.act {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 42px;
  border-radius: 10px; border: 0; color: #fff; font-weight: 700; font-size: 13px; padding: 4px 6px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18);
}
.act:disabled { opacity: .45; filter: saturate(.5); }
.act:active:not(:disabled) { transform: translateY(1px); }
.act-play { background: linear-gradient(180deg, #c2783b, #8f4f22); }
.act-forest { background: linear-gradient(180deg, #3f8550, var(--forest)); }
.act-grassland { background: linear-gradient(180deg, #d8b437, #a78417); color: #2a1d05; }
.act-wetland { background: linear-gradient(180deg, #3e83c7, var(--water)); }
.act-ico { font-size: 16px; }
.act-txt b { font-size: 15px; }
.act-plus { position: absolute; top: -5px; inset-inline-end: -3px; background: var(--gold); color: #2a1d05; width: 16px; height: 16px; border-radius: 50%; font-size: 12px; line-height: 16px; text-align: center; }
body.my-turn .g-actions .act:not(:disabled) { animation: glow 2.2s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), 0 0 12px rgba(255, 215, 122, .55); } }

/* ---------------- the player mat ---------------- */
.mat { position: relative; width: 100%; aspect-ratio: 1601 / 982; border-radius: 10px; overflow: hidden; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); background: #3b5c43; }
.mat-inner { position: absolute; top: 0; height: 100%; width: 100%; left: 0; background: url(img/ui/mat.webp) center / 100% 100% no-repeat; }
/* Phones: only the five columns of slots are shown (the habitat labels become the action buttons above) */
.mat.crop { aspect-ratio: 1216 / 982; }
.mat.crop .mat-inner { width: calc(100% * 1601 / 1216); left: calc(-100% * 296 / 1216); }
.slot { position: absolute; display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.slot.next { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .55); }
body.my-turn .slot.next { box-shadow: inset 0 0 0 2px rgba(255, 215, 122, .8); }
.board-card { height: 96%; }
.board-card .bird-img { border-radius: 5px; }
.board-card.target .bird-img { box-shadow: 0 0 0 2px var(--gold), 0 0 12px rgba(217, 161, 59, .95); }
.board-card.chosen .bird-img { box-shadow: 0 0 0 3px #4cc06a, 0 0 14px rgba(76, 192, 106, .95); }
.board-card.fresh { animation: land .7s ease-out; }
@keyframes land { from { transform: translateY(-16px) scale(1.08); opacity: .3; } }
.badges {
  position: absolute; bottom: 2px; inset-inline: 2px; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px;
  font-size: 10px; font-weight: 800; line-height: 1;
}
.badges > span { display: inline-flex; align-items: center; gap: 1px; background: rgba(255, 252, 244, .92); border-radius: 6px; padding: 1px 3px; box-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.badges .egg { width: 10px; height: 12px; object-fit: contain; }
.badges .fi { width: 11px; height: 11px; }
.plus-eggs, .minus-eggs { color: #fff !important; background: #3c9a52 !important; font-size: 11px; }
.minus-eggs { background: var(--red) !important; }
.mat-label { position: absolute; background: transparent; border: 0; border-radius: 8px; }
.mat-label.live:hover { background: rgba(255, 215, 122, .18); box-shadow: inset 0 0 0 2px rgba(255, 215, 122, .7); }
.mat.crop .mat-label { display: none; }

/* ---------------- my supply ---------------- */
.g-me { display: flex; align-items: center; gap: 6px; }
.foods { display: flex; gap: 3px; flex: 1; min-width: 0; }
.food { display: inline-flex; align-items: center; gap: 2px; background: rgba(246, 239, 223, .95); border: 1px solid transparent; border-radius: 8px; padding: 2px 5px 2px 3px; font-size: 13px; }
.food .fi { width: 20px; height: 20px; }
.food.zero { opacity: .45; }
.food.pick { border-color: var(--gold); box-shadow: 0 0 10px rgba(217, 161, 59, .9); }
.me-bonus { background: rgba(246, 239, 223, .95); }
.me-bonus-n { color: #f6efdf; font-size: 13px; }
.me-score { background: transparent; border: 0; color: #f6efdf; font-size: 12px; white-space: nowrap; padding: 2px 4px; }
.me-score b { color: #ffd77a; font-size: 16px; }

/* ---------------- hand ---------------- */
.hand { display: flex; gap: 6px; overflow-x: auto; padding: 6px 2px 4px; scroll-snap-type: x proximity; min-height: 118px; }
.hand-card { width: 72px; scroll-snap-align: start; transition: transform .15s; }
.hand-card.playable .bird-img { box-shadow: 0 0 0 2px #7fd18f, 0 0 12px rgba(127, 209, 143, .8); }
.hand-empty { color: rgba(246, 239, 223, .6); font-size: 13px; padding: 30px 6px; }

/* ---------------- food icons, nests, habitats ---------------- */
.fi { width: 18px; height: 18px; object-fit: contain; vertical-align: middle; display: inline-block; }
.fi-xs { width: 13px; height: 13px; }
.fi-lg { width: 34px; height: 34px; }
.fi-wild { border-radius: 50%; background: conic-gradient(#3b78c2 0 20%, #c8423a 0 40%, #4f8a3c 0 60%, #8a6a4a 0 80%, #e2a73b 0); }
.cost { display: inline-flex; align-items: center; gap: 1px; flex-wrap: wrap; }
.slash { font-weight: 800; color: var(--ink-2); margin: 0 1px; }
.egg { width: 14px; height: 16px; object-fit: contain; vertical-align: middle; }
.nest { width: 18px; height: 18px; vertical-align: middle; color: var(--brown); }
.hab { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; font-size: 14px; transform: rotate(45deg) scale(.8); margin: 0 3px; }
.hab-forest { background: var(--forest); }
.hab-grassland { background: var(--grass); }
.hab-wetland { background: var(--water); }

/* ---------------- prompt bar & ticker ---------------- */
.g-prompt {
  flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--panel); padding: 8px 10px; box-shadow: 0 -4px 16px rgba(0, 0, 0, .3); min-height: 56px;
  border-top: 3px solid transparent;
}
body.my-turn .g-prompt { border-top-color: var(--gold); }
.pr-text { flex: 1 1 180px; font-size: 14px; font-weight: 600; min-width: 0; }
.pr-wait { color: var(--ink-2); font-weight: 500; }
.pr-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pr-btns .btn { min-height: 38px; }
.g-ticker {
  position: fixed; top: calc(52px + env(safe-area-inset-top)); inset-inline: 10px; z-index: 20;
  background: rgba(28, 38, 31, .94); color: #f6efdf; border-radius: 10px; padding: 6px 10px; font-size: 13px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35); pointer-events: none; animation: drop .25s ease-out;
}
@keyframes drop { from { transform: translateY(-8px); opacity: 0; } }
.log-warning { color: #f0b49f; }
.log-success { color: #9fe0a9; font-weight: 700; }

/* ---------------- sheets ---------------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(10, 16, 12, .55); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 88vh; background: var(--panel); border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .4); animation: up .22s ease-out; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.wide { max-width: 860px; }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
.sheet-close { position: absolute; top: 6px; inset-inline-end: 8px; z-index: 2; width: 36px; height: 36px; border: 0; background: rgba(0, 0, 0, .06); border-radius: 50%; font-size: 22px; line-height: 1; }
.sheet-body { overflow-y: auto; padding: 16px 16px 18px; }
.sheet-body h2 { margin: 0 0 8px; font-size: 18px; padding-inline-end: 36px; }
.sheet-body h3 { margin: 14px 0 6px; font-size: 14px; color: var(--ink-2); }
.sheet-row { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.sheet-row .btn { flex: 1; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.confirm-backdrop { align-items: center; z-index: 60; }
.confirm-sheet { border-radius: 16px; max-width: 380px; margin: 16px; padding: 18px; }
.confirm-sheet h2 { margin: 0 0 6px; font-size: 18px; }
.confirm-sheet p { margin: 0 0 14px; color: var(--ink-2); font-size: 14px; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }

.card-sheet { display: flex; flex-direction: column; gap: 12px; }
.card-big { align-self: center; width: min(62vw, 300px); }
.card-big .bird-img { width: 100%; border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); display: block; aspect-ratio: 520 / 790; object-fit: cover; background: #e9e0c9; }
.card-info { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card-head h2 { margin: 0; }
.card-sub { font-size: 13px; color: var(--ink-2); }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.facts > div { background: #fffaf0; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; display: flex; flex-direction: column; gap: 2px; }
.facts span { font-size: 11px; color: var(--ink-2); }
.facts b { font-size: 14px; display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.power { border-radius: 10px; padding: 8px 10px; border-inline-start: 5px solid var(--brown); background: #fbf2df; }
.power p { margin: 4px 0 0; font-size: 14px; }
.power-when { font-size: 12px; font-weight: 700; color: var(--brown); margin-inline-end: 6px; }
.power-white { border-color: #b8ad95; background: #fffdf8; }
.power-white .power-when { color: #6b6552; }
.power-pink { border-color: var(--pink); background: #fbe9f0; }
.power-pink .power-when { color: var(--pink); }
.power-none { color: var(--ink-2); font-size: 14px; }
.on-bird { background: #eef6e6; border-radius: 8px; padding: 6px 10px; font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.play-opts { display: flex; flex-direction: column; gap: 6px; }
.play-opts small { font-weight: 600; opacity: .85; }

.play-wiz .play-head { display: flex; gap: 12px; align-items: center; }
.play-wiz .play-head .bird-img { width: 64px; border-radius: 6px; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.pay-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.pay-opt { border: 2px solid var(--line); background: #fffaf0; border-radius: 10px; padding: 6px 10px; min-height: 40px; }
.pay-opt .fi { width: 24px; height: 24px; }
.pay-opt.on { border-color: var(--green); background: #e8f4e2; }
.egg-rows { display: flex; flex-direction: column; gap: 4px; }
.egg-row { display: flex; align-items: center; gap: 8px; background: #fffaf0; border-radius: 8px; padding: 4px 8px; }
.egg-bird { flex: 1; font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.egg-have { font-size: 12px; color: var(--ink-2); }
.stepper { display: inline-flex; align-items: center; gap: 6px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.card-grid .card { width: 100%; }
.card-cap { display: block; text-align: center; font-size: 11.5px; margin-top: 3px; color: var(--ink); font-weight: 600; }
.food-picks { display: flex; gap: 8px; flex-wrap: wrap; }
.food-pick { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; padding: 6px 8px; border-radius: 12px; border: 2px solid var(--line); background: #fffaf0; font-size: 12px; }
.food-pick.on { border-color: var(--green); background: #e8f4e2; }
.picked { display: flex; gap: 6px; flex-wrap: wrap; min-height: 34px; margin-top: 10px; }
.chip-food { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 2px 8px; }

.bonus-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.bonus-card { position: relative; display: flex; flex-direction: column; gap: 4px; border: 2px solid var(--line); background: #fffaf0; border-radius: 12px; padding: 6px; text-align: start; }
.bonus-card img { width: 100%; border-radius: 8px; aspect-ratio: 520 / 790; object-fit: cover; }
.bonus-cap { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.bonus-cap small { color: var(--ink-2); font-size: 11.5px; }
.bonus-cap em { font-style: normal; color: var(--green); font-weight: 700; font-size: 12px; }
.tick { position: absolute; top: 8px; inset-inline-end: 8px; background: var(--green); color: #fff; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 800; }

.setup-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.setup-card { width: 100%; }
.setup-count { flex: 1; font-weight: 700; }
.setup-count.ok { color: var(--green); }
.setup-count.bad { color: var(--red); }

.goal-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: 10px; background: #fffaf0; margin-bottom: 6px; border: 1px solid var(--line); }
.goal-row.current { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.goal-row img { width: 56px; height: 56px; border-radius: 8px; flex: none; }
.goal-row small { display: block; }
.goal-players { list-style: none; margin: 4px 0 0; padding: 0; font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.goal-players li { display: flex; align-items: center; gap: 4px; }

.score-wrap { overflow-x: auto; }
.score-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.score-table th, .score-table td { padding: 6px 6px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.score-table th { font-size: 12.5px; }
.score-table th .pc-dot { background: var(--pc); margin-inline-end: 3px; width: 9px; height: 9px; }
.score-table td:first-child { text-align: start; color: var(--ink-2); }
.score-table tr.total td { font-weight: 800; font-size: 16px; color: var(--ink); background: #fbf2df; }
.score-table tr.sub td { font-size: 12px; color: var(--ink-2); }
.results h2 { text-align: center; font-size: 22px; }

.menu-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.menu-list .btn { justify-content: flex-start; }
.g-log { list-style: none; margin: 0; padding: 0; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.g-log li { padding: 3px 6px; border-radius: 6px; }
.sheet .g-log li:nth-child(odd) { background: rgba(0, 0, 0, .03); }
.sheet .log-warning { color: #9b3a1f; }
.sheet .log-success { color: #2c7a3d; }
.rules h3 { color: var(--forest); }
.rules ul { padding-inline-start: 18px; }
.rules p, .rules li { font-size: 14px; }

.toast {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 70;
  background: #2b2a22; color: #fff; padding: 10px 16px; border-radius: 10px; max-width: calc(100vw - 32px); font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35); text-align: center;
}

/* Desktop log panel is hidden on phones */
.g-log-panel { display: none; }

/* ---------------- phones held sideways ---------------- */
body.lay-phone.landscape .g-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); grid-template-rows: auto 1fr; align-content: start; }
body.lay-phone.landscape .g-table { grid-column: 1; grid-row: 1; }
body.lay-phone.landscape .g-center { grid-column: 2; grid-row: 1 / span 2; }
body.lay-phone.landscape .tray .card { width: 54px; }

/* ---------------- tablets / small laptops on the phone layout ---------------- */
@media (min-width: 640px) {
  body.lay-phone .g-center, body.lay-phone .g-table { max-width: 720px; margin-inline: auto; width: 100%; }
  body.lay-phone .hand-card { width: 88px; }
  body.lay-phone .tray .card { width: 60px; }
  body.lay-phone .die { width: 32px; height: 32px; }
  body.lay-phone .feeder .dice { grid-template-columns: repeat(5, 32px); }
  body.lay-phone .goals { grid-template-columns: repeat(4, 40px); }
  body.lay-phone .goal { width: 40px; height: 40px; }
  .card-sheet { flex-direction: row; align-items: flex-start; }
  .card-big { width: 280px; flex: none; }
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 18px; max-height: 90vh; }
}

/* ---------------- desktop ---------------- */
body.lay-desktop { font-size: 15px; }
body.lay-desktop .g-top { padding: 8px 16px; min-height: 52px; }
body.lay-desktop .g-status { font-size: 16px; }
body.lay-desktop .g-players { padding: 0 16px 8px; gap: 10px; }
body.lay-desktop .pchip { max-width: 220px; padding: 6px 12px; }
body.lay-desktop .g-body {
  display: grid; grid-template-columns: 280px minmax(0, 1fr) 280px; gap: 14px; padding: 0 16px 10px; overflow: hidden;
}
body.lay-desktop .g-table { display: flex; flex-direction: column; gap: 10px; padding: 0; overflow-y: auto; }
body.lay-desktop .tbl-block { padding: 10px; }
body.lay-desktop .tbl-block h3 { font-size: 13px; margin-bottom: 6px; }
body.lay-desktop .feeder .dice { grid-template-columns: repeat(5, 40px); gap: 6px; }
body.lay-desktop .die { width: 40px; height: 40px; border-radius: 8px; padding: 4px; }
body.lay-desktop .tray { gap: 8px; flex-wrap: wrap; }
body.lay-desktop .tray .card { width: 72px; }
body.lay-desktop .goals { grid-template-columns: repeat(4, 54px); gap: 8px; }
body.lay-desktop .goal { width: 54px; height: 54px; }
body.lay-desktop .goal-r { width: 17px; height: 17px; font-size: 11px; }
body.lay-desktop .goal-pts, body.lay-desktop .goal-now { font-size: 12px; }
body.lay-desktop .g-center { padding: 0; overflow-y: auto; gap: 10px; max-width: 1100px; margin-inline: auto; width: 100%; }
body.lay-desktop .g-actions { grid-template-columns: repeat(4, 1fr); }
body.lay-desktop .act { min-height: 48px; font-size: 15px; }
body.lay-desktop .badges { font-size: 12px; bottom: 4px; }
body.lay-desktop .badges .egg { width: 13px; height: 15px; }
body.lay-desktop .badges .fi { width: 14px; height: 14px; }
body.lay-desktop .food .fi { width: 26px; height: 26px; }
body.lay-desktop .food { font-size: 15px; padding: 3px 8px 3px 4px; }
body.lay-desktop .hand { min-height: 150px; flex-wrap: wrap; overflow: visible; }
body.lay-desktop .hand-card { width: 96px; }
body.lay-desktop .hand-card:hover { transform: translateY(-6px); }
body.lay-desktop .g-log-panel { display: flex; flex-direction: column; background: rgba(246, 239, 223, .08); border-radius: 12px; padding: 10px; min-height: 0; color: #f6efdf; }
body.lay-desktop .g-log-panel h3 { margin: 0 0 8px; font-size: 13px; opacity: .8; }
body.lay-desktop .g-log-panel .g-log { overflow-y: auto; }
body.lay-desktop .g-log-panel .g-log li:first-child { background: rgba(255, 215, 122, .12); }
body.lay-desktop .g-prompt { padding: 10px 16px; justify-content: center; }
body.lay-desktop .pr-text { flex: 0 1 auto; font-size: 15px; }
body.lay-desktop .g-ticker { display: none; }
body.lay-desktop .sheet-backdrop { align-items: center; }
body.lay-desktop .sheet { border-radius: 18px; }
body.lay-desktop .card-sheet { flex-direction: row; align-items: flex-start; }
body.lay-desktop .card-big { width: 320px; flex: none; }
@media (max-width: 1250px) {
  body.lay-desktop .g-body { grid-template-columns: 240px minmax(0, 1fr) 220px; }
  body.lay-desktop .feeder .dice { grid-template-columns: repeat(5, 34px); }
  body.lay-desktop .die { width: 34px; height: 34px; }
}

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

/* Cards with a caption under them size by width, the picture keeps the card shape */
.setup-card, .card-grid .card { aspect-ratio: auto; min-width: 0; }
.setup-card .bird-img, .card-grid .card .bird-img { height: auto; aspect-ratio: 520 / 790; }
.setup-cards > *, .card-grid > * { min-width: 0; }
.setup-card .card-cap .fi { width: 14px; height: 14px; }
.tray .card { width: auto; flex: 1 1 0; max-width: 46px; min-width: 0; }
body.lay-phone.landscape .tray .card { max-width: 54px; }
@media (min-width: 640px) { body.lay-phone .tray .card { max-width: 60px; } }
body.lay-desktop .tray .card { flex: none; width: 72px; max-width: none; }
.g-body, .g-center, .g-table, .g-log, .hand, .sheet-body { scrollbar-width: thin; scrollbar-color: rgba(246, 239, 223, .25) transparent; }
.sheet-body { scrollbar-color: rgba(60, 50, 30, .3) transparent; }
/* Results screen: the BoardBazi bar is back above the table */
body.with-bar.in-game .view-game { padding-top: calc(var(--bar-h) + env(safe-area-inset-top)); }
body.with-bar.in-game .g-top { padding-top: 4px; }
