/* Quoridor · BoardBazi
   Phone first: players on top, the board in the middle, what to do now at the bottom.
   body.lay-desktop puts players, the buttons and the move list in a sidebar next to a large board.
   Colours from the box art: candle-lit walnut, mahogany board, light wood walls and gold lettering. */

:root {
  --bg: #1b1210;
  --bg-2: #241815;
  --panel: #f6ecdb;
  --panel-2: #eadbc0;
  --ink: #2b1d16;
  --ink-2: #7b6450;
  --line: rgba(70, 40, 20, .18);
  --gold: #d9a94e;
  --gold-2: #a8792a;
  --mahogany: #6a2e2b;
  --accent: #8a3b2e;
  --radius: 12px;
  --app-h: 100vh;
  --bar-h: 40px;
  --font: Vazirmatn, "Vazir", Tahoma, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  /* Pawn colours */
  --p-light: #f1dca8;
  --p-dark: #5a3220;
  --p-red: #c0302e;
  --p-honey: #d8912f;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  font-size: 15px;
  line-height: 1.5;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.center { text-align: center; }
body.busy { cursor: progress; }

.c-light { --pc: var(--p-light); }
.c-dark { --pc: var(--p-dark); }
.c-red { --pc: var(--p-red); }
.c-honey { --pc: var(--p-honey); }
[data-color="light"] { --pc: var(--p-light); }
[data-color="dark"] { --pc: var(--p-dark); }
[data-color="red"] { --pc: var(--p-red); }
[data-color="honey"] { --pc: var(--p-honey); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--pc, #999); box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); margin-inline-end: 6px; vertical-align: middle; flex: none; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 14px; border-radius: 11px;
  border: 1px solid var(--line); background: #fffaf2; color: var(--ink);
  text-decoration: none; font-weight: 700; white-space: nowrap;
  transition: transform .08s, background .15s, opacity .15s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; }
.btn-gold { background: linear-gradient(180deg, #f0c873, var(--gold-2)); border-color: #8a5f18; color: #2a1904; }
.btn-ghost { background: transparent; }
.btn-danger { background: #f6d9d1; border-color: #dba08f; color: #7a2412; }
.btn-lg { min-height: 50px; font-size: 17px; width: 100%; }
.btn-sm { min-height: 34px; padding: 4px 10px; font-size: 13px; }
.btn-xs { min-height: 28px; min-width: 28px; padding: 2px 8px; font-size: 13px; }
.icon-btn { background: transparent; border: 0; color: #fff; font-size: 22px; width: 44px; height: 44px; flex: none; }
.btn:focus-visible, .seg button:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.ico-wall { display: inline-block; width: 5px; height: 14px; border-radius: 1px; background: url(img/walls/v.webp) center / 100% 100%; box-shadow: 0 1px 1px rgba(0, 0, 0, .4); vertical-align: -2px; margin-inline-end: 4px; }

.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); color: var(--ink-2); font-weight: 700; }
.tag-off { background: #f2d6cf; color: #8b2e1a; }

/* Segmented choice */
.seg { display: flex; gap: 4px; background: var(--panel-2); padding: 3px; border-radius: 10px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 7px 8px; font-size: 14px; font-weight: 700; min-height: 38px; }
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); color: var(--accent); }
.seg button:disabled { opacity: .7; }
.seg button.on:disabled { opacity: 1; }

/* ---------------- splash ---------------- */
.splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: radial-gradient(circle at 50% 35%, #4a2a20, var(--bg)); transition: opacity .45s; }
.splash.gone { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; color: var(--gold); }
.splash-logo { width: 84px; height: 84px; object-fit: contain; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .55)); animation: hop 1.6s ease-in-out infinite; }
.splash-title { font-family: Georgia, "Times New Roman", serif; font-size: 28px; letter-spacing: .3em; margin: 12px 0 18px; padding-inline-start: .3em; }
.splash-bar { width: 220px; height: 6px; background: rgba(255, 255, 255, .15); border-radius: 6px; overflow: hidden; margin: 0 auto; }
.splash-fill { height: 100%; width: 0; background: var(--gold); transition: width .2s; }
.splash-text { margin-top: 10px; font-size: 13px; opacity: .8; color: #f3e5cc; }
@keyframes hop { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(-14px); } 60% { transform: translateY(0); } }

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

/* ---------------- intro / home / lobby ---------------- */
.app { min-height: var(--app-h); }
.view-intro { position: relative; min-height: var(--app-h); display: flex; align-items: center; justify-content: center; padding: 16px; overflow: hidden; }
.intro-hero { position: fixed; inset: 0; background: url(img/ui/hero.webp) center / cover no-repeat; }
.intro-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20, 12, 8, .2), rgba(20, 12, 8, .78)); }
@media (orientation: portrait) { .intro-hero { background-image: url(img/ui/hero-tall.webp); background-position: center top; } }
.intro-card {
  position: relative; z-index: 1; width: 100%; max-width: 440px;
  background: rgba(246, 236, 219, .96); border-radius: 18px; padding: 22px 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5); display: flex; flex-direction: column; gap: 12px;
  border: 1px solid rgba(255, 255, 255, .5);
}
.intro-box { width: 92px; align-self: center; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .3)); margin-top: -4px; }
.intro-title { margin: 0; text-align: center; font-size: 30px; color: var(--mahogany); letter-spacing: .02em; }
.intro-sub { margin: -8px 0 0; text-align: center; color: var(--gold-2); font-size: 14px; font-weight: 700; }
.intro-text { margin: 0; color: var(--ink); font-size: 14.5px; text-align: justify; }
.intro-facts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; list-style: none; margin: 0; padding: 0; }
.intro-facts li { background: var(--panel-2); border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.intro-hint { background: #fff3cf; border-radius: 8px; padding: 8px 10px; margin: 0; font-size: 14px; }
.intro-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.intro-link { text-align: center; color: var(--accent); text-decoration: none; font-size: 14px; }
.intro-note { margin: 0; text-align: center; font-size: 12px; color: var(--ink-2); }
.intro-rules { align-self: center; }
.lang-switch { display: flex; gap: 4px; justify-content: flex-end; }
.lang-switch button { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 2px 10px; font-size: 13px; min-height: 30px; }
.lang-switch button.on { background: var(--mahogany); color: #fff; border-color: var(--mahogany); }
.dev-login { border-top: 1px dashed var(--line); padding-top: 10px; font-size: 13px; }
.dev-login .row { display: flex; gap: 6px; margin-top: 4px; }
.dev-login input, .join-form input { flex: 1; min-width: 0; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); padding: 6px 10px; font: inherit; background: #fff; }
.home-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.home-hello { color: var(--ink-2); font-size: 13px; }
.home-name { font-size: 22px; font-weight: 800; overflow-wrap: anywhere; }
.home-tools { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.home-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.home-stats:empty { display: none; }
.home-stats div { background: var(--panel-2); border-radius: 10px; padding: 8px; text-align: center; }
.home-stats b { display: block; font-size: 20px; }
.home-stats span { font-size: 12px; color: var(--ink-2); }
.home-block { display: flex; flex-direction: column; gap: 8px; background: rgba(255, 255, 255, .45); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.home-block h2 { margin: 0; font-size: 15px; color: var(--mahogany); }
.join-form { display: flex; gap: 8px; }
.join-form input { text-transform: uppercase; letter-spacing: .2em; text-align: center; font-weight: 800; }
#btn-rules-home { align-self: center; }

.lobby-top { display: flex; align-items: center; gap: 10px; }
.chip { background: var(--panel-2); border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.lobby-code { flex: 1; font-size: 30px; font-weight: 800; letter-spacing: .18em; color: var(--mahogany); text-align: center; }
.lobby-help { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.lobby-count { font-weight: 700; font-size: 14px; }
.lobby-seats { display: flex; flex-direction: column; gap: 6px; }
.seat { display: flex; align-items: center; gap: 8px; background: #fffaf2; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; min-height: 46px; }
.seat-icon { width: 26px; text-align: center; font-size: 18px; flex: none; }
.seat-empty { border-style: dashed; background: transparent; color: var(--ink-2); }
.seat-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px dashed var(--line); flex: none; margin-inline: 2px; }
.seat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.seat-name small { color: var(--ink-2); font-weight: 400; }
.lobby-settings { display: flex; flex-direction: column; gap: 8px; }
.setting { display: flex; flex-direction: column; gap: 4px; }
.setting > span { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.toggle { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border-radius: 10px; padding: 8px 10px; cursor: pointer; min-height: 48px; }
.toggle > span:first-child { flex: 1; display: flex; flex-direction: column; }
.toggle strong { font-size: 14px; }
.toggle small { color: var(--ink-2); font-size: 12px; line-height: 1.4; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-ui { width: 44px; height: 26px; border-radius: 26px; background: #c9b38f; 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: #fff; transition: inset-inline-start .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.toggle input:checked + .toggle-ui { background: var(--mahogany); }
.toggle input:checked + .toggle-ui::after { inset-inline-start: 21px; }
.toggle input:disabled + .toggle-ui { opacity: .55; }
.toggle input:focus-visible + .toggle-ui { outline: 2px solid var(--gold); outline-offset: 2px; }
.lobby-actions { display: flex; gap: 8px; }
.lobby-actions .btn { flex: 1; }

/* ---------------- game view ---------------- */
.view-game {
  height: var(--app-h); overflow: hidden; color: #f3e5cc;
  display: grid; grid-template-columns: 100%;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "top" "players" "board" "dock";
  background: radial-gradient(ellipse at 50% 45%, #3a2219, var(--bg) 70%);
}
.g-top {
  grid-area: top; display: flex; align-items: center; gap: 6px;
  padding: env(safe-area-inset-top) 6px 0; min-height: calc(46px + env(safe-area-inset-top));
  background: linear-gradient(180deg, #120c0a, #1b1210);
}
.g-status { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 14px; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .1); }
.g-timer.low { background: #b8432c; color: #fff; animation: pulse 1s infinite; }
.g-conn { width: 9px; height: 9px; border-radius: 50%; background: #4caf50; margin-inline: 6px; flex: none; }
.g-conn.lost { background: #e0533a; }
@keyframes pulse { 50% { opacity: .55; } }

/* Players */
.g-players { grid-area: players; display: flex; gap: 6px; padding: 6px 8px; overflow-x: auto; scrollbar-width: none; }
.g-players::-webkit-scrollbar { display: none; }
.pl {
  flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 12px; background: rgba(255, 255, 255, .06);
  border: 2px solid transparent; position: relative; cursor: pointer;
}
.pl.turn { border-color: var(--pc); background: rgba(255, 255, 255, .12); box-shadow: 0 0 14px -3px var(--pc); }
.pl.gone { opacity: .55; }
.pl-pawn { width: 30px; height: 30px; object-fit: contain; flex: none; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .55)); }
.pl-main { min-width: 0; flex: 1; }
.pl-name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-stats { display: flex; gap: 10px; font-size: 12.5px; color: #d6c3a4; font-variant-numeric: tabular-nums; white-space: nowrap; align-items: center; }
.pl-stats span { display: inline-flex; align-items: center; }
.pl-tag { font-size: 10px; padding: 0 5px; border-radius: 6px; background: #8b2e1a; color: #fff; }
.pl-timer { position: absolute; top: -8px; inset-inline-end: 6px; font-size: 11px; font-weight: 800; padding: 0 6px; border-radius: 999px; background: #2b1d16; border: 1px solid var(--pc); font-variant-numeric: tabular-nums; }
.pl-timer.low { background: #b8432c; }
body.lay-phone .g-players .pl.me { order: 9; }
/* Four players on a phone: two rows of two */
body.lay-phone:not(.landscape) .g-players.four { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; }

/* Board area: the trays and the board */
.g-board-wrap { grid-area: board; position: relative; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: 4px 8px; gap: 4px; }
.board-box { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.tray {
  height: 24px; width: calc(var(--board, 300px) * .8); border-radius: 8px; flex: none;
  background: linear-gradient(180deg, #1a1311, #2a201c); box-shadow: inset 0 2px 6px rgba(0, 0, 0, .8), 0 1px 0 rgba(255, 255, 255, .06);
  display: flex; align-items: center; justify-content: center; padding: 3px 10px;
}
.tray-sticks { display: flex; gap: 7px; align-items: center; height: 100%; }
.tray-sticks i { display: block; width: 6px; height: 100%; border-radius: 1px; background: url(img/walls/v.webp) center / 100% 100%; box-shadow: 1px 1px 2px rgba(0, 0, 0, .6); }

.qboard {
  position: relative; touch-action: none; user-select: none; -webkit-user-select: none;
  background: url(img/board/wood.webp) center / cover, var(--mahogany);
  border-radius: calc(var(--pad) * .9);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(255, 255, 255, .06), inset 0 2px 10px rgba(255, 200, 160, .12);
}
.qb-area { position: absolute; }
.qb-cells, .qb-hints, .qb-walls, .qb-pawns { position: absolute; inset: 0; }
.qb-cells { z-index: 1; }
.qb-hints { z-index: 2; pointer-events: none; }
.qb-walls { z-index: 3; pointer-events: none; }
.qb-pawns { z-index: 4; pointer-events: none; }
.qb-cell { position: absolute; background: url(img/board/cell.webp) center / cover, #2c2626; border-radius: 2px; box-shadow: 0 1px 1px rgba(0, 0, 0, .35); }

.qb-goals { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.qb-goal { position: absolute; background: var(--pc); opacity: .55; border-radius: 4px; }
.qb-goal.mine { opacity: .95; box-shadow: 0 0 8px var(--pc); }
.qb-goal.top { top: calc(var(--pad) * .3); left: var(--pad); right: var(--pad); height: calc(var(--pad) * .32); }
.qb-goal.bottom { bottom: calc(var(--pad) * .3); left: var(--pad); right: var(--pad); height: calc(var(--pad) * .32); }
.qb-goal.left { left: calc(var(--pad) * .3); top: var(--pad); bottom: var(--pad); width: calc(var(--pad) * .32); }
.qb-goal.right { right: calc(var(--pad) * .3); top: var(--pad); bottom: var(--pad); width: calc(var(--pad) * .32); }

.qb-coords { position: absolute; inset: 0; pointer-events: none; z-index: 1; font: 700 max(8px, calc(var(--pad) * .5)) / 1 var(--font); color: rgba(255, 228, 196, .55); }
.qb-coord { position: absolute; }
.qb-coord.col { bottom: 0; height: var(--pad); display: grid; place-items: center; transform: translateX(-50%); }
.qb-coord.row { left: 0; width: var(--pad); display: grid; place-items: center; transform: translateY(-50%); }
/* Goal strips and coordinates share the frame: shift the letters inwards when both are drawn */
.qb-coords .qb-coord.col { line-height: 1; }

.qb-target, .qb-from, .qb-path { position: absolute; width: var(--cell); height: var(--cell); display: grid; place-items: center; }
.qb-target::after { content: ""; width: 34%; height: 34%; border-radius: 50%; background: rgba(240, 200, 115, .85); box-shadow: 0 0 10px rgba(240, 200, 115, .8); animation: breathe 1.4s ease-in-out infinite; }
.qb-target.hover::after { width: 62%; height: 62%; background: rgba(240, 200, 115, .45); border: 2px solid #f0c873; }
.qb-from::after { content: ""; width: 60%; height: 60%; border-radius: 50%; border: 2px dashed rgba(255, 230, 200, .35); }
.qb-path::after { content: ""; width: 16%; height: 16%; border-radius: 50%; background: rgba(255, 240, 210, .55); }
@keyframes breathe { 50% { transform: scale(.8); opacity: .7; } }

.qb-wall { position: absolute; border-radius: 2px; box-shadow: 1px 2px 3px rgba(0, 0, 0, .65), inset 0 0 0 1px rgba(255, 255, 255, .12); z-index: 3; }
.qb-wall.v { background: url(img/walls/v.webp) center / 100% 100%, #d8b47c; }
.qb-wall.h { background: url(img/walls/h.webp) center / 100% 100%, #d8b47c; }
.qb-wall.last { box-shadow: 0 0 0 2px var(--pc, #f0c873), 0 0 12px var(--pc, #f0c873), 1px 2px 3px rgba(0, 0, 0, .65); }
.qb-wall.drop { animation: drop .32s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes drop { from { transform: scale(1.35); opacity: .2; } }
.qb-wall.ghost { z-index: 5; opacity: .9; box-shadow: 0 0 0 2px #f0c873, 0 0 16px #f0c873; pointer-events: none; }
.qb-wall.ghost.bad { box-shadow: 0 0 0 2px #e0533a, 0 0 16px #e0533a; filter: grayscale(.4) brightness(.8); opacity: .75; }

.qb-pawn { position: absolute; left: 0; top: 0; display: grid; place-items: center; transition: transform .28s cubic-bezier(.3, .9, .4, 1.15); will-change: transform; }
.qb-pawn img { width: 84%; height: 84%; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .6)); pointer-events: none; }
.qb-pawn.turn::before { content: ""; position: absolute; inset: 4%; border-radius: 50%; box-shadow: 0 0 0 2px var(--pc), 0 0 14px 2px var(--pc); animation: breathe 1.6s ease-in-out infinite; }

/* Dock: what to do now and the buttons */
.g-dock {
  grid-area: dock; display: flex; flex-direction: column; gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #24180f, #160f0b); border-top: 1px solid rgba(255, 255, 255, .08);
}
.dock-text { font-size: 13.5px; color: #e9d8bb; line-height: 1.35; min-height: 18px; text-align: center; }
.dock-text .warn { color: #ff9b85; font-weight: 700; }
.dock-actions { display: flex; gap: 6px; }
.dock-actions .btn { flex: 1 1 0; min-height: 46px; padding-inline: 8px; }
.dock-actions .btn-ghost { color: #f3e5cc; border-color: rgba(255, 255, 255, .25); }
.dock-actions:empty { display: none; }

.g-toast { position: absolute; inset-inline: 12px; top: 8px; z-index: 6; margin: 0 auto; max-width: 420px; background: rgba(20, 12, 8, .92); color: #fff; border-radius: 12px; padding: 8px 12px; font-size: 13.5px; text-align: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .5); pointer-events: none; }

.g-log-panel { display: none; }
.g-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.g-log li { padding: 4px 8px; border-radius: 8px; background: rgba(255, 255, 255, .05); display: flex; align-items: center; }
.g-log li.log-success { background: rgba(217, 169, 78, .18); }
.g-log li.log-warning { background: rgba(184, 67, 44, .22); }

/* Phone held sideways: board on one side, players and buttons on the other */
body.lay-phone.landscape .view-game {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 34%);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "board top" "board players" "board dock";
}
body.lay-phone.landscape .g-top { padding-top: 4px; min-height: 42px; }
body.lay-phone.landscape .g-players { flex-direction: column; overflow-y: auto; overflow-x: hidden; }
body.lay-phone.landscape .pl { flex: none; }
body.lay-phone.landscape .g-board-wrap { padding: 6px; }
body.lay-phone.landscape .tray { display: none; }
body.lay-phone.landscape .dock-actions { flex-wrap: wrap; }

/* ---------------- desktop ---------------- */
body.lay-desktop .view-game {
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  grid-template-areas: "top top" "board players" "board dock" "board log";
}
body.lay-desktop .g-top { padding-inline: 12px; }
body.lay-desktop .g-players { flex-direction: column; overflow: visible; padding: 12px; gap: 8px; background: rgba(0, 0, 0, .18); }
body.lay-desktop .pl { flex: none; padding: 8px 10px; }
body.lay-desktop .pl-pawn { width: 38px; height: 38px; }
body.lay-desktop .pl-name { font-size: 15px; }
body.lay-desktop .pl-stats { font-size: 13.5px; }
body.lay-desktop .g-board-wrap { padding: 14px; }
body.lay-desktop .tray { height: 28px; }
body.lay-desktop .g-dock { padding: 12px; background: rgba(0, 0, 0, .25); border-top: 1px solid rgba(255, 255, 255, .06); border-bottom: 1px solid rgba(255, 255, 255, .06); }
body.lay-desktop .dock-actions { flex-wrap: wrap; }
body.lay-desktop .g-log-panel { grid-area: log; display: flex; flex-direction: column; min-height: 0; padding: 10px 12px; background: rgba(0, 0, 0, .3); }
body.lay-desktop .g-log-panel h3 { margin: 0 0 8px; font-size: 13px; color: #cdb995; font-weight: 700; }
body.lay-desktop .g-log { overflow-y: auto; min-height: 0; flex: 1; }
body.lay-desktop .qboard { cursor: pointer; }

/* ---------------- sheets ---------------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(10, 6, 4, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--panel); color: var(--ink); border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0, 0, 0, .4);
  animation: up .22s ease-out;
}
.sheet.wide { max-width: 760px; }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
body.lay-desktop .sheet-backdrop { align-items: center; }
body.lay-desktop .sheet { border-radius: 18px; }
.sheet h2 { margin: 0 0 10px; font-size: 19px; padding-inline-end: 36px; }
.sheet h3 { margin: 14px 0 6px; font-size: 14px; color: var(--ink-2); }
.sheet-close { position: absolute; top: 8px; inset-inline-end: 8px; width: 40px; height: 40px; border: 0; background: transparent; font-size: 26px; color: var(--ink-2); }
.menu-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.menu-list .btn { justify-content: flex-start; }
.menu-toggles { display: flex; flex-direction: column; gap: 6px; }
.rules { font-size: 14px; }
.rules h4 { margin: 12px 0 4px; font-size: 14.5px; color: var(--mahogany); }
.rules p, .rules li { margin: 0 0 6px; text-align: justify; }
.rules ul { margin: 0 0 8px; padding-inline-start: 20px; }
.about { display: flex; gap: 12px; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.about img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; filter: sepia(.25); }
.about p { margin: 0; }
.sheet .g-log li { background: var(--panel-2); }
.sheet .g-log li.log-success { background: #f6e3b0; }
.sheet .g-log li.log-warning { background: #f2d6cf; }

.results-head { text-align: center; }
.results-head h2 { font-size: 24px; color: var(--mahogany); padding: 0; margin-bottom: 2px; }
.results-head p { margin: 0 0 10px; font-size: 13.5px; }
.results-pawn { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .35)); animation: hop 1.6s ease-in-out 2; }
.score-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.score-table th, .score-table td { padding: 7px 4px; text-align: center; border-bottom: 1px solid var(--line); }
.score-table th { font-size: 12px; color: var(--ink-2); font-weight: 700; }
.score-table td:nth-child(2), .score-table th:nth-child(2) { text-align: start; }
.score-table .who { display: flex; align-items: center; gap: 6px; font-weight: 700; max-width: 200px; }
.score-table .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-table .who small { color: var(--ink-2); font-weight: 400; }
.score-table .who img { width: 24px; height: 24px; object-fit: contain; flex: none; }
.score-table tr.win { background: rgba(217, 169, 78, .22); }
.sheet-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1; }

.confirm-backdrop { align-items: center; z-index: 60; padding: 16px; }
.confirm-sheet { border-radius: 16px; max-width: 380px; }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions .btn { flex: 1; }

.toast {
  position: fixed; z-index: 70; inset-inline: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 420px;
  background: #2a1a10; color: #fff; padding: 10px 14px; border-radius: 12px; font-size: 14px; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
body.in-game .toast { bottom: calc(120px + env(safe-area-inset-bottom)); }

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