/* Risk · BoardBazi — dark command-room theme with brass accents.
   Phone first: sign-in, home and lobby are ordinary pages; the game is always a landscape table
   (drawn turned 90 degrees on an upright phone). Laptops and desktops get a roomier layout. */

@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: #0d1116;
  --bg-2: #141a22;
  --panel: #171e27;
  --panel-2: #1f2833;
  --panel-3: #283340;
  --line: rgba(255, 255, 255, 0.09);
  --text: #ece5d3;
  --muted: #98a2ad;
  --gold: #d6ad55;
  --gold-2: #f2d48b;
  --gold-ink: #2a1d05;
  --red: #c9372c;
  --red-2: #e2493c;
  --blue: #2f6fd1;
  --green: #3aa45a;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --app-h: 100dvh;
  --c-blue: #2a73db;
  --c-orange: #f07a1a;
  --c-green: #2b9a3e;
  --c-yellow: #f0c419;
  --c-black: #3a3a42;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', Tahoma, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* pinch-zoom works, double-tap does not zoom by accident */
  touch-action: manipulation;
}

body {
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(214, 173, 85, 0.10), transparent),
    radial-gradient(circle at 0% 100%, rgba(201, 55, 44, 0.08), transparent 40%),
    var(--bg);
  background-attachment: fixed;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.center { text-align: center; }

.app-root { position: relative; min-height: 100dvh; }

/* ---------- splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg);
}
.splash-icon { width: 92px; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .6)); animation: bob 1.4s ease-in-out infinite; }
.splash-title { font-size: 34px; font-weight: 900; letter-spacing: .04em; color: var(--gold-2); }
.splash-bar { width: 200px; height: 6px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.splash-fill { width: 8%; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .2s; }
@keyframes bob { 50% { transform: translateY(-6px); } }

/* ---------- buttons & bits ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 10px;
  font-weight: 700; text-decoration: none; text-align: center;
  transition: transform .08s, filter .15s, opacity .15s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .42; }
.btn-lg { min-height: 52px; font-size: 17px; }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: 13px; }
.btn-gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: var(--gold-ink); box-shadow: 0 4px 14px rgba(214, 173, 85, .25); }
.btn-blue { background: linear-gradient(180deg, #4a88e8, var(--blue)); color: #fff; }
.btn-red { background: linear-gradient(180deg, var(--red-2), var(--red)); color: #fff; }
.btn-red-dark { background: linear-gradient(180deg, #8f2a22, #6d1d17); color: #ffd9d4; border: 1px solid rgba(255, 120, 100, .35); }
.btn-ghost { background: rgba(255, 255, 255, .06); border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .1); }
.wide { width: 100%; }
.link-btn { color: var(--gold-2); font-weight: 600; padding: 6px 8px; }
.link-btn.danger { color: #ff8a7f; font-size: 13px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(16, 21, 28, .82); border: 1px solid var(--line); color: var(--text);
  font-size: 20px; font-weight: 700; backdrop-filter: blur(6px);
}
.icon-btn:disabled { opacity: .4; }
.attn { animation: attn 1.6s ease-in-out infinite; }
@keyframes attn { 50% { box-shadow: 0 0 0 3px rgba(242, 212, 139, .45); } }
body.busy .action-box .btn { pointer-events: none; opacity: .7; }

.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-inline-end: 6px; vertical-align: -1px; box-shadow: 0 0 0 2px rgba(0, 0, 0, .35); flex: none; }
.c-blue { --own: var(--c-blue); } .c-orange { --own: var(--c-orange); } .c-green { --own: var(--c-green); }
.c-yellow { --own: var(--c-yellow); } .c-black { --own: var(--c-black); }
.dot[class*="c-"] { background: var(--own); }
.who { color: color-mix(in srgb, var(--own) 70%, white); }
.who.c-black { color: #c9c9d6; }

.tag { font-size: 11px; padding: 1px 7px; border-radius: 6px; background: var(--panel-3); color: var(--muted); }
.tag-gold { background: rgba(214, 173, 85, .18); color: var(--gold-2); }
.tag-blue { background: rgba(47, 111, 209, .22); color: #9cc2ff; }
.tag-dim { opacity: .7; }

.panel { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.panel h2 { font-size: 20px; }
.panel h3 { font-size: 15px; margin: 4px 0 10px; color: var(--gold-2); }

.seg { display: inline-flex; background: var(--panel-3); border-radius: 10px; padding: 3px; gap: 3px; }
.seg-btn { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 700; font-size: 14px; }
.seg-btn.on { background: var(--gold); color: var(--gold-ink); }
.seg-btn:disabled:not(.on) { opacity: .5; }
.seg-sm .seg-btn { padding: 3px 9px; font-size: 13px; min-height: 30px; display: inline-flex; align-items: center; }

/* ---------- intro ---------- */
#introScreen { min-height: 100dvh; display: flex; flex-direction: column; }
.intro-hero { position: relative; height: 46vh; min-height: 260px; overflow: hidden; }
.intro-img { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; display: block; }
.intro-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(13, 17, 22, 0) 40%, var(--bg) 100%); }
.intro-body { position: relative; margin-top: -40px; padding: 0 20px calc(28px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; max-width: 560px; width: 100%; align-self: center; }
.brand { font-size: 44px; font-weight: 900; color: var(--gold-2); text-shadow: 0 4px 22px rgba(0, 0, 0, .7); letter-spacing: .02em; }
.tagline { font-size: 17px; color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 4px 12px; border-radius: 99px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.cta { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.note { font-size: 13px; color: var(--muted); text-align: center; }
.dev-login { display: flex; gap: 8px; }
.dev-login input, .join-form input {
  flex: 1; min-width: 0; height: 44px; padding: 0 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); outline: none;
}
.dev-login input:focus, .join-form input:focus { border-color: var(--gold); }
.rules-box { background: rgba(255, 255, 255, .03); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.rules-box summary { cursor: pointer; font-weight: 700; color: var(--gold-2); }
.rules-list { margin-top: 8px; padding-inline-start: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #d3ccbb; }
.lang-btn { align-self: center; }

@media (min-width: 900px) {
  #introScreen { flex-direction: row; height: 100dvh; }
  .intro-hero { height: auto; flex: 1.35; }
  .intro-shade { background: linear-gradient(90deg, rgba(13, 17, 22, 0) 55%, var(--bg) 100%); }
  [dir="rtl"] .intro-shade { background: linear-gradient(270deg, rgba(13, 17, 22, 0) 55%, var(--bg) 100%); }
  .intro-body { flex: 1; margin: 0; justify-content: center; padding: 40px; overflow: auto; }
  .brand { font-size: 64px; }
}

/* ---------- topbar, home, lobby ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(8px + var(--safe-top)) 14px 8px;
  background: rgba(13, 17, 22, .86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 20px; color: var(--gold-2); }
.topbar-brand img { width: 30px; }
.topbar-actions { display: flex; gap: 4px; }
.topbar-title { font-weight: 700; }
.home-body, .lobby-body { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; }
.home-body .panel { display: flex; flex-direction: column; gap: 10px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.join-form { display: flex; gap: 8px; }
.join-form input { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; text-align: center; }

.code-panel { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.big-code { font-size: 44px; font-weight: 900; letter-spacing: .3em; color: var(--gold-2); font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; padding-inline-start: .3em; }
.member-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.member { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, .04); }
.m-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; display: flex; flex-direction: column; }
.m-name small { white-space: normal; font-weight: 400; }
.color-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.color-btn {
  width: 52px; height: 52px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--own) 22%, var(--panel-2)); border: 2px solid transparent;
}
.color-btn img { width: 34px; height: 34px; object-fit: contain; }
.color-btn.on { border-color: var(--gold-2); box-shadow: 0 0 0 3px rgba(242, 212, 139, .25); }
.color-btn:disabled { opacity: .25; }
.sticky-cta { position: sticky; bottom: calc(10px + var(--safe-bottom)); }
.result-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.result-list li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; background: rgba(255, 255, 255, .04); }
.result-list li > b { width: 18px; text-align: center; color: var(--gold-2); }

/* ============================================================
   GAME: always landscape
   ============================================================ */
body.in-game { overflow: hidden; overscroll-behavior: none; }
body.in-game .app-root { height: var(--app-h); min-height: 0; overflow: hidden; }
body.phone.in-game .app-root { zoom: var(--app-zoom, 1); }

/* Upright phone: the landscape table, turned 90 degrees */
body.g-rotated .app-root {
  position: fixed; top: 0; left: 0;
  width: var(--rot-w, 100vh); height: var(--rot-h, 100vw);
  min-height: 0; margin: 0; overflow: hidden;
  transform-origin: top left;
  transform: translateX(var(--rot-h, 100vw)) rotate(90deg);
}

#gameScreen { height: 100%; }
.game {
  --side-w: clamp(214px, 31%, 272px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side-w);
  height: 100%;
}
body.desktop .game { --side-w: clamp(320px, 26vw, 400px); }

.g-map {
  position: relative; overflow: hidden; touch-action: none;
  background: radial-gradient(ellipse at center, #3a3122 0%, #1c1810 100%);
  padding-inline-start: var(--safe-left);
}
.map-svg { direction: ltr; display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }

.map-hud { position: absolute; top: 8px; inset-inline-start: 8px; z-index: 3; pointer-events: none; display: flex; gap: 6px; max-width: calc(100% - 16px); }
.turn-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border-radius: 99px;
  background: rgba(13, 17, 22, .82); border: 1px solid var(--line); font-size: 13px; font-weight: 700;
  backdrop-filter: blur(6px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.zoom-ctrls { position: absolute; bottom: 10px; inset-inline-start: 8px; z-index: 3; display: flex; flex-direction: column; gap: 6px; }
body.phone .zoom-ctrls .icon-btn { width: 34px; height: 34px; font-size: 18px; }
.map-tip {
  position: absolute; z-index: 4; pointer-events: none; padding: 5px 10px; border-radius: 8px;
  background: rgba(13, 17, 22, .9); border: 1px solid var(--line); font-size: 13px; white-space: nowrap;
}
.paused-banner {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3;
  padding: 6px 14px; border-radius: 99px; background: rgba(201, 55, 44, .9); font-weight: 700; font-size: 13px;
}

.battle-box {
  position: absolute; top: 44px; left: 50%; z-index: 4; pointer-events: none;
  transform: translate(-50%, -8px); opacity: 0;
  padding: 8px 14px; border-radius: 14px; min-width: 200px; text-align: center;
  background: rgba(13, 17, 22, .9); border: 1px solid rgba(242, 212, 139, .3); box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s;
}
.battle-box.show { opacity: 1; transform: translate(-50%, 0); }
.bb-head { font-size: 13px; }
.bb-dice { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 4px 0; }
.bb-result { font-size: 13px; }
.bb-result .won { color: var(--gold-2); }
.dice-set { display: inline-flex; gap: 3px; }
.die { width: 34px; height: 34px; object-fit: contain; animation: roll .45s ease-out; }
.die-sm { width: 20px; height: 20px; animation: none; vertical-align: middle; }
.vs { color: var(--gold-2); font-weight: 900; }
@keyframes roll { 0% { transform: rotate(-200deg) scale(.4); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* ---------- side panel ---------- */
.g-side {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border-inline-start: 1px solid var(--line);
  padding-inline-end: var(--safe-right);
  padding-bottom: var(--safe-bottom);
}
.side-head { padding: 6px 10px 0; flex: none; }
.my-color {
  display: flex; align-items: center; gap: 6px; margin-bottom: 5px; padding: 3px 8px; border-radius: 8px;
  font-size: 13px; background: color-mix(in srgb, var(--own) 22%, var(--panel-2));
  border: 1.5px solid var(--own); border-inline-start-width: 6px;
}
.my-color img { width: 20px; height: 20px; object-fit: contain; }
.my-color b { font-weight: 900; }
body.compact .my-color { font-size: 12px; padding: 2px 6px; margin-bottom: 4px; }
body.compact .my-color img { width: 16px; height: 16px; }
body.desktop .my-color { font-size: 14.5px; padding: 6px 10px; margin-bottom: 8px; }
body.desktop .my-color img { width: 24px; height: 24px; }
.phase-line { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.phase-line b { color: var(--gold-2); font-size: 14px; }
.timer-text { margin-inline-start: auto; font-variant-numeric: tabular-nums; color: var(--gold-2); font-weight: 700; }
.timer-bar { height: 4px; margin: 5px 0 4px; border-radius: 4px; background: var(--panel-3); overflow: hidden; }
.timer-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .5s linear; }
.timer-fill.low { background: linear-gradient(90deg, var(--red), var(--red-2)); }

.player-list { list-style: none; flex: none; padding: 2px 6px; display: flex; flex-direction: column; gap: 2px; }
.pl {
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 6px;
  padding: 3px 6px; border-radius: 8px; font-size: 12.5px; border: 1px solid transparent;
}
.pl.turn { background: color-mix(in srgb, var(--own, #fff) 14%, transparent); border-color: rgba(242, 212, 139, .45); }
.pl .pl-icon { width: 24px; height: 24px; border-radius: 6px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--own) 30%, var(--panel-2)); }
.pl .pl-icon img { width: 18px; height: 18px; object-fit: contain; }
.pl.turn .pl-icon { box-shadow: 0 0 0 2px var(--gold-2); }
.pl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; display: flex; flex-direction: column; line-height: 1.25; }
.pl-status { color: #ff9c8f; font-weight: 400; font-size: 11px; }
.pl-stats { display: flex; gap: 7px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.pl.out { opacity: .45; }
.pl.placing .pl-icon { animation: attn 1.6s ease-in-out infinite; }

.action-box {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 6px 10px 8px; display: flex; flex-direction: column; gap: 7px;
  border-top: 1px solid var(--line);
}
.act-title { font-weight: 800; color: var(--gold-2); font-size: 14px; }
.act-help { font-size: 12.5px; color: var(--muted); }
.act-help.warn { color: #ffb3a8; }
.act-sel { font-size: 13px; font-weight: 600; }
.act-wait { font-size: 13px; color: var(--muted); }
.act-info { font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; margin-top: auto; }
.draft-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.draft-left { font-weight: 800; color: var(--gold-2); font-size: 15px; }
.draft-left.done { color: #8fe0a2; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btn-row .btn { flex: 1; }
.end-row { margin-top: 2px; }
.count-row { display: flex; align-items: center; gap: 4px; }
.count-row input[type="range"] { flex: 1; min-width: 40px; accent-color: var(--gold); }
.count-row .icon-btn { width: 32px; height: 32px; font-size: 18px; flex: none; }
.count-row .btn-sm { padding: 2px 8px; min-height: 30px; flex: none; }
.battle-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); padding: 4px 6px; border-radius: 8px; background: rgba(255, 255, 255, .03); }

.side-log { display: none; }
.side-tabs { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.tab-btn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 5px 2px 6px; font-size: 11px; color: var(--muted); }
.tab-btn:active { background: rgba(255, 255, 255, .05); }
.tab-ico { font-size: 16px; line-height: 1.2; color: var(--text); }
.tab-badge { position: absolute; top: 2px; inset-inline-end: 18%; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--gold); color: var(--gold-ink); font-size: 11px; line-height: 17px; }
.tab-badge:empty { display: none; }
.tab-btn.attn .tab-ico { color: var(--gold-2); }
.card-ico { display: inline-block; width: 9px; height: 13px; border-radius: 2px; margin-inline-end: 2px; vertical-align: -1px; background: url('/material/cards/back.webp') center / cover; box-shadow: 0 0 0 1px rgba(255, 255, 255, .35); }
.tab-ico .card-ico { width: 12px; height: 17px; }
.tab-btn.attn .card-ico { box-shadow: 0 0 0 2px var(--gold-2); }

/* Players as a strip over the map (phones); in the side panel on desktops */
.map-players { display: none; gap: 4px; flex-wrap: wrap; }
.mp {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px 2px 4px; border-radius: 99px;
  background: rgba(13, 17, 22, .84); border: 1px solid var(--line); font-size: 11.5px; font-weight: 700;
  font-variant-numeric: tabular-nums; backdrop-filter: blur(6px);
}
.mp img { width: 18px; height: 18px; object-fit: contain; border-radius: 50%; background: color-mix(in srgb, var(--own) 35%, var(--panel-2)); padding: 1px; }
.mp small { color: var(--muted); font-weight: 400; margin-inline-start: 1px; }
.mp .card-ico { width: 7px; height: 10px; margin-inline-start: 2px; }
.mp.turn { border-color: var(--gold-2); box-shadow: 0 0 0 2px rgba(242, 212, 139, .35); }
.mp.you img { box-shadow: 0 0 0 2px #fff; }
.mp.out { opacity: .4; }
.mp.away { border-style: dashed; }
.mp.placing { animation: attn 1.6s ease-in-out infinite; }
.phase-who { display: inline-flex; align-items: center; font-weight: 700; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-tools { display: inline-flex; gap: 4px; }
.sel-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.icon-btn.icon-sm { width: 30px; height: 30px; font-size: 15px; }
.minus-btn { font-size: 20px; }
.minus-btn.on { background: var(--red); border-color: var(--red-2); color: #fff; box-shadow: 0 0 0 2px rgba(226, 73, 60, .35); }
body.remove-mode .badge .b-pend circle { fill: #ff7a6b; stroke: #4a0d06; }

body.compact .map-players { display: flex; }
body.compact .turn-chip, body.compact .player-list { display: none; }
body.compact .act-help.opt { display: none; }
body.compact .action-box { gap: 5px; padding: 5px 8px 6px; }
body.compact .side-head { padding: 5px 8px 0; }
body.compact .phase-line { font-size: 12px; gap: 6px; }
body.compact .phase-line b { font-size: 12.5px; }
body.compact .act-info { font-size: 11px; padding-top: 4px; }
body.compact .battle-line { padding: 2px 4px; }

/* Phones: everything a touch tighter so the table fits a short landscape screen */
body.compact .act-title { font-size: 13px; }
body.compact .btn { min-height: 36px; padding: 5px 10px; font-size: 13.5px; }
body.compact .btn-sm { min-height: 30px; font-size: 12.5px; }

/* Desktop: wider side panel with the event log under the actions */
body.desktop .pl { padding: 6px 8px; font-size: 14px; grid-template-columns: 30px minmax(0, 1fr) auto; }
body.desktop .pl .pl-icon { width: 30px; height: 30px; }
body.desktop .pl .pl-icon img { width: 22px; height: 22px; }
body.desktop .pl-stats { font-size: 13px; gap: 10px; }
body.desktop .side-head { padding: 12px 14px 2px; }
body.desktop .phase-line { font-size: 14px; }
body.desktop:not(.compact) .action-box { flex: 0 1 auto; max-height: 52%; padding: 10px 14px; gap: 9px; }
body.desktop .act-title { font-size: 16px; }
body.desktop .act-help { font-size: 13.5px; }
body.desktop:not(.compact) .side-log { display: flex; flex-direction: column; flex: 1 1 0; min-height: 80px; border-top: 1px solid var(--line); padding: 8px 14px; }
body.desktop .side-log h4 { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
body.desktop .side-log .log-list { overflow-y: auto; flex: 1; }
body.desktop:not(.compact) #logBtn { display: none; }
body.desktop:not(.compact) .side-tabs { grid-template-columns: repeat(3, 1fr); }
body.desktop:not(.compact) .side-tabs:has(#missionBtn[hidden]) { grid-template-columns: repeat(2, 1fr); }
body.compact .side-tabs:has(#missionBtn[hidden]) { grid-template-columns: repeat(3, 1fr); }
body.desktop .tab-btn { flex-direction: row; justify-content: center; gap: 6px; font-size: 13px; padding: 10px 4px; }
body.desktop .die { width: 40px; height: 40px; }
body.desktop .battle-box { top: 54px; }
body.desktop .turn-chip { font-size: 14px; padding: 7px 14px; }

.log-list { list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #d4cdbd; }
.log-list li { padding: 3px 0; border-bottom: 1px solid rgba(255, 255, 255, .04); }
.log-list .log-turn { color: var(--gold-2); }
.log-list .log-eliminated, .log-list .log-game_over { color: #ff9c8f; font-weight: 700; }
.log-list .log-conquer { color: #cfe8c6; }

/* ---------- map: territories and badges ---------- */
.terr {
  fill: var(--own); fill-opacity: .5; mix-blend-mode: multiply;
  stroke: none; transition: fill-opacity .25s;
}
.terr[data-color="black"] { fill-opacity: .42; }
.terr[data-color="yellow"] { fill-opacity: .6; }
.terr.focus { fill-opacity: .7; }
.terr.sel, .terr.target, .terr.source {
  mix-blend-mode: normal; fill-opacity: .2;
  stroke-linejoin: round; paint-order: stroke;
}
.terr.sel { stroke: #fff6d6; stroke-width: 14; fill-opacity: .35; filter: url(#glow); }
.terr.source { stroke: #f2d48b; stroke-width: 8; stroke-dasharray: 28 18; animation: march 1.2s linear infinite; }
.terr.t-attack { stroke: #ff4d3a; stroke-width: 12; animation: pulse-red 1.1s ease-in-out infinite; }
.terr.t-move { stroke: #74f08f; stroke-width: 12; animation: pulse-green 1.1s ease-in-out infinite; }
.terr.flash { animation: flash 1.2s ease-out; }
/* Borders: fixed on-screen widths at any zoom */
.edge, .line { fill: none; pointer-events: none; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.edge { stroke: var(--own); stroke-width: 7px; stroke-opacity: .95; }
.line { stroke: rgba(20, 14, 6, .8); stroke-width: 1.3px; }
body.phone .edge { stroke-width: 5px; }
body.phone .line { stroke-width: 1px; }
/* Sea routes */
.sea {
  fill: none; pointer-events: none; vector-effect: non-scaling-stroke; stroke-linecap: round;
  stroke: rgba(30, 22, 10, .85); stroke-width: 2.5px; stroke-dasharray: 7 6;
}
.sea.on { stroke: #ff4d3a; stroke-width: 4px; stroke-dasharray: 10 7; animation: march-sea .8s linear infinite; }
.sea.on-move { stroke: #74f08f; }
body.phone .sea { stroke-width: 2px; }
body.phone .sea.on { stroke-width: 3px; }
@keyframes march-sea { to { stroke-dashoffset: -17; } }
@keyframes march { to { stroke-dashoffset: -46; } }
@keyframes pulse-red { 50% { stroke-opacity: .35; fill-opacity: .32; } }
@keyframes pulse-green { 50% { stroke-opacity: .35; } }
@keyframes flash { 0% { fill-opacity: .9; } 100% { fill-opacity: .3; } }

.badge { cursor: pointer; }
.badge .b-hit { fill: transparent; }
.badge .b-ring { fill: none; stroke: rgba(255, 255, 255, .9); stroke-width: 6; }
.badge .b-body { fill: var(--own); stroke: rgba(0, 0, 0, .55); stroke-width: 5; }
.badge .b-num {
  fill: var(--ink, #fff); font-family: 'Vazirmatn', system-ui, sans-serif; font-weight: 900; font-size: 46px;
  paint-order: stroke; stroke: rgba(0, 0, 0, .35); stroke-width: 3; pointer-events: none;
}
.badge .b-pend circle { fill: #ffd34d; stroke: #3a2a00; stroke-width: 4; }
.badge .b-pend text { fill: #2a1d00; font-weight: 900; font-size: 30px; font-family: 'Vazirmatn', system-ui, sans-serif; pointer-events: none; }
.badge.sel .b-ring { stroke: #ffe08a; stroke-width: 10; }
.badge.target .b-ring { stroke: #ff5a4a; stroke-width: 10; }
.badge.t-move .b-ring { stroke: #74f08f; }
.badge.source .b-ring { stroke: #ffe08a; stroke-dasharray: 14 9; }
.badge.bump .b-body { animation: bump .6s ease-out; }
@keyframes bump { 0% { stroke: #fff; stroke-width: 18; } 100% { stroke: rgba(0, 0, 0, .55); stroke-width: 5; } }

.fx-arrow { fill: none; stroke: #ffe08a; stroke-linecap: round; stroke-dasharray: 3000; stroke-dashoffset: 3000; opacity: .95; animation: draw .45s ease-out forwards, fade 1.9s ease-in forwards; filter: drop-shadow(0 0 6px rgba(0, 0, 0, .7)); }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { 70% { opacity: .95; } 100% { opacity: 0; } }

/* ---------- sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); }
.sheet {
  position: fixed; z-index: 21; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(620px, calc(100% - 24px)); max-height: calc(100% - 24px);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h3 { color: var(--gold-2); font-size: 16px; }
.sheet-body { padding: 12px 16px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.game-card { position: relative; border-radius: 10px; overflow: hidden; border: 2px solid transparent; background: #000; transition: transform .12s; }
.game-card img { display: block; width: 100%; aspect-ratio: 440 / 664; object-fit: cover; }
.game-card .card-unit { position: absolute; bottom: 0; inset-inline: 0; font-size: 11px; padding: 2px 4px; background: rgba(0, 0, 0, .65); text-align: center; }
.game-card.mine { box-shadow: inset 0 0 0 2px rgba(116, 240, 143, .5); }
.game-card.on { border-color: var(--gold-2); transform: translateY(-4px); box-shadow: 0 6px 16px rgba(214, 173, 85, .35); }
.game-card:disabled { cursor: default; }
.mission { display: flex; gap: 14px; align-items: flex-start; }
.mission-card { width: 130px; border-radius: 10px; flex: none; box-shadow: var(--shadow); }
.mission-text { font-size: 17px; font-weight: 800; color: var(--gold-2); margin-bottom: 6px; }
.cont-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cont-table th, .cont-table td { padding: 5px 6px; text-align: start; border-bottom: 1px solid var(--line); }
.cont-table th { color: var(--muted); font-weight: 600; }
.sheet-body h4 { color: var(--gold-2); }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .7); display: flex; align-items: center; justify-content: center; padding: 12px; }
.overlay-card {
  width: min(520px, 100%); max-height: 100%; overflow-y: auto; text-align: center;
  background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid rgba(242, 212, 139, .35); border-radius: 18px; padding: 18px;
  display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow);
}
.overlay-card h2 { color: var(--gold-2); font-size: 24px; }
.go-icon { font-size: 44px; }
.overlay-card .result-list li { text-align: start; }

.toast-stack { position: fixed; top: calc(10px + var(--safe-top)); left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: max-content; max-width: 90%; }
.toast { padding: 8px 16px; border-radius: 10px; background: rgba(23, 30, 39, .96); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 14px; transition: opacity .4s, transform .4s; text-align: center; }
.toast-error { border-color: rgba(226, 73, 60, .6); color: #ffc2bb; }
.toast-turn { border-color: rgba(242, 212, 139, .6); color: var(--gold-2); font-weight: 800; }
.toast.out { opacity: 0; transform: translateY(-8px); }
.conn-badge { position: fixed; bottom: calc(12px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); z-index: 41; padding: 6px 14px; border-radius: 99px; background: var(--red); font-weight: 700; font-size: 13px; }

/* Phone landscape (or the turned table): shorter sheets and overlays */
body.in-game.phone .sheet { width: min(640px, calc(100% - 16px)); max-height: calc(100% - 16px); }
body.in-game.phone .mission-card { width: 96px; }
body.in-game.phone .overlay-card { padding: 12px; gap: 6px; }
body.in-game.phone .go-icon { font-size: 30px; }
