:root {
  --ink: #281352;
  --ink-90: #1b153b;
  --ink-100: #0e0b1f;
  --ink-60: #342775;
  --yellow: #ffc20e;
  --violet: #6824d3;
  --purple: #8411ce;
  --pink: #ef4d7f;
  --lavender: #a689f7;
  --white: #fff;
  --font: Archivo, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--ink-100); color: var(--white);
  font-family: var(--font);
  overscroll-behavior: none;
}
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block; touch-action: none; }
button, input, textarea { font-family: inherit; }
[hidden] { display: none !important; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  background: linear-gradient(180deg, rgba(14,11,31,.92), rgba(14,11,31,.55) 75%, transparent);
}
#topbar .logo { height: 22px; flex: none; }
#banner { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
#banner b { font-weight: 900; font-size: 15px; color: var(--yellow); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#banner span { font-size: 13px; font-weight: 600; opacity: .92; }
.icon {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.18); background: rgba(40,19,82,.85);
  color: #fff; font-size: 20px; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.icon:active { transform: scale(.94); }
.icon.star { background: var(--yellow); border-color: #c88f00; }

#bottombar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px calc(env(safe-area-inset-bottom) + 10px);
  background: linear-gradient(0deg, rgba(14,11,31,.92), rgba(14,11,31,.5) 75%, transparent);
}
#chatForm { flex: 1; min-width: 0; display: flex; gap: 6px; }
#chatInput {
  flex: 1; min-width: 0; height: 42px; border-radius: 21px; border: 2px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.95); color: var(--ink); padding: 0 14px; font-size: 16px; font-weight: 600;
}
.icon.send { background: var(--violet); }
#dropBtn {
  height: 42px; border-radius: 21px; border: 0; padding: 0 14px; font-weight: 900; font-size: 15px;
  background: var(--yellow); color: var(--ink); flex: none;
}

.panel {
  position: absolute; left: 10px; right: 10px; bottom: calc(env(safe-area-inset-bottom) + 64px);
  max-width: 480px; margin: 0 auto;
  background: rgba(27,21,59,.97); border: 2px solid rgba(255,255,255,.12); border-radius: 18px;
  padding: 10px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.panel button {
  border: 0; border-radius: 12px; background: rgba(255,255,255,.08); color: #fff;
  padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
}
.panel button span:first-child { font-size: 24px; }
.panel button span:last-child { font-size: 11px; font-weight: 700; text-align: center; line-height: 1.1; }
.panel button:active { background: var(--violet); }

#toasts {
  position: absolute; top: calc(env(safe-area-inset-top) + 64px); left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
}
.toast {
  background: rgba(255,255,255,.96); color: var(--ink); font-weight: 800; font-size: 14px;
  padding: 8px 14px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.3);
  animation: toastIn .25s ease-out; max-width: 92vw; text-align: center;
}
.toast.yellow { background: var(--yellow); }
.toast.pink { background: var(--pink); color: #fff; }
@keyframes toastIn { from { transform: translateY(-10px) scale(.9); opacity: 0; } }

#bigmsg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 460px); text-align: center;
  background: var(--ink); border: 3px solid var(--yellow); border-radius: 24px;
  padding: 18px 18px 14px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: pop .35s cubic-bezier(.2,1.6,.4,1);
}
#bigmsg .emoji { font-size: 46px; line-height: 1; }
#bigmsg h2 { margin: 6px 0 4px; font-size: 22px; font-weight: 900; color: var(--yellow); }
#bigmsg p { margin: 6px 0; font-size: 18px; font-weight: 700; line-height: 1.3; }
#bigmsg .small { font-size: 13px; opacity: .8; font-weight: 600; }
#bigmsg button { margin-top: 8px; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } }

.overlay {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(14,11,31,.78); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}
.card {
  width: 100%; max-width: 760px; max-height: 100%; overflow: auto;
  background: var(--ink-90); border: 2px solid rgba(255,255,255,.12); border-radius: 22px;
  padding: 16px; box-shadow: 0 24px 80px rgba(0,0,0,.5);
}
.card h2, .card h3 { margin: 0 0 6px; font-weight: 900; }
.muted { opacity: .7; font-size: 13px; font-weight: 600; }

.creator-card { display: flex; flex-direction: column; gap: 12px; padding-bottom: 0; }
.creator-card > * { flex: none; }
.creator-card #enterBtn { position: sticky; bottom: 0; margin: 0 -16px; border-radius: 0 0 20px 20px; box-shadow: 0 -10px 24px rgba(14,11,31,.7); }
.creator-head { display: flex; align-items: center; gap: 14px; }
.creator-head h1 { margin: 0; font-size: 26px; font-weight: 900; color: var(--yellow); line-height: 1; }
.creator-head p { margin: 4px 0 0; font-weight: 600; opacity: .85; }
.logo-big { height: 34px; }
.creator-body { display: grid; grid-template-columns: 240px 1fr; gap: 14px; min-height: 0; }
.preview-col { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
#preview {
  width: 100%; max-width: 240px; aspect-ratio: 1; align-self: center;
  background: radial-gradient(circle at 50% 60%, #3d2d8a, #1b153b 70%); border-radius: 18px;
}
#nameInput {
  height: 46px; border-radius: 14px; border: 2px solid var(--yellow); background: #fff; color: var(--ink);
  font-size: 18px; font-weight: 800; padding: 0 12px; text-align: center;
}
.row { display: flex; gap: 8px; justify-content: center; }
.options-col { min-width: 0; }
.section-title { font-weight: 900; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--lavender); margin: 10px 0 6px; }
.section-title:first-child { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 2px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06); color: #fff;
  border-radius: 12px; padding: 6px 10px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 1px; font-size: 13px; font-weight: 800; line-height: 1.15;
}
.chip small { font-size: 10.5px; font-weight: 700; color: var(--yellow); opacity: .9; }
.chip.on { border-color: var(--yellow); background: rgba(255,194,14,.16); }
.chip.color { width: 34px; height: 34px; border-radius: 50%; padding: 0; }
.chip.color.on { box-shadow: 0 0 0 3px var(--yellow); }
.chip.preset { flex-direction: row; align-items: center; gap: 6px; }
.chip.preset canvas { width: 34px; height: 34px; }

.btn {
  border: 2px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: #fff;
  border-radius: 14px; padding: 10px 14px; font-weight: 800; font-size: 15px; cursor: pointer;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--violet); border-color: var(--violet); }
.btn.danger { background: rgba(239,77,127,.2); border-color: var(--pink); }
.btn.ghost { background: transparent; }
.btn.big { font-size: 19px; padding: 14px; background: var(--yellow); border-color: var(--yellow); color: var(--ink); font-weight: 900; }

.host-card { max-width: 560px; display: flex; flex-direction: column; gap: 10px; }
.host-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.host-grid .btn { font-size: 14px; text-align: left; }
details { background: rgba(255,255,255,.05); border-radius: 14px; padding: 10px; }
summary { font-weight: 800; cursor: pointer; }
details label { display: block; margin: 10px 0 4px; font-weight: 800; font-size: 13px; }
textarea {
  width: 100%; border-radius: 10px; border: 2px solid rgba(255,255,255,.15); background: #fff; color: var(--ink);
  font-size: 13px; padding: 8px; font-weight: 600; resize: vertical;
}
details .btn { margin-top: 8px; width: 100%; }

.podium-card { max-width: 480px; text-align: center; }
#podiumList { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.prow { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.06); border-radius: 14px; padding: 8px 12px; text-align: left; }
.prow .pos { font-size: 24px; width: 34px; text-align: center; }
.prow .nm { flex: 1; font-weight: 900; font-size: 17px; }
.prow .nm small { display: block; font-size: 12px; font-weight: 700; color: var(--yellow); }
.prow .pts { font-weight: 900; color: var(--yellow); font-size: 18px; }
.prow.first { background: rgba(255,194,14,.18); border: 2px solid var(--yellow); }

#refHolder canvas { width: 100%; border-radius: 12px; margin: 8px 0; }
#refImg .card { max-width: 520px; text-align: center; }

#conn {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); z-index: 20;
  background: var(--pink); color: #fff; font-weight: 800; padding: 8px 16px; border-radius: 999px;
}

@media (max-width: 640px) {
  .creator-body { grid-template-columns: 1fr; }
  #preview { max-width: 180px; }
  .creator-head h1 { font-size: 22px; }
  .host-grid { grid-template-columns: 1fr; }
}

/* ---------- computador primeiro ---------- */
#where {
  flex: none; font-weight: 900; font-size: 13px; color: var(--ink); background: var(--yellow);
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}
#where:empty { display: none; }
#bottombar { justify-content: center; }
#chatForm { max-width: 560px; }
#minimapBox {
  position: absolute; right: 14px; bottom: calc(env(safe-area-inset-bottom) + 78px);
  border: 3px solid var(--yellow); border-radius: 16px; overflow: hidden; background: var(--ink-90);
  box-shadow: 0 10px 30px rgba(0,0,0,.45); line-height: 0;
}
#minimap { width: 256px; height: 176px; cursor: crosshair; }
#keys {
  position: absolute; left: 14px; bottom: calc(env(safe-area-inset-bottom) + 80px);
  font-size: 12px; font-weight: 600; color: rgba(255,255,255,.85);
  background: rgba(14,11,31,.7); padding: 6px 10px; border-radius: 10px; pointer-events: none;
}
#keys b { color: var(--yellow); }
.panel { grid-template-columns: repeat(6, 1fr); max-width: 640px; }
.panel kbd {
  font: inherit; font-size: 10px; background: rgba(255,255,255,.18); border-radius: 4px; padding: 0 4px;
}
.creator-card { max-width: 1040px; }
.creator-body { grid-template-columns: 280px 1fr; }
#preview { max-width: 280px; }
.chip.item {
  width: 104px; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 6px 4px 8px;
  font-size: 12px;
}
.chip.item canvas { width: 56px; height: 56px; border-radius: 10px; background: radial-gradient(circle at 50% 55%, #3d2d8a, #1b153b 75%); }
@media (max-width: 820px) {
  #keys { display: none; }
  #minimapBox { bottom: calc(env(safe-area-inset-bottom) + 72px); right: 8px; }
  #minimap { width: 150px; height: 103px; }
  .panel { grid-template-columns: repeat(4, 1fr); }
  #where { display: none; }
}
@media (max-width: 640px) {
  .chip.item { width: 88px; }
}

@media (min-width: 821px) {
  #topbar { padding: 12px 18px 14px; gap: 14px; }
  #topbar .logo { height: 28px; }
  #banner b { font-size: 22px; }
  #banner span { font-size: 15px; }
}
