:root {
  --bg: #140b29;
  --panel: #1f1340;
  --panel-2: #2a1a55;
  --line: #3b2a6e;
  --text: #f4f0ff;
  --muted: #b6a9dc;
  --teal: #2ee6c5;
  --coral: #ff6b6b;
  --yellow: #ffd166;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}

a { color: var(--teal); }

.wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 22px; letter-spacing: .5px;
  color: var(--text); text-decoration: none;
}
.brand .dot { width: 14px; height: 14px; border-radius: 4px; background: var(--teal); box-shadow: 18px 0 var(--coral), 36px 0 var(--yellow); margin-right: 40px; }

header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }

h1 { font-size: clamp(26px, 4vw, 36px); line-height: 1.15; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 0 0 12px; }
p.lead { color: var(--muted); margin: 0 0 24px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.grid { display: grid; gap: 16px; }
@media (min-width: 760px) { .grid.two { grid-template-columns: 1fr 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 18px;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--teal); color: #0b1a17;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.warn { background: var(--coral); color: #2a0b0b; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn.block { width: 100%; }

label { display: block; font-weight: 600; margin: 0 0 6px; }
input[type=text], input[type=file] {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit;
}
input[type=text]:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.field { margin-bottom: 16px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; width: 18px; height: 18px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.code {
  font: 800 34px/1 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 6px; color: var(--yellow);
}

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--panel-2); color: var(--muted); }
.pill.ok { background: rgba(46, 230, 197, .15); color: var(--teal); }
.pill.warn { background: rgba(255, 209, 102, .15); color: var(--yellow); }
.pill.bad { background: rgba(255, 107, 107, .15); color: var(--coral); }

.rooms { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.rooms li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px; background: var(--panel-2); border-radius: 12px; }
.rooms .game { font-weight: 700; }
.empty { color: var(--muted); padding: 16px 0; }

.notice { border-left: 3px solid var(--yellow); padding: 8px 12px; background: rgba(255, 209, 102, .08); border-radius: 0 10px 10px 0; font-size: 14px; color: var(--muted); }
.error { color: var(--coral); font-weight: 600; min-height: 1.5em; }

/* ---------- Anfitrião ---------- */
.host-layout { display: grid; gap: 16px; }
@media (min-width: 900px) { .host-layout { grid-template-columns: 1fr 300px; } }
.screen {
  background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 8 / 7; width: 100%;
  display: grid; place-items: center;
}
.screen canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.screen:fullscreen { border-radius: 0; aspect-ratio: auto; }
.screen:fullscreen canvas { width: 100% !important; height: 100% !important; object-fit: contain; }
.qr { background: #fff; border-radius: 12px; padding: 8px; width: 100%; max-width: 220px; aspect-ratio: 1; display: block; margin: 12px auto; }
.guest { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px; background: var(--panel-2); border-radius: 10px; }
.keys { font-size: 13px; color: var(--muted); }
.keys kbd { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font: 12px ui-monospace, monospace; color: var(--text); }

.modal { position: fixed; inset: 0; background: rgba(5, 2, 15, .8); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal[hidden] { display: none; }
.modal .card { max-width: 420px; width: 100%; text-align: center; }
.modal .big { font-size: 22px; font-weight: 800; color: var(--yellow); margin: 12px 0; }
.progress { height: 6px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--teal); width: 0; transition: width .2s; }

/* ---------- Convidado (celular) ---------- */
body.play { overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.play-join { max-width: 420px; margin: 0 auto; padding: 24px 16px; }
.stage { position: fixed; inset: 0; display: none; background: #000; }
.stage.on { display: block; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.hud { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; z-index: 5; }
.hud .btn { padding: 6px 10px; font-size: 13px; background: rgba(31, 19, 64, .75); color: var(--text); border: 1px solid var(--line); }
.status { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; color: var(--muted); z-index: 4; padding: 16px; }

.pad { position: absolute; inset: 0; z-index: 3; }
.pad.hidden { display: none; }
.pad .zone, .pad .b {
  position: absolute; display: grid; place-items: center;
  color: rgba(255, 255, 255, .85); font-weight: 800;
  background: rgba(255, 255, 255, .12); border: 2px solid rgba(255, 255, 255, .25);
  transition: background .05s;
}
.pad .on { background: rgba(46, 230, 197, .45) !important; }
/* Direcional em cruz: os braços são só visuais; o toque é calculado pela posição no quadrado todo
   (permite diagonal e deslizar o dedo entre direções). */
.pad .dpad { position: absolute; left: 4vmin; bottom: 6vmin; width: 38vmin; height: 38vmin; }
.pad .dpad .arm {
  position: absolute; display: grid; place-items: center; width: 34%; height: 34%;
  color: rgba(255, 255, 255, .85); font-size: 4.5vmin;
  background: rgba(255, 255, 255, .14); border: 2px solid rgba(255, 255, 255, .28);
  transition: background .05s;
}
.pad .dpad .up { left: 33%; top: 0; border-radius: 10px 10px 0 0; border-bottom: 0; }
.pad .dpad .down { left: 33%; bottom: 0; border-radius: 0 0 10px 10px; border-top: 0; }
.pad .dpad .left { top: 33%; left: 0; border-radius: 10px 0 0 10px; border-right: 0; }
.pad .dpad .right { top: 33%; right: 0; border-radius: 0 10px 10px 0; border-left: 0; }
.pad .dpad .center { left: 33%; top: 33%; border: 0; border-radius: 0; }
.pad .face { position: absolute; right: 4vmin; bottom: 6vmin; width: 40vmin; height: 40vmin; }
.pad .face .b { width: 14vmin; height: 14vmin; border-radius: 50%; font-size: 5vmin; }
.pad .face [data-btn=x] { top: 0; left: 13vmin; }
.pad .face [data-btn=y] { top: 13vmin; left: 0; }
.pad .face [data-btn=a] { top: 13vmin; right: 0; }
.pad .face [data-btn=b] { bottom: 0; left: 13vmin; }
.pad .b.shoulder { top: 4vmin; width: 22vmin; height: 10vmin; border-radius: 12px; font-size: 4vmin; }
.pad [data-btn=l] { left: 4vmin; }
.pad [data-btn=r] { right: 4vmin; }
.pad .b.mini { bottom: 3vmin; width: 16vmin; height: 7vmin; border-radius: 99px; font-size: 3vmin; }
.pad [data-btn=select] { left: calc(50% - 18vmin); }
.pad [data-btn=start] { left: calc(50% + 2vmin); }
@media (orientation: portrait) {
  .stage video { height: 56%; bottom: auto; }
}
