:root {
  --ink: #0f0b16;
  --ink2: #1b1426;
  --panel: #2b2238;
  --panel-hi: #4f4170;
  --bg: #120d1c;
  --well: #1d1729;
  --text: #f3e9d2;
  --dim: #c9b8e8;
  --gold: #f2c14e;
  --red: #ff6b5e;
  --cp8: polygon(8px 0, calc(100% - 8px) 0, calc(100% - 8px) 4px, calc(100% - 4px) 4px, calc(100% - 4px) 8px, 100% 8px, 100% calc(100% - 8px), calc(100% - 4px) calc(100% - 8px), calc(100% - 4px) calc(100% - 4px), calc(100% - 8px) calc(100% - 4px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 4px), 4px calc(100% - 4px), 4px calc(100% - 8px), 0 calc(100% - 8px), 0 8px, 4px 8px, 4px 4px, 8px 4px);
  --cp4: polygon(4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px), 0 4px, 4px 4px);
  --px: 'Press Start 2P', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body {
  color: var(--text);
  font-family: 'VT323', 'Courier New', monospace;
  background-image: linear-gradient(rgba(255, 255, 255, 0.025) 2px, transparent 2px);
  background-size: 100% 6px;
}
[hidden] { display: none !important; }
svg { display: block; flex-shrink: 0; }
h1, h2 { margin: 0; }

#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: 10px; padding: 12px 16px 16px; }

.frame { background: var(--ink); padding: 4px; clip-path: var(--cp8); position: relative; }
.panel { background: var(--panel); box-shadow: inset 4px 4px 0 var(--panel-hi), inset -4px -4px 0 var(--ink2); clip-path: var(--cp4); }

/* ---------- cabeçalho ---------- */
.bar { min-height: 48px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; padding: 6px 14px; }
.brand { display: flex; align-items: center; gap: 12px; }
.title { font-family: var(--px); font-size: 18px; color: var(--gold); letter-spacing: 1px; text-shadow: 2px 2px 0 #a2650f, 4px 4px 0 #6e1a0c, 6px 6px 0 var(--ink); }
.badge { font-family: var(--px); font-size: 9px; color: var(--ink2); background: #9fd8e8; padding: 6px 8px; box-shadow: inset 0 -3px 0 #3d7f99; }
.banner { display: flex; align-items: center; height: 34px; padding: 0 22px; background: var(--dim); box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.35); clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 50%, 100% 100%, 0 100%, 12px 50%); }
.banner span { font-family: var(--px); font-size: 10px; color: var(--ink2); white-space: nowrap; }
.hud-right { display: flex; align-items: center; gap: 8px; }
.chip { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; background: var(--ink2); box-shadow: inset 0 0 0 3px var(--ink), inset 0 6px 0 0 var(--panel); }
.px9 { font-family: var(--px); font-size: 10px; color: var(--dim); }
.px8 { font-family: var(--px); font-size: 8px; color: var(--text); }

/* ---------- colunas ---------- */
.row { flex: 1; min-height: 0; display: flex; gap: 10px; }
.side { flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.side.left { width: 280px; }
.side.right { width: 310px; }
.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.card { flex: 1; position: relative; display: flex; flex-direction: column; gap: 8px; padding: 8px 14px 18px; overflow: auto; }
.ph { display: flex; align-items: center; gap: 8px; margin: -4px -10px 2px; padding: 7px 10px; background: var(--ink2); box-shadow: inset 0 -3px 0 var(--ink); }
.ph h2 { font-family: var(--px); font-size: 9px; color: var(--gold); letter-spacing: 1px; }
.led { margin-left: auto; width: 6px; height: 6px; background: #9fd8e8; box-shadow: inset -2px -2px 0 #3d7f99; }
.rivet { position: absolute; width: 6px; height: 6px; background: #c9a24b; box-shadow: inset -2px -2px 0 #7a4510; bottom: 8px; }
.rivet.l { left: 8px; } .rivet.r { right: 8px; }
.txt { font-size: 20px; line-height: 1.1; }
.dim { color: var(--dim); }
.note { font-size: 19px; line-height: 1.1; color: var(--dim); }
.sub { font-size: 18px; line-height: 1.1; color: var(--dim); }

.plist { display: flex; flex-direction: column; gap: 8px; }
.pl { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--well); box-shadow: inset 0 0 0 2px var(--ink), inset 4px 0 0 2px var(--c); }
.pl.on { background: #4a3d63; }
.pl.off { opacity: 0.55; }
.pl .sw { width: 22px; height: 22px; flex-shrink: 0; background: var(--c); box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.4), inset -2px -2px 0 rgba(0, 0, 0, 0.35); }
.pl .nm { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pl .nm b { font-family: var(--px); font-size: 9px; font-weight: 400; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl .nm small { font-size: 18px; line-height: 1; color: var(--dim); }
.pl .tag { font-family: var(--px); font-size: 8px; }

.curname { font-family: var(--px); font-size: 12px; line-height: 1.5; text-shadow: 2px 2px 0 var(--ink); color: var(--dim); }
.eq { display: flex; align-items: center; gap: 8px; }
.segs { display: flex; gap: 2px; }
.segs i { width: 11px; height: 14px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35); background: var(--well); }
.mood { color: #f58a6e; line-height: 1; }
.rules { display: flex; flex-direction: column; gap: 6px; font-size: 19px; line-height: 1.05; }
.rules .red { color: var(--red); }
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 10px; padding-top: 8px; border-top: 3px dashed #4a3d63; }
.legend div { display: flex; align-items: center; gap: 7px; font-size: 17px; line-height: 1; }
.legend i { width: 20px; height: 11px; flex-shrink: 0; border: 2px solid var(--ink); }

/* ---------- palco ---------- */
.stage-frame { flex: 1; min-width: 0; display: flex; }
.stage {
  flex: 1; min-width: 0; position: relative; overflow: hidden; clip-path: var(--cp4);
  background-color: var(--well);
  background-image: linear-gradient(#271f36 3px, transparent 3px), linear-gradient(90deg, #271f36 3px, transparent 3px);
  background-size: 72px 36px;
}
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: default; touch-action: none; image-rendering: pixelated; }
.vignette { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 6px 6px 0 rgba(0, 0, 0, 0.45), inset -3px -3px 0 rgba(255, 255, 255, 0.05); }
.torch { position: absolute; top: 110px; display: flex; flex-direction: column; align-items: center; }
.torch.l { left: 28px; } .torch.r { right: 28px; }
.torch .f1 { width: 8px; height: 8px; background: var(--gold); }
.torch .f2 { width: 16px; height: 10px; background: #f58a3a; }
.torch .f3 { width: 12px; height: 8px; background: #d9472b; }
.torch .f4 { width: 8px; height: 36px; background: #7a4a22; }
.help { position: absolute; left: 12px; top: 12px; pointer-events: none; padding: 3px; clip-path: var(--cp4); }
.help-in { padding: 6px 9px; background: var(--ink2); font-family: var(--px); font-size: 7px; color: var(--dim); line-height: 2; }

.expanel { position: absolute; right: 12px; top: 12px; width: 250px; pointer-events: none; }
.ex-in { display: flex; flex-direction: column; gap: 6px; padding: 8px 12px 12px; }
.ex-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -2px -6px 2px; padding: 7px 6px; background: var(--ink2); }
.lbl { font-family: var(--px); font-size: 7px; color: var(--dim); }
.lbl.v { color: var(--text); }
.lbl9 { font-family: var(--px); font-size: 9px; color: var(--dim); }
.spread { display: flex; justify-content: space-between; }
.meter { position: relative; height: 12px; padding: 2px; background: var(--well); box-shadow: inset 0 0 0 2px var(--ink); }
.meter .fill { height: 100%; width: 0; background: #86c98d; }
.meter .fill.gold { background: var(--gold); }
.meter .limit { position: absolute; top: -3px; height: 18px; width: 3px; background: #e9fbff; box-shadow: 0 0 0 2px var(--ink); }
#exSpecial { display: flex; flex-direction: column; gap: 6px; }

.toast { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); pointer-events: none; display: flex; align-items: center; height: 34px; padding: 0 24px; background: #6e1a0c; box-shadow: inset 0 3px 0 #a8321b, inset 0 -3px 0 #3a0c05; clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 50%, 100% 100%, 0 100%, 12px 50%); max-width: calc(100% - 24px); }
.toast span { font-family: var(--px); font-size: 9px; color: #fff1a8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.offline { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); padding: 8px 14px; background: #6e1a0c; font-family: var(--px); font-size: 8px; color: #fff1a8; box-shadow: inset 0 0 0 3px var(--ink); z-index: 5; }
.nogl { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--ink); border: 3px solid var(--gold); padding: 16px 20px; font-size: 22px; max-width: 90%; }

.tools { position: absolute; left: 0; right: 0; bottom: 14px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 0 10px; }

/* ---------- botões e campos ---------- */
.btn { padding: 4px; border: 0; background: var(--ink); cursor: pointer; clip-path: var(--cp8); font: inherit; }
.btn > span { min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 14px; font-family: var(--px); font-size: 10px; color: var(--text); background: var(--panel); box-shadow: inset 0 4px 0 var(--panel-hi), inset 0 -5px 0 var(--ink2); clip-path: var(--cp4); }
.btn.violet > span { background: #4a3d63; box-shadow: inset 0 4px 0 #6b5a8e, inset 0 -5px 0 #2a1f40; }
.btn.gold > span { color: var(--ink2); background: var(--gold); box-shadow: inset 0 4px 0 #fff1a8, inset 0 -5px 0 #a2650f; }
.btn.small > span { min-height: 26px; font-size: 8px; padding: 0 10px; }
.btn:hover > span { filter: brightness(1.12); }
.btn:active > span { transform: translateY(2px); }
.btn:focus-visible > span { filter: brightness(1.3); box-shadow: inset 0 0 0 3px #fff1a8; }
.btn:disabled { cursor: not-allowed; }
.btn:disabled > span { filter: grayscale(0.7) brightness(0.7); }
.btn[aria-pressed="true"] > span { background: #9fd8e8; color: var(--ink2); box-shadow: inset 0 4px 0 #e9fbff, inset 0 -5px 0 #3d7f99; }

.opt { height: 44px; min-width: 64px; padding: 0 16px; border: 0; cursor: pointer; font-family: var(--px); font-size: 11px; color: var(--text); background: #4a3d63; box-shadow: inset 0 0 0 3px var(--ink), inset 0 4px 0 3px #6b5a8e; }
.opt[aria-pressed="true"] { color: var(--ink2); background: var(--gold); box-shadow: inset 0 0 0 3px var(--ink), inset 0 4px 0 3px #fff1a8; }
.opt:disabled { cursor: default; }
.opt:focus-visible { outline: 3px solid #fff1a8; outline-offset: 2px; }

.inp { width: 100%; height: 44px; padding: 0 12px; border: 0; font-family: 'VT323', monospace; font-size: 26px; color: var(--text); background: var(--well); box-shadow: inset 0 0 0 3px var(--ink), inset 0 6px 0 3px var(--ink2); text-transform: uppercase; }
.inp:focus { outline: 3px solid var(--gold); outline-offset: 0; }
.inp::placeholder { color: #6b6380; }
.inp.code { letter-spacing: 6px; }
.inp.link { font-size: 18px; text-transform: none; }
.field { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: left; }

/* ---------- janelas ---------- */
.modal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(15, 11, 22, 0.55); padding: 16px; z-index: 4; }
.box { width: 400px; max-width: 100%; }
.box.wide { width: 440px; }
.box-in { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px 18px; text-align: center; }
.mtitle { font-family: var(--px); font-size: 14px; line-height: 1.6; color: var(--gold); text-shadow: 2px 2px 0 #6e1a0c; }
.mtitle.lose { font-size: 13px; text-shadow: 2px 2px 0 var(--ink); }
.linkrow { display: flex; gap: 8px; width: 100%; align-items: center; }
.opts { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pick { display: flex; gap: 8px; }

.entry { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 11, 22, 0.72); z-index: 10; overflow: auto; }
.bigtitle { font-family: var(--px); font-size: 22px; color: var(--gold); letter-spacing: 1px; text-shadow: 2px 2px 0 #a2650f, 4px 4px 0 #6e1a0c, 6px 6px 0 var(--ink); margin-bottom: 4px; }
.entry .btn.gold { width: 100%; }
.or { display: flex; align-items: center; gap: 10px; width: 100%; }
.or i { flex: 1; height: 3px; background: #4a3d63; }
.joinrow { display: flex; gap: 8px; align-items: flex-end; width: 100%; }
.err { min-height: 20px; font-size: 20px; color: var(--red); }

/* ---------- telas estreitas ---------- */
@media (max-width: 1100px) {
  .side.left { width: 240px; }
  .side.right { width: 260px; }
}
@media (max-width: 900px) {
  #app { height: auto; min-height: 100vh; padding: 10px; }
  .row { flex-direction: column; }
  .side.left, .side.right { width: auto; }
  .stage-frame { order: -1; flex: none; height: 72vh; min-height: 420px; }
  .help { display: none; }
  .torch { display: none; }
  .expanel { width: 200px; right: 8px; top: 8px; }
  .title { font-size: 14px; }
}
