/* Dig Out — prison concrete, orange jumpsuits */
:root {
  --bg: #14110f;
  --bg2: #1d1916;
  --panel: #241f1b;
  --panel2: #2e2823;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f3ece4;
  --muted: #a99f94;
  --orange: #f26a1b;
  --orange2: #ff8a3d;
  --green: #4caf6a;
  --red: #e0483e;
  --blue: #4f9bd1;
  --gold: #f2b84b;
  --radius: 12px;
  --top-h: 34px;
  --app-height: 100dvh;
  --board-size: 360px;
  --card-h: 120px;
  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;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(242, 106, 27, 0.10), transparent 60%),
    linear-gradient(180deg, #181412, var(--bg));
  background-attachment: fixed;
}

img { max-width: 100%; user-select: none; -webkit-user-drag: none; }
button, input { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------------- buttons & inputs ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, var(--orange2), var(--orange)); border-color: transparent; color: #1b0d03; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: rgba(255, 255, 255, 0.04); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.09); }
.btn-danger { background: transparent; border-color: rgba(224, 72, 62, 0.6); color: #ff8d84; }
.btn-link { background: none; border: none; color: var(--orange2); min-height: 0; padding: 6px; font-weight: 500; }
.btn-lg { min-height: 48px; font-size: 16px; padding: 10px 22px; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 13px; }

input[type=text] {
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #120f0d;
  color: var(--text);
  font-size: 16px;
}
input[type=text]:focus { outline: 2px solid var(--orange); outline-offset: 1px; }

.switch {
  appearance: none;
  width: 46px; height: 26px;
  border-radius: 13px;
  background: #4a423b;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.switch::before {
  content: '';
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform 0.2s;
}
.switch:checked { background: var(--orange); }
.switch:checked::before { transform: translateX(-20px); }
.switch:disabled { opacity: 0.5; }

/* ---------------- splash ---------------- */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: var(--bg);
  transition: opacity 0.3s;
}
.splash.done { opacity: 0; pointer-events: none; }
.splash-logo { width: 96px; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.splash-title { font-size: 26px; font-weight: 900; color: var(--orange2); }
.splash-bar { width: 200px; height: 6px; border-radius: 3px; background: #2c2622; overflow: hidden; }
.splash-fill { height: 100%; width: 0; background: var(--orange); transition: width 0.2s; }
.splash-text { color: var(--muted); font-size: 13px; }

/* ---------------- 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, 18, 29, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.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, #6366f1, #06b6d4); 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, #6366f1, #06b6d4); }
.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; }

/* ---------------- pages ---------------- */
.main { padding: 16px max(12px, env(safe-area-inset-right)) 32px max(12px, env(safe-area-inset-left)); }
body.in-game .main { padding: 0; }
.view { max-width: 980px; margin: 0 auto; }
body.in-game #view-game { max-width: none; }

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.panel-title { margin: 6px 0 4px; font-size: 22px; }

.intro { display: grid; grid-template-columns: 1fr; gap: 0; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: var(--panel); }
.intro-hero { width: 100%; aspect-ratio: 16/8; object-fit: cover; display: block; }
.intro-body { padding: 18px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.intro-title { margin: 0; font-size: 30px; font-weight: 900; color: var(--orange2); }
.intro-lead { margin: 0; max-width: 560px; color: #ddd3c8; }
.intro-facts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; list-style: none; padding: 0; margin: 0; }
.intro-facts li { background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 20px; padding: 2px 12px; font-size: 13px; }
.auth-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 6px; }
.auth-hint { background: rgba(242,106,27,.12); border: 1px solid rgba(242,106,27,.4); border-radius: 10px; padding: 8px 12px; margin: 0; }
.auth-note { font-size: 12px; color: var(--muted); margin: 0; }
.dev-login { display: flex; gap: 8px; margin-top: 6px; }
@media (min-width: 860px) {
  .intro { grid-template-columns: 1.1fr 1fr; align-items: center; }
  .intro-hero { height: 100%; aspect-ratio: auto; min-height: 380px; }
}

.home-banner { width: 100%; border-radius: 12px; max-height: 180px; object-fit: cover; display: block; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 14px 0 8px; }
.box { background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.box h3 { margin: 0; }
.box p { margin: 0; font-size: 13px; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 700; }

.lobby-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tag { font-size: 12px; color: var(--muted); }
.lobby-code { font-size: 34px; font-weight: 900; letter-spacing: 6px; color: var(--orange2); }
.lobby-sub { display: flex; justify-content: space-between; margin: 14px 0 8px; font-weight: 700; }
.lobby-members { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.member { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line); min-width: 0; }
.member-ava { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #3a322c; font-weight: 700; flex-shrink: 0; }
.member-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member small { color: var(--muted); display: block; font-size: 11px; }
.member .x { background: none; border: none; color: #ff8d84; font-size: 18px; cursor: pointer; }
.member.empty { border-style: dashed; color: var(--muted); justify-content: center; min-height: 52px; }
.dot-off { color: var(--red); }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 14px 0; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid var(--line); cursor: pointer; }
.setting small { display: block; font-size: 12px; }
.lobby-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.lobby-actions #btn-start { flex: 1; min-width: 160px; }

/* ================= GAME ================= */
body.in-game { overflow: hidden; }
.app-root { position: relative; min-height: 100dvh; }
body.in-game .app-root { height: var(--app-height); min-height: 0; overflow: hidden; }

.g-screen {
  direction: ltr;
  display: grid;
  grid-template-columns: calc(var(--board-size) * 1.1) minmax(0, 1fr);
  grid-template-rows: var(--top-h) minmax(0, 1fr);
  height: var(--app-height);
  width: 100%;
  gap: 0 6px;
  padding: 0 max(4px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
}

/* top status bar */
.g-top {
  direction: rtl;
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.g-icon { flex-shrink: 0; width: 28px; height: 26px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.05); 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; }
.g-turn { font-weight: 700; flex-shrink: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-turn.mine { color: var(--orange2); }
.g-timebar { width: 60px; 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 1s linear; }
.g-timebar-fill.mine { background: var(--orange); }
.g-timebar-fill.urgent { background: var(--red); }
.g-timer { font-variant-numeric: tabular-nums; flex-shrink: 0; color: var(--muted); }
.g-timer.urgent { color: var(--red); font-weight: 700; }
.g-last { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.g-away { color: #ffb4a8; font-size: 12px; white-space: nowrap; }
@keyframes blink { 50% { opacity: 0.3; } }

/* board */
.g-boardwrap { grid-row: 2; grid-column: 1; display: flex; align-items: center; justify-content: flex-end; min-height: 0; }
.g-board { position: relative; width: var(--board-size); height: var(--board-size); box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.g-board-img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 10px; }
.g-layer { position: absolute; inset: 0; pointer-events: none; }
.g-layer > * { pointer-events: auto; }

.g-room { position: absolute; border-radius: 6px; border: 2px solid transparent; transition: background 0.2s, border-color 0.2s; }
.g-room.selectable { border-color: var(--orange2); background: rgba(242,106,27,.18); cursor: pointer; animation: pulse 1.2s infinite; }
.g-room.mine { box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
@keyframes pulse { 50% { background: rgba(242,106,27,.32); } }

.g-pawn {
  position: absolute;
  width: calc(var(--board-size) * 0.05);
  height: calc(var(--board-size) * 0.105);
  transform: translate(-50%, -50%);
  transition: left 0.6s cubic-bezier(.2,.8,.2,1), top 0.6s cubic-bezier(.2,.8,.2,1);
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.7));
  pointer-events: auto;
  cursor: pointer;
}
.g-pawn img { width: 100%; height: 100%; object-fit: contain; }
.g-pawn.active::after { content: ''; position: absolute; left: 10%; right: 10%; bottom: -3px; height: 4px; border-radius: 50%; background: var(--orange2); box-shadow: 0 0 8px var(--orange2); }
.g-pawn .pn { position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%); font-size: max(8px, calc(var(--board-size) * 0.02)); line-height: 1.3; background: rgba(0,0,0,.75); border-radius: 4px; padding: 0 2px; white-space: nowrap; direction: rtl; }
.g-pawn.me .pn { background: var(--orange); color: #1b0d03; font-weight: 700; }

.g-pile, .g-gang { position: absolute; cursor: pointer; }
.g-pile > img, .g-gang > .gcard {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  border-radius: calc(var(--board-size) * 0.008);
  box-shadow: 1px 1px 0 #000, 2px 2px 0 #333, 3px 3px 0 #000, 0 4px 10px rgba(0,0,0,.6);
}
.g-pile .cnt, .g-gang .cnt {
  position: absolute; top: -3%; right: -3%; z-index: 1;
  min-width: calc(var(--board-size) * 0.036); text-align: center;
  background: rgba(0,0,0,.85); border: 1px solid rgba(255,255,255,.3); border-radius: 10px; padding: 0 3px;
  font-weight: 700; line-height: 1.35; font-size: max(9px, calc(var(--board-size) * 0.021));
}
/* the cafeteria's spot lies sideways: a portrait card turned 90 degrees fills it */
.g-pile.sideways > img { inset: auto; left: 17.1%; top: -26%; width: 65.8%; height: 152%; transform: rotate(90deg); }
.g-gang .cnt { top: 2%; right: auto; left: 2%; min-width: 0; padding: 0 3px; font-size: max(8px, calc(var(--board-size) * 0.018)); }
.g-pawn.michel { width: calc(var(--board-size) * 0.045); height: calc(var(--board-size) * 0.095); cursor: default; }
.g-pawn.michel .pn { background: #1d4f73; }
.g-gang .mem { position: absolute; left: 0; right: 0; bottom: 2%; display: flex; justify-content: center; flex-wrap: wrap; }
.g-gang .mem img { width: calc(var(--board-size) * 0.03); height: calc(var(--board-size) * 0.062); object-fit: contain; filter: drop-shadow(0 1px 2px #000); }

.g-dice { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); display: flex; gap: 8px; pointer-events: none; z-index: 3; }
.g-dice img { width: calc(var(--board-size) * 0.12); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.6); animation: roll 0.6s ease-out; }
@keyframes roll { 0% { transform: rotate(-200deg) scale(0.3); opacity: 0; } 70% { transform: rotate(15deg) scale(1.1); opacity: 1; } 100% { transform: none; } }

/* side panel */
.g-side { direction: rtl; grid-row: 2; grid-column: 2; display: flex; flex-direction: column; gap: 5px; min-width: 0; min-height: 0; padding-top: 4px; }

.g-opps { display: flex; gap: 4px; overflow-x: auto; flex-shrink: 0; scrollbar-width: none; }
.g-opps::-webkit-scrollbar { display: none; }
.opp {
  flex: 1 0 auto; min-width: 92px; max-width: 170px;
  display: grid; grid-template-columns: auto 1fr; gap: 0 5px; align-items: center;
  padding: 3px 6px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line);
  cursor: pointer; font-size: 11px; position: relative;
}
.opp.active { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange) inset; }
.opp.removed { opacity: 0.4; }
.opp.offline .opp-name::after { content: ' 📡'; }
.opp-pawn { grid-row: span 2; width: 18px; height: 36px; object-fit: contain; }
.opp-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.opp-stats { display: flex; gap: 6px; color: var(--muted); white-space: nowrap; }
.opp-gang { position: absolute; top: 3px; left: 4px; width: 7px; height: 7px; border-radius: 50%; }

.g-me {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 4px 8px; border-radius: 10px; background: linear-gradient(90deg, rgba(242,106,27,.14), rgba(242,106,27,.04)); border: 1px solid rgba(242,106,27,.3);
  font-size: 12px; flex-shrink: 0;
}
.me-name { font-weight: 700; font-size: 13px; }
.me-tunnel { display: flex; align-items: center; gap: 4px; }
.me-bar { width: 70px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; }
.me-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--orange), var(--gold)); }
.chip { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 10px; background: rgba(0,0,0,.3); border: 1px solid var(--line); white-space: nowrap; cursor: default; }
.chip.btnish { cursor: pointer; }
.chip.hurt { border-color: rgba(224,72,62,.6); color: #ffb4a8; }
.chip img { width: 14px; height: 14px; object-fit: contain; }

.g-hand { flex: 1 1 auto; min-height: 0; display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; align-items: center; padding: 2px; scrollbar-width: thin; }
.hcard { position: relative; height: min(100%, var(--card-h)); aspect-ratio: 2 / 3; flex-shrink: 0; border-radius: 7px; overflow: hidden; cursor: pointer; border: 1px solid rgba(255,255,255,.12); background: #000; transition: transform 0.12s; }
.hcard img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hcard:hover { transform: translateY(-3px); }
.hcard.sel { outline: 3px solid var(--orange2); outline-offset: -3px; }
.hcard.dim { opacity: 0.4; }
.hcard .badge { position: absolute; bottom: 2px; left: 2px; background: rgba(0,0,0,.8); border-radius: 6px; padding: 0 4px; font-size: 10px; font-weight: 700; }
.hand-empty { color: var(--muted); font-size: 12px; margin: auto; }

.g-actions { display: flex; flex-wrap: wrap; gap: 4px; flex-shrink: 0; }
.act {
  flex: 1 0 auto; min-width: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  padding: 3px 4px; border-radius: 9px; min-height: 40px;
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  font-size: 11px; font-weight: 700; cursor: pointer; line-height: 1.2;
}
.act .ic { font-size: 15px; }
.act.on { background: linear-gradient(180deg, #3b2c20, #2d2219); border-color: rgba(242,106,27,.5); }
.act.off { opacity: 0.38; }
.act.end { background: linear-gradient(180deg, var(--orange2), var(--orange)); color: #1b0d03; border-color: transparent; }
.act.end.off { background: var(--panel2); color: var(--text); }
.wait-note { flex: 1 1 100%; text-align: center; color: var(--muted); font-size: 12px; padding: 4px; }

/* sheets & dialogs */
.sheet-backdrop {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}
body:not(.in-game) .sheet-backdrop { position: fixed; align-items: center; }
.sheet {
  position: relative;
  width: min(620px, 100%);
  max-height: 92%;
  overflow: auto;
  background: linear-gradient(180deg, #2b241f, #201b17);
  border: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  padding: 14px 16px 16px;
  box-shadow: 0 -10px 40px rgba(0,0,0,.5);
  animation: up 0.18s ease-out;
}
body:not(.in-game) .sheet { border-radius: 16px; max-height: 88vh; }
.sheet-sm { width: min(380px, 100%); text-align: center; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-close { position: absolute; top: 6px; left: 8px; background: none; border: none; color: var(--muted); font-size: 24px; cursor: pointer; }
.sheet-title { margin: 0 0 8px; font-size: 17px; }
.sheet-body h3 { margin: 0 0 8px; font-size: 17px; }
.sheet-body h4 { margin: 12px 0 6px; font-size: 14px; color: var(--muted); }
.sheet-body p { margin: 4px 0 10px; font-size: 13px; }
.row-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.row-btns .btn { flex: 1; min-width: 110px; }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.opt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; border-radius: 10px; background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--text); cursor: pointer; font-size: 13px; text-align: center; }
.opt small { color: var(--muted); font-size: 11px; }
.opt:hover:not(:disabled) { border-color: var(--orange); }
.opt.sel { border-color: var(--orange2); background: rgba(242,106,27,.18); }
.opt:disabled { opacity: 0.4; cursor: not-allowed; }
.opt img { width: 44px; height: 66px; object-fit: cover; border-radius: 5px; }
.opt .pawn { width: 22px; height: 46px; object-fit: contain; }
.cards-pick { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.cards-pick .hcard { height: 104px; }
.big-card { display: block; margin: 0 auto 8px; max-height: 46vh; max-width: 100%; border-radius: 10px; }
body.in-game .big-card { max-height: calc(var(--app-height) * 0.5); }
.split { display: flex; gap: 12px; align-items: flex-start; }
.split > img { width: 38%; max-width: 220px; border-radius: 10px; flex-shrink: 0; }
.split > div { flex: 1; min-width: 0; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 8px 0; }
.stepper button { width: 42px; height: 42px; border-radius: 50%; font-size: 22px; }
.stepper b { font-size: 28px; min-width: 40px; text-align: center; }
.log-list { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.log-list div { padding: 3px 8px; border-radius: 6px; background: rgba(255,255,255,.03); }
.log-list .k-turn { color: var(--orange2); font-weight: 700; background: none; }
.log-list .k-guard { background: rgba(79,155,209,.12); }
.log-list .k-fight, .log-list .k-racket { background: rgba(224,72,62,.10); }
.log-list .k-dig, .log-list .k-win { background: rgba(76,175,106,.14); }
.rules h4 { color: var(--orange2) !important; }
.rules ul { margin: 0; padding-inline-start: 18px; font-size: 13px; }
.rules li { margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; }

.zoom { position: absolute; inset: 0; z-index: 60; background: rgba(0,0,0,.8); display: grid; place-items: center; padding: 12px; cursor: zoom-out; }
body:not(.in-game) .zoom { position: fixed; }
.zoom img { max-width: 100%; max-height: 100%; border-radius: 12px; box-shadow: 0 10px 50px rgba(0,0,0,.8); }

.toasts { position: absolute; top: calc(var(--top-h) + 6px); left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(460px, 92%); }
body:not(.in-game) .toasts { position: fixed; top: 60px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 8px; background: rgba(28,24,21,.96); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,.5); animation: up 0.2s ease-out; }
.toast img { width: 34px; border-radius: 4px; }
.toast.warn { border-color: rgba(224,72,62,.6); }
.toast.good { border-color: rgba(76,175,106,.6); }

/* game over */
.final { display: flex; flex-direction: column; gap: 6px; }
.final-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: rgba(255,255,255,.04); }
.final-row.win { background: rgba(242,184,75,.15); border: 1px solid rgba(242,184,75,.5); }
.final-row img { width: 20px; height: 42px; object-fit: contain; }
.final-row .nm { flex: 1; font-weight: 700; }

/* ---------------- phone held upright during a game: the table turned 90° ---------------- */
body.g-rotated .app-root {
  position: fixed; top: 0; left: 0;
  width: var(--rot-w, 100vh);
  height: var(--rot-h, 100vw);
  transform-origin: top left;
  transform: translateX(var(--rot-h, 100vw)) rotate(90deg);
}
body.g-phone.in-game .app-root { zoom: var(--app-zoom, 1); }

/* ---------------- small landscape phones ---------------- */
body.g-tight { --top-h: 28px; }
body.g-tight .g-top { font-size: 12px; gap: 6px; }
body.g-tight .act { min-height: 34px; font-size: 10px; min-width: 46px; padding: 2px; }
body.g-tight .act .ic { font-size: 13px; }
body.g-tight .opp { min-width: 84px; padding: 2px 5px; }
body.g-tight .opp-pawn { width: 14px; height: 28px; }
body.g-tight .g-me { padding: 2px 6px; gap: 5px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
body.g-tight .g-me::-webkit-scrollbar { display: none; }
body.g-tight .me-bar { width: 44px; }
body.g-tight .g-opps .opp-stats { gap: 4px; }
body.g-tight .sheet { padding: 10px 12px 12px; }

/* ---------------- desktop & laptop ---------------- */
body.g-desktop { --top-h: 46px; }
body.g-desktop .g-screen { max-width: 1680px; margin: 0 auto; gap: 0 14px; padding: 0 14px 14px; }
body.g-desktop .g-top { font-size: 15px; gap: 12px; }
body.g-desktop .g-icon { width: 36px; height: 32px; font-size: 16px; }
body.g-desktop .g-timebar { width: 120px; }
body.g-desktop .g-last { font-size: 13px; }
body.g-desktop .g-side { gap: 10px; padding-top: 10px; }
body.g-desktop .opp { min-width: 150px; max-width: 220px; font-size: 13px; padding: 6px 10px; }
body.g-desktop .opp-name { font-size: 14px; }
body.g-desktop .opp-pawn { width: 24px; height: 48px; }
body.g-desktop .g-me { font-size: 14px; padding: 8px 12px; }
body.g-desktop .me-name { font-size: 16px; }
body.g-desktop .me-bar { width: 140px; height: 8px; }
body.g-desktop .chip img { width: 18px; height: 18px; }
body.g-desktop .act { min-height: 58px; font-size: 13px; min-width: 76px; }
body.g-desktop .act .ic { font-size: 20px; }
body.g-desktop .hcard .badge { font-size: 12px; }
body.g-desktop .g-hand { flex-wrap: wrap; overflow-x: hidden; overflow-y: auto; align-content: flex-start; align-items: flex-start; }
body.g-desktop .hcard { height: var(--card-h); }
body.g-desktop .sheet { width: min(720px, 96%); border-radius: 16px; margin-bottom: 20px; }
body.g-desktop .sheet-backdrop { align-items: center; }
body.g-desktop .opt img { width: 60px; height: 90px; }
body.g-desktop .cards-pick .hcard { height: 140px; }

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