/* =========================================================
   PERMANEÇA NA VIDEIRA — núcleo visual
   Conceito: palco de game show num vinhedo ao entardecer.
   Noite cor de uva + luz dourada do pôr do sol + folhas.
   Tema único escuro (projetor/TV), tipografia fluida pelo viewport.
   ========================================================= */
@font-face { font-family: "Cinzel"; src: url("../fonts/cinzel-normal.woff2") format("woff2"); font-weight: 400 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("../fonts/nunito-normal.woff2") format("woff2"); font-weight: 200 1000; font-style: normal; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("../fonts/nunito-italic.woff2") format("woff2"); font-weight: 200 1000; font-style: italic; font-display: swap; }

:root {
  color-scheme: dark;
  /* cor */
  --night: #170d22;        /* fundo: noite cor de uva */
  --night-2: #21122e;      /* superfícies elevadas */
  --night-3: #2d1940;      /* cartões */
  --cream: #fff4e0;        /* texto principal */
  --cream-dim: #d8c6b2;    /* texto secundário */
  --gold: #f6b93b;         /* acento: luz do sol */
  --gold-2: #ffd77a;
  --gold-ink: #2a1606;     /* texto sobre dourado */
  --grape: #8e4fd8;
  --grape-deep: #4d2380;
  --leaf: #4cc263;
  --leaf-deep: #2b7a3b;
  --ok: #3fd47a;
  --bad: #ff5b61;
  --line: rgba(255, 240, 220, .14);
  --line-strong: rgba(255, 240, 220, .28);
  --surface: rgba(33, 18, 46, .86);
  --surface-2: rgba(45, 25, 64, .92);
  --shadow: 0 1.2rem 3rem rgba(6, 2, 12, .55);
  /* equipes */
  --t1: #b07bff; --t1-deep: #6b33c9; --t1-ink: #1b0a33;
  --t2: #ff9d42; --t2-deep: #c95c08; --t2-ink: #2e1300;
  --t3: #52d46d; --t3-deep: #1f8a44; --t3-ink: #062610;
  /* tipo */
  --f-display: "Cinzel", "Trajan Pro", Georgia, "Times New Roman", serif;
  --f-ui: "Nunito", ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 1rem;
  --topbar-h: 3.4rem;
}

* { box-sizing: border-box; }
html { font-size: clamp(15px, calc(0.6vw + 0.55vh + 4px), 25px); height: 100%; }
body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--night); color: var(--cream);
  font-family: var(--f-ui); font-weight: 600; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold-2); outline-offset: 3px; border-radius: .4rem; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- moldura do app ---------- */
#app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex: none; z-index: 50;
  display: flex; align-items: center; gap: .8rem; padding-inline: 1rem;
  background: linear-gradient(180deg, rgba(23,13,34,.98), rgba(23,13,34,.86));
  border-bottom: 1px solid var(--line);
}
.topbar .home-btn { display: inline-flex; align-items: center; gap: .45rem; }
.topbar .screen-title { font-family: var(--f-display); font-weight: 800; letter-spacing: .06em; font-size: 1.05rem; color: var(--gold-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .spacer { flex: 1; }
.topbar .tools { display: flex; gap: .4rem; }
body.no-topbar .topbar { display: none; }
#screen { flex: 1; min-height: 0; position: relative; overflow: auto; }
#screen.fit { overflow: hidden; }

/* ---------- botões ---------- */
.btn {
  --b-bg: rgba(255, 244, 224, .08); --b-fg: var(--cream); --b-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  padding: .62em 1.15em; border-radius: .8rem; border: 1px solid var(--b-bd);
  background: var(--b-bg); color: var(--b-fg);
  font-weight: 900; letter-spacing: .01em; line-height: 1.1; text-decoration: none;
  transition: transform .12s ease, filter .12s ease, background .2s;
  user-select: none;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; }
.btn-gold { --b-bg: linear-gradient(180deg, var(--gold-2), var(--gold)); --b-fg: var(--gold-ink); --b-bd: #ffe3a3; box-shadow: 0 .35rem 0 #b7791a, 0 .6rem 1.4rem rgba(246,185,59,.25); }
.btn-gold:active { box-shadow: 0 .15rem 0 #b7791a; transform: translateY(.2rem); }
.btn-ok { --b-bg: linear-gradient(180deg, #67e79a, #26b45f); --b-fg: #04210f; --b-bd: #9df3be; box-shadow: 0 .3rem 0 #187a3f; }
.btn-bad { --b-bg: linear-gradient(180deg, #ff8c90, #e2434a); --b-fg: #2c0306; --b-bd: #ffb3b6; box-shadow: 0 .3rem 0 #9b1f25; }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; }
.btn-sm { padding: .42em .8em; font-size: .85rem; border-radius: .65rem; }
.btn-lg { padding: .85em 1.6em; font-size: 1.2rem; border-radius: 1rem; }
.btn-xl { padding: .9em 2em; font-size: 1.6rem; border-radius: 1.2rem; }
.icon-btn { width: 2.4rem; height: 2.4rem; padding: 0; border-radius: .7rem; font-size: 1.1rem; }
.btn-team { --b-bg: linear-gradient(180deg, var(--tc), var(--tcd)); --b-fg: var(--tink); --b-bd: color-mix(in srgb, var(--tc) 60%, white); box-shadow: 0 .35rem 0 color-mix(in srgb, var(--tcd) 70%, black); }

/* cores por equipe: aplique .team-1/.team-2/.team-3 em qualquer elemento */
.team-1 { --tc: var(--t1); --tcd: var(--t1-deep); --tink: var(--t1-ink); }
.team-2 { --tc: var(--t2); --tcd: var(--t2-deep); --tink: var(--t2-ink); }
.team-3 { --tc: var(--t3); --tcd: var(--t3-deep); --tink: var(--t3-ink); }

/* ---------- placar compacto (topbar) ---------- */
.scorebar { display: flex; gap: .5rem; align-items: center; }
.score-chip {
  position: relative; display: inline-flex; align-items: center; gap: .45rem;
  padding: .28rem .75rem .28rem .45rem; border-radius: 999px;
  background: color-mix(in srgb, var(--tc) 18%, var(--night-2));
  border: 2px solid color-mix(in srgb, var(--tc) 70%, transparent);
  font-weight: 900; white-space: nowrap; cursor: pointer;
}
.score-chip .emo { font-size: 1.15rem; line-height: 1; }
.score-chip .nm { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; color: var(--cream); font-size: .9rem; }
.score-chip .pts { font-variant-numeric: tabular-nums; color: var(--tc); font-size: 1.1rem; min-width: 1.6em; text-align: right; }
.score-chip.is-turn { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc) 55%, transparent), 0 0 1.2rem color-mix(in srgb, var(--tc) 60%, transparent); }
.score-chip.bump { animation: chipBump .6s ease; }
@keyframes chipBump { 30% { transform: scale(1.18); } 60% { transform: scale(.96); } }

.float-pts {
  position: fixed; z-index: 400; pointer-events: none;
  font-family: var(--f-ui); font-weight: 1000; font-size: 1.6rem;
  text-shadow: 0 .15rem .6rem rgba(0,0,0,.6);
  animation: floatUp 1.3s ease-out forwards;
}
@keyframes floatUp { from { opacity: 0; transform: translate(-50%, 0) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -.6rem) scale(1.15); } to { opacity: 0; transform: translate(-50%, -3.4rem) scale(1); } }

/* ---------- modal ---------- */
.modal-wrap {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 1rem;
  background: rgba(10, 4, 18, .72); backdrop-filter: blur(6px);
  animation: fadeIn .2s ease;
}
.modal {
  width: min(46rem, 100%); max-height: calc(100% - 1rem); overflow: auto;
  background: linear-gradient(180deg, var(--night-3), var(--night-2));
  border: 1px solid var(--line-strong); border-radius: 1.4rem; box-shadow: var(--shadow);
  padding: 1.6rem 1.8rem; text-align: center;
  animation: popIn .32s cubic-bezier(.2, 1.4, .4, 1);
}
.modal.wide { width: min(64rem, 100%); }
.modal h2 { font-family: var(--f-display); font-weight: 900; font-size: 2rem; margin: 0 0 .3rem; color: var(--gold-2); letter-spacing: .04em; text-wrap: balance; }
.modal .sub { color: var(--cream-dim); margin: 0 0 1.1rem; font-size: 1.05rem; text-wrap: balance; }
.modal .actions { display: flex; flex-wrap: wrap; gap: .8rem; justify-content: center; margin-top: 1.2rem; }
.team-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .9rem; margin-top: .6rem; }
.team-choice .btn-team { flex-direction: column; padding: 1rem .8rem; font-size: 1.3rem; border-radius: 1.1rem; min-height: 7.5rem; }
.team-choice .btn-team .emo { font-size: 2.6rem; line-height: 1; }
.team-choice .btn-team kbd { font-family: var(--f-ui); font-size: .75rem; font-weight: 900; opacity: .7; border: 1px solid currentColor; border-radius: .35rem; padding: 0 .35rem; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.85) translateY(1rem); } }

/* ---------- toast ---------- */
.toast-area { position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%); z-index: 350; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; }
.toast { background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: .6rem 1.2rem; font-weight: 800; box-shadow: var(--shadow); animation: popIn .25s ease; }

/* ---------- barra de tempo ---------- */
.timerbar { position: relative; height: 1.9rem; border-radius: 999px; background: rgba(255,244,224,.1); border: 1px solid var(--line); overflow: hidden; }
.timerbar .fill { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, var(--leaf), var(--gold)); transition: width .25s linear, background .3s; }
.timerbar.warn .fill { background: linear-gradient(90deg, #ff9b45, var(--bad)); }
.timerbar .txt { position: relative; z-index: 1; display: grid; place-items: center; height: 100%; font-weight: 1000; font-variant-numeric: tabular-nums; text-shadow: 0 1px 3px rgba(0,0,0,.7); }

/* ---------- utilidades ---------- */
.eyebrow { font-family: var(--f-ui); font-weight: 900; letter-spacing: .18em; text-transform: uppercase; font-size: .78rem; color: var(--gold); }
.display { font-family: var(--f-display); font-weight: 900; letter-spacing: .03em; text-wrap: balance; }
.gold-text { background: linear-gradient(180deg, #fff1c4 0%, var(--gold-2) 35%, var(--gold) 70%, #c9831b 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.bg-photo { position: absolute; inset: 0; background-size: cover; background-position: center; z-index: 0; }
.bg-photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(23,13,34,.45), rgba(23,13,34,.85) 70%, var(--night)); }
kbd { font-family: var(--f-ui); font-weight: 900; font-size: .8em; padding: .05em .4em; border-radius: .35rem; border: 1px solid var(--line-strong); background: rgba(255,244,224,.06); }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 380; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (max-width: 760px) {
  .topbar .screen-title { display: none; }
  .score-chip .nm { display: none; }
}
