:root {
  --bg: #0b0812; --panel: #15101f; --panel2: #1d1630; --line: #34284d; --text: #ece6f7; --muted: #a59bb8;
  --neon: #a855f7; --neon2: #d8b4fe; --gold: #facc15; --red: #ef4444; --green: #4ade80; --twitch: #9146ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
#app { height: 100%; }
.screen { height: 100%; }

/* ---------- Lobby ---------- */
#lobby { display: flex; gap: 18px; align-items: stretch; justify-content: center; padding: 18px; overflow: auto;
  background: radial-gradient(circle at 20% 10%, rgba(168,85,247,0.22), transparent 50%), radial-gradient(circle at 90% 90%, rgba(80,140,255,0.15), transparent 50%), var(--bg); }
.lobby-card, .rank-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.lobby-card { max-width: 560px; flex: 1 1 460px; }
.rank-card { width: 330px; flex: 0 1 330px; display: flex; flex-direction: column; }
.logo { font-size: 54px; font-weight: 900; margin: 0; letter-spacing: -1px; text-transform: uppercase;
  background: linear-gradient(90deg, #fff, var(--neon2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo span { background: linear-gradient(90deg, var(--neon), #ff6bd5); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tag { color: var(--muted); margin: 4px 0 16px; }
.who { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel2); border-radius: 10px; margin-bottom: 14px; min-height: 48px; }
.who img { width: 32px; height: 32px; border-radius: 50%; }
.lobby-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.msg { color: var(--neon2); min-height: 20px; margin: 10px 0; }
.howto { color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 6px; }
.howto b { color: var(--text); }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab { flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px; cursor: pointer; }
.tab.on { border-color: var(--neon); color: #fff; background: rgba(168,85,247,0.2); }
.rank { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.rank li { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.rank li .pos { width: 22px; text-align: right; color: var(--muted); font-weight: 800; }
.rank li img { width: 24px; height: 24px; border-radius: 50%; background: #333; }
.rank li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank li .sc { font-weight: 800; color: var(--gold); }
.rank li.me { background: rgba(168,85,247,0.15); border-radius: 6px; }
.muted { color: var(--muted); }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; cursor: pointer; transition: transform .08s, border-color .15s, background .15s; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--neon); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.big { padding: 12px 26px; font-size: 17px; font-weight: 800; background: linear-gradient(90deg, #7c3aed, #a855f7); border-color: #b47cff; }
.btn.twitch { background: var(--twitch); border-color: #b18bff; }
.btn.sm { padding: 6px 10px; }
.btn.go { background: linear-gradient(90deg, #15803d, #22c55e); border-color: #4ade80; font-weight: 800; }
.btn.go.running { background: var(--panel2); border-color: var(--line); font-weight: 600; }
.btn.danger:hover { border-color: var(--red); }
kbd { font-size: 10px; background: rgba(0,0,0,0.35); padding: 1px 5px; border-radius: 4px; margin-left: 4px; opacity: 0.8; }

/* ---------- Jogo ---------- */
#game { display: flex; flex-direction: column; }
.hud { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.stat { display: flex; align-items: center; gap: 6px; background: var(--panel2); padding: 5px 12px; border-radius: 8px; font-size: 15px; }
.stat b { font-size: 17px; }
.stat small { color: var(--muted); }
.stat .ico { color: var(--neon2); font-weight: 900; }
.spacer { flex: 1; }
.auto { display: flex; gap: 4px; align-items: center; color: var(--muted); cursor: pointer; }
.play { flex: 1; display: flex; min-height: 0; }
.board { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; background: #07050b; }
#cv { display: block; touch-action: none; border-radius: 6px; }
.side { width: 270px; background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.shop { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; cursor: pointer; text-align: center; position: relative; user-select: none; }
.card:hover { border-color: var(--neon); }
.card.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.card.poor { opacity: 0.45; }
.card canvas { width: 64px; height: 64px; display: block; margin: 0 auto; }
.card .n { font-weight: 800; font-size: 13px; }
.card .r { font-size: 11px; color: var(--muted); }
.card .c { color: var(--gold); font-weight: 800; }
.card .k { position: absolute; top: 4px; left: 6px; font-size: 10px; color: var(--muted); }
.sel { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.sel h3 { margin: 0; font-size: 16px; }
.sel .sub { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.sel .row { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.sel .mode { flex: 1; text-align: center; font-weight: 700; }
.paths { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.up { border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: 12px; background: rgba(0,0,0,0.2); }
.up .t { font-weight: 800; font-size: 12px; }
.up .d { color: var(--muted); font-size: 11px; min-height: 28px; }
.up .pips { display: flex; gap: 3px; margin-bottom: 4px; }
.up .pip { flex: 1; height: 5px; border-radius: 3px; background: #2b2340; }
.up .pip.on { background: var(--green); }
.up.b .pip.on { background: #60a5fa; }
.up button { width: 100%; margin-top: 4px; padding: 5px; font-size: 12px; }
.up.max { opacity: 0.8; }
.next { font-size: 12px; color: var(--muted); background: rgba(0,0,0,0.2); border-radius: 10px; padding: 8px; }
.next b { color: var(--text); }
.toast { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: rgba(10,6,16,0.9); border: 1px solid var(--line); padding: 6px 14px; border-radius: 8px; pointer-events: none; opacity: 0; transition: opacity .2s; }
.toast.show { opacity: 1; }
.banner { position: absolute; left: 50%; top: 40%; transform: translate(-50%,-50%); font-size: 40px; font-weight: 900; text-transform: uppercase; color: #fff; text-shadow: 0 0 18px var(--neon), 0 3px 0 #000; pointer-events: none; opacity: 0; transition: opacity .3s; text-align: center; }
.banner.show { opacity: 1; }
.banner small { display: block; font-size: 16px; color: var(--neon2); }

.modal { position: fixed; inset: 0; background: rgba(5,3,10,0.75); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal-card { background: var(--panel); border: 1px solid var(--neon); border-radius: 16px; padding: 24px; max-width: 420px; text-align: center; }
.modal-card h2 { margin: 0 0 8px; font-size: 28px; }
.modal-card .lobby-actions { justify-content: center; }

@media (max-width: 820px) {
  #lobby { flex-direction: column; }
  .rank-card { width: auto; flex: 1 1 auto; min-height: 260px; }
  .play { flex-direction: column; }
  .side { width: auto; border-left: 0; border-top: 1px solid var(--line); max-height: 42%; }
  .shop { display: flex; overflow-x: auto; gap: 6px; }
  .card { min-width: 74px; }
  .card canvas { width: 40px; height: 40px; }
  .card .r { display: none; }
  .hud { gap: 6px; padding: 6px; }
  .btn.go kbd { display: none; }
  .logo { font-size: 40px; }
}

.rotate { display: none; }
@media (max-width: 820px) and (orientation: portrait) {
  .rotate { display: block; position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); font-size: 12px; color: var(--muted); background: rgba(0,0,0,0.6); padding: 3px 10px; border-radius: 8px; pointer-events: none; }
}
