:root {
  --bg: #F3F5FF; --panel: #FFFFFF; --ink: #16204A; --muted: #56608C;
  --red: #D42A33; --stripe: #FFFFFF; --gold: #F2B400; --gold-ink: #16204A;
  --ok: #1F8A4C; --line: #D6DBF2;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1330; --panel: #19204D; --ink: #F1F3FF; --muted: #A8B0DA;
    --red: #F2545C; --stripe: #EDEFFA; --gold: #FFC83D; --gold-ink: #16204A;
    --ok: #4CD487; --line: #2C356B; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1330; --panel: #19204D; --ink: #F1F3FF; --muted: #A8B0DA;
  --red: #F2545C; --stripe: #EDEFFA; --gold: #FFC83D; --gold-ink: #16204A;
  --ok: #4CD487; --line: #2C356B; color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  font-size: 1.05rem; line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.lona {
  height: 44px; position: relative;
  background: repeating-linear-gradient(90deg, var(--red) 0 40px, var(--stripe) 40px 80px);
}
.lona::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 20px;
  background:
    radial-gradient(circle at 20px 0, var(--red) 19.5px, transparent 20px) 0 0 / 80px 20px repeat-x,
    radial-gradient(circle at 60px 0, var(--stripe) 19.5px, transparent 20px) 0 0 / 80px 20px repeat-x;
}
header.titulo { text-align: center; padding: 2rem 1rem .5rem; }
header.titulo h1 {
  font-family: "Rye", Georgia, serif; font-weight: 400;
  font-size: clamp(1.8rem, 6vw, 3rem); line-height: 1.05; margin: 0;
  color: var(--red); text-shadow: 3px 3px 0 var(--gold);
}
main {
  max-width: 1040px; margin: 0 auto; padding: 1rem 1rem 3rem;
  display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 1.5rem; align-items: start;
}
@media (max-width: 820px) { main { grid-template-columns: minmax(0, 1fr); } }

.palco {
  background: var(--panel); border: 2px solid var(--ink); border-radius: 18px;
  padding: 1.5rem; box-shadow: 6px 6px 0 var(--ink); min-height: 340px;
}
.rodada { font-weight: 800; color: var(--red); margin: 0 0 .25rem; }
.palco h2 {
  font-family: "Rye", Georgia, serif; font-weight: 400;
  font-size: clamp(1.4rem, 3.4vw, 2rem); line-height: 1.18; margin: 0 0 .75rem;
}
.palco p { max-width: 62ch; }
.muted { color: var(--muted); }

.treino {
  display: inline-block; background: var(--gold); color: var(--gold-ink); font-weight: 800;
  border: 2px solid var(--ink); border-radius: 999px; padding: .15rem .8rem; margin-bottom: .75rem;
}

.saldo { display: flex; align-items: center; gap: .9rem; margin: 0 0 1rem; }
.ficha {
  width: 54px; height: 54px; border-radius: 50%; flex: none;
  background:
    radial-gradient(circle, var(--gold) 0 52%, transparent 53%),
    repeating-conic-gradient(var(--red) 0 22.5deg, var(--stripe) 22.5deg 45deg);
  border: 2px solid var(--ink);
}
.saldo .valor { font-family: "Rye", Georgia, serif; font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.saldo small { display: block; color: var(--muted); font-weight: 600; }

.categoria { display: flex; gap: .5rem; flex-wrap: wrap; margin: .25rem 0 1rem; }
.tag { border: 2px solid var(--ink); border-radius: 999px; padding: .2rem .8rem; font-weight: 700; font-size: .92rem; }

.aposta-valor {
  font-family: "Rye", Georgia, serif; font-size: clamp(2.4rem, 9vw, 3.6rem);
  line-height: 1; color: var(--red); margin: .5rem 0; font-variant-numeric: tabular-nums;
}
input[type="range"] { width: 100%; max-width: 520px; accent-color: var(--red); height: 2.5rem; }
.atalhos { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: .5rem; max-width: 520px; }
.atalho {
  border: 2px solid var(--ink); background: var(--bg); color: var(--ink);
  border-radius: 999px; padding: .65rem .5rem; font: inherit; font-weight: 700; cursor: pointer;
}
.atalho:hover { background: var(--line); }

.btn {
  appearance: none; border: 2px solid var(--ink); background: var(--gold); color: var(--gold-ink);
  font: inherit; font-weight: 800; padding: .9rem 1.4rem; border-radius: 999px; cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink); transition: transform .08s, box-shadow .08s; min-height: 3.2rem;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secundario { background: var(--panel); color: var(--ink); }
.btn.perigo { background: var(--red); color: #fff; }
.btn:focus-visible, .opcao:focus-visible, .atalho:focus-visible, input:focus-visible {
  outline: 3px solid var(--red); outline-offset: 3px;
}
.acoes { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.25rem; }
.acoes .btn { flex: 1 1 auto; }
input[type="text"], input[type="password"] {
  width: 100%; max-width: 360px; padding: .8rem 1rem; border: 2px solid var(--ink);
  border-radius: 12px; background: var(--bg); color: var(--ink); font: inherit; margin-bottom: 1rem;
}
label { font-weight: 600; display: block; margin-bottom: .4rem; }

.cronometro { display: flex; align-items: center; gap: .75rem; margin: 1rem 0; }
.barra { flex: 1; height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; }
.barra span {
  display: block; height: 100%; width: 100%;
  background: repeating-linear-gradient(90deg, var(--red) 0 14px, var(--gold) 14px 28px);
}
.segundos { font-weight: 800; min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }
.em-jogo { font-weight: 700; color: var(--muted); }
.em-jogo strong { color: var(--red); }

.opcoes { display: grid; gap: .65rem; margin-top: 1rem; }
.opcao {
  text-align: left; border: 2px solid var(--ink); border-radius: 12px; min-height: 3.4rem;
  background: var(--bg); color: var(--ink); padding: .85rem 1rem; cursor: pointer; font: inherit; font-weight: 600;
  display: flex; justify-content: space-between; gap: .75rem; align-items: center;
}
.opcao:hover:not(:disabled) { background: var(--line); }
.opcao.escolhida { outline: 3px solid var(--gold); outline-offset: 2px; }
.opcao.certa { background: var(--ok); color: #fff; border-color: var(--ok); }
.opcao.errada { background: var(--red); color: #fff; border-color: var(--red); }
.opcao:disabled { cursor: default; }
.opcao .qtd { font-variant-numeric: tabular-nums; font-weight: 800; white-space: nowrap; }
.resultado { border-radius: 14px; padding: .9rem 1rem; margin: .5rem 0 1rem; color: #fff; font-weight: 800; font-size: 1.3rem; text-align: center; animation: pop .35s ease-out; }
.resultado small { display: block; font-size: .95rem; font-weight: 600; opacity: .9; }
.resultado.bom { background: var(--ok); }
.resultado.ruim { background: var(--red); animation: pop .35s ease-out, tremer .4s .35s; }
.opcao .sua { margin-left: .5rem; padding: .1rem .5rem; border-radius: 999px; background: rgba(255, 255, 255, .25); font-size: .75rem; font-weight: 800; text-transform: uppercase; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes tremer { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .resultado { animation: none; } }
.feedback { font-weight: 800; margin-top: 1rem; min-height: 1.5em; font-size: 1.15rem; }
.feedback.bom { color: var(--ok); }
.feedback.ruim { color: var(--red); }
.erro { color: var(--red); font-weight: 700; min-height: 1.5em; }

aside.placar { background: var(--panel); border: 2px solid var(--ink); border-radius: 18px; padding: 1.25rem; }
aside.placar h3 { font-family: "Rye", Georgia, serif; font-weight: 400; margin: 0 0 .75rem; font-size: 1.3rem; }
aside.placar ol { list-style: none; margin: 0; padding: 0; }
aside.placar li {
  display: flex; justify-content: space-between; gap: .5rem; padding: .45rem .25rem;
  border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums;
}
aside.placar li:last-child { border-bottom: 0; }
aside.placar li.voce { font-weight: 800; color: var(--red); }
aside.placar li.zerado { color: var(--muted); text-decoration: line-through; }
aside.placar li.separador { justify-content: center; color: var(--muted); border-bottom: 0; }
.pos { color: var(--muted); margin-right: .4rem; }
.nome-placar { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delta { font-size: .85rem; font-weight: 700; margin-left: .35rem; }
.delta.mais { color: var(--ok); }
.delta.menos { color: var(--red); }

.ingresso {
  margin: 1.5rem 0; display: flex; max-width: 480px; background: var(--gold); color: #16204A;
  border-radius: 14px; overflow: hidden; border: 2px solid #16204A;
  -webkit-mask: radial-gradient(circle at 70% 0, transparent 12px, #000 12.5px) top / 100% 51% no-repeat,
                radial-gradient(circle at 70% 100%, transparent 12px, #000 12.5px) bottom / 100% 51% no-repeat;
          mask: radial-gradient(circle at 70% 0, transparent 12px, #000 12.5px) top / 100% 51% no-repeat,
                radial-gradient(circle at 70% 100%, transparent 12px, #000 12.5px) bottom / 100% 51% no-repeat;
}
.ingresso .corpo { flex: 0 0 70%; padding: 1.25rem; border-right: 2px dashed #16204A; }
.ingresso .canhoto { flex: 1; padding: 1rem; display: grid; place-items: center; text-align: center; font-weight: 800; }
.ingresso h4 { font-family: "Rye", Georgia, serif; font-weight: 400; font-size: 1.5rem; margin: 0 0 .25rem; }
.ingresso p { margin: 0; }

.conexao {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%);
  background: var(--red); color: #fff; font-weight: 800; padding: .5rem 1rem; border-radius: 999px; z-index: 10;
}

/* Telão */
body.telao main { max-width: 1400px; grid-template-columns: minmax(0, 1fr) 340px; }
body.telao .palco { min-height: 60vh; padding: 2rem; }
body.telao .palco h2 { font-size: clamp(1.8rem, 3.6vw, 3rem); }
body.telao .opcao { font-size: 1.35rem; min-height: 4rem; }
body.telao .contador { font-family: "Rye", Georgia, serif; font-size: clamp(3rem, 8vw, 6rem); line-height: 1; color: var(--red); }
.nomes { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.nomes span { border: 2px solid var(--ink); border-radius: 999px; padding: .2rem .8rem; font-weight: 700; background: var(--bg); }
.nomes button {
  border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0 0 0 .4rem;
}
.controles {
  max-width: 1400px; margin: 0 auto; padding: 0 1rem 2rem; display: flex; flex-wrap: wrap; gap: .75rem; align-items: center;
}
.controles .dica { color: var(--muted); font-weight: 600; }
.entrada-link { font-size: 1.4rem; font-weight: 800; }
.entrada-link code { background: var(--line); padding: .1rem .5rem; border-radius: 8px; }

@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }

.botao-som {
  position: fixed; z-index: 20;
  right: calc(12px + env(safe-area-inset-right, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  font: inherit; font-size: .85rem; font-weight: 800; cursor: pointer;
  background: var(--panel); color: var(--ink); border: 2px solid var(--ink); border-radius: 999px;
  padding: .35rem .8rem; box-shadow: 2px 2px 0 var(--ink);
}
.botao-som[aria-pressed="false"] { color: var(--muted); }
.botao-som:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
#palco { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#palco input { -webkit-user-select: text; user-select: text; }
