:root {
  --panel-top: #1b2a4a;
  --panel-bottom: #0b1226;
  --bevel-light: #8fb0ff;
  --bevel-dark: #0a1020;
  --text: #f4f1e8;
  --muted: #9fb0d8;
  --accent: #f5c518;
  --p1: #3aa0ff;
  --p2: #ff4a4a;
  --good: #3ddc84;
  --bad: #ff5a4a;
  --title-font: 'Press Start 2P', monospace;
  --body-font: 'VT323', monospace;
}

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  overflow: hidden;
  color: var(--text);
  font-family: var(--body-font);
  user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  display: block;
}

#ui, #hud, #toast {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#ui > *, #toast > * { pointer-events: auto; }

.pixel { image-rendering: pixelated; }

/* ---------- painéis ---------- */
.panel {
  background: linear-gradient(var(--panel-top), var(--panel-bottom));
  border: 3px solid;
  border-color: var(--bevel-light) var(--bevel-dark) var(--bevel-dark) var(--bevel-light);
  box-shadow: 0 0 0 2px #000, 6px 6px 0 rgba(0, 0, 0, 0.5);
  padding: 16px 20px;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  pointer-events: auto;
}
.screen.dim { background: rgba(5, 8, 20, 0.55); }
.screen.black { background: #000; }

h1, h2, h3 { font-family: var(--title-font); margin: 0; font-weight: normal; }
h2 { font-size: clamp(14px, 2.2vw, 22px); color: var(--accent); text-shadow: 3px 3px 0 #000; text-align: center; }

.hint {
  font-size: clamp(16px, 1.8vw, 22px);
  color: var(--muted);
  text-shadow: 2px 2px 0 #000;
  text-align: center;
}

/* ---------- logo ---------- */
.logo {
  font-family: var(--title-font);
  font-size: clamp(34px, 8vw, 96px);
  line-height: 1.1;
  text-align: center;
  color: var(--accent);
  text-shadow: 4px 4px 0 #c8102e, 8px 8px 0 #000;
  letter-spacing: 4px;
}
.logo small { display: block; font-size: 0.32em; color: var(--text); text-shadow: 3px 3px 0 #000; letter-spacing: 6px; margin-top: 10px; }
.blink { animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

.press-start {
  font-family: var(--title-font);
  font-size: clamp(14px, 2.2vw, 22px);
  color: var(--text);
  text-shadow: 3px 3px 0 #000;
}

/* ---------- boot ---------- */
.boot-logo { display: grid; grid-template-columns: repeat(3, 34px); gap: 6px; animation: bootIn 2.2s ease-out forwards; }
.boot-logo i { width: 34px; height: 34px; background: #2a4ad8; box-shadow: 0 0 18px #4a7aff; opacity: 0; animation: cube 2.2s ease-out forwards; }
.boot-logo i:nth-child(odd) { background: #6a8cff; }
@keyframes cube { 30% { opacity: 1; } 100% { opacity: 1; } }
@keyframes bootIn { from { transform: scale(0.4) rotate(-30deg); filter: blur(6px); } to { transform: none; filter: none; } }
.boot-text { font-family: var(--title-font); font-size: 14px; letter-spacing: 8px; color: #cfd8ff; opacity: 0; animation: fadeIn 1s 1.2s forwards; }
@keyframes fadeIn { to { opacity: 1; } }

/* ---------- menus ---------- */
.menu { display: flex; flex-direction: column; gap: 6px; min-width: min(480px, 88vw); }
.item {
  font-family: var(--title-font);
  font-size: clamp(11px, 1.5vw, 15px);
  padding: 10px 14px 10px 34px;
  position: relative;
  color: var(--text);
  text-shadow: 2px 2px 0 #000;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border: 2px solid transparent;
}
.item .val { color: var(--accent); white-space: nowrap; }
.item.focus { background: linear-gradient(90deg, rgba(90, 140, 255, 0.55), rgba(90, 140, 255, 0.05)); border-color: rgba(143, 176, 255, 0.6); }
.item.focus::before { content: '▶'; position: absolute; left: 10px; color: var(--accent); animation: blink 0.8s steps(2, start) infinite; }
.item.disabled { opacity: 0.45; }

input.code {
  font-family: var(--title-font);
  font-size: 28px;
  width: 7ch;
  text-align: center;
  letter-spacing: 8px;
  text-transform: uppercase;
  background: #050a18;
  color: var(--accent);
  border: 3px solid var(--bevel-light);
  padding: 10px;
  outline: none;
}

.room-code { font-family: var(--title-font); font-size: clamp(32px, 6vw, 64px); color: var(--accent); letter-spacing: 12px; text-shadow: 4px 4px 0 #000; }
.status-line { font-size: 24px; text-shadow: 2px 2px 0 #000; }
.status-line.ok { color: var(--good); }
.status-line.err { color: var(--bad); }

/* ---------- seleção de jogo ---------- */
.cards { display: flex; gap: 28px; flex-wrap: wrap; justify-content: center; }
.card { width: min(340px, 80vw); cursor: pointer; transition: transform 0.12s; }
.card.focus { transform: scale(1.06); border-color: var(--accent) #6a5410 #6a5410 var(--accent); }
.card h3 { font-size: 16px; color: var(--accent); margin-bottom: 10px; text-shadow: 2px 2px 0 #000; }
.card p { font-size: 20px; margin: 4px 0; line-height: 1.05; }
.card .icon { height: 90px; display: flex; align-items: flex-end; justify-content: center; gap: 4px; margin-bottom: 10px; }
.cup-icon { width: 22px; height: 28px; background: linear-gradient(90deg, #8a0a1e, #e8203e 50%, #8a0a1e); clip-path: polygon(0 0, 100% 0, 82% 100%, 18% 100%); }
.cup-icon.flip { transform: rotate(180deg); }

/* ---------- seleção de personagem ---------- */
.cs { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(220px, 26vw) 1fr minmax(220px, 26vw); gap: 12px; padding: 14px; box-sizing: border-box; pointer-events: auto; }
.cs-center { display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 10px; }
.cs-bottom { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.cs-grid { display: grid; grid-template-columns: repeat(6, auto); gap: 6px; padding: 10px; }
.cs-cell { position: relative; width: clamp(44px, 5.4vw, 70px); aspect-ratio: 5 / 6; border: 3px solid #0a1020; cursor: pointer; background: #000; }
.cs-cell img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.cs-cell.p1 { border-color: var(--p1); }
.cs-cell.p2 { border-color: var(--p2); }
.cs-cell.p1.p2 { border-color: var(--p1) var(--p2) var(--p2) var(--p1); }
.cs-cell .tag { position: absolute; top: -12px; font-family: var(--title-font); font-size: 9px; padding: 2px 3px; color: #fff; text-shadow: 1px 1px 0 #000; }
.cs-cell .tag.t1 { left: -4px; background: var(--p1); }
.cs-cell .tag.t2 { right: -4px; background: var(--p2); }
.cs-side { display: flex; flex-direction: column; gap: 8px; align-self: start; }
.cs-side.p1 { border-color: var(--p1) #0a2a50 #0a2a50 var(--p1); }
.cs-side.p2 { border-color: var(--p2) #501010 #501010 var(--p2); }
.cs-side .who { font-family: var(--title-font); font-size: 12px; }
.cs-side.p1 .who { color: var(--p1); }
.cs-side.p2 .who { color: var(--p2); }
.cs-side .name { font-family: var(--title-font); font-size: clamp(11px, 1.3vw, 15px); color: var(--text); }
.cs-side .nick { font-size: 22px; color: var(--accent); }
.cs-side .ready { font-family: var(--title-font); font-size: 12px; color: var(--good); }
.stat { display: grid; grid-template-columns: 7.5em 1fr; align-items: center; font-size: 20px; }
.bar { display: flex; gap: 3px; }
.bar i { flex: 1; height: 12px; background: #1a2440; border: 1px solid #000; }
.bar i.on { background: linear-gradient(#ffe066, #f5a318); }
.special { font-size: 19px; line-height: 1.05; color: #d8e0ff; }
.special b { font-family: var(--title-font); font-size: 10px; color: var(--accent); display: block; margin-bottom: 4px; }
.cs-side .dance { font-size: 19px; color: var(--muted); }
.cs-side .dance b { font-weight: normal; color: var(--accent); }

/* ---------- HUD ---------- */
#hud { font-family: var(--body-font); }
.hud-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.hud-card { display: flex; gap: 10px; align-items: center; padding: 8px 12px; min-width: 250px; }
.hud-card.p1 { border-color: var(--p1) #0a2a50 #0a2a50 var(--p1); }
.hud-card.p2 { border-color: var(--p2) #501010 #501010 var(--p2); flex-direction: row-reverse; text-align: right; }
.hud-card.active { box-shadow: 0 0 0 2px #000, 0 0 16px var(--accent); }
.hud-face { width: 46px; height: 55px; image-rendering: pixelated; border: 2px solid #000; }
.hud-name { font-family: var(--title-font); font-size: 11px; }
.hud-sub { font-size: 19px; color: var(--muted); }
.cups-mini { display: flex; gap: 3px; margin: 3px 0; }
.p2 .cups-mini { justify-content: flex-end; }
.cups-mini i { width: 12px; height: 14px; background: #c8102e; clip-path: polygon(0 0, 100% 0, 80% 100%, 20% 100%); }
.cups-mini i.gone { background: #333; }
.drunk { height: 8px; width: 120px; background: #1a2440; border: 1px solid #000; }
.p2 .drunk { margin-left: auto; }
.drunk > i { display: block; height: 100%; background: linear-gradient(90deg, #f5c518, #ff7a18, #ff2a2a); }
.special-pill { font-family: var(--title-font); font-size: 9px; padding: 3px 5px; background: #2a3a6a; border: 1px solid var(--bevel-light); display: inline-block; margin-top: 3px; }
.special-pill .chg { font-style: normal; letter-spacing: 1px; color: #6a7aa8; }
.special-pill.armed { background: #7a5a00; border-color: var(--accent); }
.special-pill.ready { background: #7a5a00; border-color: var(--accent); animation: glow 0.8s ease-in-out infinite alternate; }
.special-pill.ready .chg { color: var(--accent); }
@keyframes glow { to { box-shadow: 0 0 12px var(--accent); } }
.mugs { font-size: 20px; margin-left: 6px; }
.hud-center { text-align: center; padding-top: 4px; }
.turn { font-family: var(--title-font); font-size: clamp(11px, 1.4vw, 15px); text-shadow: 2px 2px 0 #000; }
.throws { font-size: 24px; letter-spacing: 4px; color: var(--accent); text-shadow: 2px 2px 0 #000; }
.status-badge { font-family: var(--title-font); font-size: 11px; color: #ff9a2a; text-shadow: 2px 2px 0 #000; }

.meters { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); display: flex; gap: 22px; align-items: flex-end; }
.meter-h { width: min(420px, 60vw); height: 22px; position: relative; background: linear-gradient(90deg, #c8102e, #f5c518 35%, #3ddc84 50%, #f5c518 65%, #c8102e); border: 3px solid #000; box-shadow: 0 0 0 2px var(--bevel-light); }
.meter-v { width: 22px; height: 160px; position: relative; background: linear-gradient(0deg, #1a2440, #3ddc84 55%, #f5c518 78%, #c8102e); border: 3px solid #000; box-shadow: 0 0 0 2px var(--bevel-light); }
.meter-h .mk { position: absolute; top: -8px; width: 6px; height: 34px; background: #fff; border: 2px solid #000; transform: translateX(-50%); }
.meter-v .mk { position: absolute; left: -8px; width: 34px; height: 6px; background: #fff; border: 2px solid #000; transform: translateY(50%); }
.meter-label { font-family: var(--title-font); font-size: 10px; text-align: center; margin-top: 6px; text-shadow: 2px 2px 0 #000; }
.locked .mk { background: var(--accent); }
.dim-meter { opacity: 0.35; }

.hint-bar { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; font-size: 21px; color: #dfe6ff; text-shadow: 2px 2px 0 #000; }

.popup {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%);
  font-family: var(--title-font); font-size: clamp(22px, 5vw, 54px); color: var(--accent);
  text-shadow: 4px 4px 0 #c8102e, 7px 7px 0 #000; white-space: nowrap;
  animation: pop 1.3s ease-out forwards;
}
.popup.fire { color: #ffb02a; text-shadow: 4px 4px 0 #c81e0e, 7px 7px 0 #000; }
.popup.small { font-size: clamp(14px, 2.6vw, 28px); top: 30%; }
.popup.big { font-size: clamp(40px, 10vw, 120px); }
@keyframes pop {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  25% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(1); opacity: 0; }
}

.radio {
  position: absolute; left: 12px; bottom: 12px; font-size: 22px; padding: 6px 12px;
  transform: translateX(-120%); transition: transform 0.4s ease-out;
}
.radio.show { transform: none; }
.radio b { font-family: var(--title-font); font-size: 10px; color: var(--accent); margin-right: 6px; }

/* flip cup */
.fc-team { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px; min-width: 260px; }
.fc-team.p1 { border-color: var(--p1) #0a2a50 #0a2a50 var(--p1); }
.fc-team.p2 { border-color: var(--p2) #501010 #501010 var(--p2); }
.fc-faces { display: flex; gap: 6px; }
.fc-faces .f { position: relative; }
.fc-faces img { width: 38px; height: 46px; image-rendering: pixelated; border: 2px solid #000; opacity: 0.55; }
.fc-faces .f.active img { opacity: 1; border-color: var(--accent); }
.fc-faces .f.done img { opacity: 1; filter: grayscale(0.6); }
.fc-faces .f.done::after { content: '✓'; position: absolute; right: 2px; bottom: 0; color: var(--good); font-size: 26px; text-shadow: 2px 2px 0 #000; }
.fc-bar { height: 16px; background: #1a2440; border: 2px solid #000; position: relative; }
.fc-bar > i { display: block; height: 100%; background: linear-gradient(90deg, #e0a52a, #ffe08a); }
.fc-bar .zone { position: absolute; top: 0; bottom: 0; background: rgba(61, 220, 132, 0.8); }
.fc-bar .mk { position: absolute; top: -5px; width: 4px; height: 22px; background: #fff; border: 1px solid #000; transform: translateX(-50%); }
.fc-label { font-family: var(--title-font); font-size: 9px; color: var(--muted); }
.wins { font-family: var(--title-font); font-size: 12px; color: var(--accent); }

/* resultados */
.results { text-align: center; min-width: min(560px, 90vw); }
.results .winner-face { width: 96px; height: 115px; image-rendering: pixelated; border: 3px solid var(--accent); margin: 8px auto; display: block; }
.results table { margin: 10px auto; border-collapse: collapse; font-size: 22px; }
.results td, .results th { padding: 2px 14px; }
.results th { font-family: var(--title-font); font-size: 10px; color: var(--muted); font-weight: normal; }

.controls-table { border-collapse: collapse; font-size: 22px; }
.controls-table td, .controls-table th { padding: 4px 16px; border-bottom: 1px solid #22335a; }
.controls-table th { font-family: var(--title-font); font-size: 11px; color: var(--accent); font-weight: normal; }

.credits { text-align: center; font-size: 22px; line-height: 1.3; max-width: 640px; }
.credits .names { columns: 2; margin: 10px 0; }

/* toast */
#toast { display: flex; justify-content: center; align-items: flex-start; padding-top: 24px; }
.toast-msg { font-family: var(--title-font); font-size: 12px; padding: 12px 18px; animation: pop 3.2s ease-out forwards; position: static; transform: none; }

.loading-bar { width: min(420px, 70vw); height: 14px; border: 3px solid var(--bevel-light); background: #050a18; }
.loading-bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #3a6aff, #8fb0ff); transition: width 0.1s; }

@media (max-width: 760px) {
  .cs { grid-template-columns: 1fr; overflow-y: auto; }
  .hud-card { min-width: 0; }
}

/* escolha do local */
.map-card { width: min(270px, 80vw); }
.map-icon { font-size: 54px; line-height: 90px; }
