:root {
  --bg: #12162b;
  --bg-2: #1b2142;
  --card: #222a52;
  --card-2: #2a3360;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f5f2ea;
  --muted: #a4abcf;
  --gold: #ffc93c;
  --gold-2: #ffaa1f;
  --ink: #2b1d00;
  --red: #e8463c;
  --green: #2bb067;
  --yellow: #f7bd2f;
  --blue: #3184ea;
  --board: #f6efe0;
  --board-line: #d9ccb2;
  --radius: 16px;
  --font-h: 'Fredoka', ui-rounded, system-ui, sans-serif;
  --font-b: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(120% 60% at 50% -10%, #2b3470 0%, transparent 60%),
    radial-gradient(80% 50% at 100% 110%, #3a2350 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-b);
  font-size: 16px;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
input { -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

.screen {
  min-height: 100dvh;
  padding: calc(var(--safe-t) + 8px) 14px calc(var(--safe-b) + 12px);
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* ---------- botões ---------- */
.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  background: var(--card-2);
  font-family: var(--font-h);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.2px;
  transition: transform 0.08s ease, filter 0.15s;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary {
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-2) 100%);
  color: var(--ink);
  box-shadow: 0 3px 0 #b86f00, 0 10px 24px rgba(255, 170, 31, 0.25);
}
.btn.big { width: 100%; padding: 15px 20px; font-size: 19px; }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn.danger { background: #4a2333; color: #ffb3c0; }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 0;
  background: var(--card);
  font-size: 18px;
  display: grid; place-items: center;
}

.topbar {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.topbar-title {
  text-align: center;
  font-family: var(--font-h);
  font-weight: 600;
  font-size: 17px;
  color: var(--muted);
}

/* ---------- início ---------- */
.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 10px 6px;
}
.logo {
  width: 112px; height: 112px;
  margin: 0 auto 4px;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.45));
  transform: rotate(-8deg);
  animation: logo-in 0.7s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes logo-in { from { transform: rotate(-40deg) scale(0.6); opacity: 0; } }
.title {
  font-family: var(--font-h);
  font-size: 46px;
  line-height: 0.95;
  text-align: center;
  margin: 0;
  font-weight: 700;
}
.title span {
  display: block;
  font-size: 22px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 1px;
}
.tagline { text-align: center; color: var(--muted); margin: 0 0 8px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; }
input {
  width: 100%;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  font: 600 18px var(--font-b);
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--gold); }
#home-actions { display: flex; flex-direction: column; gap: 12px; }
.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-row { display: flex; gap: 10px; }
.join-row input {
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 6px;
  font-family: var(--font-h);
  font-size: 22px;
}
.invite {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  border: 2px solid rgba(255, 201, 60, 0.35);
}
.invite p { margin: 0 0 10px; }
.invite b { font-family: var(--font-h); letter-spacing: 3px; color: var(--gold); }

/* ---------- sala ---------- */
.lobby { display: flex; flex-direction: column; gap: 14px; }
.invite-card {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
}
.code-block { flex: 1; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.label { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; }
.room-code {
  font-family: var(--font-h);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 6px;
  line-height: 1;
  color: var(--gold);
}
.qr {
  width: 112px; height: 112px;
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  flex-shrink: 0;
}
.qr svg { width: 100%; height: 100%; display: block; }
.qr:empty { display: none; }

.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seat {
  --c: var(--red);
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 2px solid transparent;
  overflow: hidden;
}
.seat::before {
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 5px;
  background: var(--c);
}
.seat.c1 { --c: var(--green); }
.seat.c2 { --c: var(--yellow); }
.seat.c3 { --c: var(--blue); }
.seat.mine { border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--card)); }
.seat.empty { background: transparent; border: 2px dashed var(--line); }
.seat-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15); }
.seat-name { font-family: var(--font-h); font-size: 19px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat.empty .seat-name { color: var(--muted); font-weight: 500; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); }
.badge.you { background: var(--c); color: #fff; }
.seat-actions { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.seat-actions button {
  border: 0; border-radius: 999px; padding: 6px 10px;
  font: 700 13px var(--font-b);
  background: rgba(255, 255, 255, 0.1);
}

.rules {
  background: var(--card);
  border-radius: var(--radius);
  padding: 4px 14px;
}
.rules summary {
  padding: 12px 0;
  font-family: var(--font-h);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex; justify-content: space-between;
}
.rules summary::after { content: '▾'; color: var(--muted); }
.rules[open] summary::after { content: '▴'; }
.fixed-rules { margin: 0 0 8px; padding-left: 18px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.toggles { display: flex; flex-direction: column; padding-bottom: 10px; }
.toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-weight: 700; font-size: 15px;
}
.switch { position: relative; width: 46px; height: 28px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: #3a4370; transition: background 0.2s;
  pointer-events: none;
}
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; transition: transform 0.2s;
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:disabled + span { opacity: 0.55; }
.hint { text-align: center; color: var(--muted); font-size: 14px; margin: 0; min-height: 20px; }

/* ---------- jogo ---------- */
#screen-game { padding-bottom: calc(var(--safe-b) + 8px); }
.board-area { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.board-wrap {
  width: min(100%, calc(100dvh - 285px));
  min-width: 260px;
  max-width: 100%;
  aspect-ratio: 1 / 0.98;
  position: relative;
  perspective: 1300px;
  perspective-origin: 50% 0%;
  margin-bottom: 20px;
}
.board-3d {
  position: absolute;
  inset: -4% 0 auto 0;
  aspect-ratio: 1;
  transform: rotateX(22deg);
  transform-origin: 50% 50%;
  transform-style: preserve-3d;
}
/* moldura de madeira com espessura (as sombras empilhadas viram a lateral) */
.board-frame {
  width: 100%;
  height: 100%;
  padding: 2.8%;
  border-radius: 3.2%;
  background:
    repeating-linear-gradient(94deg, rgba(255, 220, 170, 0.045) 0 1px, transparent 1px 7px, rgba(0, 0, 0, 0.09) 7px 8px, transparent 8px 15px),
    repeating-linear-gradient(88deg, transparent 0 23px, rgba(0, 0, 0, 0.08) 23px 25px, transparent 25px 41px),
    linear-gradient(135deg, #9a5f2c 0%, #7a4620 35%, #8d5426 62%, #64391a 100%);
  box-shadow:
    inset 0 1.5px 0 rgba(255, 220, 170, 0.28),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(0, 0, 0, 0.3),
    0 1px 0 #5a3415, 0 2px 0 #55311a, 0 3px 0 #502e13, 0 4px 0 #4b2b12,
    0 5px 0 #462810, 0 6px 0 #41250f, 0 7px 0 #3c220e, 0 8px 0 #371f0c,
    0 9px 0 #321c0b, 0 10px 0 #2d190a,
    0 22px 30px rgba(0, 0, 0, 0.6), 0 40px 60px rgba(0, 0, 0, 0.35);
}
#board {
  width: 100%; height: 100%; display: block;
  border-radius: 2.4%;
  overflow: visible;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
}

.piece { transition: transform 0.16s cubic-bezier(0.3, 0.7, 0.35, 1.15), opacity 0.25s; }
.piece.flying { transition: transform 0.5s cubic-bezier(0.5, -0.4, 0.4, 1.3); }
.piece .hit { fill: transparent; }
.piece .shadow { fill: rgba(40, 25, 0, 0.3); }
.piece .glow, .piece .halo, .piece .arrow { opacity: 0; transition: opacity 0.2s; }
.piece.movable .arrow { opacity: 1; animation: nudge 0.9s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(-0.05px); } 50% { transform: translateY(0.1px); } }
.piece .halo { fill: none; stroke: #fff; stroke-width: 0.07; stroke-dasharray: 0.14 0.09; stroke-linecap: round; }
.piece.movable { cursor: pointer; }
.piece.movable .glow { opacity: 1; animation: glow 1.1s ease-in-out infinite; }
.piece.movable .halo { opacity: 1; animation: march 1.4s linear infinite; }
.piece.movable .hop { animation: hop 0.9s ease-in-out infinite; }
.pieces.choosing .piece:not(.movable) { opacity: 0.7; }
@keyframes glow { 50% { opacity: 0.45; } }
@keyframes march { to { stroke-dashoffset: -0.92; } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-0.16px); } }

.target { cursor: pointer; }
.target .t-hit { fill: transparent; }
.target .t-ghost { animation: ghost 1.4s ease-in-out infinite; filter: drop-shadow(0 0 0.06px rgba(255, 255, 255, 0.9)); }
.target .t-floor { animation: floor 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ghost { 0%, 100% { opacity: 0.95; transform: translateY(0); } 50% { opacity: 0.65; transform: translateY(-0.06px); } }
@keyframes floor { 50% { transform: scale(1.15); opacity: 0.6; } }

.pbar { width: min(100%, calc(100dvh - 300px)); min-width: 260px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-height: 38px; }
.slot { display: flex; }
.slot[data-corner="1"], .slot[data-corner="2"] { justify-content: flex-end; }
.chip {
  --c: var(--red);
  position: relative;
  display: flex; align-items: center; gap: 7px;
  max-width: 100%;
  padding: 6px 11px 6px 7px;
  border-radius: 999px;
  background: var(--card);
  border: 2px solid transparent;
  font-weight: 800; font-size: 14px;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.chip.c1 { --c: var(--green); }
.chip.c2 { --c: var(--yellow); }
.chip.c3 { --c: var(--blue); }
.chip .dot { width: 20px; height: 20px; border-radius: 50%; background: var(--c); flex-shrink: 0; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2); }
.chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.chip.turn { border-color: var(--c); background: color-mix(in srgb, var(--c) 22%, var(--card)); transform: scale(1.04); box-shadow: 0 0 18px color-mix(in srgb, var(--c) 45%, transparent); }
.chip.off { opacity: 0.6; }
.chip.done .dot::after { content: '🏆'; font-size: 12px; display: grid; place-items: center; height: 100%; }
.bubble {
  position: absolute; top: -8px; left: 50%;
  font-size: 30px;
  animation: bubble 1.8s ease-out forwards;
  pointer-events: none;
  z-index: 5;
}
@keyframes bubble {
  0% { transform: translate(-50%, 10px) scale(0.3); opacity: 0; }
  15% { transform: translate(-50%, -18px) scale(1.2); opacity: 1; }
  75% { transform: translate(-50%, -34px) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -54px) scale(0.9); opacity: 0; }
}

.controls {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 14px;
  margin-top: 10px;
  background: var(--card);
  border-radius: 22px;
  padding: 12px 12px 12px 16px;
}
.status-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.event { font-size: 13px; color: var(--muted); min-height: 18px; font-weight: 700; }
.event.flash { animation: flash 0.6s ease; }
@keyframes flash { from { color: var(--gold); transform: translateX(-4px); } }
.status { font-family: var(--font-h); font-size: 19px; font-weight: 600; line-height: 1.2; }
.status .who { display: inline; }
.status small { font-family: var(--font-b); font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.status .sdot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: 0.05em; }

.dice {
  --c: var(--gold);
  --size: 52px;
  position: relative;
  width: 80px; height: 80px; flex-shrink: 0;
  border: 0; padding: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 62%, color-mix(in srgb, var(--c) 34%, transparent) 0%, transparent 68%);
  display: grid; place-items: center;
  perspective: 420px;
  transition: opacity 0.2s;
}
.dice:disabled { cursor: default; }
.dice-shadow {
  position: absolute; left: 50%; top: 78%;
  width: 46px; height: 10px; margin-left: -23px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  filter: blur(3px);
}
.cube-hop { display: block; transform-style: preserve-3d; }
.cube-view {
  display: block;
  width: var(--size); height: var(--size);
  transform-style: preserve-3d;
  transform: rotateX(-13deg) rotateY(-15deg);
}
.cube {
  position: relative; display: block;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.82s cubic-bezier(0.15, 0.85, 0.3, 1.06);
}
.cube.instant { transition: none; }
.face, .layer { position: absolute; inset: 0; border-radius: 16%; }
.face {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 15%;
  background: radial-gradient(circle at 30% 25%, #ffffff 0%, #f7f3ea 55%, #e8e0cf 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05), inset 0 -3px 6px rgba(0, 0, 0, 0.08);
  backface-visibility: hidden;
}
.layer { --inset: 2px; background: #e9e1d0; backface-visibility: hidden; }
.face i { width: 78%; aspect-ratio: 1; border-radius: 50%; place-self: center; }
.face i.on {
  background: radial-gradient(circle at 38% 32%, #4b4354 0%, #15111a 75%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}
.face.f1 i.on { width: 118%; background: radial-gradient(circle at 38% 32%, color-mix(in srgb, var(--c) 70%, #fff) 0%, var(--c) 45%, color-mix(in srgb, var(--c) 55%, #000) 100%); }
.cube.empty .face i.on { opacity: 0.18; }
.f1 { transform: translateZ(calc(var(--size) / 2)); }
.layer.f1 { transform: translateZ(calc(var(--size) / 2 - var(--inset))); }
.f6 { transform: rotateY(180deg) translateZ(calc(var(--size) / 2)); }
.layer.f6 { transform: rotateY(180deg) translateZ(calc(var(--size) / 2 - var(--inset))); }
.f2 { transform: rotateY(90deg) translateZ(calc(var(--size) / 2)); }
.layer.f2 { transform: rotateY(90deg) translateZ(calc(var(--size) / 2 - var(--inset))); }
.f5 { transform: rotateY(-90deg) translateZ(calc(var(--size) / 2)); }
.layer.f5 { transform: rotateY(-90deg) translateZ(calc(var(--size) / 2 - var(--inset))); }
.f3 { transform: rotateX(90deg) translateZ(calc(var(--size) / 2)); }
.layer.f3 { transform: rotateX(90deg) translateZ(calc(var(--size) / 2 - var(--inset))); }
.f4 { transform: rotateX(-90deg) translateZ(calc(var(--size) / 2)); }
.layer.f4 { transform: rotateX(-90deg) translateZ(calc(var(--size) / 2 - var(--inset))); }

.dice.ready .cube-hop { animation: idle 1.1s ease-in-out infinite; }
.dice.ready .dice-shadow { animation: idle-shadow 1.1s ease-in-out infinite; }
.dice.ready { background: radial-gradient(circle at 50% 62%, color-mix(in srgb, var(--c) 60%, transparent) 0%, transparent 70%); }
@keyframes idle { 50% { transform: translateY(-6px); } }
@keyframes idle-shadow { 50% { transform: scale(0.75); opacity: 0.6; } }
.dice.rolling .cube-hop { animation: roll-hop 0.86s cubic-bezier(0.3, 0.6, 0.4, 1); }
.dice.rolling .dice-shadow { animation: roll-shadow 0.86s cubic-bezier(0.3, 0.6, 0.4, 1); }
@keyframes roll-hop {
  0% { transform: translateY(0); }
  22% { transform: translateY(-30px); }
  48% { transform: translateY(0); }
  62% { transform: translateY(-10px); }
  76% { transform: translateY(0); }
  86% { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}
@keyframes roll-shadow {
  0%, 48%, 76%, 100% { transform: scale(1); opacity: 1; }
  22% { transform: scale(0.5); opacity: 0.35; }
  62% { transform: scale(0.8); opacity: 0.7; }
}

.emotes { display: flex; justify-content: space-between; gap: 4px; margin-top: 10px; }
.emotes button {
  flex: 1; border: 0; background: transparent; font-size: 24px; padding: 6px 0; border-radius: 12px;
  transition: transform 0.1s;
}
.emotes button:active { transform: scale(1.3); background: var(--card); }

/* ---------- fim de jogo ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(8, 10, 24, 0.72);
  backdrop-filter: blur(4px);
  display: grid; place-items: end center;
  padding: 16px 12px calc(var(--safe-b) + 16px);
  animation: fade 0.3s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: relative; overflow: hidden;
  width: 100%; max-width: 480px;
  background: var(--bg-2);
  border-radius: 26px;
  padding: 22px 18px 18px;
  animation: up 0.45s cubic-bezier(0.2, 1.2, 0.4, 1);
}
@keyframes up { from { transform: translateY(60px); opacity: 0; } }
.sheet h2 { font-family: var(--font-h); font-size: 30px; text-align: center; margin: 0 0 14px; }
.podium { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.podium li {
  --c: var(--red);
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: 14px; padding: 10px 12px;
  border-left: 5px solid var(--c);
  font-weight: 800;
}
.podium li.c1 { --c: var(--green); } .podium li.c2 { --c: var(--yellow); } .podium li.c3 { --c: var(--blue); }
.podium .medal { font-size: 24px; width: 30px; text-align: center; }
.podium .pn { flex: 1; font-family: var(--font-h); font-size: 18px; font-weight: 600; }
.podium .ps { color: var(--muted); font-size: 12px; text-align: right; }
.over-actions { display: flex; flex-direction: column; gap: 10px; }
.over-actions .row { display: flex; gap: 10px; }
.over-actions .row .btn { flex: 1; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i {
  position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(560px) rotate(720deg); opacity: 0; } }

/* ---------- ranking ---------- */
.ranking { display: flex; flex-direction: column; gap: 12px; }
.seg { display: flex; background: var(--card); padding: 4px; border-radius: 999px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 4px; border-radius: 999px; font-weight: 800; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--gold); color: var(--ink); }
.rank-list, .history-list { display: flex; flex-direction: column; gap: 8px; }
.rank-row {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px;
  background: var(--card); border-radius: 14px; padding: 11px 14px;
}
.rank-row.top { background: linear-gradient(90deg, rgba(255, 201, 60, 0.2), var(--card) 70%); }
.rank-pos { font-family: var(--font-h); font-size: 20px; text-align: center; color: var(--muted); }
.rank-name { font-family: var(--font-h); font-size: 18px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-sub { font-size: 12px; color: var(--muted); font-weight: 700; }
.rank-pts { text-align: right; }
.rank-pts b { font-family: var(--font-h); font-size: 22px; color: var(--gold); display: block; line-height: 1; }
.rank-pts span { font-size: 11px; color: var(--muted); font-weight: 800; text-transform: uppercase; }
.section-title { font-family: var(--font-h); font-size: 18px; margin: 10px 0 0; color: var(--muted); font-weight: 600; }
.hist { background: var(--card); border-radius: 14px; padding: 10px 14px; }
.hist-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 800; margin-bottom: 6px; }
.hist-players { display: flex; flex-wrap: wrap; gap: 6px 12px; font-weight: 700; font-size: 14px; }
.hist-players span { display: inline-flex; align-items: center; gap: 5px; }
.hist-players .sdot { width: 10px; height: 10px; border-radius: 50%; }
.empty-state { text-align: center; color: var(--muted); padding: 24px 10px; background: var(--card); border-radius: 14px; }

/* ---------- avisos ---------- */
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 60px);
  transform: translate(-50%, -20px);
  width: max-content;
  background: #fff; color: #1a1d33;
  padding: 11px 18px; border-radius: 16px;
  font-weight: 800; font-size: 15px; line-height: 1.35;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.25s;
  z-index: 40; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.conn-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  padding: calc(var(--safe-t) + 6px) 12px 6px;
  text-align: center; font-weight: 800; font-size: 13px;
  background: #b4462f; color: #fff;
}

@media (max-height: 640px) {
  .controls { margin-top: 6px; padding: 8px 10px 8px 14px; }
  .dice { width: 68px; height: 68px; --size: 44px; }
  .emotes { margin-top: 4px; }
  .emotes button { font-size: 20px; padding: 2px 0; }
}

/* ---------- tempo da vez ---------- */
.turn-timer {
  --c: var(--gold);
  position: absolute; left: 0; right: 0; bottom: 0; height: 5px;
  background: rgba(255, 255, 255, 0.07);
}
.turn-timer i {
  display: block; height: 100%;
  background: var(--c);
  transform-origin: left center;
  transition: transform 0.1s linear;
}
.turn-timer.warn i { background: #ff5a4e; animation: blink 0.5s ease-in-out infinite alternate; }
@keyframes blink { to { opacity: 0.45; } }
.tleft { font-family: var(--font-b); font-size: 13px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.tleft.warn { color: #ff7a6e; }
.strikes { font-size: 11px; margin-left: 2px; }
.time-row { flex-wrap: wrap; }
.seg.mini { padding: 3px; }
.seg.mini button { padding: 6px 10px; font-size: 13px; }
.seg.mini button:disabled { cursor: default; }
.seg.mini button:disabled:not(.on) { opacity: 0.6; }
.seg.mini { background: var(--bg-2); }

/* ---------- dado 3D (WebGL) ---------- */
.dice3d-host { position: absolute; inset: -16px; pointer-events: none; display: none; }
.dice3d-host canvas { width: 100%; height: 100%; display: block; }
.dice.has3d .dice3d-host { display: block; }
.dice.has3d .cube-hop, .dice.has3d .dice-shadow { display: none; }
.dice.has3d.ready .dice3d-host { animation: idle 1.1s ease-in-out infinite; }

/* ---------- efeitos ---------- */
.fx-layer { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 18; }
.fx-flash {
  --c: #ff3b30;
  position: fixed; inset: 0; pointer-events: none; z-index: 17;
  box-shadow: inset 0 0 90px 20px var(--c);
  animation: fx-flash 650ms ease-out forwards;
}
@keyframes fx-flash { 0% { opacity: 0; } 15% { opacity: 0.85; } 100% { opacity: 0; } }
.board-wrap.fx-shake { animation: fx-shake 0.5s cubic-bezier(.36,.07,.19,.97); }
@keyframes fx-shake {
  10%, 90% { transform: translate(-2px, 1px); }
  20%, 80% { transform: translate(4px, -2px); }
  30%, 50%, 70% { transform: translate(-7px, 2px); }
  40%, 60% { transform: translate(7px, -1px); }
}
.dice.fx-nope { animation: fx-nope 0.45s ease; }
@keyframes fx-nope { 20%, 60% { transform: translateX(-8px) rotate(-6deg); } 40%, 80% { transform: translateX(8px) rotate(6deg); } }
.dice.six { background: radial-gradient(circle at 50% 60%, rgba(255, 216, 74, 0.85) 0%, rgba(255, 176, 32, 0.25) 45%, transparent 72%) !important; }
.dice.six .dice3d-host { animation: six-pop 0.6s cubic-bezier(.2,1.6,.4,1); }
@keyframes six-pop { 0% { transform: scale(1); } 40% { transform: scale(1.22) rotate(-6deg); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .board-wrap.fx-shake, .dice.fx-nope, .dice.six .dice3d-host { animation: none; }
}

.rank-sub.soft { font-weight: 600; opacity: 0.8; }
.hist-kind { font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 6px; }
.hist-kind small { font-weight: 600; }
.hist-kind.k-friends { color: var(--gold); }
.hist-players .of { color: var(--muted); font-size: 12px; font-weight: 700; }

/* ---------- modos de jogo ---------- */
.modes { display: flex; flex-direction: column; gap: 10px; }
.size-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.mode-card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  width: 100%; border: 2px solid transparent; border-radius: 18px;
  background: var(--card); padding: 14px 16px; color: var(--text);
  transition: transform 0.08s, border-color 0.2s, background 0.2s;
}
.mode-card:active { transform: scale(0.98); }
.mode-card:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
#btn-mode-bots { background: linear-gradient(180deg, var(--gold) 0%, var(--gold-2) 100%); color: var(--ink); box-shadow: 0 3px 0 #b86f00, 0 10px 24px rgba(255, 170, 31, 0.22); }
#btn-mode-bots small { color: rgba(43, 29, 0, 0.75); }
.mode-card.open { border-color: var(--gold); }
.mode-ico { font-size: 30px; width: 40px; text-align: center; flex-shrink: 0; }
.mode-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mode-txt b { font-family: var(--font-h); font-size: 19px; font-weight: 600; }
.mode-txt small { font-size: 13px; color: var(--muted); font-weight: 700; }
.friends-box { display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 6px; }

.queue { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 20px 6px; }
.queue h2 { font-family: var(--font-h); font-size: 28px; margin: 6px 0 0; }
.queue-info { font-family: var(--font-h); font-size: 20px; color: var(--gold); margin: 0; }
.queue .btn { width: 100%; max-width: 380px; }
.queue-orbit { position: relative; width: 120px; height: 120px; animation: orbit 2.4s linear infinite; }
.queue-orbit i { position: absolute; width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 -4px 0 rgba(0,0,0,0.25); }
.queue-orbit i:nth-child(1) { background: var(--red); top: 0; left: 45px; }
.queue-orbit i:nth-child(2) { background: var(--green); top: 45px; right: 0; }
.queue-orbit i:nth-child(3) { background: var(--yellow); bottom: 0; left: 45px; }
.queue-orbit i:nth-child(4) { background: var(--blue); top: 45px; left: 0; }
@keyframes orbit { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .queue-orbit { animation: none; } }
.hist-kind.k-online { color: #8fd0ff; }
