/* Câmara dos Corruptos: interface em papel de Diário Oficial */
:root {
  --paper: #f3ead3;
  --paper-dark: #e4d7b6;
  --ink: #1f1b16;
  --ink-soft: #5a5145;
  --red: #b3261e;
  --green: #1f6b3a;
  --gold: #c9a227;
  --night: #16241c;
  --serif: Georgia, 'Times New Roman', serif;
  --mono: 'Courier New', Courier, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--night);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.hidden { display: none !important; }

/* ---------- papel ---------- */
.paper-bg {
  background:
    repeating-linear-gradient(0deg, rgba(60, 40, 10, .045) 0 1px, transparent 1px 28px),
    radial-gradient(ellipse at 30% 20%, #f8f1df, var(--paper) 60%, var(--paper-dark));
}
.screen { position: fixed; inset: 0; }
#screen-home, #screen-lobby { display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.sheet {
  width: min(560px, 100%);
  padding: 28px 28px 22px;
  background: rgba(255, 252, 240, .7);
  border: 3px double var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.masthead { display: flex; align-items: center; gap: 14px; position: relative; border-bottom: 3px double var(--ink); padding-bottom: 14px; margin-bottom: 14px; }
.brasao { width: 76px; height: 76px; flex: none; color: var(--ink); }
.kicker { margin: 0 0 4px; font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
h1 { margin: 0; font-size: clamp(28px, 7vw, 42px); line-height: 1; letter-spacing: -.01em; text-wrap: balance; }
h2 { margin: 0; font-size: clamp(24px, 5vw, 38px); line-height: 1.05; text-wrap: balance; }
.lead { margin: 0 0 18px; font-size: 18px; color: var(--ink-soft); text-wrap: pretty; }
.fineprint { margin: 16px 0 0; font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.error { min-height: 22px; margin: 10px 0 0; color: var(--red); font-weight: 700; }

/* ---------- carimbos ---------- */
.stamp {
  display: inline-block;
  padding: 4px 12px;
  border: 4px solid var(--red);
  border-radius: 6px;
  color: var(--red);
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  transform: rotate(-8deg);
  opacity: .88;
  white-space: nowrap;
}
.stamp.urgent { position: absolute; right: -16px; top: -34px; font-size: 14px; background: rgba(255, 252, 240, .85); }
.stamp.green { border-color: var(--green); color: var(--green); }

/* ---------- formulário ---------- */
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
input {
  width: 100%;
  padding: 12px 14px;
  font: 700 20px var(--serif);
  color: var(--ink);
  background: #fffdf5;
  border: 2px solid var(--ink);
  border-radius: 0;
  user-select: text;
}
input:focus-visible, .btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.code-input { width: 150px; text-align: center; text-transform: uppercase; letter-spacing: .3em; font-family: var(--mono); }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }
.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; font-family: var(--mono); font-size: 12px; text-transform: uppercase; color: var(--ink-soft); }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--ink-soft); }

.btn {
  padding: 12px 18px;
  font: 700 18px var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink);
  background: #fffdf5;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { width: 100%; background: var(--ink); color: var(--paper); box-shadow: 3px 3px 0 var(--gold); }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn.danger { background: var(--red); color: #fff; }
.btn.good { background: var(--green); color: #fff; }

/* ---------- lobby ---------- */
.code-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.big-code { font: 700 clamp(48px, 16vw, 84px)/1 var(--mono); letter-spacing: .12em; }
.player-list { list-style: none; margin: 0 0 18px; padding: 0; border-top: 2px solid var(--ink); }
.player-list li { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px dashed var(--ink-soft); font-size: 20px; font-weight: 700; }
.tie { width: 14px; height: 26px; flex: none; clip-path: polygon(50% 0, 100% 18%, 72% 100%, 50% 88%, 28% 100%, 0 18%); border-radius: 2px; }
.tag { margin-left: auto; padding: 2px 8px; border: 1px solid var(--ink); font: 700 11px var(--mono); letter-spacing: .08em; }
.tag + .tag { margin-left: 0; }

/* ---------- jogo ---------- */
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; background: var(--night); }
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 10px 0;
  pointer-events: none;
}
.hud-card {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 6px 12px;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, .5);
  font-family: var(--mono);
  color: var(--ink);
  text-align: left;
}
.hud-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.hud-value { font-size: clamp(20px, 3.2vw, 30px); font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hud-card.crime .hud-value { color: var(--red); }
.hud-card.role { margin-left: auto; pointer-events: auto; cursor: pointer; }
.hud-card.role .hud-value { font-size: clamp(15px, 2.4vw, 22px); }
.hud-card.role.corrupto .hud-value { color: var(--red); }
.hud-card.role.honesto .hud-value { color: var(--green); }
.hud-card.role.laranja .hud-value { color: #c05a00; }

#banner {
  position: absolute; left: 0; right: 0; top: 22%;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: var(--red); color: #fff;
  border-block: 4px solid #fff;
  font: 700 clamp(18px, 3.4vw, 30px)/1.15 var(--serif);
  animation: slide-in .35s ease-out;
  z-index: 30;
}
.plantao { flex: none; padding: 4px 10px; background: #fff; color: var(--red); font: 700 clamp(14px, 2vw, 20px) var(--mono); letter-spacing: .1em; text-transform: uppercase; }
@keyframes slide-in { from { transform: translateX(-100%); } to { transform: none; } }

#toasts { position: absolute; left: 50%; top: 88px; transform: translateX(-50%); width: min(640px, 94vw); display: flex; flex-direction: column; gap: 8px; pointer-events: none; z-index: 25; }
.toast {
  padding: 10px 14px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-left: 10px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .5);
  font-size: clamp(16px, 2.4vw, 20px);
  font-weight: 700;
  animation: toast-in .25s ease-out;
}
.toast.good { border-left-color: var(--green); }
.toast.bad { border-left-color: var(--red); }
.toast small { display: block; font: 400 13px var(--mono); color: var(--ink-soft); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

#buttons { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: flex-end; gap: 12px; z-index: 10; }
.btn.action { min-width: 190px; padding: 16px 18px; font-size: 20px; background: var(--gold); }
.btn.denuncia { min-width: 190px; padding: 16px 18px; font-size: 22px; background: var(--red); color: #fff; border-color: #fff; box-shadow: 3px 3px 0 #000; }

#holds, #hands { display: flex; gap: 8px; }
.btn.hold { padding: 9px 12px; font-size: 15px; touch-action: none; user-select: none; -webkit-user-select: none; }
.btn.hold kbd { margin-left: 4px; padding: 1px 6px; font: 700 12px var(--mono); border: 1px solid currentColor; border-radius: 3px; opacity: .75; }
.btn.hold.on { background: var(--green); color: #fff; }
@media (pointer: coarse) { .btn.hold kbd { display: none; } .btn.hold { padding: 13px 14px; font-size: 16px; } }
#deal { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); width: min(420px, 78vw); padding: 8px 12px 10px; background: var(--paper); border: 2px solid var(--ink); box-shadow: 3px 3px 0 rgba(0, 0, 0, .5); font-weight: 700; text-align: center; z-index: 12; pointer-events: none; }
.dealbar { height: 12px; margin-top: 6px; background: rgba(0, 0, 0, .18); border: 1px solid var(--ink); }
.dealbar i { display: block; height: 100%; background: var(--green); transform-origin: left; transform: scaleX(0); }

#joystick { position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); width: 130px; height: 130px; border-radius: 50%; background: rgba(243, 234, 211, .25); border: 3px solid rgba(243, 234, 211, .7); touch-action: none; z-index: 10; display: none; }
#stick { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: var(--paper); border: 3px solid var(--ink); }
@media (pointer: coarse) { #joystick { display: block; } }

#voicebar { position: fixed; left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); display: flex; gap: 8px; z-index: 46; }
@media (pointer: coarse) { #voicebar { left: 50%; transform: translateX(-50%); } }
#btn-voice.on { background: var(--green); color: #fff; }
#btn-mute.muted { background: var(--red); color: #fff; }

/* ---------- camadas ---------- */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 40; overflow: auto; }
#modal { background: rgba(10, 14, 12, .6); }
.card {
  width: min(560px, 100%);
  padding: 20px;
  background: var(--paper);
  border: 3px double var(--ink);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.card h3 { margin: 0 0 4px; font-size: clamp(22px, 4vw, 30px); }
.card p { margin: 6px 0; }
.card .mono { font-family: var(--mono); font-size: 14px; color: var(--ink-soft); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.actions .btn { flex: 1; min-width: 140px; }
.timerbar { height: 8px; margin: 12px 0 0; background: var(--paper-dark); border: 1px solid var(--ink); }
.timerbar i { display: block; height: 100%; background: var(--ink); transform-origin: left; }

/* mesa do blefe */
.hand { display: flex; gap: 10px; margin: 12px 0; }
.verba {
  flex: 1; min-height: 96px; padding: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 2px solid var(--ink); background: #fffdf5; cursor: pointer;
  font: 700 15px var(--mono); text-transform: uppercase; text-align: center;
}
.verba b { font-size: 26px; }
.verba.limpa { color: var(--green); }
.verba.caixa2 { color: var(--red); }
.verba.sel { outline: 4px solid var(--gold); transform: translateY(-6px); }
.seats { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; padding: 0; list-style: none; }
.seats li { padding: 4px 10px; border: 1px solid var(--ink); font: 700 14px var(--mono); }
.seats li.turn { background: var(--ink); color: var(--paper); }
.lastplay { padding: 10px; border: 2px dashed var(--ink); font-weight: 700; font-size: 20px; }

/* reunião */
#meeting {
  inset: auto 0 0 0; max-height: 60%;
  flex-direction: column; justify-content: flex-start; gap: 8px;
  padding-top: 12px; padding-bottom: 70px;
  border-top: 4px double var(--ink); box-shadow: 0 -10px 30px rgba(0, 0, 0, .55);
  z-index: 45;
}
.meeting-head { width: min(900px, 100%); display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; border-bottom: 3px double var(--ink); padding-bottom: 8px; }
.clock { font: 700 clamp(40px, 7vw, 64px)/1 var(--mono); font-variant-numeric: tabular-nums; }
.clock.hot { color: var(--red); }
.meeting-hint { width: min(900px, 100%); margin: 0; font-size: clamp(17px, 2.6vw, 22px); font-weight: 700; }
.grid { width: min(900px, 100%); display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.dep {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 12px;
  background: #fffdf5; border: 2px solid var(--ink);
  font: 700 20px var(--serif); color: var(--ink); text-align: left;
}
button.dep { cursor: pointer; box-shadow: 3px 3px 0 var(--ink); }
button.dep:hover { background: #fff3c4; }
.dep.out { opacity: .55; }
.dep.out .pname { text-decoration: line-through; }
.dep.accused { outline: 5px solid var(--red); }
.dep.picked { background: var(--ink); color: var(--paper); }
.dep .meta { margin-left: auto; font: 700 12px var(--mono); text-decoration: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.dep .proc { color: var(--red); }
.dep .ok { color: var(--green); }
.meeting-actions { width: min(900px, 100%); display: flex; flex-wrap: wrap; gap: 10px; }
.meeting-actions .btn { flex: 1; min-width: 200px; padding: 16px; font-size: 22px; }

/* carimbo e manchete */
#stampview { background: rgba(10, 14, 12, .78); z-index: 50; }
.jornal { position: relative; width: min(640px, 100%); padding: 22px 22px clamp(84px, 16vw, 120px); background: #fbf6e6; border: 1px solid #000; box-shadow: 0 16px 50px rgba(0, 0, 0, .6); transform: rotate(-1.2deg); }
.jornal .nome { margin: 0; padding-bottom: 6px; border-bottom: 4px double #000; font: 700 clamp(20px, 4vw, 30px) var(--serif); text-align: center; letter-spacing: .04em; text-transform: uppercase; }
.jornal .edicao { margin: 4px 0 14px; font: 12px var(--mono); text-align: center; color: var(--ink-soft); }
.jornal h2 { font-size: clamp(26px, 6vw, 46px); }
.jornal .sub { margin: 12px 0 0; font-size: clamp(17px, 2.6vw, 22px); }
.jornal .stamp { position: absolute; right: 14px; bottom: 14px; font-size: clamp(30px, 8vw, 60px); border-width: 7px; transform: rotate(-12deg); animation: slam .45s cubic-bezier(.2, 1.4, .4, 1) both .25s; }
@keyframes slam { 0% { transform: scale(4) rotate(-28deg); opacity: 0; } 70% { transform: scale(.92) rotate(-12deg); opacity: 1; } 100% { transform: scale(1) rotate(-12deg); opacity: .92; } }

/* revelação do papel */
#reveal { background: rgba(10, 14, 12, .9); z-index: 55; text-align: center; color: var(--paper); flex-direction: column; gap: 10px; }
#reveal .kicker { color: var(--paper-dark); font-size: 16px; }
#reveal h2 { font-size: clamp(40px, 11vw, 96px); }
#reveal p { margin: 0; font-size: clamp(18px, 3vw, 26px); max-width: 30ch; text-wrap: balance; }
#reveal .corrupto { color: #ff6b5e; }
#reveal .honesto { color: #7fd69a; }
#reveal .laranja { color: #ffa94d; }

/* fim de jogo */
#gameover { flex-direction: column; justify-content: flex-start; gap: 12px; z-index: 44; text-align: center; padding-top: 24px; padding-bottom: 76px; }
#gameover h2 { font-size: clamp(34px, 8vw, 72px); }
#gameover .grid { text-align: left; }
#gameover .dep .meta { font-size: 13px; }

@media (max-height: 520px) {
  .hud-card { padding: 3px 8px; }
  .hud-label { font-size: 9px; }
  .btn.action, .btn.denuncia { min-width: 150px; padding: 10px 12px; font-size: 17px; }
  #toasts { top: 62px; }
  .jornal { padding: 12px 18px 64px; }
  .jornal .edicao { margin-bottom: 8px; }
  .jornal h2 { font-size: 26px; }
  .jornal .sub { margin-top: 6px; font-size: 16px; }
  .jornal .stamp { font-size: 30px; border-width: 5px; right: 10px; bottom: 8px; }
  .clock { font-size: 36px; }
  #meeting { max-height: 74%; padding-top: 8px; }
  #meeting h2 { font-size: 22px; }
  .meeting-hint { font-size: 16px; }
  .dep { padding: 8px 10px; font-size: 17px; }
  .meeting-actions .btn { padding: 10px; font-size: 18px; }
  #mapbox { width: 132px; top: 62px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}

/* ---------- 3D: rótulos presos ao mundo e minimapa ---------- */
#labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.label {
  position: absolute; left: 0; top: 0;
  white-space: nowrap;
  font: 700 17px var(--serif);
  color: #fff;
  text-shadow: 0 0 3px #000, 0 1px 3px #000, 0 0 8px rgba(0, 0, 0, .8);
  will-change: transform;
}
.label i { display: inline-block; width: 9px; height: 15px; margin-right: 6px; vertical-align: -2px; clip-path: polygon(50% 0, 100% 18%, 72% 100%, 50% 88%, 28% 100%, 0 18%); }
.label.me { color: #ffe27a; }
.label.partner { color: #ff8a80; }
.label.ghost { opacity: .6; }
/* ---------- a Operação ---------- */
#raidfx { position: absolute; inset: 0; z-index: 30; pointer-events: none; display: flex; align-items: flex-start; justify-content: center; padding-top: max(36vh, 250px); animation: giroflex .5s steps(1) infinite; }
#raidfx.strike { padding-top: 64vh; animation: giroflex .25s steps(1) infinite; } /* embaixo: o teto, de onde caem os agentes, fica livre */
#raidfx.strike .raid-box b { font-size: clamp(26px, 6vw, 54px); }
@keyframes giroflex {
  0% { box-shadow: inset 0 0 90px 30px rgba(255, 30, 30, .75); }
  50% { box-shadow: inset 0 0 90px 30px rgba(30, 90, 255, .75); }
}
.raid-box { padding: 10px 26px 12px; background: rgba(12, 14, 20, .86); border: 3px solid #fff; color: #fff; text-align: center; box-shadow: 4px 4px 0 #000; }
.raid-box span { display: block; font: 700 clamp(15px, 2.4vw, 22px) var(--mono); letter-spacing: .12em; color: #ffd84a; }
.raid-box b { display: block; font: 900 clamp(48px, 10vw, 96px)/1 var(--mono); }
.raid-box small { display: block; font: 700 clamp(13px, 2vw, 17px) var(--mono); }
.label.police { background: #1a2338; font-size: 13px; }

.label.whisper { padding: 1px 8px; background: rgba(20, 24, 20, .8); color: #fff; font: italic 700 14px var(--mono); text-shadow: none; border-radius: 10px; }
.label.flag { padding: 2px 10px; background: var(--red); color: #fff; font: 700 19px var(--mono); text-shadow: none; border: 2px solid #fff; }
.label.point {
  padding: 4px 10px;
  background: rgba(243, 234, 211, .94);
  border: 2px solid var(--ink);
  border-bottom: 5px solid var(--gold);
  color: var(--ink);
  font: 700 15px var(--mono);
  text-align: center; text-shadow: none; text-transform: uppercase;
}
.label.point small { display: block; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.label.point.session { border-bottom-color: #3f7fd1; }
.label.point.cooldown { border-bottom-color: #6f6a60; opacity: .85; }
.label.point.table { border-bottom-color: var(--green); }

#mapbox {
  position: absolute; right: 10px; top: 88px;
  width: 190px;
  display: flex; flex-direction: column; gap: 6px;
  z-index: 8;
}
#minimap { width: 100%; height: auto; display: block; background: var(--night); border: 2px solid var(--paper); box-shadow: 2px 2px 0 rgba(0, 0, 0, .5); }
#hud-room { padding: 3px 8px; background: var(--paper); border: 2px solid var(--ink); font: 700 13px var(--mono); text-transform: uppercase; text-align: center; }
@media (pointer: coarse) { #mapbox { width: 140px; } }
.in-meeting #mapbox { display: none; }
@media (pointer: coarse) { #toasts { width: min(480px, 58vw); } }
