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

/* Blood Bound: obsidian night, crimson rose, sapphire gargoyle, antique gold */
:root {
  --bg: #0b0a12;
  --panel: #151422;
  --panel2: #1f1d32;
  --line: rgba(255, 255, 255, 0.11);
  --text: #f3eee4;
  --muted: #a4a1b8;
  --phoenix: #d94854;
  --gargoyle: #4580e6;
  --inquisitor: #a57ce6;
  --gold: #e0b34a;
  --green: #5fbf73;
  --red: #e04a5a;
  --top-h: 36px;
  --side-w: 280px;
  --app-height: 100dvh;
  --app-width: 100vw;
  --seat-w: 94px;
  --seat-h: 90px;
  font-family: 'Vazirmatn', Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

img { user-select: none; -webkit-user-drag: none; }
button, input { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------------- buttons (table) ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 6px 12px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text);
  font-size: 13.5px; font-weight: 700; cursor: pointer;
  transition: transform .08s ease, filter .15s ease, border-color .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, #f3c867, var(--gold)); color: #241a05; border-color: transparent; }
.btn-attack { background: linear-gradient(180deg, #e05361, #b32d3b); color: #fff; border-color: rgba(255, 255, 255, .15); }
.btn-ghost { background: rgba(255, 255, 255, .06); }
.btn-danger { background: rgba(224, 74, 90, .2); border-color: rgba(224, 74, 90, .55); color: #ffd6da; }

/* ---------------- splash ---------------- */
.bb-splash-logo { width: 82px; border-radius: 10px; box-shadow: 0 12px 42px rgba(0, 0, 0, .7); }
.bb-splash-title { font-size: 26px; font-weight: 900; color: var(--bh-game); }

/* ---------------- BoardBazi bar ---------------- */
.bb-bar {
  display: flex; align-items: center; gap: 10px;
  height: 44px;
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  box-sizing: content-box;
  background: rgba(14, 14, 24, .92);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  color: #f8fafc; font-size: 14px;
  position: sticky; top: 0; z-index: 20;
}
.bb-brand, .bb-chip { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; min-width: 0; }
.bb-mark { width: 24px; height: 24px; border-radius: 6px; background: linear-gradient(135deg, #c93b4b, #4580e6); display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.bb-spacer { flex: 1; }
.bb-avatar { width: 24px; height: 24px; border-radius: 50%; background: #334155; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.bb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.bb-level { font-size: 12px; color: #94a3b8; white-space: nowrap; }
.bb-xp { width: 48px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .15); overflow: hidden; flex-shrink: 0; }
.bb-xp-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #c93b4b, #4580e6); }
.bb-logout { background: none; border: 1px solid rgba(255, 255, 255, .15); color: #94a3b8; border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
@media (max-width: 420px) { .bb-word { display: none; } .bb-name { max-width: 90px; } }
body.in-game .bb-bar { display: none; }

/* ---------------- lobby extras ---------------- */
.bb-center { flex: 1; justify-content: center; }
.bb-auth-card { width: 100%; }
.bb-wait { text-align: center; margin: 10px 0 0; }
.bb-results { display: flex; flex-direction: column; gap: 14px; }
.bb-results-sheet, .bb-rules-sheet { max-height: calc(var(--app-height) * .92); overflow-y: auto; }
.bb-rules p { margin: 0 0 10px; line-height: 1.8; }
.bb-rules h3 { margin: 14px 0 6px; }
.bb-rules ul { margin: 0 0 12px; padding-inline-start: 20px; }
.bb-rules li { margin-bottom: 6px; line-height: 1.7; }

/* ================= GAME ================= */
body.in-game { overflow: hidden; background: radial-gradient(1100px 700px at 30% 20%, #24162b, var(--bg) 72%); }
.app-root { position: relative; min-height: 100dvh; }
body.in-game .app-root { height: var(--app-height); min-height: 0; overflow: hidden; }
body.in-game #bh-root { background: transparent; }
#game-root { font-family: 'Vazirmatn', Tahoma, sans-serif; line-height: 1.45; color: var(--text); }

/* Grid stays LTR so seat positions around the circle never mirror between RTL/LTR */
.g-screen {
  direction: ltr;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-w);
  grid-template-rows: var(--top-h) minmax(0, 1fr);
  height: var(--app-height);
  width: 100%;
  gap: 0 8px;
  padding: 0 max(4px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
}
html[dir="rtl"] .g-top, html[dir="rtl"] .g-side, html[dir="rtl"] .g-center, html[dir="rtl"] .sheet, html[dir="rtl"] .toasts { direction: rtl; }

.g-top {
  grid-row: 1; grid-column: 1 / -1;
  display: flex; align-items: center; gap: 6px;
  min-width: 0; font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.g-icon {
  flex-shrink: 0; width: 30px; height: 26px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .06);
  color: var(--text); cursor: pointer; font-size: 14px;
  display: grid; place-items: center; padding: 0;
}
.g-conn { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.g-conn.lost { background: var(--red); animation: blink 1s infinite; }
.g-round { color: var(--muted); flex-shrink: 0; white-space: nowrap; font-size: 12px; }
.g-phase { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.g-phase.mine { color: var(--gold); }
.g-grow { flex: 1; }
.g-timebar { width: 64px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; flex-shrink: 0; }
.g-timebar-fill { height: 100%; background: var(--muted); transition: width .25s linear; }
.g-timebar-fill.mine { background: var(--gold); }
.g-timebar-fill.urgent { background: var(--red); }
.g-timer { font-variant-numeric: tabular-nums; flex-shrink: 0; color: var(--muted); font-size: 12px; }
.g-timer.urgent { color: var(--red); font-weight: 700; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------------- table felt & center ---------------- */
.g-table-wrap { grid-row: 2; grid-column: 1; min-height: 0; min-width: 0; padding: 4px 0; }
.g-table { position: relative; width: 100%; height: 100%; }
.g-felt {
  position: absolute; inset: calc(var(--seat-h) * .42) calc(var(--seat-w) * .42);
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 42%, #2c1c36 0%, #191528 62%, #110f1b 100%);
  box-shadow: inset 0 0 0 2px rgba(224, 179, 74, .22), inset 0 0 60px rgba(0, 0, 0, .65), 0 12px 44px rgba(0, 0, 0, .55);
}
.g-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(56%, 380px); max-height: 54%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-align: center; pointer-events: none; overflow: hidden;
}
.c-dagger-wrap { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--gold); font-weight: 800; }
.c-dagger-wrap img { width: 22px; height: 22px; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .8)); }
.c-title { font-size: 15px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.c-sub { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.c-supply { font-size: 10.5px; color: #c8c3d9; background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .08); border-radius: 999px; padding: 2px 9px; }
.c-last { font-size: 11px; color: #e2ddd0; background: rgba(0, 0, 0, .38); border-radius: 8px; padding: 2px 8px; margin-top: 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.c-phoenix { color: #ff9aa3; }
.c-gargoyle { color: #97bdff; }
.c-inquisitor { color: #d3b8ff; }

/* ---------------- seat cards ---------------- */
.g-ring { position: absolute; inset: 0; }
.seat {
  position: absolute;
  width: var(--seat-w); height: var(--seat-h);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 4px 3px 3px;
  border-radius: 12px; border: 1px solid var(--line);
  background: rgba(22, 20, 36, .94); color: var(--text);
  cursor: pointer; font: inherit;
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
}
.seat.me { border-color: rgba(224, 179, 74, .65); box-shadow: 0 0 0 1px rgba(224, 179, 74, .3); }
.seat.dagger { border-color: rgba(217, 72, 84, .85); box-shadow: 0 0 14px rgba(217, 72, 84, .45); }
.seat.targeted { border-color: var(--red); box-shadow: 0 0 18px rgba(224, 74, 90, .75); }
.seat.offline .seat-name { color: var(--muted); }
.seat.selectable { border-color: var(--gold); box-shadow: 0 0 14px rgba(224, 179, 74, .55); animation: pulse 1.3s ease-in-out infinite; }
.seat.selected { border-color: #fff; background: rgba(224, 179, 74, .26); animation: none; transform: scale(1.05); z-index: 4; }
.seat.selected-true { border-color: #ffd966; background: rgba(224, 179, 74, .32); animation: none; transform: scale(1.05); z-index: 4; }
.seat.selected-false { border-color: #c3a4ff; background: rgba(165, 124, 230, .28); animation: none; transform: scale(1.05); z-index: 4; }
.seat.disabled-target { opacity: .62; }
@keyframes pulse { 50% { box-shadow: 0 0 3px rgba(224, 179, 74, .2); } }

.seat-top { display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; position: relative; min-height: 0; }
.seat-card { position: relative; width: calc(var(--seat-h) * .28); height: calc(var(--seat-h) * .42); flex-shrink: 0; border-radius: 5px; overflow: hidden; border: 1px solid rgba(255, 255, 255, .2); background: #0d0c16; }
.seat-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.seat-card.peeked { outline: 2px dashed rgba(224, 179, 74, .85); outline-offset: 1px; }
.seat-dagger { width: calc(var(--seat-h) * .24); height: calc(var(--seat-h) * .24); object-fit: contain; filter: drop-shadow(0 1px 4px rgba(0, 0, 0, .85)); flex-shrink: 0; }
.seat-clue { width: calc(var(--seat-h) * .22); height: calc(var(--seat-h) * .22); border-radius: 50%; object-fit: cover; border: 1px solid rgba(255, 255, 255, .5); box-shadow: 0 0 6px rgba(0, 0, 0, .7); flex-shrink: 0; }

.seat-name { flex-shrink: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 700; line-height: 1.2; }

.seat-wounds { display: flex; align-items: center; justify-content: center; gap: 3px; flex-shrink: 0; }
.w-slot {
  width: calc(var(--seat-h) * .21); height: calc(var(--seat-h) * .21);
  border-radius: 50%; border: 1px dashed rgba(255, 255, 255, .18);
  background: rgba(0, 0, 0, .35); overflow: hidden; display: grid; place-items: center;
}
.w-slot.filled { border: 1px solid rgba(255, 255, 255, .35); background: transparent; }
.w-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }

.seat-badges { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 2px; min-height: 13px; }
.s-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px; height: 13px; border-radius: 6px;
  font-size: 9px; font-weight: 800; line-height: 1; white-space: nowrap;
  background: rgba(255, 255, 255, .11); color: #ece8f6;
}
.s-badge.shield-green { background: rgba(72, 184, 108, .28); border: 1px solid rgba(72, 184, 108, .7); color: #b7f5cb; }
.s-badge.shield-purple { background: rgba(165, 124, 230, .28); border: 1px solid rgba(165, 124, 230, .7); color: #e2d1ff; }
.s-badge.sword-green { background: rgba(45, 130, 74, .28); border: 1px solid rgba(72, 184, 108, .55); color: #8ee0a9; }
.s-badge.sword-purple { background: rgba(114, 78, 178, .28); border: 1px solid rgba(165, 124, 230, .55); color: #cfaeff; }
.s-badge.quill { background: rgba(224, 179, 74, .25); border: 1px solid rgba(224, 179, 74, .65); color: #ffe49c; }
.s-badge.fan { background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .35); }
.s-badge.staff { background: rgba(120, 180, 230, .22); border: 1px solid rgba(120, 180, 230, .55); color: #bde0ff; }
.s-badge.curse { background: rgba(165, 124, 230, .24); border: 1px solid rgba(165, 124, 230, .6); color: #e6d8ff; }
.s-badge.curse-true { background: rgba(224, 179, 74, .32); border: 1px solid var(--gold); color: #ffe58f; }
.s-badge.grace { background: rgba(224, 74, 90, .25); color: #ffb4a8; font-variant-numeric: tabular-nums; }
.s-badge.sel-tag { background: var(--gold); color: #241a05; }
.s-badge.sel-false { background: var(--inquisitor); color: #190d2d; }

/* ---------------- side panel / bottom control sheet ---------------- */
.g-side { grid-row: 2; grid-column: 2; display: flex; flex-direction: column; gap: 8px; min-height: 0; padding: 4px 0; overflow-y: auto; scrollbar-width: thin; }

.g-me {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line);
  position: relative; user-select: none;
}
.me-card-btn {
  position: relative; width: 38px; height: 64px; padding: 0; border: 0; background: none;
  cursor: pointer; flex-shrink: 0; border-radius: 6px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .24);
}
.me-card-btn img { width: 100%; height: 100%; display: block; object-fit: cover; }
.me-text { min-width: 0; flex: 1; }
.me-clan { font-weight: 800; font-size: 13.5px; line-height: 1.25; }
.me-role { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-clue-line { font-size: 11px; color: #ddd6ea; display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.me-clue-line img { width: 15px; height: 15px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.me-hide {
  flex-shrink: 0; align-self: flex-start;
  padding: 3px 8px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05); color: var(--muted);
  font: inherit; font-size: 11px; cursor: pointer;
}
.me-hide.on { color: var(--gold); border-color: rgba(224, 179, 74, .55); }

.g-prompt { font-size: 13px; line-height: 1.45; padding: 0 2px; }
.g-prompt p { margin: 0 0 4px; }
.g-prompt .alert { color: #ffc2c8; font-weight: 700; }

.g-controls { display: flex; flex-direction: column; gap: 6px; }
.tok-choices { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-start; }
.tok-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .22); background: var(--panel2); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: transform .08s ease, border-color .15s ease, background .15s ease;
}
.tok-btn:active { transform: scale(.96); }
.tok-btn:hover { border-color: var(--gold); }
.tok-btn img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.tok-btn.selected { border-color: var(--gold); background: rgba(224, 179, 74, .22); color: #ffe7a3; }

.ability-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 10px;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line);
}
.ability-preview img { width: 46px; height: 68px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.ability-preview-txt { font-size: 12px; line-height: 1.45; color: #e2dceb; }

.color-picks { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; }
.color-chip {
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.color-chip.selected.green { border-color: #5fbf73; background: rgba(95, 191, 115, .22); color: #c7f9d4; }
.color-chip.selected.purple { border-color: #a57ce6; background: rgba(165, 124, 230, .25); color: #e8dbff; }

.g-actions { display: flex; flex-direction: column; gap: 6px; }
.g-actions .btn { width: 100%; }
.g-log { display: none; }

/* ---------------- sheets, confirm, toasts ---------------- */
.sheet-backdrop { position: absolute; inset: 0; z-index: 50; background: rgba(5, 6, 12, .65); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  position: relative; width: min(600px, 96%); max-height: 88%; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px 16px 0 0;
  padding: 16px 16px 18px; box-shadow: 0 -10px 40px rgba(0, 0, 0, .55);
  font-size: 14px; color: var(--text);
}
.sheet-sm { width: min(420px, 96%); }
.sheet-title { margin: 0 0 10px; font-size: 16px; }
.sheet-close { position: absolute; top: 8px; inset-inline-end: 10px; width: 32px; height: 32px; border: 0; background: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.row-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.menu-list { display: grid; gap: 8px; }

.reveal-big { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 10px; }
.reveal-big > img { width: 92px; height: 158px; object-fit: cover; border-radius: 9px; border: 1px solid rgba(255, 255, 255, .22); flex-shrink: 0; }
.reveal-name { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.reveal-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0; }
.reveal-card-box {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); text-align: center;
}
.reveal-card-box img { width: 96px; height: 165px; object-fit: cover; border-radius: 8px; }

.ref-list { display: grid; gap: 8px; margin-bottom: 14px; }
.ref-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
.ref-toks { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.ref-toks img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.ref-item-img { width: 38px; height: 55px; object-fit: cover; border-radius: 5px; flex-shrink: 0; }

.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 8px; }
.result-seat {
  display: flex; gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: 10px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line);
}
.result-seat.won { border-color: rgba(224, 179, 74, .6); background: rgba(224, 179, 74, .1); }
.result-seat > img { width: 42px; height: 72px; object-fit: cover; border-radius: 5px; flex-shrink: 0; }

.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.log-list li, .g-log li { padding: 3px 0; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.log-list li.private, .g-log li.private { font-weight: 800; color: #ffe6a8; }
.log-r { display: inline-block; min-width: 18px; margin-inline-end: 6px; color: var(--muted); font-size: 11px; }

.toasts { position: absolute; top: calc(var(--top-h) + 6px); left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 6px; pointer-events: none; width: min(460px, 90%); }
.toast { pointer-events: auto; background: rgba(21, 20, 34, .97); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; font-size: 13px; box-shadow: 0 8px 30px rgba(0, 0, 0, .55); animation: up .2s ease-out; }
.toast.warn { border-color: rgba(224, 74, 90, .65); }
.toast.good { border-color: rgba(95, 191, 115, .65); }
@keyframes up { from { transform: translateY(-6px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .seat.selectable { animation: none; } .toast { animation: none; } }

/* ---------------- phone upright (portrait): table on top, control sheet at bottom ---------------- */
body.g-phone.in-game .app-root { zoom: var(--app-zoom, 1); }
body.g-portrait .g-screen {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--top-h) minmax(0, 1fr) auto;
  gap: 0;
  padding: 0;
}
body.g-portrait .g-top { padding: 0 max(6px, env(safe-area-inset-left)); }
body.g-portrait .g-table-wrap { grid-row: 2; grid-column: 1; padding: 4px max(3px, env(safe-area-inset-left)); }
body.g-portrait .g-side {
  grid-row: 3; grid-column: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: clamp(206px, calc(var(--app-height) * .33), 268px);
  gap: 5px;
  overflow: hidden;
  padding: 7px 10px max(8px, env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .5);
}
body.g-portrait .g-me { padding: 4px 6px; gap: 7px; }
body.g-portrait .me-card-btn { width: 28px; height: 48px; }
body.g-portrait .me-clan { font-size: 12.5px; }
body.g-portrait .me-role { font-size: 11px; }
body.g-portrait .me-clue-line { font-size: 10.5px; }
body.g-portrait .me-hide-txt { display: none; }
body.g-portrait .g-prompt { font-size: 12px; line-height: 1.4; }
body.g-portrait .g-controls { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
body.g-portrait .ability-preview img { width: 34px; height: 50px; }
body.g-portrait .ability-preview-txt { font-size: 11px; }
body.g-portrait .g-actions { flex-direction: row; flex-wrap: wrap; }
body.g-portrait .g-actions .btn { flex: 1 1 0; width: auto; min-height: 38px; padding: 4px 8px; font-size: 12.5px; }
body.g-portrait .g-center { width: max(124px, calc(100% - 2 * var(--seat-w) - 10px)); max-height: 62%; gap: 2px; }
body.g-portrait .c-title { font-size: 13.5px; }
body.g-portrait .c-sub { font-size: 10.5px; }
body.g-portrait .c-supply { font-size: 9.5px; padding: 1px 6px; }
body.g-portrait .c-last { font-size: 10px; }
.seat.small { padding: 2px 2px; }
.seat.small .seat-name { font-size: 9.5px; }
.seat.small .s-badge { font-size: 8px; height: 11px; padding: 0 3px; }
@media (max-height: 700px) {
  body.g-portrait .g-side { height: clamp(190px, calc(var(--app-height) * .34), 236px); gap: 4px; padding-top: 6px; }
  body.g-portrait .me-card-btn { width: 25px; height: 43px; }
  body.g-portrait .g-actions .btn { min-height: 35px; font-size: 12px; }
}

/* ---------------- small landscape phones ---------------- */
body.g-tight { --top-h: 28px; }
body.g-tight .g-top { font-size: 12px; gap: 5px; }
body.g-tight .g-me { padding: 4px 6px; }
body.g-tight .me-card-btn { width: 28px; height: 48px; }
body.g-tight .g-prompt { font-size: 12px; }
body.g-tight .btn { min-height: 34px; font-size: 12px; padding: 4px 8px; }
body.g-tight .seat-name { font-size: 10px; }
body.g-tight .c-title { font-size: 13px; }
body.g-narrow .g-round { display: none; }

/* ---------------- desktop and laptop windows ---------------- */
body.g-desktop { --top-h: 46px; }
body.g-desktop .g-screen { max-width: 1680px; margin: 0 auto; gap: 0 16px; padding: 0 16px 16px; }
body.g-desktop .g-top { font-size: 15px; gap: 10px; }
body.g-desktop .g-icon { width: 36px; height: 32px; font-size: 16px; }
body.g-desktop .g-round { font-size: 14px; }
body.g-desktop .g-timebar { width: 136px; }
body.g-desktop .g-timer { font-size: 14px; }
body.g-desktop .g-side { gap: 10px; padding-top: 10px; }
body.g-desktop .g-me { padding: 10px 12px; gap: 12px; }
body.g-desktop .me-card-btn { width: 56px; height: 96px; }
body.g-desktop .me-clan { font-size: 16px; }
body.g-desktop .me-role { font-size: 13.5px; }
body.g-desktop .me-clue-line { font-size: 12.5px; }
body.g-desktop .g-prompt { font-size: 14px; }
body.g-desktop .seat-name { font-size: 13px; }
body.g-desktop .s-badge { font-size: 10px; height: 15px; padding: 0 5px; }
body.g-desktop .c-title { font-size: 20px; }
body.g-desktop .c-dagger-wrap { font-size: 15px; }
body.g-desktop .c-dagger-wrap img { width: 30px; height: 30px; }
body.g-desktop .c-sub { font-size: 13.5px; }
body.g-desktop .c-supply { font-size: 12px; }
body.g-desktop .c-last { font-size: 13px; }
body.g-desktop .g-log {
  display: block; list-style: none; margin: 0; padding: 8px 10px;
  flex: 1; min-height: 120px; overflow-y: auto;
  font-size: 13px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; color: #dcd6ca;
}
body.g-desktop .sheet-backdrop { align-items: center; }
body.g-desktop .sheet { border-radius: 16px; }
