:root {
  --bg: #12141c;
  --panel: #1c1f2b;
  --line: #2c3142;
  --text: #eef0f6;
  --muted: #9aa1b5;
  --accent: #ff7a2f;
  --accent2: #ffd23d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(circle at 50% 0%, #20253a 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
.hidden { display: none !important; }
button {
  font: inherit; color: var(--text); background: #2a2f40; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; cursor: pointer; transition: transform .08s, background .15s;
}
button:hover { background: #343a4f; }
button:active { transform: scale(.97); }
button.primary { background: linear-gradient(180deg, #ff8c42, #f0611c); border-color: #f0611c; font-weight: 700; color: #fff; }
button.primary:hover { background: linear-gradient(180deg, #ff9b57, #f56f2c); }
input {
  font: inherit; width: 100%; margin-top: 6px; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #11131b; color: var(--text); outline: none;
}
input:focus { border-color: var(--accent); }

/* ----- menu ----- */
#menu { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card {
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 24px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
h1 { margin: 0; text-align: center; font-size: 44px; letter-spacing: 2px; font-weight: 900; line-height: 1; }
h1 span { color: var(--accent); margin-left: 8px; }
.tag { margin: -4px 0 6px; text-align: center; color: var(--muted); }
label { font-size: 14px; color: var(--muted); }
.help { font-size: 13px; color: var(--muted); line-height: 1.6; border-top: 1px solid var(--line); padding-top: 12px; }
.help b { color: var(--text); }

/* ----- jogo ----- */
#game {
  display: grid; grid-template-columns: 1fr 270px; gap: 16px; padding: 12px 16px;
  min-height: 100%; align-items: start;
}
#main { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
#hud {
  width: min(100%, calc((100vh - 70px) * 17 / 13)); display: flex; justify-content: space-between;
  font-weight: 700; font-size: 15px; min-height: 22px;
}
#hudTime.danger { color: #ff5252; }
#stage {
  position: relative; width: min(100%, calc((100vh - 70px) * 17 / 13)); aspect-ratio: 17 / 13;
  border-radius: 12px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
canvas { display: block; width: 100%; height: 100%; image-rendering: auto; background: #2f6b3a; }
#overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; text-align: center; pointer-events: none; padding: 16px;
}
#overlay.dim { background: rgba(10, 12, 20, .55); }
#overlay .big { font-size: clamp(36px, 9vw, 96px); font-weight: 900; text-shadow: 0 4px 0 rgba(0,0,0,.4); }
#overlay .mid { font-size: clamp(18px, 3.4vw, 32px); font-weight: 800; text-shadow: 0 3px 0 rgba(0,0,0,.4); }
#overlay .sub { color: #d7dbea; font-size: clamp(13px, 2vw, 17px); }
#overlay button { pointer-events: auto; font-size: 20px; padding: 14px 26px; }
#overlay .banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.6);
  padding: 6px 14px; border-radius: 999px; font-size: 14px; white-space: nowrap;
}

#side {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px; position: sticky; top: 12px;
}
.small { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.roomBox { display: flex; flex-direction: column; gap: 6px; }
#roomName { font-size: 22px; font-weight: 800; color: var(--accent2); word-break: break-all; }
#plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#plist li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #151823;
  border-radius: 10px; border: 1px solid var(--line); font-size: 14px;
}
#plist li.me { border-color: var(--accent); }
#plist li.dead { opacity: .45; }
#plist .dot { width: 16px; height: 16px; border-radius: 50%; flex: none; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
#plist .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#plist .sc { color: var(--muted); font-size: 12px; white-space: nowrap; }
.voiceBox { display: flex; flex-direction: column; }
#voiceBtn { background: #1f3a2a; border-color: #2f6b45; }
#voiceBtn:hover { background: #26482f; }
#voiceCtl { display: flex; gap: 6px; }
#muteBtn { flex: 1; background: #1f3a2a; border-color: #2f6b45; }
#muteBtn.off { background: #4a1f24; border-color: #8a2f38; }
#deafBtn.off { background: #4a1f24; border-color: #8a2f38; }
#deafBtn, #voiceLeave { flex: none; padding: 10px 12px; }
#plist .vc { font-size: 13px; transition: filter .1s; }
#plist .vc.talk { filter: drop-shadow(0 0 4px #3ddc6a); }
#plist li.talking { border-color: #3ddc6a; }
.small .hint { text-transform: none; letter-spacing: 0; opacity: .7; }
#chat { display: flex; flex-direction: column; gap: 6px; }
#chatLog {
  height: 190px; overflow-y: auto; background: #151823; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font-size: 13px; line-height: 1.45; display: flex; flex-direction: column; gap: 3px;
  overflow-wrap: anywhere;
}
#chatLog .sys { color: var(--muted); font-style: italic; font-size: 12px; }
#chatLog .who { font-weight: 700; }
#chatLog:empty::before { content: "Nenhuma mensagem ainda"; color: var(--muted); font-size: 12px; }
#chatForm { display: flex; gap: 6px; }
#chatForm input { margin-top: 0; padding: 9px 10px; font-size: 14px; }
#chatForm button { padding: 0 14px; flex: none; }
.footer { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }

/* ----- toque ----- */
#touch { display: none; width: 100%; justify-content: space-between; align-items: center; padding: 6px 8px; user-select: none; touch-action: none; }
body.touch #touch { display: flex; }
#pad {
  width: 150px; height: 150px; border-radius: 50%; background: rgba(255,255,255,.07);
  border: 2px solid rgba(255,255,255,.15); position: relative; touch-action: none;
}
#knob {
  position: absolute; width: 60px; height: 60px; left: 45px; top: 45px; border-radius: 50%;
  background: rgba(255,255,255,.25); pointer-events: none; transition: transform .05s;
}
#bombBtn {
  width: 110px; height: 110px; border-radius: 50%; font-size: 46px; touch-action: none;
  background: radial-gradient(circle at 35% 30%, #ff9b57, #d94f12); border: 3px solid #ffb27a;
}

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2a2f40;
  border: 1px solid var(--line); padding: 10px 18px; border-radius: 999px; z-index: 10;
}

@media (max-width: 900px) {
  #game { grid-template-columns: 1fr; padding: 8px; gap: 10px; }
  #hud, #stage { width: 100%; }
  #side { position: static; }
}
