/* Coup · BoardBazi
   Phone first: the other players on top, the claim in play in the middle, your two cards and the action
   buttons at the bottom. body.lay-desktop adds a sidebar (event log, character guide) next to a wider
   table; body.landscape puts the two halves side by side for phones held sideways.
   The look follows the game's art: a dark palace at night, gold for what you can press, and each
   character's own colour (Duke magenta, Assassin steel, Captain blue, Ambassador green, Contessa red). */

@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 {
  color-scheme: dark;
  --void: #0b070e;
  --bg: #140c18;
  --bg-lit: #2a1630;
  --s1: rgba(30, 19, 36, .88);
  --s2: #261a2d;
  --s3: #35263d;
  --line: rgba(246, 222, 190, .12);
  --line-2: rgba(246, 222, 190, .22);
  --t1: #f6ede2;
  --t2: #c9b9c4;
  --t3: #9d8c99;
  --gold: #e3b45a;
  --gold-2: #f7d98f;
  --on-gold: #2a1606;
  --red: #ef5350;
  --green: #4fd18b;
  --blue: #5aa9ff;
  --duke: #d24aa8;
  --assassin: #9aa3b5;
  --captain: #3d97f0;
  --ambassador: #a9cc3c;
  --contessa: #ee4b45;
  --font: 'Vazirmatn', Tahoma, 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --app-h: 100vh;
  --bar-h: 40px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--void);
  color: var(--t1);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  font-size: 15px;
  line-height: 1.55;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--gold-2); }
img { user-select: none; -webkit-user-drag: none; }
.hidden { display: none !important; }
body.busy { cursor: progress; }

/* ---------------- character colours ---------------- */
.rl-duke { --rc: var(--duke); }
.rl-assassin { --rc: var(--assassin); }
.rl-captain { --rc: var(--captain); }
.rl-ambassador { --rc: var(--ambassador); }
.rl-contessa { --rc: var(--contessa); }
.rl { color: var(--rc); font-weight: 800; }

/* ---------------- buttons and controls ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 8px 16px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--s2); color: var(--t1);
  text-decoration: none; font-weight: 700; white-space: nowrap;
  transition: transform .08s, background .15s, opacity .15s, box-shadow .15s;
}
.btn:hover:not(:disabled) { background: var(--s3); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: var(--on-gold); border-color: transparent;
  box-shadow: 0 2px 0 #9a6f22, 0 10px 18px -10px rgba(227, 180, 90, .7);
}
.btn-gold:hover:not(:disabled) { background: linear-gradient(180deg, #fbe4a8, #ebc06c); }
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(239, 83, 80, .14); border-color: rgba(239, 83, 80, .45); color: #ffc0bd; }
.btn-lg { min-height: 54px; font-size: 17px; width: 100%; }
.btn-sm { min-height: 38px; padding: 4px 12px; font-size: 13.5px; }
.icon-btn { background: transparent; border: 0; color: var(--t1); width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; }
.icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .06); }
.icon-btn.sm { width: 34px; height: 34px; font-size: 20px; }
.btn:focus-visible, .seg button:focus-visible, .icon-btn:focus-visible, .card:focus-visible, .plate:focus-visible, .act-btn:focus-visible {
  outline: 3px solid var(--gold-2); outline-offset: 2px;
}

.tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--s3); color: var(--t2); font-weight: 700; white-space: nowrap; }
.tag-you { background: rgba(227, 180, 90, .2); color: var(--gold-2); }
.tag-host { background: rgba(227, 180, 90, .14); color: var(--gold); }
.tag-off { background: rgba(239, 83, 80, .18); color: #ffc0bd; }
.tag-bluff { background: rgba(239, 83, 80, .2); color: #ffb3ae; }
.tag-have { background: rgba(79, 209, 139, .18); color: #a7f0c8; }

.seg { display: flex; gap: 4px; background: var(--s2); padding: 3px; border-radius: 12px; border: 1px solid var(--line); }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 6px 8px; font-size: 15px; font-weight: 800; min-height: 40px; color: var(--t2); }
.seg button.on { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: var(--on-gold); }

.toggle { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--s2); border: 1px solid var(--line); cursor: pointer; }
.toggle > span:first-child { flex: 1; display: flex; flex-direction: column; }
.toggle strong { font-size: 14px; }
.toggle small { font-size: 12px; color: var(--t3); line-height: 1.5; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-ui { width: 44px; height: 26px; border-radius: 13px; background: var(--s3); position: relative; flex: none; transition: background .15s; }
.toggle-ui::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--t2); transition: transform .15s, background .15s; }
.toggle input:checked + .toggle-ui { background: var(--green); }
.toggle input:checked + .toggle-ui::after { background: #fff; transform: translateX(18px); }
[dir='rtl'] .toggle input:checked + .toggle-ui::after { transform: translateX(-18px); }
.toggle input:focus-visible + .toggle-ui { outline: 3px solid var(--gold-2); outline-offset: 2px; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, #4b2f55, #2b1b33); border: 1px solid var(--line-2);
  font-size: 13px; font-weight: 800; color: var(--gold-2);
}
.coin-ico {
  display: inline-block; width: 18px; height: 18px; flex: none; vertical-align: -4px;
  background: url('material/coin1.webp') center / contain no-repeat;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .5));
}
.coin-ico.big { width: 26px; height: 26px; }

/* ---------------- splash ---------------- */
.splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 40%, var(--bg-lit), var(--bg) 55%, var(--void));
  transition: opacity .45s;
}
.splash.gone { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; }
.splash-crown { font-size: 54px; color: var(--gold); animation: glow 1.6s ease-in-out infinite alternate; }
.splash-title { font-size: 44px; font-weight: 900; margin: 4px 0; letter-spacing: .02em; }
.splash-text { font-size: 13px; color: var(--t2); }
@keyframes glow { from { text-shadow: 0 0 8px rgba(227, 180, 90, .2); transform: translateY(0); } to { text-shadow: 0 0 26px rgba(227, 180, 90, .8); transform: translateY(-4px); } }

/* ---------------- 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;
}
.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) + 14px); }
/* Results screen: the bar sits above the table */
body.with-bar .view-game { padding-top: calc(var(--bar-h) + env(safe-area-inset-top)); }
@media (max-width: 380px) { .bb-word { display: none; } }

/* ---------------- intro / home / lobby ---------------- */
.view-intro {
  position: relative; min-height: var(--app-h); padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; align-items: flex-start; overflow-x: hidden;
}
.hero {
  position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(11, 7, 14, .35) 0%, rgba(11, 7, 14, .78) 42%, var(--void) 78%),
    url('material/hero-portrait.webp') center top / cover no-repeat;
}
.lay-desktop .hero {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(11, 7, 14, .25), rgba(11, 7, 14, .88) 70%),
    url('material/hero-wide.webp') center / cover no-repeat;
}
.intro-card {
  position: relative; width: 100%; max-width: 460px; margin-top: 18vh;
  display: flex; flex-direction: column; gap: 12px;
  padding: 20px 18px; border-radius: 22px;
  background: linear-gradient(180deg, rgba(36, 22, 42, .82), rgba(20, 12, 24, .92));
  border: 1px solid var(--line-2);
  box-shadow: 0 30px 60px -30px #000, inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.home-card, .lobby-card { margin-top: 6vh; }
.lay-desktop .intro-card { margin-top: 10vh; }
.lang-switch { display: flex; gap: 4px; align-self: flex-end; }
.lang-switch.center { align-self: center; }
.lang-switch button { border: 1px solid var(--line); background: transparent; color: var(--t2); border-radius: 8px; padding: 2px 10px; font-size: 12.5px; }
.lang-switch button.on { background: var(--s3); color: var(--t1); }
.intro-fan { position: relative; height: 120px; margin: -64px auto 4px; width: 240px; }
.intro-fan img {
  position: absolute; bottom: 0; left: 50%; width: 70px; border-radius: 8px;
  box-shadow: 0 10px 20px -8px #000; border: 1px solid rgba(255, 255, 255, .25);
  transform-origin: 50% 120%; animation: fanIn .8s var(--ease) both;
}
.intro-fan img:nth-child(1) { transform: translateX(-50%) rotate(-28deg); animation-delay: .05s; }
.intro-fan img:nth-child(2) { transform: translateX(-50%) rotate(-14deg); animation-delay: .1s; }
.intro-fan img:nth-child(3) { transform: translateX(-50%) rotate(0deg) translateY(-8px); animation-delay: .15s; z-index: 2; }
.intro-fan img:nth-child(4) { transform: translateX(-50%) rotate(14deg); animation-delay: .2s; }
.intro-fan img:nth-child(5) { transform: translateX(-50%) rotate(28deg); animation-delay: .25s; }
@keyframes fanIn { from { opacity: 0; translate: 0 30px; } to { opacity: 1; translate: 0 0; } }
.intro-title { margin: 0; text-align: center; font-size: 46px; font-weight: 900; line-height: 1.1; color: var(--gold-2); text-shadow: 0 2px 20px rgba(227, 180, 90, .35); }
.intro-sub { margin: 0; text-align: center; color: var(--gold); font-weight: 700; }
.intro-text { margin: 0; color: var(--t2); font-size: 14.5px; text-align: center; line-height: 1.85; }
.intro-facts { list-style: none; display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.intro-facts li { font-size: 12.5px; padding: 3px 12px; border-radius: 999px; background: rgba(227, 180, 90, .1); border: 1px solid rgba(227, 180, 90, .25); color: var(--gold-2); }
.intro-hint { margin: 0; padding: 8px 12px; border-radius: 10px; background: rgba(90, 169, 255, .12); border: 1px solid rgba(90, 169, 255, .3); font-size: 13.5px; text-align: center; }
.intro-actions { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.intro-link { font-size: 13.5px; color: var(--t2); text-decoration: none; }
.intro-link strong { color: var(--gold-2); }
.intro-note { margin: 0; text-align: center; font-size: 12px; color: var(--t3); }
.intro-more, .home-foot { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.dev-login { border-top: 1px dashed var(--line-2); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--t3); }
.dev-login .row { display: flex; gap: 6px; }
input {
  font: inherit; color: var(--t1); background: var(--s2); border: 1px solid var(--line-2); border-radius: 12px;
  min-height: 46px; padding: 6px 12px; width: 100%; min-width: 0;
}
input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.home-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.home-welcome { font-size: 13px; color: var(--t3); }
.home-name { font-size: 22px; font-weight: 900; color: var(--gold-2); }
.home-stats { font-size: 12.5px; color: var(--t2); }
.panel-box { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 16px; background: rgba(0, 0, 0, .22); border: 1px solid var(--line); }
.panel-box h2 { margin: 0; font-size: 17px; }
.panel-box p { margin: 0; color: var(--t2); font-size: 13.5px; }
.quick-box { background: linear-gradient(160deg, rgba(227, 180, 90, .12), rgba(0, 0, 0, .2) 60%); border-color: rgba(227, 180, 90, .3); }
.field-row { display: flex; align-items: center; gap: 10px; }
.field-label { font-size: 13px; color: var(--t2); font-weight: 700; flex: none; }
.field-row .seg { flex: 1; }
.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: .25em; text-align: center; font-weight: 800; }
.join-row .btn { flex: none; }

.lobby-code-box { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 16px; background: rgba(227, 180, 90, .1); border: 1px solid rgba(227, 180, 90, .3); }
.lobby-code-label { font-size: 13px; color: var(--t2); }
.lobby-code { flex: 1; font-size: 30px; font-weight: 900; letter-spacing: .25em; color: var(--gold-2); text-align: center; font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; }
.lobby-count { margin: 4px 0 0; font-size: 14px; color: var(--t2); }
.lobby-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lobby-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; background: var(--s2); border: 1px solid var(--line); min-height: 48px; }
.lobby-row.empty { background: transparent; border-style: dashed; color: var(--t3); }
.lobby-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lobby-hint { margin: 0; text-align: center; color: var(--t3); font-size: 13px; min-height: 1em; }

/* ---------------- the table ---------------- */
.view-game {
  height: var(--app-h); display: flex; flex-direction: column; overflow: hidden;
  background:
    radial-gradient(ellipse 120% 70% at 50% 45%, rgba(70, 30, 70, .55), transparent 70%),
    radial-gradient(ellipse at 50% 120%, rgba(227, 180, 90, .12), transparent 60%),
    var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}
.g-hud {
  flex: none; display: flex; align-items: center; gap: 2px;
  padding: calc(env(safe-area-inset-top) + 2px) 6px 2px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 6, 12, .5);
}
body.with-bar .g-hud { padding-top: 2px; }
.hud-mid { flex: 1; display: flex; justify-content: center; align-items: center; gap: 6px; min-width: 0; }
.hud-pill { font-size: 12.5px; padding: 2px 10px; border-radius: 999px; background: var(--s2); color: var(--t2); white-space: nowrap; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.conn-dot.lost { background: var(--red); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.g-body { flex: 1; min-height: 0; display: flex; }
.g-table {
  flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px;
  padding: 8px 10px 10px; overflow-y: auto; overflow-x: hidden;
}
.g-side { display: none; }

/* Opponents */
.opps { display: grid; gap: 6px; grid-template-columns: repeat(2, minmax(0, 1fr)); flex: none; }
.opps[data-count='1'] { grid-template-columns: minmax(0, 260px); justify-content: center; }
.opps[data-count='3'], .opps[data-count='5'] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.plate {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 7px 8px; min-width: 0;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--s1); text-align: start;
  transition: border-color .2s, box-shadow .2s, opacity .3s, transform .15s;
}
.plate-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.plate-top .avatar { width: 24px; height: 24px; font-size: 12px; }
.pname { font-weight: 800; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.plate-mid { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.minis { display: flex; gap: 3px; }
.mini { position: relative; width: 24px; height: 36px; border-radius: 4px; overflow: hidden; background: #222; box-shadow: 0 2px 4px rgba(0, 0, 0, .5); flex: none; }
.mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini.dead img { filter: grayscale(1) brightness(.55); }
.mini.dead::after { content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--red); font-weight: 900; font-size: 18px; text-shadow: 0 0 4px #000; }
.coins { position: relative; display: flex; align-items: center; gap: 4px; font-size: 16px; }
.coins b { font-weight: 900; color: var(--gold-2); }
.claims { display: flex; flex-wrap: wrap; gap: 3px; min-height: 0; }
.claims:empty { display: none; }
.chip { font-size: 10.5px; line-height: 1.5; font-weight: 800; padding: 0 6px; border-radius: 999px; color: var(--rc); background: color-mix(in srgb, var(--rc) 16%, transparent); border: 1px solid color-mix(in srgb, var(--rc) 40%, transparent); }
.plate-status { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 0; }
.plate-status:empty { display: none; }
.st { font-size: 11px; color: var(--t3); font-weight: 700; }
.st-out { color: var(--red); letter-spacing: .05em; }
.st-ok { color: var(--green); font-size: 14px; }
.st-off { color: #ffb3ae; }
.st-wait { display: inline-flex; gap: 3px; }
.st-wait i { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); animation: dot 1s infinite; }
.st-wait i:nth-child(2) { animation-delay: .15s; }
.st-wait i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.plate.turn { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 22px -6px rgba(227, 180, 90, .8); }
.plate.acting { border-color: var(--gold); }
.plate.targeted { border-color: var(--red); box-shadow: 0 0 0 1px var(--red), 0 0 20px -6px rgba(239, 83, 80, .9); }
.plate.blocking { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue), 0 0 20px -6px rgba(90, 169, 255, .9); }
.plate.winner { border-color: var(--gold-2); box-shadow: 0 0 0 2px var(--gold-2), 0 0 30px -4px rgba(247, 217, 143, .9); }
.plate.out { opacity: .5; filter: saturate(.4); }
.plate.targetable { cursor: pointer; border-color: var(--red); animation: pulse 1.1s ease-in-out infinite; }
.plate.targetable:hover { transform: translateY(-2px); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 83, 80, .0); } 50% { box-shadow: 0 0 0 4px rgba(239, 83, 80, .45); } }
.hit { animation: hit .5s; }
@keyframes hit { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

/* Stage: the claim in play */
.stage {
  flex: 1 1 auto; min-height: 104px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: 18px; text-align: center;
  background: radial-gradient(ellipse at 50% 50%, rgba(227, 180, 90, .08), transparent 70%);
}
.stage-title { font-size: 19px; font-weight: 900; }
.stage-title.gold { color: var(--gold-2); text-shadow: 0 0 18px rgba(227, 180, 90, .5); }
.stage-sub { font-size: 13.5px; color: var(--t2); }
.stage-sub.dots::after { content: ''; animation: ell 1.2s steps(4) infinite; }
@keyframes ell { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.nm { color: var(--t1); font-weight: 800; }
.claim { display: flex; align-items: center; gap: 12px; text-align: start; max-width: 100%; animation: rise .35s var(--ease); }
.claim-art { width: 62px; aspect-ratio: 440 / 665; border-radius: 8px; object-fit: cover; flex: none; border: 2px solid var(--rc, var(--gold)); box-shadow: 0 8px 20px -8px #000, 0 0 18px -4px var(--rc, var(--gold)); }
.claim-duke { --rc: var(--duke); }
.claim-assassin { --rc: var(--assassin); }
.claim-captain { --rc: var(--captain); }
.claim-ambassador { --rc: var(--ambassador); }
.claim-contessa { --rc: var(--contessa); }
.claim-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.claim-line { font-size: 15px; font-weight: 700; line-height: 1.6; }
.claim-act { font-size: 17px; font-weight: 900; color: var(--gold-2); }
.arrow { color: var(--red); }
[dir='ltr'] .arrow { display: inline-block; transform: scaleX(-1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.stage-win { animation: rise .5s var(--ease); }
.stage-win .crown, .res-head .crown { font-size: 44px; color: var(--gold); text-shadow: 0 0 24px rgba(227, 180, 90, .8); line-height: 1; }
.clock { position: relative; width: min(280px, 80%); height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .1); overflow: visible; }
.clock-fill { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 6px; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .2s linear; }
.clock-num { position: absolute; inset-inline-end: -30px; top: -8px; font-size: 12px; font-weight: 800; color: var(--t2); min-width: 24px; text-align: center; }
.clock.low .clock-fill { background: var(--red); }
.clock.low .clock-num { color: var(--red); }
.ticker { font-size: 12.5px; color: var(--t3); max-width: 100%; line-height: 1.6; }
.ticker .nm { color: var(--t2); }
.ticker.fresh { animation: fresh 1.2s; }
@keyframes fresh { 0% { color: var(--gold-2); } 100% { color: var(--t3); } }

/* Me */
.me-area {
  position: relative; flex: none; display: flex; align-items: flex-end; gap: 12px; padding: 8px 10px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .1), rgba(0, 0, 0, .3)); border: 1px solid var(--line);
  transition: border-color .2s, box-shadow .2s;
}
.me-area:empty { display: none; }
.me-area.turn { border-color: var(--gold); box-shadow: 0 0 26px -10px rgba(227, 180, 90, .9); }
.me-area.targeted { border-color: var(--red); box-shadow: 0 0 26px -8px rgba(239, 83, 80, .9); }
.me-area.out { opacity: .65; }
.me-cards { display: flex; gap: 8px; flex: none; }
.card {
  --ch: clamp(108px, 19vh, 176px);
  position: relative; display: block; padding: 0; border: 0; border-radius: 10px; overflow: hidden; flex: none;
  height: var(--ch); aspect-ratio: 440 / 665; background: #1d1220;
  box-shadow: 0 10px 22px -10px #000, 0 0 0 1px rgba(255, 255, 255, .12);
  transition: transform .2s var(--ease), box-shadow .2s, filter .3s;
}
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-name {
  position: absolute; inset-inline: 0; bottom: 0; padding: 14px 4px 3px; font-size: 12px; font-weight: 900; text-align: center;
  color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .85) 55%); text-shadow: 0 1px 2px #000;
  border-bottom: 3px solid var(--rc);
}
.card.dead { filter: grayscale(1) brightness(.5); transform: rotate(-5deg) scale(.94); }
.card.dead::after { content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--red); font-size: 54px; font-weight: 900; text-shadow: 0 0 10px #000; }
.losing .card.pickable { cursor: pointer; box-shadow: 0 0 0 2px var(--red), 0 10px 24px -6px rgba(239, 83, 80, .8); animation: wiggle 1.4s ease-in-out infinite; }
.losing .card.pickable:hover { transform: translateY(-6px); }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-2deg); } 75% { transform: rotate(2deg); } }
.me-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding-bottom: 4px; }
.me-coins { position: relative; display: flex; align-items: baseline; gap: 6px; }
.me-coins b { font-size: 30px; font-weight: 900; color: var(--gold-2); line-height: 1; }
.me-coins small { color: var(--t3); }
.float { position: absolute; inset-inline-start: 50%; top: -6px; font-weight: 900; font-size: 18px; pointer-events: none; animation: floatUp 1.3s var(--ease) forwards; text-shadow: 0 2px 4px #000; }
.float.up { color: var(--green); }
.float.down { color: var(--red); }
@keyframes floatUp { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-34px); } }

/* Panel: what I can do */
.panel { flex: none; display: flex; flex-direction: column; gap: 8px; }
.panel.empty { display: none; }
.panel-msg { text-align: center; font-weight: 800; font-size: 15px; }
.panel-msg.warn { color: #ffb3ae; }
.panel-msg small { font-weight: 600; color: var(--t3); }
.panel-hint { text-align: center; font-size: 13px; color: var(--t2); }
.panel-row { display: flex; gap: 8px; justify-content: center; }
.panel-row .btn { flex: 1; max-width: 260px; }
.act-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.act-btn {
  position: relative; display: flex; flex-direction: column; align-items: stretch; padding: 0; overflow: hidden; min-width: 0;
  border-radius: 12px; border: 1px solid var(--line-2); background: var(--s2); text-align: center;
  border-top: 3px solid var(--rc, var(--gold)); transition: transform .08s, opacity .15s, box-shadow .15s;
}
.act-btn img { width: 100%; height: 40px; object-fit: cover; object-position: center 22%; display: block; opacity: .9; }
.act-btn.act-income img, .act-btn.act-foreign_aid img, .act-btn.act-coup img { object-position: center 55%; }
.act-txt { display: flex; flex-direction: column; padding: 3px 2px 5px; line-height: 1.3; }
.act-txt b { font-size: 13px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-txt small { font-size: 10.5px; color: var(--t3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-btn .tag { position: absolute; top: 3px; inset-inline-end: 3px; font-size: 9.5px; padding: 0 5px; }
.act-btn:active:not(:disabled) { transform: scale(.96); }
.act-btn:hover:not(:disabled) { box-shadow: 0 0 0 1px var(--rc, var(--gold)); }
.act-btn:disabled { opacity: .3; filter: grayscale(.7); }
.act-btn.on { box-shadow: 0 0 0 2px var(--gold-2); }
.act-coup:not(:disabled) { --rc: var(--gold); background: linear-gradient(180deg, rgba(227, 180, 90, .2), var(--s2)); }
.targets { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.target-btn { flex: 1 1 140px; justify-content: flex-start; gap: 8px; border-color: rgba(239, 83, 80, .5); }
.target-btn small { margin-inline-start: auto; display: flex; align-items: center; gap: 3px; color: var(--gold-2); font-weight: 800; }
.respond-row { display: flex; flex-wrap: wrap; gap: 6px; }
.respond-row .btn { flex: 1 1 30%; min-height: 54px; font-size: 16px; }
.btn-allow { background: rgba(79, 209, 139, .14); border-color: rgba(79, 209, 139, .5); }
.btn-challenge { background: linear-gradient(180deg, #f2615e, #c93a37); border-color: transparent; color: #fff; box-shadow: 0 2px 0 #7d1f1d; }
.btn-block { background: color-mix(in srgb, var(--rc) 22%, var(--s2)); border-color: var(--rc); }
.btn-block .tag { font-size: 10px; }

/* Stamp, toasts, reactions */
.stamp {
  position: fixed; z-index: 40; left: 50%; top: 42%; transform: translate(-50%, -50%) rotate(-8deg) scale(.6);
  padding: 8px 26px; border-radius: 14px; border: 4px solid currentColor; font-size: 34px; font-weight: 900;
  background: rgba(10, 6, 12, .82); pointer-events: none; opacity: 0; white-space: nowrap;
  text-shadow: 0 0 18px currentColor;
}
.stamp.show { animation: stamp 1.1s var(--ease) forwards; }
@keyframes stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(2); }
  18% { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(.95); }
  26% { transform: translate(-50%, -50%) rotate(-8deg) scale(1.05); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
}
.stamp-red { color: #ff6b67; }
.stamp-green { color: #6ff0a6; }
.stamp-blue { color: #7fbcff; }
.stamp-gold { color: var(--gold-2); }
.stamp-dark { color: #c9b9c4; }
.toast {
  position: fixed; z-index: 80; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 24px); padding: 10px 16px; border-radius: 14px;
  background: var(--gold-2); color: var(--on-gold); font-weight: 700; font-size: 14px; box-shadow: 0 10px 30px -10px #000; text-align: center;
}
.g-toast {
  position: fixed; z-index: 35; left: 50%; top: calc(env(safe-area-inset-top) + 56px); transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 12px;
  background: rgba(20, 12, 24, .95); border: 1px solid var(--line-2); font-size: 13.5px; text-align: center; box-shadow: 0 10px 30px -10px #000;
  animation: rise .3s var(--ease);
}
.react-pop {
  position: fixed; z-index: 45; top: calc(env(safe-area-inset-top) + 50px); inset-inline-end: 8px;
  display: grid; grid-template-columns: repeat(2, auto); gap: 6px; padding: 8px; border-radius: 14px;
  background: rgba(20, 12, 24, .97); border: 1px solid var(--line-2); box-shadow: 0 20px 40px -16px #000;
}
.react-pop button { border: 1px solid var(--line); background: var(--s2); border-radius: 10px; padding: 8px 10px; font-size: 13.5px; text-align: start; }
.bubble-anchor { position: absolute; top: 0; inset-inline-start: 50%; width: 0; height: 0; }
.bubble {
  position: absolute; bottom: 4px; left: 0; transform: translateX(-50%); z-index: 20; white-space: nowrap;
  padding: 4px 10px; border-radius: 12px; background: #fff; color: #1c1020; font-weight: 800; font-size: 12.5px;
  box-shadow: 0 8px 16px -6px #000; animation: pop 3.2s var(--ease) forwards; pointer-events: none;
}
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, 6px) scale(.8); } 10% { opacity: 1; transform: translate(-50%, 0) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }

/* ---------------- sheets & dialogs ---------------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(5, 3, 6, .6); }
.sheet-body {
  position: relative; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0;
  background: linear-gradient(180deg, #2a1a30, #1a0f1e); border: 1px solid var(--line-2); border-bottom: 0;
  box-shadow: 0 -20px 60px -20px #000; animation: sheetUp .3s var(--ease);
}
.sheet.wide .sheet-body { max-width: 720px; }
.sheet-x { position: absolute; top: 8px; inset-inline-end: 8px; font-size: 26px; }
.sheet h3 { margin: 0 0 10px; font-size: 19px; padding-inline-end: 40px; color: var(--gold-2); }
.sheet-hint { margin: 0 0 10px; color: var(--t2); font-size: 13.5px; text-align: center; }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.confirm { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(5, 3, 6, .65); }
.confirm-box { width: 100%; max-width: 380px; padding: 18px; border-radius: 20px; background: #24162a; border: 1px solid var(--line-2); }
.confirm-box h3 { margin: 0 0 6px; font-size: 18px; }
.confirm-box p { margin: 0 0 14px; color: var(--t2); font-size: 14px; }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions .btn { flex: 1; }

.rules h4 { margin: 14px 0 4px; color: var(--gold); font-size: 15px; }
.rules p, .rules li { color: var(--t2); font-size: 14px; line-height: 1.85; }
.rules ul { margin: 0; padding-inline-start: 20px; }
.rules b { color: var(--t1); }
.cheat { display: flex; flex-direction: column; gap: 8px; }
.cheat-row { display: flex; gap: 10px; align-items: center; padding: 6px; border-radius: 12px; background: rgba(0, 0, 0, .2); border-inline-start: 3px solid var(--rc); }
.cheat-row img { width: 46px; aspect-ratio: 440 / 665; object-fit: cover; border-radius: 6px; flex: none; }
.cheat-row div { display: flex; flex-direction: column; font-size: 13px; color: var(--t2); line-height: 1.6; }
.cheat-row b { color: var(--rc); font-size: 14.5px; }
.cheat-row .blk { color: var(--t1); }
.cheat h4 { margin: 6px 0 0; color: var(--gold); font-size: 14px; }
.cheat-general { margin: 0; padding-inline-start: 18px; color: var(--t2); font-size: 13px; line-height: 1.8; }
.log-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.lg { font-size: 13.5px; color: var(--t2); padding: 5px 8px; border-radius: 8px; background: rgba(0, 0, 0, .18); line-height: 1.7; }
.lg-challenge, .lg-caught { border-inline-start: 3px solid var(--red); }
.lg-proved { border-inline-start: 3px solid var(--green); }
.lg-block, .lg-blocked { border-inline-start: 3px solid var(--blue); }
.lg-out, .lg-win { border-inline-start: 3px solid var(--gold); color: var(--t1); }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.menu-row .seg { flex: 0 1 260px; }
.menu-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.ex-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; justify-items: center; margin-bottom: 14px; }
.ex-cards[data-n='3'], .ex-cards[data-n='4'] { grid-template-columns: repeat(4, 1fr); }
.ex-cards[data-n='3'] { grid-template-columns: repeat(3, 1fr); }
.ex-card { --ch: auto; width: 100%; max-width: 120px; height: auto; cursor: pointer; opacity: .62; }
.ex-card.kept { opacity: 1; transform: translateY(-6px); box-shadow: 0 0 0 3px var(--gold-2), 0 12px 26px -8px rgba(227, 180, 90, .7); }

.res-head { text-align: center; }
.res-head h3 { padding: 0; margin: 4px 0 12px; }
.res-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.res-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(0, 0, 0, .22); border: 1px solid var(--line); }
.res-row.first { border-color: var(--gold); background: rgba(227, 180, 90, .12); }
.res-row.mine .res-name { color: var(--gold-2); }
.res-place { width: 28px; text-align: center; font-weight: 900; font-size: 18px; color: var(--gold); }
.res-name { flex: 1; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.res-cards { display: flex; gap: 4px; }
.res-cards img { width: 26px; aspect-ratio: 440 / 665; border-radius: 4px; object-fit: cover; }
.res-actions { display: flex; flex-direction: column; gap: 8px; }

/* ---------------- small phones ---------------- */
@media (max-height: 700px) {
  .g-table { gap: 6px; padding-top: 6px; }
  .plate { padding: 5px 7px; gap: 3px; }
  .mini { width: 20px; height: 30px; }
  .stage { min-height: 84px; padding: 4px; }
  .claim-art { width: 48px; }
  .act-btn img { height: 30px; }
  .card { --ch: clamp(96px, 17vh, 140px); }
}
@media (max-width: 360px) {
  .act-txt b { font-size: 12px; }
  .act-txt small { display: none; }
  .respond-row .btn { font-size: 14.5px; }
}

/* ---------------- phones held sideways ---------------- */
body.landscape .g-table {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: auto 1fr auto;
  grid-template-areas: 'opps me' 'stage me' 'stage panel'; align-items: start;
}
body.landscape .opps { grid-area: opps; grid-template-columns: repeat(3, minmax(0, 1fr)); }
body.landscape .opps[data-count='1'] { grid-template-columns: minmax(0, 220px); }
body.landscape .opps[data-count='2'], body.landscape .opps[data-count='4'] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.landscape .stage { grid-area: stage; min-height: 0; }
body.landscape .me-area { grid-area: me; }
body.landscape .panel { grid-area: panel; }
body.landscape .card { --ch: clamp(84px, 30vh, 130px); }
body.landscape .act-btn img { height: 26px; }
body.landscape .g-hud { min-height: 0; }
body.landscape .g-hud .icon-btn { height: 36px; }

/* ---------------- desktop ---------------- */
body.lay-desktop .g-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
body.lay-desktop .g-table { padding: 16px 24px 18px; gap: 14px; align-items: center; }
body.lay-desktop .g-table > * { width: 100%; max-width: 980px; }
body.lay-desktop .opps { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
body.lay-desktop .plate { width: 178px; padding: 10px 12px; gap: 6px; }
body.lay-desktop .plate-top .avatar { width: 30px; height: 30px; font-size: 14px; }
body.lay-desktop .pname { font-size: 15px; }
body.lay-desktop .mini { width: 34px; height: 51px; border-radius: 5px; }
body.lay-desktop .coins { font-size: 19px; }
body.lay-desktop .coin-ico { width: 22px; height: 22px; }
body.lay-desktop .stage { min-height: 170px; }
body.lay-desktop .claim-art { width: 92px; }
body.lay-desktop .claim-line { font-size: 17px; }
body.lay-desktop .claim-act { font-size: 21px; }
body.lay-desktop .stage-title { font-size: 24px; }
body.lay-desktop .card { --ch: clamp(170px, 26vh, 230px); }
body.lay-desktop .me-area { padding: 12px 16px; gap: 20px; max-width: 760px; }
body.lay-desktop .panel { max-width: 760px; }
body.lay-desktop .act-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
body.lay-desktop .act-btn img { height: 64px; }
body.lay-desktop .g-side {
  display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 14px; overflow: hidden;
  border-inline-start: 1px solid var(--line); background: rgba(10, 6, 12, .45);
}
body.lay-desktop .g-side h3 { margin: 0; font-size: 15px; color: var(--gold); }
body.lay-desktop .g-side .log-list { flex: 1; min-height: 0; overflow-y: auto; padding-inline-end: 4px; }
body.lay-desktop .side-cheat { flex: none; max-height: 46%; overflow-y: auto; border-top: 1px solid var(--line); padding-top: 10px; }
body.lay-desktop .side-cheat .cheat-row img { width: 36px; }
body.lay-desktop #btn-log, body.lay-desktop #btn-cheat { display: none; }
body.lay-desktop .sheet { align-items: center; padding: 20px; }
body.lay-desktop .sheet-body { border-radius: 22px; border-bottom: 1px solid var(--line-2); }
body.lay-desktop .react-pop { inset-inline-end: 356px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
