* { box-sizing: border-box; }
html { height: 100%; background: #19251c; }
body {
  margin: 0; height: 100vh; height: 100dvh; overflow: hidden;
  color: #fffdf3; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: linear-gradient(90deg, #0d1c1866, #0d1c1810), url("./fundo.png") 88% center / cover no-repeat;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .6; }
:focus-visible { outline: 3px solid #c9dc94; outline-offset: 3px; }
[hidden] { display: none !important; }
.ag {
  width: 100%; max-width: 1600px; height: 100%; min-height: 0; margin: auto;
  padding: max(16px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, min(480px, 55dvh)) minmax(0, 1fr); gap: 16px;
}
.ag-intro { grid-row: 1; align-self: end; justify-self: center; display: grid; justify-items: center; gap: 8px; max-width: 100%; text-align: center; }
.ag-heading { text-align: center; }
.ag h1 { font-size: clamp(1.5rem, 3vw, 2.5rem); letter-spacing: -.055em; line-height: 1.1; margin: 0; text-shadow: 0 2px 12px #000a; }
.ag h1 span { color: #c0d796; }
.ag-nav { position: fixed; right: max(24px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); }
.ag-nav a {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px;
  padding: 6px 12px; background: #15271ddd; color: #fffdf3; border: 1px solid #e2eac744;
  border-radius: 7px; text-decoration: none; font-size: .75rem;
}
.ag-countdown { display: inline-flex; align-items: center; padding: 8px 14px; gap: 18px; border-radius: 9px; background: #15271de6; border: 1px solid #e2eac733; }
.ag-countdown p { font-size: .72rem; margin: 0; color: #e1e7d5; }
.ag-time { text-align: center; }
.ag-time strong { display: block; font: 600 1.2rem/1.2 ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.ag-time span { font-size: .55rem; text-transform: uppercase; letter-spacing: .07em; color: #cad7ba; }
#retired { display: inline-block; margin: 0; padding: 8px 14px; background: #15271de6; border-radius: 8px; font-size: .8rem; }
.ag-machine {
  grid-row: 2; justify-self: center; width: min(960px, 100%); height: 100%; min-height: 0;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid #cdd7c377; border-radius: 12px; overflow: hidden; box-shadow: 0 8px 30px #0004;
  color: #263d32;
}
.ag-scorebar { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; gap: 8px; background: #fffef8; font-size: .6rem; letter-spacing: .06em; }
.ag-level { font-weight: 700; }
.ag-scorebar > div { display: flex; align-items: center; gap: 16px; color: #657568; }
.ag-scorebar > div > span { display: inline-flex; align-items: center; white-space: nowrap; }
.ag-webinar-score canvas { width: 28px; height: 31px; }
.ag-scorebar strong { color: #284f3b; font: 700 1rem ui-monospace, monospace; padding-left: 4px; }
.ag-stage { position: relative; min-height: 0; background: #f0f3e7; }
#game { display: block; width: 100%; height: 100%; position: absolute; inset: 0; touch-action: manipulation; }
.ag-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px 12px 12px 70px; text-align: center; background: #f0f3e740; }
.ag-tag { color: #627749; font: 700 .6rem ui-monospace, monospace; letter-spacing: .12em; }
.ag-overlay h2 { font-size: clamp(1.1rem, 2.5vw, 1.8rem); letter-spacing: -.04em; margin: 8px 0 4px; line-height: 1.15; }
.ag-overlay p { font-size: .8rem; color: #52634e; margin: 0 0 14px; }
.ag-primary { border: 0; border-radius: 7px; min-height: 44px; padding: 9px 20px; background: #284f3b; color: #fff; font-weight: 650; font-size: .85rem; box-shadow: 0 3px 0 #153426; }
.ag-primary:hover { background: #356449; }
.ag-overlay-actions { display: flex; align-items: center; justify-content: center; gap: 8px; max-width: 100%; }
.ag-help { min-height: 44px; padding: 8px 10px; border: 1px solid #8da17e; border-radius: 7px; background: #f0f3e7; color: #284f3b; font-size: .72rem; }
.ag-help:hover { background: #e2e8d3; }
.ag-overlay-actions { flex-wrap: wrap; }
#down { touch-action: none; user-select: none; -webkit-user-select: none; }
#down[aria-pressed="true"] { background: #284f3b; color: white; }
.ag-record-input { display: flex; gap: 8px; margin: 6px 0; }
.ag-vr { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; min-height: 44px; padding: 0 3px; border: 0; border-radius: 7px; background: transparent; color: #284f3b; font-size: .65rem; line-height: 1.1; }
.ag-vr canvas { display: block; width: 72px; height: auto; }
.ag-vr:hover canvas { filter: brightness(1.12); }
.ag-record-input .ag-vr canvas { width: 86px; }
#ranking-player strong { overflow-wrap: anywhere; }
.ag-record-input input { width: 100%; min-width: 0; border: 1px solid #8da17e; border-radius: 6px; padding: 8px; font: inherit; background: #fff; color: #263d32; }
#record-form label { font-weight: 650; font-size: .85rem; }
#record-note { display: block; font-size: .7rem; color: #657568; }
.ag-ranking-list { padding: 0; list-style: none; counter-reset: ranking; }
.ag-ranking-list li { counter-increment: ranking; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #cdd7c3; padding: 8px 0; font-size: .85rem; }
.ag-ranking-list li::before { content: counter(ranking, decimal-leading-zero); color: #657568; font: .8rem ui-monospace, monospace; }
.ag-ranking-list li span { flex: 1; overflow-wrap: anywhere; }
.ag-ranking-list strong { font: 700 1rem ui-monospace, monospace; }
#teams-preview { width: 92px; height: auto; }
.ag-machine :focus-visible, dialog :focus-visible { outline-color: #9e6629; outline-offset: -3px; }
.ag-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 12px; background: #fffef8; color: #657568; font-size: .68rem; }
.ag-controls > div { display: flex; gap: 8px; }
.ag-controls button { border: 1px solid #d2dbca; border-radius: 5px; background: #f3f5ed; color: #284f3b; padding: 5px 12px; min-height: 40px; }
kbd { border: 1px solid #aab79e; border-bottom-width: 2px; border-radius: 4px; padding: 1px 4px; font-size: .65rem; }
dialog { width: min(480px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 20px; border: 1px solid #cdd7c3; border-radius: 12px; background: #f7f8f2; color: #263d32; box-shadow: 0 16px 60px #0005; }
dialog::backdrop { background: #0d1c18b3; }
.ag-help-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ag-help-heading h2 { margin: 0; font-size: 1.3rem; }
.ag-help-heading button { min-width: 44px; min-height: 44px; border: 1px solid #cdd7c3; border-radius: 6px; background: transparent; color: inherit; }
dialog p { font-size: .8rem; }
.ag-guide { display: grid; gap: 14px; }
.ag-guide article { display: flex; align-items: center; gap: 12px; }
.ag-guide canvas { width: 40px; height: 44px; flex-shrink: 0; }
.ag-guide h3 { font-size: .82rem; margin: 0 0 3px; }
.ag-guide p { font-size: .75rem; margin: 0; color: #657568; }
.ag-footnote { color: #657568; margin-bottom: 0; }
.ag-no-script { position: fixed; inset: 40% 10% auto; padding: 20px; background: #15271d; border-radius: 12px; }
@media (max-width: 600px) {
  body { background-position: 85% center; }
  .ag { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); gap: 10px; }
  .ag { grid-template-rows: minmax(0, 1fr) minmax(0, min(calc((100vw - 24px) * .6 + 90px), 48dvh)) minmax(0, 1fr); }
  .ag-nav { right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
  .ag-nav a { min-height: 36px; padding: 4px 9px; font-size: .68rem; }
  .ag-countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px 18px; padding: 7px 12px; }
  .ag-countdown p { grid-column: 1 / -1; font-size: .65rem; }
  .ag-scorebar { padding: 7px 10px; }
  .ag-level { display: none; }
  .ag-scorebar > div { width: 100%; justify-content: space-between; gap: 8px; }
  .ag-scorebar strong { font-size: .9rem; }
  .ag-overlay { padding: 8px 8px 8px 42px; }
  .ag-tag { font-size: .48rem; }
  .ag-overlay h2 { font-size: 1.2rem; }
  .ag-overlay p { font-size: .7rem; margin-bottom: 10px; }
  .ag-primary { padding: 8px 12px; font-size: .78rem; }
  .ag-controls { padding: 6px 8px; }
  .ag-controls > span { display: none; }
  .ag-controls > div { width: 100%; }
  .ag-controls button { flex: 1; min-height: 44px; padding: 5px 6px; }
  .ag-overlay-actions { gap: 5px; }
  .ag-overlay-actions .ag-help { min-height: 36px; padding: 6px; font-size: .65rem; }
}
@media (max-height: 500px) and (min-width: 480px) {
  .ag { padding: 8px 16px 46px; gap: 8px; grid-template-rows: auto minmax(0, 1fr); }
  .ag-intro { display: flex; align-items: center; justify-content: center; gap: 14px; }
  .ag h1 { font-size: 1.25rem; }
  .ag-nav { right: 16px; bottom: 8px; }
  .ag-nav a { min-height: 30px; padding: 4px 7px; font-size: .65rem; }
  .ag-countdown { display: grid; grid-template-columns: repeat(4, 1fr); padding: 4px 8px; gap: 2px 10px; }
  .ag-countdown p { grid-column: 1 / -1; font-size: .6rem; }
  .ag-time strong { font-size: .9rem; }
  .ag-scorebar { padding: 4px 10px; }
  .ag-controls { padding: 4px 10px; }
  .ag-controls button { min-height: 36px; }
  .ag-tag { display: none; }
  .ag-overlay h2 { font-size: 1.2rem; margin-top: 0; }
  .ag-overlay p { font-size: .7rem; margin-bottom: 7px; }
}
