/* ============================================================
   MENCH - STYLESHEET
   Made for phones: one column with the board as large as the screen allows and the dice button
   pinned to the bottom, in reach of the thumb. Larger screens show the same column centred.
   ============================================================ */

:root {
  --bg: #1b1f3b;
  --bg-dark: #10132a;
  --bg-light: #2a3060;
  --panel: rgba(16, 19, 42, 0.82);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #f5f3ee;
  --muted: #aab0d0;
  --accent: #ffcc33;
  --accent-dark: #e0a400;

  --red: #e53935;
  --green: #2e9d4a;
  --yellow: #f2c200;
  --blue: #1e7be0;

  --board: #f7edd3;
  --board-edge: #b98a52;
  --line: #3a2f25;

  --radius: 14px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body { min-height: 100%; }

body {
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% 0%, var(--bg-light) 0%, var(--bg) 45%, var(--bg-dark) 100%) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Vazirmatn, Tahoma, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  overscroll-behavior: none;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

.app { min-height: 100dvh; }
.view { display: none; }
.view.active { display: block; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.center { text-align: center; }

.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Pages ---------- */
.page {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(16px + var(--safe-top)) 16px calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.page-head { display: flex; align-items: center; gap: 10px; }
.page-head h2 { font-size: 1.2rem; }
.lang-row { display: flex; justify-content: flex-end; }

/* ---------- Panels, buttons, inputs ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.panel-title {
  font-weight: 800;
  margin-bottom: 10px;
  display: flex;
  gap: 6px;
  align-items: baseline;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s ease;
  min-height: 44px;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; filter: grayscale(1); cursor: not-allowed; box-shadow: none; }
.btn-lg { padding: 14px 18px; font-size: 1.05rem; }
.btn-sm { padding: 7px 12px; min-height: 36px; font-size: 0.88rem; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #2a1d00;
  box-shadow: 0 4px 14px rgba(255, 204, 51, 0.35);
}
.btn-accent {
  background: linear-gradient(180deg, #4fc3f7 0%, #1e88e5 100%);
  color: #04213d;
  box-shadow: 0 4px 14px rgba(79, 195, 247, 0.3);
}
.btn-ghost { background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.18); }
.btn-danger { background: rgba(229, 57, 53, 0.18); border: 1px solid rgba(229, 57, 53, 0.55); color: #ffd0d1; }
.btn-link {
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  min-height: 36px;
  padding: 6px 10px;
  font-weight: 600;
}

input[type="text"] {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 11px 14px;
  min-height: 44px;
  outline: none;
}
input:focus { border-color: var(--accent); }
input:disabled { opacity: 0.45; }

.icon-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1.2rem;
  display: grid;
  place-items: center;
  flex: none;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 16px; }
.chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82rem;
}

/* ---------- Landing ---------- */
.hero { text-align: center; padding: 10px 0 2px; }
.hero-logo { display: flex; justify-content: center; gap: 8px; align-items: center; }
.hero-die {
  font-size: 3.4rem;
  line-height: 1;
  color: #fff;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5));
  margin: 0 4px;
}
.pawn-ico {
  width: 22px;
  height: 30px;
  background: var(--c);
  border-radius: 50% 50% 40% 40% / 40% 40% 60% 60%;
  box-shadow: inset -3px -4px 0 rgba(0, 0, 0, 0.25), 0 4px 8px rgba(0, 0, 0, 0.4);
}
.hero-title {
  font-size: 2.8rem;
  letter-spacing: 0.06em;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 var(--red), 0 8px 20px rgba(0, 0, 0, 0.5);
}
.hero-tagline { color: var(--muted); margin-top: 4px; }
.lead { line-height: 1.6; }

.account { display: flex; gap: 12px; align-items: center; }
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: var(--accent);
  color: #2a1d00;
  flex: none;
}
.account-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.account-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.local-panel { border-color: rgba(79, 195, 247, 0.35); }
.local-panel .muted { margin-bottom: 12px; line-height: 1.5; }

.rules summary { font-weight: 700; cursor: pointer; }
.rules ul, .menu-rules ul {
  margin: 10px 0 0;
  padding-inline-start: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #e3e5f3;
  font-size: 0.92rem;
}

/* ---------- Segmented controls, colours ---------- */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.segmented button {
  border: 0;
  background: none;
  border-radius: 9px;
  padding: 9px;
  font-weight: 700;
  color: var(--muted);
}
.segmented button.active { background: var(--accent); color: #2a1d00; }
.segmented.readonly button { cursor: default; }
.segmented.mini { padding: 3px; gap: 2px; flex: none; }
.segmented.mini button { padding: 6px 9px; font-size: 1rem; min-width: 38px; }

.color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 0 0 2px rgba(255, 255, 255, 0.25);
  flex: none;
}
.color-dot.big { width: 26px; height: 26px; }

.color-picker { display: flex; gap: 4px; }
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: var(--c);
  opacity: 0.55;
}
.swatch.active { opacity: 1; border-color: #fff; box-shadow: 0 0 0 2px var(--c); }

/* ---------- One phone setup ---------- */
.local-seats { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.local-seat {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 8px;
}
.local-seat input { flex: 1; min-width: 0; padding: 9px 12px; min-height: 40px; }
.local-seat.off .color-dot { opacity: 0.35; }

/* ---------- Lobby ---------- */
.lobby-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.room-code {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.lobby-players { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.lobby-player {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 8px 10px;
}
.lobby-player .name {
  flex: 1;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  white-space: nowrap;
}
.tag-host { background: rgba(255, 204, 51, 0.2); color: var(--accent); }
.tag-you { background: rgba(79, 195, 247, 0.25); color: #c4e8ff; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #3ddc84; flex: none; }
.online-dot.off { background: #777; }
#addBotBtn { margin-top: 10px; width: 100%; }

.mini-btn {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  min-width: 36px;
  height: 34px;
  padding: 0 7px;
  font-size: 0.8rem;
  font-weight: 700;
}

.standings { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.standings li {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 10px;
  border-radius: 10px;
}
.standings .place { font-weight: 900; width: 26px; text-align: center; }
.standings .name { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.standings .worth { font-weight: 700; color: var(--accent); font-size: 0.85rem; }

/* ============================================================
   GAME TABLE
   ============================================================ */
#gameView.active {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + var(--safe-top)) 12px 6px;
}
.topbar-info { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.topbar-room { font-weight: 800; letter-spacing: 0.12em; }

/* Player strip */
.players {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  padding: 0 10px 6px;
}
.player {
  position: relative;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  border-top: 4px solid var(--c);
  padding: 5px 7px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.player.active {
  background: color-mix(in srgb, var(--c) 28%, transparent);
  box-shadow: 0 0 0 2px var(--c), 0 4px 14px color-mix(in srgb, var(--c) 45%, transparent);
  transform: translateY(-1px);
}
.player-name {
  font-weight: 800;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-sub { font-size: 0.74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Board: as large as the free space allows, always square */
.board-wrap {
  flex: 1;
  min-height: 0;
  container-type: size;
  display: grid;
  place-items: center;
  padding: 4px 8px;
}
.board {
  position: relative;
  /* Leave room for the wooden frame drawn around it */
  width: calc(min(100cqw, 100cqh) - 2 * clamp(4px, 1.4cqw, 9px));
  aspect-ratio: 1;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.55), transparent 70%),
    var(--board);
  border-radius: 4%;
  box-shadow: 0 0 0 clamp(4px, 1.4cqw, 9px) var(--board-edge), 0 14px 30px rgba(0, 0, 0, 0.55);
  direction: ltr;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.cells, .targets, .pieces { position: absolute; inset: 0; }
.targets { z-index: 40; pointer-events: none; }
.pieces { z-index: 30; pointer-events: none; }
.board.choosing .targets { pointer-events: auto; }

.base {
  position: absolute;
  width: calc(100% / 11 * 2.3);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 18%;
  background: color-mix(in srgb, var(--c) 22%, var(--board));
  border: 2px solid color-mix(in srgb, var(--c) 70%, black);
}
.base.unused { filter: grayscale(0.8); opacity: 0.45; }

.corner-name {
  position: absolute;
  transform: translate(-50%, -50%);
  max-width: calc(100% / 11 * 2.2);
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--c);
  color: #fff;
  font-weight: 800;
  font-size: clamp(9px, 2.9cqw, 13px);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  unicode-bidi: plaintext;
  z-index: 5;
  pointer-events: none;
}
.corner-name.turn { outline: 2px solid #fff; box-shadow: 0 0 0 4px var(--c), 0 2px 8px rgba(0, 0, 0, 0.4); }

.cell {
  position: absolute;
  width: calc(100% / 11 * 0.82);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: clamp(1px, 0.45cqw, 2.5px) solid var(--line);
  background: #fffdf6;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
  display: grid;
  place-items: center;
}
.cell.start { background: var(--c); }
.cell.goal { background: color-mix(in srgb, var(--c) 80%, white); }
.cell.yard { background: color-mix(in srgb, var(--c) 45%, white); border-color: color-mix(in srgb, var(--c) 60%, black); }
.cell .arrow {
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(8px, 2.6cqw, 16px);
  font-weight: 900;
  transform: rotate(calc(var(--a, 0deg) + var(--rot, 0deg)));
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}
.center-star {
  position: absolute;
  width: calc(100% / 11 * 0.95);
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  border-radius: 50%;
  background: conic-gradient(from -45deg, var(--green) 0 25%, var(--yellow) 0 50%, var(--blue) 0 75%, var(--red) 0 100%);
  border: 2px solid var(--line);
}

/* Pieces */
.piece {
  position: absolute;
  width: calc(100% / 11 * 0.78);
  aspect-ratio: 40 / 48;
  transform: translate(-50%, -66%);
  background: none;
  border: 0;
  padding: 0;
  transition: left 0.14s linear, top 0.14s linear, transform 0.2s ease;
  pointer-events: none;
}
.piece svg { width: 100%; height: 100%; overflow: visible; display: block; }
.piece .body { fill: var(--c); stroke: rgba(0, 0, 0, 0.55); stroke-width: 1.6; }
.piece.home { transform: translate(-50%, -66%) scale(0.88); }
.piece.walking { transform: translate(-50%, -80%) scale(1.08); z-index: 99 !important; }
.piece.knocked { transition: left 0.42s cubic-bezier(.5, -0.4, .5, 1.4), top 0.42s cubic-bezier(.5, -0.4, .5, 1.4); }
.piece.movable {
  pointer-events: auto;
  cursor: pointer;
  animation: hop 0.7s ease-in-out infinite alternate;
  z-index: 98 !important;
}
.piece.movable::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 92%;
  width: 150%;
  aspect-ratio: 2.4;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 10px #fff, 0 0 0 2px var(--c);
  animation: glow 0.7s ease-in-out infinite alternate;
}
/* A generous invisible tap area around small pieces */
.piece.movable::before { content: ''; position: absolute; inset: -40% -45%; }

@keyframes hop {
  from { transform: translate(-50%, -66%); }
  to { transform: translate(-50%, -84%); }
}
@keyframes glow {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

.target {
  position: absolute;
  width: calc(100% / 11 * 0.82);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px dashed var(--c);
  background: color-mix(in srgb, var(--c) 18%, transparent);
  animation: glow 0.7s ease-in-out infinite alternate;
  padding: 0;
}
.target.capture { border-style: solid; border-color: #fff; box-shadow: 0 0 0 3px var(--red), 0 0 12px var(--red); }

/* Dice */
.die {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  background: linear-gradient(145deg, #ffffff, #e6e2d8);
  border-radius: 22%;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.35);
  padding: 13%;
  gap: 4%;
  border: 0;
}
.die i { border-radius: 50%; }
.die i.on { background: radial-gradient(circle at 35% 35%, #555, #111); }
.die[data-v=""]::after {
  content: '?';
  grid-area: 1 / 1 / 4 / 4;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #9a9384;
  font-size: clamp(14px, 5cqw, 30px);
}
.die[data-v=""] i { display: none; }

.big-die {
  position: absolute;
  z-index: 50;
  width: calc(100% / 11 * 1.55);
  aspect-ratio: 1;
  /* Percent padding on an absolutely placed box counts from the board's width: 13% of the die */
  padding: calc(100% / 11 * 1.55 * 0.13);
  gap: 3%;
  transform: translate(-50%, -50%);
  outline: clamp(2px, 0.8cqw, 4px) solid var(--c);
  transition: left 0.3s ease, top 0.3s ease;
}
.big-die:disabled { cursor: default; }
.big-die.can-roll { animation: pulse 0.9s ease-in-out infinite; cursor: pointer; }
.big-die.rolling { animation: tumble 0.15s linear infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 70%, transparent), 0 4px 10px rgba(0, 0, 0, 0.35); transform: translate(-50%, -50%) scale(1); }
  50% { box-shadow: 0 0 0 10px transparent, 0 4px 10px rgba(0, 0, 0, 0.35); transform: translate(-50%, -50%) scale(1.07); }
}
@keyframes tumble {
  0% { transform: translate(-50%, -50%) rotate(0deg) scale(1.05); }
  50% { transform: translate(-46%, -56%) rotate(180deg) scale(0.95); }
  100% { transform: translate(-50%, -50%) rotate(360deg) scale(1.05); }
}

.burst {
  position: absolute;
  z-index: 60;
  transform: translate(-50%, -50%);
  font-size: clamp(22px, 9cqw, 50px);
  pointer-events: none;
}
.burst.pop { animation: pop 0.45s ease-out forwards; }
@keyframes pop {
  from { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  to { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

/* Dock */
.dock {
  position: relative;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.35));
}
.dock-row { display: flex; align-items: center; gap: 10px; min-height: 64px; }
.dock-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.action-text {
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.35;
  border-inline-start: 4px solid var(--c, var(--accent));
  padding-inline-start: 8px;
}
.ticker {
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.who { color: color-mix(in srgb, var(--c) 75%, white); }

.roll-btn {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 16px;
  padding: 10px 16px;
  min-height: 56px;
  font-weight: 900;
  font-size: 1.05rem;
  color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 85%, white), color-mix(in srgb, var(--c) 85%, black));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 45%, transparent), inset 0 -3px 0 rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.roll-btn:active { transform: scale(0.96); }
.small-die { width: 30px; height: 30px; padding: 4px; gap: 1px; }

.timer {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 2px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.timer-bar { height: 100%; background: var(--c, var(--accent)); transition: width 0.25s linear; }
.timer-bar.low { background: var(--red); }

/* ---------- Sheets, modals, toasts ---------- */
.log { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; }
.log li { padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); }

.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 120; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  max-height: 86dvh;
  overflow-y: auto;
  background: #181c3a;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border: 1px solid var(--panel-border);
  padding: 8px 16px calc(18px + var(--safe-bottom));
  z-index: 121;
  transform: translateY(105%);
  transition: transform 0.25s ease;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.25); margin: 0 auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { font-size: 1.15rem; }
.menu-rules { margin-top: 12px; }

.switch-row {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
}
.switch-row input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}
.result-panel { width: min(420px, 100%); text-align: center; display: flex; flex-direction: column; gap: 12px; }
.result-trophy { font-size: 3.2rem; animation: pop-in 0.5s ease-out; }
@keyframes pop-in { from { transform: scale(0.2); } to { transform: scale(1); } }
.confirm-panel { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; line-height: 1.6; }
.confirm-panel .row > * { flex: 1; }

.toast {
  position: fixed;
  left: 50%;
  top: max(14px, var(--safe-top));
  transform: translate(-50%, -160%);
  background: #fff;
  color: #1b1f3b;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 140;
  max-width: calc(100vw - 32px);
  transition: transform 0.25s ease;
  text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
.toast .who { color: color-mix(in srgb, var(--c) 80%, black); }

.conn-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--red);
  color: #fff;
  text-align: center;
  font-weight: 700;
  padding: 8px 8px calc(8px + var(--safe-bottom));
  z-index: 150;
}

/* Short phones in landscape or tiny screens: tighten the chrome around the board */
@media (max-height: 600px) {
  .topbar { padding-top: calc(4px + var(--safe-top)); padding-bottom: 2px; }
  .icon-btn { width: 34px; height: 34px; }
  .dock-row { min-height: 50px; }
  .roll-btn { min-height: 46px; padding: 6px 12px; }
  .player { padding: 3px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .piece.movable, .big-die.can-roll, .target, .piece.movable::after { animation: none; }
}

/* Phones held sideways: board on one side, players and the dice button on the other */
@media (orientation: landscape) and (max-height: 600px) {
  #gameView.active {
    display: grid;
    max-width: none;
    grid-template-columns: minmax(0, 100dvh) minmax(220px, 1fr);
    grid-template-rows: auto 1fr auto;
    grid-template-areas: "board top" "board players" "board dock";
  }
  .topbar { grid-area: top; }
  .players { grid-area: players; grid-auto-flow: row; align-content: start; }
  .board-wrap { grid-area: board; }
  .dock { grid-area: dock; }
}
[dir="rtl"] #localBackBtn { transform: scaleX(-1); }
