:root {
  --bg: #0b0a1a;
  --bg2: #16132e;
  --panel: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f5f5f4;
  --muted: #a8a29e;
  --accent: #facc15;
  --accent2: #f97316;
  --p1: #3b82f6;
  --p2: #ef4444;
  --ok: #22c55e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: Inter, system-ui, sans-serif; overflow: hidden; }
body { background: radial-gradient(ellipse at top, #2e1065 0%, var(--bg) 60%) fixed; }
button { font: inherit; cursor: pointer; }
input { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

.screen { display: none; position: fixed; inset: 0; overflow-y: auto; padding: 16px; }
.screen.active { display: flex; flex-direction: column; }

/* ---------- MENU ---------- */
#menu { align-items: center; gap: 24px; padding-top: max(24px, env(safe-area-inset-top)); }
.logo { text-align: center; margin-top: 2vh; }
.logo-top { font-family: 'Bebas Neue', Impact, sans-serif; letter-spacing: 0.4em; color: var(--accent); font-size: 1.1rem; }
.logo h1 { font-family: 'Bebas Neue', Impact, sans-serif; font-size: clamp(3rem, 11vw, 7rem); line-height: 0.85; margin: 4px 0; letter-spacing: 0.02em;
  background: linear-gradient(180deg, #fff7ae 0%, #facc15 45%, #c2410c 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #000) drop-shadow(0 0 24px rgba(250, 204, 21, 0.35)); transform: skewX(-6deg); }
.logo h1 span { display: block; font-size: 0.8em; background: linear-gradient(180deg, #fecaca, #ef4444 50%, #7f1d1d); -webkit-background-clip: text; background-clip: text; }
.logo-sub { color: var(--muted); font-size: 0.95rem; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; width: min(820px, 100%); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px; backdrop-filter: blur(6px); }
.panel h2 { margin: 6px 0 0; font-family: 'Bebas Neue', Impact, sans-serif; font-weight: 400; letter-spacing: 0.06em; font-size: 1.6rem; color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.field input, .join-row input, .chat input { background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 11px 12px; font-size: 1rem; outline: none; }
.field input:focus, .join-row input:focus, .chat input:focus { border-color: var(--accent); }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 0.3em; font-weight: 800; text-align: center; }
.check { font-size: 0.85rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }

.btn { background: rgba(255, 255, 255, 0.1); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font-weight: 800; transition: transform 0.08s, background 0.15s; }
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.18); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #fde047, #f59e0b); color: #1c1917; border: none; box-shadow: 0 4px 0 #92400e; }
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #fef08a, #fbbf24); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 0.85rem; }
.btn.big { font-size: 1.3rem; padding: 14px 40px; font-family: 'Bebas Neue', Impact, sans-serif; letter-spacing: 0.1em; font-weight: 400; }
.btn.ready-on { background: linear-gradient(180deg, #86efac, #16a34a); box-shadow: 0 4px 0 #14532d; }

.seg { display: flex; background: rgba(0, 0, 0, 0.3); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; background: none; border: none; color: var(--muted); padding: 8px; border-radius: 8px; font-weight: 600; }
.seg button.on { background: rgba(255, 255, 255, 0.15); color: var(--text); }

.rooms-title { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.room-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-height: 180px; overflow-y: auto; }
.room-item { display: flex; justify-content: space-between; align-items: center; background: rgba(0, 0, 0, 0.25); border-radius: 10px; padding: 8px 10px; font-size: 0.9rem; gap: 8px; }
.room-item b { letter-spacing: 0.15em; color: var(--accent); }
.room-item span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- SELEÇÃO ---------- */
#select { gap: 12px; }
.select-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.select-title { text-align: center; flex: 1; }
.select-title h2 { margin: 0; font-family: 'Bebas Neue', Impact, sans-serif; font-weight: 400; font-size: clamp(1.6rem, 4vw, 2.6rem); letter-spacing: 0.06em; color: var(--accent); }
.room-box { display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); padding: 6px 6px 6px 12px; border-radius: 12px; }
.room-box b { color: var(--accent); letter-spacing: 0.2em; font-size: 1.2rem; }
.select-body { display: grid; grid-template-columns: 220px 1fr 220px; gap: 16px; align-items: start; flex: 1; min-height: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; align-content: start; }
.card { position: relative; background: #fff; color: #1f2937; border-radius: 14px; padding: 10px 8px 8px; border: 3px solid transparent; text-align: center; transition: transform 0.1s; user-select: none; }
.card:hover { transform: translateY(-3px); }
.card img { width: 70px; height: 70px; border-radius: 50%; border: 3px solid #e5e7eb; display: block; margin: 0 auto 6px; }
.card .pct { position: absolute; top: 6px; right: 8px; font-weight: 800; color: #eab308; font-size: 0.75rem; }
.card .party { font-size: 0.65rem; font-weight: 800; color: #6b7280; letter-spacing: 0.05em; }
.card .nm { font-weight: 800; font-size: 0.82rem; line-height: 1.1; margin-top: 2px; min-height: 2.2em; display: flex; align-items: center; justify-content: center; }
.card.p0 { border-color: var(--p1); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.4), 0 0 24px rgba(59, 130, 246, 0.6); }
.card.p1 { border-color: var(--p2); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.4), 0 0 24px rgba(239, 68, 68, 0.6); }
.card.p0.p1 { border-color: #a855f7; }
.card .tag { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); font-size: 0.65rem; font-weight: 800; padding: 2px 8px; border-radius: 99px; color: #fff; white-space: nowrap; }
.card .tag.t0 { background: var(--p1); }
.card .tag.t1 { background: var(--p2); top: auto; bottom: -9px; }
.side { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; min-height: 260px; text-align: center; }
.side.s0 { border-color: rgba(59, 130, 246, 0.6); }
.side.s1 { border-color: rgba(239, 68, 68, 0.6); }
.side .who { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.12em; }
.side.s0 .who { color: #93c5fd; }
.side.s1 .who { color: #fca5a5; }
.side .pname { font-weight: 800; font-size: 1rem; margin: 2px 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side img { width: 120px; height: 120px; border-radius: 50%; border: 4px solid var(--accent); }
.side h3 { font-family: 'Bebas Neue', Impact, sans-serif; font-weight: 400; font-size: 1.6rem; margin: 6px 0 0; letter-spacing: 0.04em; line-height: 1; }
.side .meta { color: var(--muted); font-size: 0.8rem; margin-bottom: 8px; }
.side .mv { text-align: left; font-size: 0.8rem; background: rgba(0, 0, 0, 0.25); border-radius: 8px; padding: 6px 8px; margin-top: 6px; }
.side .mv b { color: var(--accent); }
.side .mv small { color: var(--muted); display: block; }
.side .status { margin-top: 10px; font-weight: 800; }
.side .status.ok { color: var(--ok); }
.side .empty { color: var(--muted); margin-top: 60px; }
.select-foot { display: flex; justify-content: center; align-items: center; gap: 16px; flex-wrap: wrap; padding-bottom: 8px; }
.score { font-weight: 800; color: var(--muted); }
.score b { color: var(--accent); }
.chat { position: fixed; right: 16px; bottom: 16px; width: min(320px, calc(100vw - 32px)); background: rgba(11, 10, 26, 0.92); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.chat-log { max-height: 120px; overflow-y: auto; font-size: 0.82rem; display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.chat-log b { color: var(--accent); }
.chat input { width: 100%; padding: 8px 10px; font-size: 0.9rem; }

/* ---------- JOGO ---------- */
#game { padding: 0; background: #000; align-items: center; justify-content: center; }
.game-bar { position: absolute; top: max(6px, env(safe-area-inset-top)); left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 0 8px; z-index: 5; pointer-events: none; }
.game-bar > * { pointer-events: auto; }
.game-bar .icon { background: rgba(0, 0, 0, 0.5); border: 1px solid var(--line); color: #fff; border-radius: 8px; width: 34px; height: 34px; font-size: 1rem; }
.game-bar .ping { margin-left: auto; margin-right: 8px; font-size: 0.75rem; color: var(--muted); background: rgba(0, 0, 0, 0.5); padding: 4px 8px; border-radius: 6px; }
.game-bar #btnMute { margin-right: 6px; }
.stage-wrap { width: 100%; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.stage { position: relative; width: min(100vw, calc(100dvh * 16 / 9)); aspect-ratio: 16 / 9; max-height: 100dvh; }
#cv { width: 100%; height: 100%; display: block; image-rendering: auto; }
.overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; backdrop-filter: blur(3px); }
.overlay h2 { font-family: 'Bebas Neue', Impact, sans-serif; font-weight: 400; font-size: clamp(2rem, 6vw, 3.5rem); margin: 0; color: var(--accent); letter-spacing: 0.06em; text-align: center; }
.overlay .btn { min-width: 240px; }
.overlay p { margin: 0; color: var(--muted); text-align: center; padding: 0 16px; }

.touch { position: fixed; left: 0; right: 0; bottom: 0; height: 42vh; pointer-events: none; z-index: 4; }
.touch .stick { position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: 18px; width: 150px; height: 150px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); border: 2px solid rgba(255, 255, 255, 0.25); pointer-events: auto; touch-action: none; }
.touch .knob { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); }
.touch .tbtns { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: 14px; display: grid; grid-template-columns: repeat(2, 76px); gap: 10px; pointer-events: auto; }
.touch .tbtns button { height: 66px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); background: rgba(250, 204, 21, 0.25); color: #fff; font-weight: 800; font-size: 0.68rem; touch-action: none; user-select: none; -webkit-user-select: none; }
.touch .tbtns button.on { background: rgba(250, 204, 21, 0.6); }
.touch .tbtns button.sup { background: rgba(239, 68, 68, 0.3); }

/* ---------- MODAL / TOAST ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.modal-card { position: relative; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(860px, 100%); max-height: 90dvh; overflow-y: auto; }
.modal-card h2 { font-family: 'Bebas Neue', Impact, sans-serif; font-weight: 400; color: var(--accent); margin: 0 0 8px; font-size: 1.8rem; letter-spacing: 0.05em; }
.close { position: absolute; top: 12px; right: 12px; background: none; border: none; color: var(--text); font-size: 1.3rem; }
.keys { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-bottom: 12px; }
.keys th, .keys td { border-bottom: 1px solid var(--line); padding: 6px; text-align: left; }
.keys th { color: var(--muted); font-weight: 600; }
.tips { font-size: 0.88rem; line-height: 1.5; padding-left: 18px; }
.move-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.move-item { display: flex; gap: 10px; background: rgba(0, 0, 0, 0.25); border-radius: 10px; padding: 8px; font-size: 0.8rem; align-items: center; }
.move-item img { width: 44px; height: 44px; border-radius: 50%; }
.move-item b { display: block; }
.move-item span { color: var(--muted); }
.toast { position: fixed; top: 16px; left: 50%; transform: translate(-50%, calc(-100% - 40px)); background: #1c1917; border: 1px solid var(--accent); color: var(--text); padding: 10px 16px; border-radius: 10px; transition: transform 0.25s; z-index: 30; max-width: calc(100vw - 32px); font-size: 0.9rem; }
.toast.show { transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .select-body { grid-template-columns: 1fr 1fr; }
  .grid { grid-column: 1 / -1; order: -1; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
  .card img { width: 54px; height: 54px; }
  .card .nm { font-size: 0.72rem; }
  .side { min-height: 0; padding: 10px; }
  .side img { width: 70px; height: 70px; }
  .side .mv { display: none; }
  .side .empty { margin-top: 10px; }
}
