/* ---------------------------------------------------------------- tokens (mesmos do Fibonacci Votações) */
:root {
  --bg: #0b1020;
  --bg-2: #111832;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.08);
  --surface-solid: #151d3a;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #eef1ff;
  --muted: #9aa3c7;
  --accent: #8b7bff;
  --accent-2: #4fd1c5;
  --warn: #ffb547;
  --danger: #ff6b81;
  --ok: #3ddc97;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  --glow-1: rgba(139, 123, 255, 0.22);
  --glow-2: rgba(79, 209, 197, 0.14);
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Outfit, system-ui, sans-serif;
  overflow: hidden;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.bg-glow {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(900px 600px at 15% 10%, var(--glow-1), transparent 60%),
              radial-gradient(800px 600px at 90% 90%, var(--glow-2), transparent 60%);
}

/* ---------------------------------------------------------------- botões e campos */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 0.6rem 1rem; color: var(--text); background: var(--surface-2);
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--accent), #6a55f5); border-color: transparent; color: #fff; }
.btn-ghost { background: var(--surface); }
.btn-lg { padding: 0.85rem 1.4rem; font-size: 1.05rem; }
.btn.small { padding: 0.45rem 0.7rem; font-size: 0.92rem; }
.btn.active { border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(79, 209, 197, 0.35) inset; }
.chip {
  font: inherit; font-size: 0.8rem; cursor: pointer; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0.2rem 0.6rem;
}
.field { display: grid; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.75rem; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
kbd {
  font-family: 'JetBrains Mono', monospace; font-size: 0.78rem;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 6px; padding: 0.05rem 0.35rem;
}

/* ---------------------------------------------------------------- entrada */
.landing { position: relative; min-height: 100%; display: grid; place-items: center; padding: 24px 16px; overflow: auto; height: 100%; }
.landing-card {
  width: min(920px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; padding: 28px; box-shadow: var(--shadow); backdrop-filter: blur(10px);
}
.landing-card h1 { margin: 0 0 0.25rem; font-size: clamp(1.6rem, 4vw, 2.3rem); }
.landing-card h2 { font-size: 1rem; margin: 1rem 0 0.5rem; color: var(--muted); font-weight: 600; }
.landing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 18px; }
@media (max-width: 760px) { .landing-grid { grid-template-columns: 1fr; } }
.profile { display: grid; gap: 14px; align-content: start; }
.look-wrap { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: start; }
.look-wrap canvas { background: linear-gradient(#e2e8f2, #c9d2e2); border-radius: 14px; width: 120px; height: 140px; }
.look-editor { display: grid; gap: 8px; }
.look-row { display: grid; gap: 4px; }
.look-row > span { font-size: 0.78rem; color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0;
  box-shadow: 0 0 0 1px var(--border-strong) inset;
}
.swatch.on { border-color: #fff; transform: scale(1.12); }
.opt {
  font: inherit; font-size: 0.78rem; cursor: pointer; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0.15rem 0.55rem;
}
.opt.on { background: var(--accent); border-color: transparent; color: #fff; }
.rooms-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 260px; overflow: auto; }
.rooms-list li button {
  width: 100%; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 0.7rem 0.9rem;
}
.rooms-list li button:hover { border-color: var(--accent); }
.rooms-list .who { color: var(--muted); font-size: 0.82rem; }
.create-form { display: flex; gap: 8px; margin-top: 14px; }
.create-form .btn { white-space: nowrap; }
.join-box { background: rgba(139, 123, 255, 0.12); border: 1px solid rgba(139, 123, 255, 0.4); border-radius: 14px; padding: 14px; display: grid; gap: 10px; }
.join-box p { margin: 0; }
.setup-error { background: rgba(255, 107, 129, 0.12); border: 1px solid rgba(255, 107, 129, 0.45); border-radius: 12px; padding: 0.7rem 0.9rem; margin-top: 12px; }

/* ---------------------------------------------------------------- jogo */
.game { position: fixed; inset: 0; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.topbar {
  position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 10px;
  pointer-events: none; flex-wrap: wrap;
}
.topbar > * { pointer-events: auto; }
.room-title, .actions {
  display: flex; align-items: center; gap: 8px; background: rgba(11, 16, 32, 0.78); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 14px; padding: 6px 10px;
}
.room-title span:first-child { font-weight: 700; }
.net-status { color: var(--ok); font-size: 0.8rem; }
.net-status.off { color: var(--danger); }
.actions { flex-wrap: wrap; }

.panel {
  position: absolute; top: 64px; right: 10px; width: min(330px, calc(100% - 20px)); max-height: calc(100% - 140px); overflow: auto;
  background: rgba(15, 20, 42, 0.92); backdrop-filter: blur(10px); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: grid; gap: 10px;
}
.panel h3 { margin: 0; font-size: 1.05rem; }
.panel .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel select { width: auto; padding: 0.4rem 0.6rem; }
.speaker-card { background: linear-gradient(135deg, rgba(79, 209, 197, 0.18), rgba(139, 123, 255, 0.18)); border-radius: 14px; padding: 12px; text-align: center; }
.speaker-card.over { background: linear-gradient(135deg, rgba(255, 107, 129, 0.25), rgba(255, 181, 71, 0.15)); }
.speaker-name { font-size: 1.25rem; font-weight: 800; }
.clock { font-family: 'JetBrains Mono', monospace; font-size: 2rem; font-weight: 700; }
.order { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.order li { display: flex; justify-content: space-between; padding: 0.35rem 0.6rem; border-radius: 10px; background: var(--surface); font-size: 0.92rem; }
.order li.now { background: rgba(79, 209, 197, 0.2); font-weight: 700; }
.order li.done { opacity: 0.5; text-decoration: line-through; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.people li { display: flex; align-items: center; gap: 8px; padding: 0.4rem 0.55rem; border-radius: 10px; background: var(--surface); }
.people .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(255,255,255,0.15); }
.people .meta { margin-left: auto; color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.people .host { font-size: 0.75rem; color: var(--warn); }

.chat-log {
  position: absolute; left: 10px; bottom: 54px; width: min(380px, calc(100% - 20px)); max-height: 34%;
  overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; pointer-events: none;
}
.chat-log .msg {
  background: rgba(11, 16, 32, 0.72); border-radius: 10px; padding: 0.3rem 0.6rem; font-size: 0.88rem;
  width: fit-content; max-width: 100%; animation: fadein 0.2s; transition: opacity 1s;
}
.chat-log .msg b { color: var(--accent-2); }
.chat-log .msg.sys { color: var(--muted); font-style: italic; }
.chat-log.faded .msg.old { opacity: 0; }
.chat-form { position: absolute; left: 10px; bottom: 12px; width: min(420px, calc(100% - 20px)); }
.keys-hint {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); font-size: 0.78rem; color: var(--muted);
  background: rgba(11, 16, 32, 0.65); border-radius: 999px; padding: 0.3rem 0.8rem; white-space: nowrap; pointer-events: none;
}
.chat-form:not([hidden]) ~ .keys-hint { display: none; }
@media (max-width: 900px) { .keys-hint { display: none; } }

.dialog {
  background: var(--surface-solid); color: var(--text); border: 1px solid var(--border-strong); border-radius: 20px;
  padding: 20px; width: min(520px, calc(100% - 32px)); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(5, 8, 20, 0.6); backdrop-filter: blur(3px); }
.dialog h2 { margin-top: 0; }
.dialog .field { margin-top: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog textarea { resize: vertical; }
.help-list { padding-left: 1.1rem; line-height: 1.9; }

.toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; pointer-events: none; }
.toast {
  background: rgba(21, 29, 58, 0.95); border: 1px solid var(--border-strong); border-radius: 12px; padding: 0.55rem 1rem;
  box-shadow: var(--shadow); animation: fadein 0.2s; text-align: center;
}
.toast.error { border-color: var(--danger); }
@keyframes fadein { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- toque (celular) */
.touch { position: absolute; inset: auto 0 0 0; height: 46%; pointer-events: none; }
.joy {
  position: absolute; left: 22px; bottom: 26px; width: 130px; height: 130px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08); border: 2px solid rgba(255, 255, 255, 0.18); pointer-events: auto; touch-action: none;
}
.joy-knob { position: absolute; left: 40px; top: 40px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); }
.touch-btns { position: absolute; right: 18px; bottom: 26px; display: grid; grid-template-columns: repeat(2, 64px); gap: 12px; pointer-events: auto; }
.touch-btns button {
  width: 64px; height: 64px; border-radius: 50%; font-size: 1.6rem; border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(11, 16, 32, 0.6); color: #fff; touch-action: none;
}
.touch-btns button.on { background: rgba(139, 123, 255, 0.6); }

/* ---------------------------------------------------------------- tela estreita */
@media (max-width: 640px) {
  .topbar { top: 6px; left: 6px; right: 6px; gap: 6px; }
  .room-title, .actions { padding: 4px 6px; gap: 4px; border-radius: 12px; }
  .room-title span:first-child { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .btn.small { padding: 0.3rem 0.45rem; font-size: 0.8rem; }
  .chip { font-size: 0.72rem; }
  .panel { top: 92px; max-height: calc(100% - 300px); }
}
.has-touch .chat-log { bottom: 200px; max-height: 22%; }
.has-touch .chat-form { bottom: 200px; }
