/* =========================================================
   Ludo Max — visual de jogo: painéis em relevo, botões 3D,
   tipografia Lilita One (títulos) + Nunito (texto).
   ========================================================= */
:root {
  --bg0: #0d0a26;
  --bg1: #191250;
  --bg2: #2a1f76;
  --panel-a: #352a8f;
  --panel-b: #241c68;
  --edge: #5546c9;
  --edge-dark: #120c3c;
  --ink: #120c3c;
  --text: #ffffff;
  --muted: #b8b1f0;
  --gold: #ffc83d;
  --gold-d: #c97a00;
  --blue: #3aa0ff;
  --blue-d: #1a5fc4;
  --green: #36d07c;
  --green-d: #138a4a;
  --red: #ff4d5e;
  --red-d: #b51c33;
  --pc: #ffc83d; /* cor do jogador da vez */
  --display: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--text); }
body {
  font-family: var(--body);
  font-weight: 800;
  font-size: 15px;
  line-height: 1.25;
  background-color: var(--bg0);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.07) 1.2px, transparent 1.6px),
    radial-gradient(110% 80% at 25% 0%, #3a2aa8 0%, transparent 55%),
    radial-gradient(90% 70% at 100% 100%, #5a1f8c 0%, transparent 55%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  background-size: 22px 22px, auto, auto, auto;
  background-attachment: fixed;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* barra de rolagem fina e discreta */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.22) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.38); }
::-webkit-scrollbar-button { display: none; }
input { font: inherit; user-select: text; -webkit-user-select: text; }
.hidden { display: none !important; }
.ic { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -0.2em; }

/* ---------- Botões ---------- */
.btn {
  --b1: #4b4fb8; --b2: #34388f; --bd: #1d1f63; --bt: #fff;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 16px; padding: 11px 18px 12px;
  font-family: var(--display); font-size: 1.1rem; letter-spacing: 0.4px; color: var(--bt);
  background: linear-gradient(180deg, var(--b1), var(--b2));
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -3px 0 rgba(0, 0, 0, 0.15), 0 5px 0 var(--bd), 0 9px 16px rgba(0, 0, 0, 0.35);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.btn::after { /* brilho */
  content: ''; position: absolute; left: 10px; right: 10px; top: 4px; height: 38%;
  border-radius: 12px 12px 30px 30px; background: linear-gradient(rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0)); pointer-events: none;
}
.btn:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -2px 0 rgba(0, 0, 0, 0.15), 0 1px 0 var(--bd), 0 3px 6px rgba(0, 0, 0, 0.3); }
.btn:disabled { filter: grayscale(0.7) brightness(0.75); pointer-events: none; }
.btn .ic { width: 1.25em; height: 1.25em; stroke-width: 2.8; }
.btn-gold { --b1: #ffd95c; --b2: #ffb21f; --bd: var(--gold-d); --bt: #5a3300; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4); }
.btn-blue { --b1: #57b4ff; --b2: #2f86f0; --bd: var(--blue-d); }
.btn-green { --b1: #5fe39b; --b2: #23b866; --bd: var(--green-d); }
.btn-red { --b1: #ff7480; --b2: #f23548; --bd: var(--red-d); }
.btn-ghost { --b1: rgba(255, 255, 255, 0.1); --b2: rgba(255, 255, 255, 0.04); --bd: rgba(0, 0, 0, 0.35); border: 2px solid rgba(255, 255, 255, 0.18); }
.btn-ghost::after { display: none; }
.btn-sm { font-size: 0.95rem; padding: 7px 12px 8px; border-radius: 13px; gap: 6px; }
.btn-lg { font-size: 1.45rem; padding: 13px 30px 14px; border-radius: 20px; }
.btn-icon {
  border: 0; width: 42px; height: 42px; border-radius: 14px; flex: none; display: grid; place-items: center;
  color: #fff; background: linear-gradient(180deg, #4a3fb5, #33298c);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25), 0 4px 0 var(--edge-dark), 0 6px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn-icon .ic { width: 22px; height: 22px; stroke-width: 2.6; }
.btn-icon:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25), 0 1px 0 var(--edge-dark); }

/* ---------- Painéis ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel-a), var(--panel-b));
  border: 3px solid var(--edge);
  border-radius: 22px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.14), inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 6px 0 var(--edge-dark), 0 16px 34px rgba(0, 0, 0, 0.45);
}
.panel-title {
  display: flex; align-items: center; gap: 8px; margin: 0 0 8px;
  font-family: var(--display); font-weight: 400; font-size: 1.2rem; letter-spacing: 0.4px;
}
.panel-title .ic { color: var(--gold); width: 22px; height: 22px; }
.count { margin-left: auto; font-size: 0.9rem; background: rgba(0, 0, 0, 0.3); padding: 2px 10px; border-radius: 99px; color: var(--gold); }
.title-stroke {
  font-family: var(--display); font-weight: 400; margin: 0; letter-spacing: 1px; color: #fff;
  text-shadow: 0 4px 0 var(--ink), 3px 3px 0 var(--ink), -3px 3px 0 var(--ink), 3px -2px 0 var(--ink), -3px -2px 0 var(--ink), 0 10px 20px rgba(0, 0, 0, 0.5);
}

.screen {
  position: fixed; inset: 0;
  padding: calc(var(--st) + 12px) calc(var(--sr) + 14px) calc(var(--sb) + 12px) calc(var(--sl) + 14px);
}

/* ---------- INÍCIO ---------- */
#home { display: flex; align-items: center; justify-content: center; gap: 4vw; }
.home-art { position: relative; width: min(44vw, 80vh); aspect-ratio: 1; display: grid; place-items: center; }
.home-art canvas { position: relative; animation: spin 120s linear infinite; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.55)); }
.home-glow { position: absolute; inset: 8%; border-radius: 50%; background: radial-gradient(circle, rgba(255, 200, 61, 0.35), transparent 65%); filter: blur(10px); }
@keyframes spin { to { transform: rotate(360deg); } }
.float-die {
  position: absolute; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; color: #3b2a00;
  background: linear-gradient(180deg, #fff, #e8e4ff); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12), 0 8px 0 rgba(0, 0, 0, 0.25), 0 14px 22px rgba(0, 0, 0, 0.4);
  animation: floaty 4.5s ease-in-out infinite;
}
.float-die .ic { width: 30px; height: 30px; stroke-width: 2.4; }
.float-die.d1 { left: -2%; top: 10%; transform: rotate(-14deg); }
.float-die.d2 { right: 0; top: 4%; color: #fff; background: linear-gradient(180deg, #ff6a7a, #e2263c); animation-delay: -1.5s; }
.float-die.d3 { right: 6%; bottom: 6%; color: #6b3d00; background: linear-gradient(180deg, #ffe07a, #ffb21f); animation-delay: -3s; }
@keyframes floaty { 50% { translate: 0 -12px; rotate: 8deg; } }

.home-card { width: min(390px, 92vw); padding: 18px 18px 20px; display: flex; flex-direction: column; gap: 11px; }
.logo { margin: 0 0 2px; display: flex; align-items: center; gap: 5px; font-family: var(--display); font-weight: 400; line-height: 1; }
.tile {
  display: inline-grid; place-items: center; width: 1.25em; height: 1.25em; font-size: clamp(2rem, 7.5vh, 3.1rem);
  border-radius: 0.22em; color: #fff; background: linear-gradient(180deg, color-mix(in srgb, var(--c) 70%, #fff), var(--c));
  box-shadow: inset 0 -0.08em 0 rgba(0, 0, 0, 0.2), 0 0.1em 0 color-mix(in srgb, var(--c) 55%, #000), 0 0.2em 0.3em rgba(0, 0, 0, 0.35);
  text-shadow: 0 0.06em 0 rgba(0, 0, 0, 0.3); animation: hopTile 2.6s ease-in-out infinite;
}
.tile:nth-child(odd) { rotate: -5deg; }
.tile:nth-child(even) { rotate: 4deg; }
.tile:nth-child(2) { animation-delay: 0.15s; }
.tile:nth-child(3) { animation-delay: 0.3s; }
.tile:nth-child(4) { animation-delay: 0.45s; }
@keyframes hopTile { 0%, 70%, 100% { translate: 0 0; } 80% { translate: 0 -8px; } }
.ribbon {
  margin-left: 8px; font-size: clamp(1.4rem, 5vh, 2rem); color: #5a3300; padding: 6px 14px 7px; border-radius: 10px;
  background: linear-gradient(180deg, #ffe07a, #ffb21f); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 4px 0 var(--gold-d); rotate: -6deg;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 0.8rem; padding: 4px 10px 4px 8px; border-radius: 99px; background: rgba(0, 0, 0, 0.28); color: var(--muted); }
.chip-tag .ic { color: var(--gold); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.input-wrap { display: flex; align-items: center; gap: 8px; background: var(--ink); border: 3px solid #3a2f9a; border-radius: 14px; padding: 0 12px; box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.3); }
.input-wrap:focus-within { border-color: var(--gold); }
.input-wrap .ic { color: var(--muted); }
.input-wrap input, .join-row input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: #fff; padding: 10px 0; font-size: 1.05rem; font-weight: 800; }
.join-row { display: flex; gap: 8px; }
.join-row input {
  background: var(--ink); border: 3px solid #3a2f9a; border-radius: 14px; padding: 9px 10px; box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.3);
  text-transform: uppercase; letter-spacing: 5px; text-align: center; font-family: var(--display); font-weight: 400; color: var(--gold);
}
.join-row input:focus { border-color: var(--gold); }
.join-row input::placeholder { color: #5d55a8; letter-spacing: 3px; }
.color-row { display: flex; flex-wrap: wrap; gap: 7px; }
.cdot {
  width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0; position: relative;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 55%, #fff), var(--c) 60%, color-mix(in srgb, var(--c) 70%, #000));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 3px 0 rgba(0, 0, 0, 0.35); transition: transform 0.12s;
}
.cdot.on { transform: scale(1.12); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--c), 0 3px 10px rgba(0, 0, 0, 0.5); }
.cdot.taken { opacity: 0.25; pointer-events: none; }
.cdot .ic { position: absolute; inset: 6px; width: 18px; height: 18px; color: #fff; stroke-width: 3.2; }

/* ---------- SALA ---------- */
#lobby { display: flex; flex-direction: column; gap: 10px; }
.lobby-head { display: flex; align-items: center; gap: 12px; }
.ticket {
  flex: 1; display: flex; align-items: center; gap: 12px; padding: 6px 16px; border-radius: 16px; max-width: 360px;
  background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.04) 0 8px, transparent 8px 16px), rgba(0, 0, 0, 0.3);
  border: 2px dashed rgba(255, 200, 61, 0.55);
}
.ticket-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 2px; color: var(--muted); }
.ticket strong { font-family: var(--display); font-weight: 400; font-size: 1.9rem; letter-spacing: 6px; color: var(--gold); line-height: 1; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); }
.lobby-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1.15fr 1.25fr 0.9fr; gap: 14px; padding-bottom: 6px; }
.lobby-col { min-height: 0; overflow-y: auto; padding: 12px 8px 14px 12px; scrollbar-gutter: stable; }
.lobby-col.preview { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; }
.preview-wrap { flex: 1; width: 100%; min-height: 0; display: grid; place-items: center; }
.caption { font-size: 0.8rem; color: var(--muted); text-align: center; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 7px; margin-bottom: 10px; }
.slot {
  position: relative; display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 5px 8px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03)); border: 2px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}
.slot.new { animation: slotIn 0.3s ease-out both; }
@keyframes slotIn { from { transform: scale(0.85); opacity: 0; } }
.slot.empty { justify-content: center; color: #6e66c0; background: transparent; border: 2px dashed rgba(255, 255, 255, 0.14); box-shadow: none; font-size: 0.85rem; gap: 5px; animation: none; }
.slot.empty.add { cursor: pointer; color: var(--muted); }
.slot.empty.add:active { transform: scale(0.97); }
.slot.off { opacity: 0.55; }
.slot .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 900; font-size: 0.95rem; }
.slot .nm.edit { cursor: text; }
.slot .tags { display: flex; gap: 3px; }
.tag { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; background: rgba(0, 0, 0, 0.3); color: var(--muted); }
.tag .ic { width: 14px; height: 14px; stroke-width: 2.8; }
.tag.host { color: var(--gold); }
.tag.you { width: auto; padding: 0 6px; font-size: 0.68rem; color: #fff; background: var(--blue); }
.kick { border: 0; background: none; color: #8d86d6; padding: 2px; display: grid; }
.kick .ic { width: 16px; height: 16px; }
.avatar {
  position: relative; flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; border: 0; padding: 0;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 55%, #fff), var(--c) 60%, color-mix(in srgb, var(--c) 65%, #000));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.22), 0 0 0 2.5px rgba(255, 255, 255, 0.85), 0 3px 0 2px rgba(0, 0, 0, 0.3);
}
.avatar .ic { width: 19px; height: 19px; stroke-width: 2.6; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.35)); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 2px solid rgba(0, 0, 0, 0.18); }
.set-row:last-child { border-bottom: 0; }
.set-row > label { display: flex; align-items: center; gap: 7px; font-size: 0.9rem; }
.set-row > label .ic { color: var(--gold); width: 18px; height: 18px; }
.seg { display: flex; background: var(--ink); border-radius: 12px; padding: 3px; gap: 2px; flex: none; box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.35); }
.seg button { border: 0; background: none; padding: 5px 9px; border-radius: 9px; font-family: var(--display); font-size: 0.85rem; color: #8b84d4; display: flex; align-items: center; gap: 3px; }
.seg button .ic { width: 14px; height: 14px; }
.seg button.on { color: #5a3300; background: linear-gradient(180deg, #ffd95c, #ffb21f); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 2px 0 var(--gold-d); }
.seg.ro button:not(.on) { opacity: 0.45; }
.toggle { width: 50px; height: 28px; border-radius: 99px; border: 0; background: var(--ink); position: relative; flex: none; box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.4); }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(180deg, #fff, #cfcaf5); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); transition: transform 0.18s cubic-bezier(0.3, 1.6, 0.5, 1); }
.toggle.on { background: linear-gradient(180deg, #5fe39b, #23b866); }
.toggle.on::after { transform: translateX(22px); }
.toggle:disabled { opacity: 0.7; }
.suggest:empty { display: none; }
.suggest {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 8px 10px; border-radius: 12px; font-size: 0.82rem;
  background: rgba(255, 200, 61, 0.12); border: 2px solid rgba(255, 200, 61, 0.35); color: #ffe7a6;
}
.suggest .ic { color: var(--gold); width: 20px; height: 20px; }
.suggest span { flex: 1; }
.lobby-foot { display: flex; align-items: center; justify-content: flex-end; gap: 14px; }
.lobby-foot p { flex: 1; margin: 0; font-size: 0.9rem; color: var(--muted); }
#btnStart:not(:disabled) { animation: pulseBtn 1.6s ease-in-out infinite; }
@keyframes pulseBtn { 50% { filter: brightness(1.12); transform: scale(1.03); } }
.palette { position: fixed; z-index: 40; padding: 10px; display: grid; grid-template-columns: repeat(5, 34px); gap: 8px; border-radius: 18px; }
.palette .cdot { width: 34px; height: 34px; }

/* ---------- JOGO ---------- */
#game { display: flex; gap: 12px; padding-top: calc(var(--st) + 8px); padding-bottom: calc(var(--sb) + 8px); }
#boardWrap {
  position: relative; flex: none; height: 100%; aspect-ratio: 1; display: grid; place-items: center;
  max-width: calc(100vw - var(--sl) - var(--sr) - 40px - min(250px, 38vw));
}
#board { touch-action: none; display: block; filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.5)); }
#panel { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 9px; max-width: 460px; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 7px; }
.turn-plate {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 5px; border-radius: 99px; height: 42px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--pc) 35%, #2a2080), color-mix(in srgb, var(--pc) 15%, #1c155a));
  border: 3px solid color-mix(in srgb, var(--pc) 80%, #fff); box-shadow: 0 4px 0 var(--edge-dark), 0 0 18px color-mix(in srgb, var(--pc) 35%, transparent);
  transition: background 0.3s, border-color 0.3s;
}
.turn-plate .avatar { width: 28px; height: 28px; }
.turn-plate .avatar .ic { width: 16px; height: 16px; }
.turn-plate .tp-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1; }
.turn-plate small { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 1.5px; color: rgba(255, 255, 255, 0.75); }
.turn-plate b { font-family: var(--display); font-weight: 400; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }

#players { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; align-content: start; padding: 2px; }
.prow {
  --c: #888; position: relative; display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 14px; min-height: 44px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03)); border: 2px solid rgba(255, 255, 255, 0.06);
  transition: background 0.25s, border-color 0.25s, transform 0.25s;
}
.prow .avatar { width: 32px; height: 32px; }
.prow .avatar .ic { width: 18px; height: 18px; }
.prow .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.prow .nm { font-weight: 900; font-size: 0.9rem; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toks { display: flex; gap: 3px; }
.tok { width: 10px; height: 10px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--c) 70%, #fff); opacity: 0.5; }
.tok.run { background: var(--c); opacity: 1; }
.tok.home { background: var(--gold); border-color: #fff; opacity: 1; box-shadow: 0 0 6px var(--gold); }
.prow.turn { background: linear-gradient(180deg, color-mix(in srgb, var(--c) 45%, transparent), color-mix(in srgb, var(--c) 18%, transparent)); border-color: var(--c); box-shadow: 0 0 16px color-mix(in srgb, var(--c) 45%, transparent); transform: scale(1.02); }
.prow.turn .avatar::before { /* anel do cronômetro */
  content: ''; position: absolute; inset: -5px; border-radius: 50%;
  background: conic-gradient(#fff calc(var(--t, 1) * 360deg), rgba(255, 255, 255, 0.12) 0);
  -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%); mask: radial-gradient(circle, transparent 58%, #000 60%);
}
.prow.off .nm { opacity: 0.55; }
.prow.done { opacity: 0.7; }
.prow .flag { color: #8d86d6; display: grid; }
.prow .flag .ic { width: 16px; height: 16px; }
.medal-badge {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-size: 0.9rem; color: #4a2d00;
  background: linear-gradient(180deg, #ffe07a, #ffb21f); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2), 0 2px 0 rgba(0, 0, 0, 0.3);
}
.medal-badge.m2 { background: linear-gradient(180deg, #f2f4ff, #aeb6d6); color: #39405e; }
.medal-badge.m3 { background: linear-gradient(180deg, #ffc89a, #d07a3c); color: #4b2208; }
.medal-badge.mx { background: rgba(0, 0, 0, 0.35); color: #fff; }

#trayBox {
  position: relative; flex: none; border-radius: 22px; padding: 13px 10px 16px; display: flex; flex-direction: column; align-items: center; gap: 7px;
  background: radial-gradient(120% 100% at 50% 0%, color-mix(in srgb, var(--pc) 22%, #3b2f9c), #1c1559 75%);
  border: 3px solid color-mix(in srgb, var(--pc) 75%, var(--edge));
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.18), inset 0 10px 24px rgba(0, 0, 0, 0.35), 0 6px 0 var(--edge-dark), 0 14px 26px rgba(0, 0, 0, 0.45);
  transition: border-color 0.3s, background 0.3s;
}
#trayBox::before { /* costura da mesa */
  content: ''; position: absolute; inset: 6px; border-radius: 16px; border: 2px dashed rgba(255, 255, 255, 0.1); pointer-events: none;
}
#trayBox.can-roll { cursor: pointer; animation: trayGlow 1.2s ease-in-out infinite; }
#trayBox.can-roll:active { transform: scale(0.98); }
@keyframes trayGlow { 50% { box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.18), inset 0 10px 24px rgba(0, 0, 0, 0.35), 0 6px 0 var(--edge-dark), 0 0 30px color-mix(in srgb, var(--pc) 75%, transparent); } }
#tray { display: flex; gap: 16px; justify-content: center; min-height: 60px; align-items: center; perspective: 520px; }
#trayHint { font-family: var(--display); font-size: 1.05rem; letter-spacing: 0.4px; min-height: 1.2em; text-align: center; display: flex; align-items: center; gap: 6px; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
#trayHint .ic { width: 20px; height: 20px; }
#trayHint.big { font-size: 1.45rem; color: var(--gold); animation: bounceHint 0.9s ease-in-out infinite; }
#trayHint.wait { font-family: var(--body); font-weight: 800; font-size: 0.88rem; color: var(--muted); text-shadow: none; }
@keyframes bounceHint { 50% { transform: translateY(-3px) scale(1.04); } }
#timerBar { position: absolute; left: 16px; right: 16px; bottom: 6px; height: 5px; border-radius: 5px; background: rgba(0, 0, 0, 0.35); overflow: hidden; opacity: 0; transition: opacity 0.2s; }
#timerBar.on { opacity: 1; }
#timerBar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--pc), #fff); transform-origin: left; }
#timerBar.low i { background: linear-gradient(90deg, #ff4d5e, #ffb0b8); }
#emotes { display: flex; justify-content: space-between; gap: 5px; flex: none; }
#emotes button {
  flex: 1; height: 36px; border: 0; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(180deg, #43389f, #2f2680); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.18), 0 3px 0 var(--edge-dark);
}
#emotes button .ic { width: 21px; height: 21px; stroke-width: 2.4; }
#emotes button:active { transform: translateY(2px) scale(0.92); box-shadow: 0 1px 0 var(--edge-dark); }

/* ---------- DADOS ---------- */
/* Dado de resina marfim: faces com bisel, quinas arredondadas, núcleo sólido e pintas cavadas. */
.die-wrap { --ds: 56px; --dx: 0px; width: var(--ds); height: var(--ds); position: relative; border: 0; background: none; padding: 0; transition: opacity 0.25s, transform 0.25s; }
#tray.n3 .die-wrap { --ds: 48px; }
.die { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 900ms cubic-bezier(0.16, 0.85, 0.24, 1); }
.face, .core { position: absolute; inset: 0; border-radius: 18%; }
.face {
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 15%;
  background:
    radial-gradient(120% 120% at 28% 22%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 55%),
    linear-gradient(150deg, #fffdf7 0%, #f6f1e6 55%, #e6dfd0 100%);
  box-shadow:
    inset 0 0 0 1px rgba(120, 100, 70, 0.14),
    inset 2px 2px 2px rgba(255, 255, 255, 0.9),
    inset -3px -4px 6px rgba(120, 100, 70, 0.22),
    inset 0 0 calc(var(--ds) * 0.18) rgba(150, 130, 100, 0.18);
}
.core { background: #e3dccd; }
.face span { display: block; }
.face .pip {
  width: 70%; height: 70%; margin: auto; border-radius: 50%;
  background: radial-gradient(circle at 62% 68%, #3d3a4a 0%, #16141f 62%, #0b0a10 100%);
  box-shadow: inset 1px 1.5px 2px rgba(0, 0, 0, 0.75), 0 1px 0 rgba(255, 255, 255, 0.85);
}
.face:first-child .pip {
  width: 92%; height: 92%;
  background: radial-gradient(circle at 62% 68%, #ff5a6a 0%, #c0122b 60%, #7d0716 100%);
  box-shadow: inset 1.5px 2px 3px rgba(60, 0, 10, 0.7), 0 1px 0 rgba(255, 255, 255, 0.85);
}
.die-shadow {
  position: absolute; left: 4%; right: 4%; bottom: -14%; height: 24%; border-radius: 50%;
  background: radial-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0) 70%); filter: blur(1px);
}
.die-wrap.rolling { animation: toss 900ms cubic-bezier(0.3, 0.7, 0.4, 1); }
.die-wrap.rolling .die-shadow { animation: tossShadow 900ms cubic-bezier(0.3, 0.7, 0.4, 1); }
/* lançado de lado, quica duas vezes e assenta (pousos em 40%, 72% e 100%, iguais ao som) */
@keyframes toss {
  0% { transform: translate(var(--dx), -70%) scale(0.85); opacity: 0.4; }
  18% { transform: translate(calc(var(--dx) * 0.6), -60%) scale(1.04); opacity: 1; }
  40% { transform: translate(calc(var(--dx) * 0.3), 0) scale(1.07, 0.93); }
  56% { transform: translate(calc(var(--dx) * 0.15), -22%); }
  72% { transform: translate(calc(var(--dx) * 0.05), 0) scale(1.03, 0.97); }
  86% { transform: translate(0, -5%); }
  100% { transform: none; }
}
@keyframes tossShadow {
  0% { transform: translateX(var(--dx)) scale(0.4); opacity: 0.2; }
  18% { transform: translateX(calc(var(--dx) * 0.6)) scale(0.5); opacity: 0.35; }
  40% { transform: translateX(calc(var(--dx) * 0.3)) scale(1); opacity: 1; }
  56% { transform: scale(0.8); opacity: 0.7; }
  72%, 100% { transform: none; opacity: 1; }
}
.die-wrap.used { opacity: 0.3; transform: scale(0.78); filter: saturate(0.4); }
.die-wrap.dim { opacity: 0.55; }
.die-wrap.sel::after { content: ''; position: absolute; inset: -8px; border-radius: 26%; border: 3px solid #fff; box-shadow: 0 0 0 3px var(--pc), 0 0 18px var(--pc); pointer-events: none; animation: selPulse 1s ease-in-out infinite; }
@keyframes selPulse { 50% { transform: scale(1.06); } }
#tray.shake .die-wrap { animation: shake 0.28s ease-in-out infinite; }
@keyframes shake { 25% { transform: rotate(-10deg) translateY(-3px) } 75% { transform: rotate(10deg) translateY(-3px) } }

/* ---------- AVISOS: feed (pequeno) e banner (grande) ---------- */
#feed { position: absolute; left: 50%; top: 4%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 5; width: max-content; max-width: 94%; }
.note {
  --c: var(--gold); display: flex; align-items: center; gap: 8px; padding: 5px 14px 5px 5px; border-radius: 99px;
  background: linear-gradient(180deg, rgba(36, 27, 104, 0.96), rgba(20, 14, 66, 0.96)); border: 2px solid color-mix(in srgb, var(--c) 70%, #fff);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 8px 18px rgba(0, 0, 0, 0.4); font-size: 0.88rem; font-weight: 800;
  animation: noteIn 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); transition: opacity 0.3s, transform 0.3s;
}
.note .nb { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25); flex: none; }
.note .nb .ic { width: 16px; height: 16px; stroke-width: 2.8; }
.note b { color: color-mix(in srgb, var(--c) 60%, #fff); font-weight: 900; }
.note.out { opacity: 0; transform: translateY(-10px) scale(0.95); }
@keyframes noteIn { from { opacity: 0; transform: translateY(-14px) scale(0.8); } }
#banner { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 6; }
.bnr { --c: var(--gold); display: flex; flex-direction: column; align-items: center; gap: 4px; animation: bnrIn 1.5s cubic-bezier(0.2, 1.4, 0.4, 1) forwards; }
.bnr .bt {
  position: relative; font-family: var(--display); font-size: clamp(2rem, 9vmin, 4rem); color: #fff; letter-spacing: 1px; padding: 4px 26px 8px;
  text-shadow: 0 4px 0 var(--ink), 3px 3px 0 var(--ink), -3px 3px 0 var(--ink), 3px -2px 0 var(--ink), -3px -2px 0 var(--ink);
  white-space: nowrap;
}
.bnr .bt::before {
  content: ''; position: absolute; inset: 14% -4%; z-index: -1; border-radius: 14px; transform: skewX(-10deg) rotate(-2deg);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 75%, #fff), var(--c)); box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.4), 0 6px 0 color-mix(in srgb, var(--c) 50%, #000), 0 14px 30px rgba(0, 0, 0, 0.45);
}
.bnr .bs { font-family: var(--display); font-size: clamp(0.95rem, 3.6vmin, 1.4rem); color: #fff; padding: 3px 14px; border-radius: 99px; background: rgba(13, 10, 38, 0.85); border: 2px solid var(--c); }
@keyframes bnrIn {
  0% { transform: scale(0.3) rotate(-8deg); opacity: 0; } 14% { transform: scale(1.12) rotate(2deg); opacity: 1; } 24% { transform: scale(1) rotate(0); }
  80% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.05) translateY(-20px); opacity: 0; }
}
#toasts { position: fixed; top: calc(var(--st) + 10px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 60; pointer-events: none; }

/* ---------- OVERLAYS ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 5, 28, 0.72); display: grid; place-items: center; z-index: 30; backdrop-filter: blur(4px); padding: 12px; }
.card { width: min(400px, 94vw); padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 11px; animation: pop 0.3s cubic-bezier(0.3, 1.5, 0.5, 1); max-height: calc(100dvh - 24px); }
.card.scroll { overflow-y: auto; }
.card-title { font-family: var(--display); font-weight: 400; font-size: 1.7rem; text-align: center; margin: 0 0 4px; text-shadow: 0 3px 0 var(--ink); }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }
.dice-ctl { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 14px; background: rgba(0, 0, 0, 0.25); }
.dice-ctl > span { display: flex; align-items: center; gap: 7px; }
.dice-ctl > span .ic { color: var(--gold); }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper .btn-icon { width: 36px; height: 36px; border-radius: 12px; }
.stepper strong { font-family: var(--display); font-weight: 400; font-size: 1.6rem; color: var(--gold); min-width: 22px; text-align: center; }
.rules { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 0.92rem; font-weight: 700; }
.rules li { display: flex; gap: 10px; align-items: flex-start; }
.rules li .ic { flex: none; width: 30px; height: 30px; padding: 6px; border-radius: 10px; background: rgba(255, 200, 61, 0.15); color: var(--gold); }
.rules b { color: var(--gold); }

.podium-wrap { width: min(560px, 96vw); display: flex; flex-direction: column; align-items: center; gap: 10px; animation: pop 0.4s cubic-bezier(0.3, 1.5, 0.5, 1); max-height: calc(100dvh - 24px); }
.podium-wrap h2 { font-size: clamp(2rem, 8vmin, 3.2rem); }
.podium-blocks { display: flex; align-items: flex-end; justify-content: center; gap: 10px; width: 100%; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 30%; max-width: 150px; }
.pod .avatar { width: 52px; height: 52px; }
.pod .avatar .ic { width: 28px; height: 28px; }
.pod .pn { font-weight: 900; font-size: 0.95rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .blk {
  width: 100%; display: grid; place-items: start center; padding-top: 8px; border-radius: 14px 14px 6px 6px;
  font-family: var(--display); font-size: 2rem; color: #4a2d00; animation: rise 0.6s cubic-bezier(0.3, 1.4, 0.5, 1) both;
  background: linear-gradient(180deg, #ffe07a, #ffb21f); box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.5), 0 6px 0 var(--gold-d);
}
.pod.p1 .blk { height: 110px; animation-delay: 0.35s; }
.pod.p2 .blk { height: 80px; background: linear-gradient(180deg, #f2f4ff, #aeb6d6); color: #39405e; box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.6), 0 6px 0 #6d7598; animation-delay: 0.15s; }
.pod.p3 .blk { height: 58px; background: linear-gradient(180deg, #ffc89a, #d07a3c); color: #4b2208; box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.45), 0 6px 0 #8a4314; }
.pod.p1 .crown { color: var(--gold); width: 34px; height: 34px; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.4)); animation: bob 1.4s ease-in-out infinite; }
@keyframes rise { from { transform: scaleY(0); transform-origin: bottom; } }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-6deg); } }
.podium-rest { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-height: 22vh; overflow-y: auto; }
.podium-rest li { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 99px; background: rgba(0, 0, 0, 0.35); font-size: 0.85rem; }
.podium-rest .avatar { width: 24px; height: 24px; }
.podium-rest .avatar .ic { width: 14px; height: 14px; }
.podium-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

#conn { position: fixed; bottom: calc(var(--sb) + 12px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: linear-gradient(180deg, #ff6a78, #e0263a); padding: 7px 16px; border-radius: 99px; font-family: var(--display); z-index: 50; box-shadow: 0 4px 0 var(--red-d); animation: pulseBtn 1.2s infinite; }
#rotateHint { position: fixed; left: 50%; top: calc(var(--st) + 8px); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 99px; z-index: 25; white-space: nowrap; font-size: 0.85rem; background: linear-gradient(180deg, #43389f, #2f2680); border: 2px solid var(--edge); box-shadow: 0 4px 0 var(--edge-dark); }
#rotateHint > .ic { color: var(--gold); }
#rotateHint button { border: 0; background: rgba(0, 0, 0, 0.3); border-radius: 50%; width: 28px; height: 28px; display: grid; place-items: center; }

/* ---------- PENTE (5+ jogadores): tabuleiro largo, painel fino ---------- */
#game[data-shape="comb"] #boardWrap { flex: 1; aspect-ratio: auto; max-width: none; min-width: 0; }
#game[data-shape="comb"] #panel { flex: none; width: clamp(180px, 23vw, 270px); margin: 0; }
#game[data-shape="comb"] #players { grid-template-columns: 1fr; }

/* ---------- RETRATO ---------- */
@media (orientation: portrait) {
  #home { flex-direction: column; justify-content: center; gap: 1vh; }
  .home-art { width: min(64vw, 34vh); }
  .float-die { width: 40px; height: 40px; border-radius: 12px; }
  .float-die .ic { width: 22px; height: 22px; }
  .lobby-body { display: flex; flex-direction: column; overflow-y: auto; }
  .lobby-col { overflow: visible; flex: none; }
  .lobby-col.preview { height: 30vh; order: -1; }
  #game { flex-direction: column; gap: 8px; }
  #boardWrap { height: auto; width: 100%; max-width: none; max-height: 58dvh; }
  #panel { width: 100%; max-width: none; }
  #players { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  #game[data-shape="comb"] #boardWrap { width: 100%; height: auto; flex: 1; max-height: none; min-height: 0; }
  #game[data-shape="comb"] #panel { width: 100%; flex: none; max-height: 38dvh; }
  #game[data-shape="comb"] #players { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* ---------- CELULAR DEITADO (pouca altura) ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  body { font-size: 14px; }
  .screen { padding-top: calc(var(--st) + 7px); padding-bottom: calc(var(--sb) + 7px); }
  .home-card { gap: 7px; padding: 12px 14px 14px; }
  .field-label { display: none; }
  .chips { display: none; }
  .btn { padding: 8px 14px 9px; font-size: 1rem; }
  .btn-lg { font-size: 1.2rem; padding: 9px 22px 10px; }
  .input-wrap input, .join-row input { padding: 7px 0; }
  .join-row input { padding: 6px 8px; }
  .cdot { width: 24px; height: 24px; }
  .cdot .ic { inset: 4px; width: 16px; height: 16px; }
  .lobby-col { padding: 8px 9px 10px; }
  .panel { border-width: 2px; border-radius: 18px; }
  .ticket strong { font-size: 1.45rem; }
  .slot { min-height: 40px; padding: 4px 6px; }
  .avatar { width: 30px; height: 30px; }
  #panel { gap: 6px; }
  .btn-icon { width: 34px; height: 34px; border-radius: 11px; }
  .btn-icon .ic { width: 19px; height: 19px; }
  .turn-plate { height: 36px; }
  .turn-plate b { font-size: 0.98rem; }
  #players { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 4px; }
  .prow { min-height: 36px; padding: 3px 6px; gap: 6px; border-radius: 11px; }
  .prow .avatar { width: 26px; height: 26px; }
  .prow .avatar .ic { width: 15px; height: 15px; }
  .prow .nm { font-size: 0.82rem; }
  .tok { width: 8px; height: 8px; border-width: 1.5px; }
  #trayBox { padding: 8px 8px 12px; gap: 3px; border-radius: 18px; }
  .die-wrap { --ds: 46px; }
  #tray.n3 .die-wrap { --ds: 40px; }
  #tray { min-height: 50px; gap: 13px; }
  #trayHint.big { font-size: 1.2rem; }
  #emotes button { height: 30px; }
  #emotes button .ic { width: 18px; height: 18px; }
  .hide-sm { display: none; }
}
@media (orientation: landscape) and (max-height: 360px) {
  #emotes { display: none; }
  .lobby-col.preview { display: none; }
  .lobby-body { grid-template-columns: 1fr 1.2fr; }
}
