/* 7 Wonders Duel — BoardBazi
   One stylesheet, two tables: .lay-phone (portrait, or .landscape) and .lay-desktop.
   The lobby and the results use the shared BoardBazi game home (bb/game-home.css, loaded first). */

@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/vazirmatn-arabic.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/vazirmatn-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #120e0a;
  --bg2: #1d1711;
  --panel: rgba(37, 29, 21, 0.92);
  --panel-2: rgba(55, 43, 31, 0.92);
  --line: rgba(226, 178, 74, 0.22);
  --gold: #e2b24a;
  --gold-2: #f6d27c;
  --text: #f4ead6;
  --muted: #b5a58a;
  --danger: #d9534f;
  --ok: #4caf6a;
  --c-brown: #8a5a2b;
  --c-grey: #8e8e8e;
  --c-yellow: #e2ad22;
  --c-red: #c8372d;
  --c-blue: #2f6fc0;
  --c-green: #3a9a4b;
  --c-purple: #7b4aa8;
  --radius: 12px;
  --serif: "Cinzel", "Trajan Pro", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: "Vazirmatn", "Vazir", "IRANSans", Tahoma, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --app-h: 100vh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
body.in-game { height: var(--app-h); overflow: hidden; }
button { font: inherit; color: inherit; }
img { -webkit-user-drag: none; user-select: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
/* The table and its sheets keep their own type inside .bh-root (which sets the lobby's font and line height) */
.view-game, .sheet-backdrop, .toast, .fly-layer { font-family: var(--sans); color: var(--text); line-height: normal; -webkit-font-smoothing: auto; }
:is(.view-game, .sheet-backdrop) :is(h1, h2, h3) { font-family: var(--serif); font-weight: 700; letter-spacing: 0.02em; }
/* Persian: serif display fonts have no Persian letters, so headings use the text font */
[dir="rtl"] :is(.view-game, .sheet-backdrop) :is(h1, h2, h3), [dir="rtl"] .g-age, [dir="rtl"] .draft-title strong, [dir="rtl"] .guild-name { font-family: var(--sans); letter-spacing: 0; }
[dir="rtl"] .effects, [dir="rtl"] .rules ul { padding-left: 0; padding-right: 18px; }
[dir="rtl"] .sheet-close { right: auto; left: 10px; }
[dir="rtl"] .sheet-title, [dir="rtl"] .sheet-card-text h2, [dir="rtl"] .sheet-wonder h2 { margin: 0 0 0 40px; }
[dir="rtl"] .price { right: auto; left: -6px; }
[dir="rtl"] .wonder-price { right: auto; left: 2px; }
[dir="rtl"] .g-log li { border-left: 0; border-right: 3px solid var(--line); }
[dir="rtl"] .pick-wonder { text-align: right; }
/* The board and the pyramid are pictures: they never mirror */
.g-board, .g-structure, .draft-grid { direction: ltr; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer;
  transition: transform .08s ease, background .2s ease, border-color .2s ease;
}
.btn:hover { border-color: rgba(226, 178, 74, .55); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-gold { background: linear-gradient(180deg, #f2c661, #c8902c); color: #2a1a06; border-color: #f6d27c; }
.btn-gold:hover { background: linear-gradient(180deg, #f8d27a, #d39b35); }
.btn-ghost { background: transparent; }
.btn-danger { border-color: rgba(217, 83, 79, .5); color: #ffb3b0; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); font-size: 18px; cursor: pointer; }
.link-btn { background: none; border: 0; color: var(--gold); text-decoration: underline; cursor: pointer; padding: 6px 0; font-size: 13px; }

/* ---------------- Icons ---------------- */
.ico { width: 22px; height: 22px; vertical-align: middle; border-radius: 50%; }
.ico.sm { width: 18px; height: 18px; }
.coin, .vp {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  width: 28px; height: 28px; background: center / contain no-repeat; font-size: 13px; font-weight: 800;
}
.coin { background-image: url("img/tokens/coin.webp"); color: #3b2405; }
.vp { background-image: url("img/tokens/vp.webp"); color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.coin.sm, .vp.sm { width: 22px; height: 22px; font-size: 11px; }
.coin.xs { width: 18px; height: 18px; font-size: 10px; }
.shield-ico { display: inline-flex; vertical-align: middle; }
.shield-ico img { width: 20px; height: 20px; margin-right: -4px; }
.free { color: var(--ok); font-weight: 700; }
.chain { color: #7fc8ff; font-weight: 700; }


/* ---------------- BoardBazi bar ---------------- */
.bb-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: calc(40px + env(safe-area-inset-top, 0px));
  padding-block: env(safe-area-inset-top, 0px) 0;
  padding-inline: max(12px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  background: rgba(14, 18, 29, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-family: var(--bh-font, var(--sans));
  font-size: 14px;
  line-height: 1;
  backdrop-filter: blur(8px);
}
.bb-brand, .bb-chip {
  display: inline-flex;
  align-items: center;
  height: 100%;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.bb-brand {
  gap: 8px;
  flex-shrink: 0;
  font-weight: 700;
}
.bb-brand:hover .bb-word, .bb-chip:hover .bb-name {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.bb-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  color: #fff;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}
.bb-chip { gap: 6px; }
.bb-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #334155;
  color: #f8fafc;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.bb-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  max-width: 200px;
}
.bb-level {
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.bb-level::before {
  content: '·';
  color: rgba(148, 163, 184, 0.6);
}
.bb-xp {
  width: 48px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
  flex-shrink: 0;
  display: inline-block;
}
.bb-xp-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #6366f1, #06b6d4);
}
.bb-signin {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding-inline: 10px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.bb-signin:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
}
@media (max-width: 420px) { .bb-word { display: none; } }
body.in-game .bb-bar { display: none; }

/* ---------------- Lobby, sign-in card, results: game-specific additions to the BoardBazi game home ---------------- */
.duel-center { flex: 1; justify-content: center; }
.duel-lang[aria-pressed="true"] { border-color: var(--bh-game); color: var(--bh-game); }
.duel-sheet-end { justify-content: flex-end; margin-top: 16px; }
.duel-scores { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.duel-scores th, .duel-scores td { padding: 6px 8px; border-bottom: 1px solid var(--bh-line); text-align: center; }
.duel-scores th { color: var(--bh-muted); font-weight: 600; }
.duel-scores td:first-child { text-align: start; color: var(--bh-muted); }
.duel-scores td:not(:first-child), .duel-scores th:not(:first-child) { width: 30%; }
.duel-scores .duel-total td { border-bottom: 0; font-weight: 800; color: var(--bh-game); }

/* ---------------- Game: shared ---------------- */
.view-game { height: var(--app-h); display: flex; flex-direction: column; background: radial-gradient(ellipse at 50% 30%, #2b2117 0%, #16110c 60%, #0d0a07 100%); }
.g-top { display: flex; align-items: center; gap: 10px; padding: calc(4px + var(--safe-top)) 10px 4px; min-height: 48px; background: rgba(10, 8, 5, .7); border-bottom: 1px solid var(--line); flex: none; }
.g-age { display: flex; flex-direction: column; line-height: 1.1; font-family: var(--serif); color: var(--gold-2); font-size: 16px; min-width: 64px; }
.g-age small { font-family: var(--sans); color: var(--muted); font-size: 11px; }
.g-status { flex: 1; text-align: center; font-weight: 600; font-size: 14px; color: #e3d6bd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-status.mine { color: var(--gold-2); text-shadow: 0 0 12px rgba(226, 178, 74, .5); }
.g-timer { font-variant-numeric: tabular-nums; font-weight: 700; padding: 4px 10px; border-radius: 8px; background: rgba(0, 0, 0, .4); border: 1px solid var(--line); font-size: 14px; }
.g-timer.urgent { color: #fff; background: var(--danger); animation: pulse 1s infinite; }
.g-conn { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }
.g-conn.lost { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.g-banner { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 6px 10px; background: rgba(12, 9, 6, .88); border-bottom: 1px solid var(--line); flex: none; }
.g-banner-item { padding: 4px 12px; border-radius: 9999px; font-size: 13px; font-weight: 600; text-align: center; border: 1px solid var(--line); }
.g-banner-offline { background: rgba(217, 83, 79, .18); border-color: rgba(217, 83, 79, .45); color: #ffc9c5; }
.g-banner-paused { background: rgba(226, 178, 74, .18); border-color: rgba(226, 178, 74, .45); color: var(--gold-2); }
.g-banner-calm { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .18); color: var(--muted); }
.g-banner-warn { background: rgba(251, 191, 36, .16); border-color: rgba(251, 191, 36, .5); color: #fde68a; }

.g-body { flex: 1; min-height: 0; }
.g-center { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.g-structure-wrap { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.g-structure { position: relative; flex: none; }
.g-hint { min-height: 30px; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 2px 10px; color: var(--muted); font-size: 13px; text-align: center; flex: none; }
.g-hint > span { line-height: 1.5; }

/* Cards in the pyramid */
.card { position: absolute; padding: 0; border: 0; border-radius: calc(var(--cw, 80px) * .07); background: #000; cursor: pointer; box-shadow: 0 3px 8px rgba(0, 0, 0, .55); transition: transform .15s ease, box-shadow .2s ease, filter .2s; }
.card .card-img, .card .guild-face { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.card.covered.up { filter: brightness(.72) saturate(.85); }
.card.down { cursor: default; }
.card.open.up { box-shadow: 0 4px 12px rgba(0, 0, 0, .7), 0 0 0 1px rgba(246, 210, 124, .35); }
.card.playable { animation: glow 2.2s ease-in-out infinite; }
.card.playable:hover { transform: translateY(-4px); }
@keyframes glow { 0%, 100% { box-shadow: 0 4px 12px rgba(0, 0, 0, .7), 0 0 0 2px rgba(246, 210, 124, .65); } 50% { box-shadow: 0 4px 16px rgba(0, 0, 0, .7), 0 0 0 2px #f6d27c, 0 0 14px rgba(246, 210, 124, .7); } }
.guild-back { filter: hue-rotate(205deg) saturate(1.6) brightness(.8); }
.price { position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; display: grid; place-items: center; font-size: 12px; font-weight: 800; border: 2px solid #1a120a; z-index: 2; }
.price.ok { background: #f2c661; color: #2a1a06; }
.price.no { background: #6e2a26; color: #ffc9c5; }
.price.chain { background: #2f6fc0; color: #fff; }

/* Guild cards have no artwork: drawn here */
.guild-face { position: relative; display: flex; flex-direction: column; align-items: center; background: linear-gradient(170deg, #5b2f86 0%, #3a1b5b 55%, #23103a 100%); color: #f1e4ff; overflow: hidden; border: 1px solid rgba(255, 255, 255, .15); }
.guild-band { width: 100%; text-align: center; padding: 6% 0 4%; background: rgba(0, 0, 0, .25); font-size: calc(var(--cw, 80px) * .26); line-height: 1; }
.guild-cost { display: flex; flex-wrap: wrap; justify-content: center; gap: 1px; padding: 6% 4%; }
.guild-cost .ico { width: calc(var(--cw, 80px) * .2); height: calc(var(--cw, 80px) * .2); }
.guild-name { margin-top: auto; padding: 0 4% 10%; text-align: center; font-family: var(--serif); font-weight: 700; font-size: calc(var(--cw, 80px) * .15); line-height: 1.1; }
.guild-name small { display: block; font-size: .75em; opacity: .75; }

/* Wonder draft */
.g-draft { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 8px; }
.draft-title { text-align: center; display: flex; flex-direction: column; gap: 2px; }
.draft-title strong { font-family: var(--serif); color: var(--gold-2); font-size: 18px; }
.draft-title span { color: var(--muted); font-size: 14px; }
.draft-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 560px; }
.draft-wonder { padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: #000; cursor: pointer; box-shadow: 0 6px 18px rgba(0, 0, 0, .6); transition: transform .15s; }
.draft-wonder img { display: block; width: 100%; aspect-ratio: 1400 / 914; object-fit: cover; }
.draft-wonder.playable { outline: 2px solid rgba(246, 210, 124, .7); }
.draft-wonder.playable:hover { transform: scale(1.03); }

/* Military & science board */
.g-board { position: relative; flex: none; width: 100%; max-width: 760px; margin: 0 auto; }
.g-board-img { display: block; width: 100%; height: auto; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .6)); }
.g-board-layer { position: absolute; inset: 0; }
.pawn { position: absolute; top: 43.5%; height: 34%; transform: translate(-50%, -50%); transition: left .7s cubic-bezier(.3, 1.3, .5, 1); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .8)); z-index: 3; }
.loot { position: absolute; top: 17%; width: 3.6%; transform: translate(-50%, -50%) rotate(90deg); filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .7)); z-index: 2; }
.board-token { position: absolute; top: 79.5%; width: 8.4%; aspect-ratio: 1; padding: 0; border: 0; background: none; border-radius: 50%; transform: translate(-50%, -50%); cursor: pointer; }
.board-token img { width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 2px 6px rgba(0, 0, 0, .7); }
.cap { position: absolute; bottom: 2%; font-size: 10px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, .45); }
.cap-me { left: 2%; }
.cap-opp { right: 2%; max-width: 30%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Cities */
.city { background: var(--panel); border: 1px solid var(--line); min-width: 0; transition: box-shadow .3s, border-color .3s; }
.city.active { border-color: rgba(246, 210, 124, .7); box-shadow: inset 0 0 0 1px rgba(246, 210, 124, .35), 0 0 18px rgba(226, 178, 74, .18); }
.city-head { display: flex; align-items: center; gap: 8px; }
.city-name { flex: 1; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.city-name .off { font-size: 11px; color: #ffb3b0; font-weight: 600; }
.city-name .off.off-calm { color: var(--muted); }
.city-stats { display: flex; gap: 4px; align-items: center; }
.cchip { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .5); }
.c-brown.cchip { background: var(--c-brown); } .c-grey.cchip { background: var(--c-grey); } .c-yellow.cchip { background: var(--c-yellow); color: #2a1a06; text-shadow: none; }
.c-red.cchip { background: var(--c-red); } .c-blue.cchip { background: var(--c-blue); } .c-green.cchip { background: var(--c-green); } .c-purple.cchip { background: var(--c-purple); }
.prod { display: inline-flex; align-items: center; gap: 1px; padding: 1px 4px 1px 1px; border-radius: 12px; background: rgba(0, 0, 0, .3); font-size: 12px; }
.prod b { min-width: 8px; }
.prod.choice { padding: 1px 3px; }
.prod.choice i { color: var(--muted); font-style: normal; font-size: 11px; }
.sci { display: inline-flex; gap: 2px; }
.sci-sym { position: relative; display: inline-flex; }
.sci-sym b { position: absolute; right: -4px; bottom: -4px; font-size: 9px; background: var(--gold); color: #2a1a06; border-radius: 6px; padding: 0 2px; }
.ptoken { width: 26px; height: 26px; border-radius: 50%; vertical-align: middle; cursor: pointer; }
.ptoken.xs { width: 20px; height: 20px; }

.wonder { position: relative; padding: 0; border: 0; background: #000; border-radius: 5px; overflow: hidden; cursor: pointer; flex: none; }
.wonder img { display: block; width: 100%; height: 100%; object-fit: cover; }
.wonder.unbuilt img { filter: grayscale(.75) brightness(.55); }
.wonder.built { box-shadow: 0 0 0 1.5px var(--gold); }
.wonder.affordable { box-shadow: 0 0 0 1.5px rgba(127, 200, 255, .8); }
.wonder.affordable img { filter: grayscale(.2) brightness(.85); }
.wonder-tuck { position: absolute; left: 50%; bottom: -2px; width: 30%; height: 18%; transform: translateX(-50%); border-radius: 2px 2px 0 0; background: #6b4a22; box-shadow: 0 -1px 2px rgba(0, 0, 0, .6); }
.wonder-tuck.age2 { background: #3a5f8c; } .wonder-tuck.age3 { background: #6b3a8c; }
.wonder-price { position: absolute; right: 2px; top: 2px; font-size: 10px; font-weight: 800; color: #ffb3b0; }
.wonder.xs { width: 44px; height: 29px; }
.wonder.md { width: 100%; aspect-ratio: 1400 / 914; }

.stacks { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.stack { display: flex; flex-direction: column; width: 46px; }
.mini { width: 46px; height: 69px; padding: 0; border: 0; border-radius: 4px; overflow: hidden; background: #000; cursor: pointer; box-shadow: 0 2px 4px rgba(0, 0, 0, .6); flex: none; --cw: 46px; }
.mini + .mini { margin-top: -50px; }
.mini .card-img, .mini .guild-face { width: 100%; height: 100%; object-fit: cover; object-position: top; display: flex; }
.stacks.big .stack, .stacks.big .mini { width: 64px; }
.stacks.big .mini { height: 96px; --cw: 64px; }
.stacks.big .mini + .mini { margin-top: -70px; }
.empty-city { font-size: 13px; padding: 6px 0; }

/* What the opponent just did */
.g-lastmove { position: fixed; left: 50%; top: calc(56px + var(--safe-top)); transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 10px; max-width: min(92vw, 460px); padding: 6px 14px 6px 6px; border-radius: 12px; background: rgba(20, 15, 10, .95); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .6); font-size: 14px; pointer-events: none; }
.g-lastmove img { height: 46px; border-radius: 4px; }
.g-lastmove.pop { animation: pop .35s ease-out; }
@keyframes pop { from { transform: translate(-50%, -12px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

.fly-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.ghost { position: fixed; border-radius: 6px; overflow: hidden; transition: transform .65s cubic-bezier(.4, .1, .3, 1), opacity .65s ease; box-shadow: 0 10px 24px rgba(0, 0, 0, .7); --cw: 80px; }
.ghost .card-img, .ghost .guild-face { width: 100%; height: 100%; object-fit: cover; display: flex; }

/* Log */
.g-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.g-log li { padding: 4px 8px; border-left: 3px solid var(--line); color: #dccfb4; }
.g-log .log-age { border-color: var(--gold); color: var(--gold-2); font-weight: 700; }
.g-log .log-military { border-color: var(--c-red); }
.g-log .log-science { border-color: var(--c-green); }
.g-log .log-wonder { border-color: #9a7cff; }
.g-log .log-coins { border-color: var(--c-yellow); }
.g-log .log-end { border-color: var(--gold); color: var(--gold-2); font-weight: 800; }
.g-log .log-warning { border-color: var(--danger); color: #ffc9c5; }
.g-log-panel { display: none; }

/* ---------------- PHONE (portrait) ---------------- */
.lay-phone .g-body { display: flex; flex-direction: column; }
.lay-phone .city { padding: 6px 8px; border-left: 0; border-right: 0; flex: none; }
.lay-phone .city-opp { order: 1; border-top: 0; }
.lay-phone .g-center { order: 2; flex: 1; padding: 4px 6px 0; }
.lay-phone .city-me { order: 3; padding-bottom: calc(6px + var(--safe-bottom)); border-bottom: 0; }
.lay-phone .strip { display: flex; gap: 8px; margin-top: 4px; cursor: pointer; align-items: center; }
.lay-phone .strip-wonders { display: grid; grid-template-columns: repeat(2, 44px); gap: 3px; flex: none; }
.lay-phone .strip-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.lay-phone .strip-row { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; min-height: 22px; }
.lay-phone .strip .ico { width: 20px; height: 20px; }
.lay-phone .city-me { position: relative; }

/* Phone held sideways: cities and board on the left, the pyramid on the right */
.lay-phone.landscape .g-body { display: grid; grid-template-columns: minmax(240px, 40%) minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "opp struct" "board struct" "me struct"; }
.lay-phone.landscape .g-center { display: contents; }
.lay-phone.landscape .city-opp { grid-area: opp; }
.lay-phone.landscape .g-board { grid-area: board; padding: 4px 6px; }
.lay-phone.landscape .city-me { grid-area: me; align-self: start; padding-bottom: 6px; }
.lay-phone.landscape .g-structure-wrap { grid-area: struct; }
.lay-phone.landscape .g-hint { grid-area: struct; align-self: end; justify-self: center; z-index: 5; margin-bottom: calc(4px + var(--safe-bottom)); border-radius: 10px; background: rgba(12, 9, 6, .75); font-size: 12px; }
.lay-phone.landscape .g-hint:empty { display: none; }
.lay-phone.landscape .city { padding: 4px 8px; }
.lay-phone.landscape .g-top { min-height: 40px; }
.lay-phone.landscape .draft-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 420px; }

/* ---------------- DESKTOP ---------------- */
.lay-desktop .g-top { padding: 8px 16px; min-height: 56px; }
.lay-desktop .g-age { font-size: 20px; }
.lay-desktop .g-status { font-size: 16px; }
.lay-desktop .g-body {
  display: grid; gap: 12px; padding: 12px;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr) minmax(250px, 300px);
  grid-template-rows: auto minmax(0, 1fr) minmax(0, .8fr) auto;
  /* Your city sits on the left, next to your capital on the board, in both languages */
  direction: ltr;
  grid-template-areas: "me board opp" "me struct opp" "me struct log" "me hint log";
}
[dir="rtl"] .lay-desktop .city, [dir="rtl"] .lay-desktop .g-log-panel, [dir="rtl"] .lay-desktop .g-hint { direction: rtl; }
.lay-desktop .g-center { display: contents; }
.lay-desktop .city { border-radius: var(--radius); padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.lay-desktop .city-opp { grid-area: opp; }
.lay-desktop .city-me { grid-area: me; }
.lay-desktop .g-board { grid-area: board; max-width: 720px; }
.lay-desktop .g-structure-wrap { grid-area: struct; }
.lay-desktop .g-hint { grid-area: hint; font-size: 14px; }
.lay-desktop .g-log-panel { grid-area: log; display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.lay-desktop .g-log-panel h3 { margin: 0 0 8px; font-size: 14px; color: var(--gold-2); }
.lay-desktop .g-log-panel .g-log { overflow-y: auto; min-height: 0; }
.lay-desktop .city-name { font-size: 16px; }
.lay-desktop .city-wonders { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.lay-desktop .city-econ, .lay-desktop .city-sci, .lay-desktop .city-tokens { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.lay-desktop .wonder-price { font-size: 12px; }
.lay-desktop .draft-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 1100px; }
.lay-desktop .draft-title strong { font-size: 24px; }
.lay-desktop .g-lastmove { top: 72px; }
.lay-desktop .price { min-width: 26px; height: 26px; font-size: 14px; }

/* ---------------- Sheets (bottom sheet on phones, dialog on desktop) ---------------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(5, 4, 2, .62); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.sheet { position: relative; width: 100%; max-height: 88vh; overflow-y: auto; overscroll-behavior: contain; background: linear-gradient(180deg, #2a2118, #1b150f); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-bottom)); box-shadow: 0 -10px 40px rgba(0, 0, 0, .6); animation: slide-up .22s ease-out; }
.sheet-close { position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .08); font-size: 22px; cursor: pointer; z-index: 2; }
.sheet-body { display: flex; flex-direction: column; gap: 12px; }
.sheet-title { margin: 0 40px 0 0; font-size: 20px; color: var(--gold-2); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sheet-sub { display: inline-flex; gap: 4px; }
.sheet-body p { margin: 0; line-height: 1.45; }
@keyframes slide-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }
.lay-desktop .sheet-backdrop { align-items: center; }
.lay-desktop .sheet { width: min(560px, 92vw); border-radius: 18px; border-bottom: 1px solid var(--line); max-height: 86vh; padding: 22px; }
.lay-desktop .sheet.wide { width: min(860px, 94vw); }
.lay-phone.landscape .sheet { max-height: 94vh; width: min(760px, 100%); }

.sheet-card { display: flex; gap: 14px; align-items: flex-start; }
.sheet-card-img { width: 42%; max-width: 220px; flex: none; --cw: 150px; }
.sheet-card-img .card-img, .sheet-card-img .guild-face { width: 100%; aspect-ratio: 2 / 3; height: auto; object-fit: cover; border-radius: 10px; box-shadow: 0 8px 22px rgba(0, 0, 0, .6); display: flex; }
.sheet-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.sheet-card-text h2, .sheet-wonder h2 { margin: 0 30px 0 0; font-size: 22px; color: var(--gold-2); }
.sheet-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.sheet-kicker.c-brown { color: #d29a62; } .sheet-kicker.c-grey { color: #c7c7c7; } .sheet-kicker.c-yellow { color: #f2c94c; } .sheet-kicker.c-red { color: #ff7a6e; }
.sheet-kicker.c-blue { color: #79aef2; } .sheet-kicker.c-green { color: #6fd185; } .sheet-kicker.c-purple { color: #c39af0; }
.sheet-cost { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.effects { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.4; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.actions .btn { justify-content: space-between; }
.actions .btn > span:only-child { margin: 0 auto; }
.act-price { display: inline-flex; align-items: center; gap: 4px; }
.act-note { font-size: 12px; color: var(--muted); margin: -2px 0 2px; display: flex; flex-wrap: wrap; align-items: center; gap: 3px; }
.sheet-wonder { display: flex; flex-direction: column; gap: 12px; }
.wonder-big { width: 100%; border-radius: 10px; box-shadow: 0 8px 22px rgba(0, 0, 0, .6); }
.lay-desktop .sheet-wonder { flex-direction: row; align-items: flex-start; }
.lay-desktop .wonder-big { width: 55%; }
.sheet-wonder > div { display: flex; flex-direction: column; gap: 8px; }
.sheet-token { display: flex; gap: 14px; align-items: center; }
.sheet-token img { width: 96px; height: 96px; border-radius: 50%; }
.sheet-token h2 { margin: 0 0 6px; color: var(--gold-2); }

.wonder-list { display: flex; flex-direction: column; gap: 8px; }
.pick-wonder { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; text-align: left; }
.pick-wonder img { width: 96px; border-radius: 6px; }
.pick-wonder.off { opacity: .5; cursor: not-allowed; }
.tuck-thumb { width: 54px; flex: none; --cw: 54px; }
.tuck-thumb .card-img, .tuck-thumb .guild-face { width: 100%; aspect-ratio: 2 / 3; height: auto; object-fit: cover; border-radius: 6px; display: flex; }
.pw-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pw-text small { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }

.token-list { display: grid; grid-template-columns: 1fr; gap: 8px; }
.lay-desktop .token-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.token-opt { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); text-align: left; cursor: pointer; }
.token-opt img { width: 54px; height: 54px; border-radius: 50%; flex: none; }
.token-opt span { display: flex; flex-direction: column; gap: 2px; }
.token-opt small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.selected { outline: 2px solid var(--gold); outline-offset: 1px; background: rgba(226, 178, 74, .14) !important; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.pick-card { padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: #000; cursor: pointer; aspect-ratio: 2 / 3; --cw: 90px; }
.pick-card .card-img, .pick-card .guild-face { width: 100%; height: 100%; object-fit: cover; display: flex; }
.kv { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kv > span { width: 92px; color: var(--muted); font-size: 13px; flex: none; }
.kv > div { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.city-wonders.big { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.score-mini { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.score-mini div { background: rgba(0, 0, 0, .25); border-radius: 8px; padding: 6px; text-align: center; display: flex; flex-direction: column; }
.score-mini span { font-size: 11px; color: var(--muted); }
.score-mini b { font-size: 16px; color: var(--gold-2); }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.segs { display: flex; gap: 4px; }
.seg { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 13px; }
.seg.on { background: var(--gold); color: #2a1a06; border-color: var(--gold); font-weight: 700; }
.rules { font-size: 14px; line-height: 1.5; }
.rules ul { padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.rules h3 { margin: 14px 0 6px; color: var(--gold-2); font-size: 16px; }

.confirm-backdrop { z-index: 70; align-items: center; padding: 16px; }
.confirm-sheet { width: min(400px, 100%); border-radius: 16px; border-bottom: 1px solid var(--line); text-align: center; }
.confirm-sheet h2 { margin: 0 0 8px; font-size: 19px; color: var(--gold-2); }
.confirm-sheet p { margin: 0 0 16px; color: var(--muted); }
.confirm-sheet p:empty { display: none; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); z-index: 80; max-width: min(92vw, 480px); padding: 12px 16px; border-radius: 12px; background: rgba(20, 15, 10, .97); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .6); font-size: 14px; text-align: center; word-break: break-word; }

body.busy .card.playable, body.busy .actions .btn { pointer-events: none; }

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