/* Planta técnica (blueprint): azul de cianótipo liso, grade de engenharia, fita métrica, cotas e carimbos.
   Sem degradês, sem brilho, sem desfoque. Raios de 0 a 2 px. As grades e as marcações da fita são SVG em data:. */
:root {
  --bg: #0b3d91;
  --panel: #09337d;
  --deep: #062a68;
  --ink: #eaf3ff;
  --ink-soft: #9dc0f2;
  --grid: #3f78d0;
  --yellow: #ffd400;
  --red: #ff4f2e;
  --green: #3ddc97;
  --navy: #07204f;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --cond: 'Arial Narrow', 'Roboto Condensed', 'Helvetica Neue', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cpath d='M120 0H0V120' fill='none' stroke='%233f78d0' stroke-width='1.5'/%3E%3C/svg%3E"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M24 0H0V24' fill='none' stroke='%233f78d0' stroke-width='1' opacity='.45'/%3E%3C/svg%3E");
  background-size: 120px 120px, 24px 24px;
  color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overflow-x: hidden;
}
#app { max-width: 560px; margin: 0 auto; padding: calc(14px + env(safe-area-inset-top)) 14px calc(80px + env(safe-area-inset-bottom)); min-height: 100dvh; display: flex; flex-direction: column; gap: 16px; }
h1, h2, h3, p { margin: 0; }
h1 { font-family: var(--cond); font-size: 2.3rem; line-height: 1; font-weight: 900; text-transform: uppercase; letter-spacing: 0.06em; }
h2 { font-family: var(--cond); font-size: 1.35rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.15; }
h3 { font-family: var(--mono); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-soft); }
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); }
a { color: var(--yellow); font-weight: 700; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---- prancha (cartão) com marcas de canto ---- */
.sheet { position: relative; background: var(--panel); border: 2px solid var(--ink); border-radius: 0; padding: 18px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.sheet::before, .sheet::after { content: ''; position: absolute; width: 14px; height: 14px; border: 0 solid var(--ink); }
.sheet::before { top: -8px; left: -8px; border-top-width: 2px; border-left-width: 2px; }
.sheet::after { bottom: -8px; right: -8px; border-bottom-width: 2px; border-right-width: 2px; }
.sheet.plain::before, .sheet.plain::after { display: none; }
.sheet.deep { background: var(--deep); }
.stamp { display: inline-block; border: 3px solid var(--red); color: var(--red); padding: 1px 10px; font-family: var(--mono); font-weight: 900; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.85rem; transform: rotate(-4deg); align-self: flex-start; background: transparent; }
.stamp.green { border-color: var(--green); color: var(--green); }
.stamp.yellow { border-color: var(--yellow); color: var(--yellow); }

/* ---- cota (linha de dimensão) ---- */
.cota { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 0.85rem; color: var(--ink); }
.cota::before, .cota::after { content: ''; flex: 1; height: 12px; border-bottom: 2px solid var(--ink); }
.cota::before { border-left: 2px solid var(--ink); }
.cota::after { border-right: 2px solid var(--ink); }
.cota b { font-weight: 700; white-space: nowrap; }

/* ---- botões: fita métrica ---- */
button {
  font: inherit; font-family: var(--cond); font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--navy); background-color: var(--yellow);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='10'%3E%3Cpath d='M1 10V1M9 10V6M17 10V6M25 10V6M33 10V6' stroke='%2307204f' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: repeat-x; background-position: left bottom; background-size: 40px 10px;
  border: 2px solid var(--ink); border-radius: 0; padding: 12px 18px 16px; min-height: 54px; cursor: pointer; text-align: center; touch-action: manipulation;
  font-size: 1.05rem; transition: transform 0.06s, opacity 0.2s;
}
button:active { transform: translateY(2px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.ghost { background-color: transparent; background-image: none; color: var(--ink); padding-bottom: 12px; }
button.red { background-color: var(--red); color: #fff; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='10'%3E%3Cpath d='M1 10V1M9 10V6M17 10V6M25 10V6M33 10V6' stroke='%23ffffff' stroke-width='2' fill='none'/%3E%3C/svg%3E"); }
button.green { background-color: var(--green); }
button.small { min-height: 40px; padding: 6px 12px 8px; font-size: 0.85rem; background-image: none; }
button.big { min-height: 68px; font-size: 1.3rem; }

input, textarea, select {
  font: inherit; color: var(--ink); background: var(--deep); border: 2px solid var(--ink); border-radius: 0;
  padding: 12px 12px; width: 100%; min-height: 52px;
}
::placeholder { color: #6f9bdc; }
textarea { resize: none; min-height: 80px; }
input:focus, textarea:focus, select:focus { outline: 3px solid var(--yellow); outline-offset: 0; }
input.code { text-transform: uppercase; letter-spacing: 0.45em; text-align: center; font-weight: 700; font-size: 1.5rem; font-family: var(--mono); }
label.field { display: flex; flex-direction: column; gap: 4px; }
label.field > span { font-family: var(--mono); font-size: 0.72rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.12em; }

.seg { display: flex; border: 2px solid var(--ink); }
.seg button { flex: 1; background: transparent; background-image: none; color: var(--ink); border: 0; min-height: 46px; padding: 8px 4px; font-size: 0.92rem; }
.seg button + button { border-left: 2px solid var(--ink); }
.seg button.on { background: var(--yellow); color: var(--navy); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 2px 10px; border: 2px solid var(--ink); font-family: var(--mono); font-weight: 700; font-size: 0.85rem; }
.chip.done { background: var(--green); color: var(--navy); border-color: var(--green); }
.chip.off { opacity: 0.45; border-style: dashed; }
.chip.master { border-color: var(--yellow); color: var(--yellow); }
button.chip { min-height: 38px; background-image: none; padding: 4px 10px; background-color: transparent; color: var(--ink); text-transform: none; letter-spacing: 0; font-family: var(--mono); font-size: 0.85rem; }
button.chip.on { background-color: var(--yellow); color: var(--navy); }

/* ---- topo ---- */
.top { display: flex; align-items: center; gap: 8px; justify-content: space-between; min-height: 38px; flex-wrap: wrap; }
.tag { font-family: var(--mono); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; border: 2px solid var(--ink); padding: 1px 8px; white-space: nowrap; }
.tag.code { background: var(--yellow); color: var(--navy); border-color: var(--yellow); letter-spacing: 0.25em; }
.tag.mode { color: var(--yellow); border-color: var(--yellow); }
.timer { position: relative; font-family: var(--mono); font-weight: 700; white-space: nowrap; flex: none; border: 2px solid var(--ink); padding: 1px 10px; min-width: 92px; overflow: hidden; }
.timer:empty { display: none; }
.timer .bar { position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--yellow); }
.timer.low { color: var(--red); border-color: var(--red); animation: pulse 0.6s infinite alternate; }
.icon-btn { background-color: transparent; background-image: none; color: var(--ink); min-height: 40px; width: 40px; padding: 0; font-size: 1.1rem; }

/* ---- home ---- */
.hero { padding-top: 3vh; display: flex; flex-direction: column; gap: 14px; }
.tape { position: relative; background-color: var(--yellow); color: var(--navy); border: 2px solid var(--ink); padding: 14px 16px 24px; font-family: var(--cond); font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; font-size: 2.6rem; line-height: 1; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='14'%3E%3Cpath d='M1 14V2M9 14V8M17 14V8M25 14V8M33 14V8' stroke='%2307204f' stroke-width='2' fill='none'/%3E%3C/svg%3E"); background-repeat: repeat-x; background-position: left bottom; background-size: 40px 14px; }
.tape i { font-style: normal; color: var(--red); }

/* ---- pergunta e chute ---- */
.qtext { font-family: var(--cond); font-size: 1.7rem; line-height: 1.15; font-weight: 900; text-transform: uppercase; letter-spacing: 0.03em; }
.qtext + .small { margin-top: -4px; }
.qby { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-soft); }
.meter { display: flex; align-items: center; gap: 10px; background: var(--deep); border: 2px solid var(--ink); padding: 6px 12px; }
.meter input { background: transparent; border: 0; outline: 0; color: var(--yellow); font-family: var(--mono); font-size: 2.2rem; font-weight: 700; text-align: right; padding: 4px 0; min-height: 0; flex: 1; min-width: 0; }
.meter input:focus { outline: 0; }
.meter .un { font-family: var(--mono); font-size: 1.1rem; color: var(--ink-soft); white-space: nowrap; }
.readout { font-family: var(--mono); font-size: 0.95rem; color: var(--ink-soft); min-height: 1.4em; text-align: right; }
.readout b { color: var(--yellow); }
.hint { border: 2px dashed var(--yellow); padding: 8px 12px; color: var(--yellow); font-family: var(--mono); font-size: 0.92rem; animation: stampin 0.35s steps(4) both; }
.dare { display: flex; align-items: center; gap: 10px; border: 2px solid var(--ink); padding: 8px 12px; cursor: pointer; background: transparent; color: var(--ink); text-align: left; font-family: var(--cond); letter-spacing: 0.06em; text-transform: uppercase; font-weight: 900; min-height: 52px; background-image: none; }
.dare.on { background: var(--red); border-color: var(--red); color: #fff; }
.dare.used { opacity: 0.4; text-decoration: line-through; cursor: not-allowed; }
.dare small { font-family: var(--mono); font-weight: 400; text-transform: none; letter-spacing: 0; display: block; opacity: 0.85; }

/* ---- régua ---- */
.ruler { position: relative; height: 150px; margin: 6px 6px 0; }
.ruler .axis { position: absolute; left: 0; right: 0; top: 75px; border-top: 3px solid var(--ink); }
.ruler .tick { position: absolute; top: 69px; height: 12px; border-left: 2px solid var(--ink); }
.ruler .tick.sm { top: 72px; height: 6px; opacity: 0.6; }
.pin { position: absolute; width: 0; display: flex; flex-direction: column; align-items: center; animation: drop 0.5s steps(6) both; }
.pin.up { bottom: 75px; }
.pin.down { top: 75px; flex-direction: column-reverse; }
.ruler.still .pin { animation: none; }
.pin .dot { min-width: 30px; height: 30px; padding: 0 4px; display: grid; place-items: center; background: var(--ink); color: var(--navy); font-family: var(--mono); font-weight: 900; font-size: 0.85rem; border: 2px solid var(--ink); white-space: nowrap; transform: translateX(0); }
.pin .stem { width: 0; height: 22px; border-left: 2px solid var(--ink); }
.pin.me .dot { background: var(--yellow); border-color: var(--yellow); }
.pin.best .dot { background: var(--green); border-color: var(--green); }
.pin.far .dot { background: transparent; color: var(--ink); }
.pin .washers { display: flex; flex-direction: column-reverse; gap: 2px; margin-bottom: 2px; }
.pin.down .washers { flex-direction: column; margin: 2px 0 0; }
.washer { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--yellow); position: relative; background: transparent; }
.washer::after { content: ''; position: absolute; inset: 3px; border: 1.5px solid var(--yellow); border-radius: 50%; }
.flag { position: absolute; left: 0; width: 0; top: 0; bottom: 0; animation: stampin 0.4s steps(4) both; animation-delay: var(--d, 1.5s); }
.flag::before { content: ''; position: absolute; left: -1px; top: 6px; bottom: 6px; border-left: 3px solid var(--red); }
.flag span { position: absolute; top: 0; left: 3px; background: var(--red); color: #fff; font-family: var(--mono); font-weight: 900; font-size: 0.78rem; padding: 1px 6px; letter-spacing: 0.08em; white-space: nowrap; }
.scalehint { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-soft); text-align: right; }

/* ---- fichas (arruelas) ---- */
.mk { display: flex; align-items: center; gap: 10px; border: 2px solid var(--ink); padding: 8px 10px; background: var(--deep); }
.mk.mine { border-color: var(--yellow); }
.mk .num { min-width: 30px; height: 30px; display: grid; place-items: center; background: var(--ink); color: var(--navy); font-family: var(--mono); font-weight: 900; }
.mk .val { flex: 1; font-family: var(--mono); font-size: 1.25rem; font-weight: 700; }
.mk .val small { color: var(--ink-soft); font-size: 0.75rem; font-weight: 400; display: block; }
.mk .ctl { display: flex; align-items: center; gap: 6px; }
.mk .ctl button { min-height: 40px; width: 40px; padding: 0 0 4px; font-size: 1.3rem; }
.mk .stackw { display: flex; gap: 3px; min-width: 40px; justify-content: center; }
.stock { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 0.9rem; }

/* ---- revelação ---- */
.answer { text-align: center; }
.answer .big { font-family: var(--mono); font-weight: 700; font-size: 2.6rem; color: var(--yellow); line-height: 1.1; animation: stampin 0.5s steps(5) both; animation-delay: 1.4s; }
.answer .un { font-family: var(--mono); color: var(--ink-soft); font-size: 1.1rem; }
.line { display: grid; grid-template-columns: 28px 1fr auto; gap: 4px 10px; align-items: baseline; padding: 8px 4px; border-bottom: 1px dashed var(--ink-soft); animation: slidein 0.4s steps(5) both; }
.line .pos { font-family: var(--mono); color: var(--ink-soft); }
.line .nm { font-weight: 700; word-break: break-word; }
.line .pts { font-family: var(--mono); font-weight: 900; color: var(--yellow); text-align: right; }
.line .det { grid-column: 2 / 4; font-family: var(--mono); font-size: 0.8rem; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.line .det .bad { color: var(--red); }
.line .det .good { color: var(--green); }
.verdict { font-family: var(--cond); text-transform: uppercase; font-weight: 900; letter-spacing: 0.06em; font-size: 1.15rem; text-align: center; }
.src { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-soft); text-align: center; }

/* ---- placar e fim ---- */
.board { display: flex; flex-direction: column; }
.row-s { display: flex; align-items: baseline; gap: 8px; padding: 6px 2px; border-bottom: 1px dashed var(--ink-soft); font-weight: 700; }
.row-s .n { width: 2.2ch; color: var(--ink-soft); font-family: var(--mono); }
.row-s .nm { word-break: break-word; }
.row-s .dots { flex: 1; }
.row-s .tot { font-family: var(--mono); font-size: 1.2rem; font-weight: 700; }
.row-s .d { color: var(--green); font-family: var(--mono); font-size: 0.85rem; }
.row-s.me { background: rgba(255, 212, 0, 0.18); }
.row-s .dare-mark { font-family: var(--mono); font-size: 0.7rem; color: var(--ink-soft); text-decoration: line-through; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; min-height: 230px; padding-top: 18px; }
.podium .col { flex: 1; max-width: 150px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-weight: 700; }
.podium .step { width: 100%; border: 2px solid var(--ink); border-bottom: 0; display: grid; place-items: start center; padding-top: 8px; font-family: var(--mono); font-size: 2rem; font-weight: 700; color: var(--navy); transform-origin: bottom; animation: rise 0.9s steps(10) both; }
.podium .c1 .step { height: 150px; background: var(--yellow); animation-delay: 1.1s; }
.podium .c2 .step { height: 105px; background: var(--ink); animation-delay: 0.6s; }
.podium .c3 .step { height: 75px; background: var(--green); animation-delay: 0.1s; }
.award { display: flex; gap: 12px; align-items: flex-start; }
.award .stamp { align-self: flex-start; min-width: 96px; text-align: center; font-size: 0.72rem; }
.award b { font-family: var(--cond); text-transform: uppercase; letter-spacing: 0.05em; font-size: 1.05rem; }
.fall { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.fall i { position: absolute; top: -30px; width: 10px; height: 18px; background: var(--c); animation: fall linear forwards; }

/* ---- passe o celular (modo local) ---- */
.gate { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; text-align: center; }
.gate .who { font-family: var(--cond); text-transform: uppercase; letter-spacing: 0.05em; font-size: 2.8rem; font-weight: 900; word-break: break-word; color: var(--yellow); }

/* ---- sala de espera ---- */
.codebox { text-align: center; align-items: center; }
.codebox .code { font-family: var(--mono); font-size: 3.4rem; font-weight: 700; letter-spacing: 0.18em; line-height: 1; text-indent: 0.18em; color: var(--yellow); }
.qr { width: 180px; max-width: 60vw; margin: 0 auto; border: 2px solid var(--ink); background: #fff; padding: 4px; }
.qr svg { display: block; width: 100%; height: auto; }
.pl { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px dashed var(--ink-soft); font-weight: 700; }
.pl .dot { width: 12px; height: 12px; background: var(--green); flex: none; }
.pl.off .dot { background: transparent; border: 2px solid var(--ink-soft); }
.pl .nm { flex: 1; word-break: break-word; }
.pl .tagm { font-family: var(--mono); font-size: 0.7rem; color: var(--yellow); border: 1px solid var(--yellow); padding: 0 6px; }

#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); opacity: 0; background: var(--yellow); color: var(--navy); border: 2px solid var(--ink); padding: 10px 16px; max-width: 90vw; text-align: center; font-weight: 700; pointer-events: none; transition: 0.25s; z-index: 60; font-family: var(--mono); font-size: 0.9rem; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- modo telão ---- */
body.tv #app { max-width: 1280px; padding: 28px 40px; font-size: 1.35rem; }
body.tv h1 { font-size: 3.6rem; }
body.tv .qtext { font-size: 3.2rem; }
body.tv .codebox .code { font-size: 8rem; }
body.tv .qr { width: 260px; }
body.tv .chip { font-size: 1.15rem; padding: 4px 14px; }
body.tv .row-s { font-size: 1.6rem; }
body.tv .ruler { height: 220px; margin: 10px 20px 0; }
body.tv .ruler .axis { top: 110px; }
body.tv .ruler .tick { top: 104px; }
body.tv .pin.up { bottom: 110px; }
body.tv .pin.down { top: 110px; }
body.tv .pin .dot { min-width: 44px; height: 44px; font-size: 1.15rem; }
body.tv .answer .big { font-size: 4.6rem; }
body.tv .line { font-size: 1.4rem; }
body.tv .tvgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

@keyframes drop { from { transform: translateY(-40px); opacity: 0; } to { transform: none; opacity: 1; } }
.pin.down { animation-name: dropdown; }
@keyframes dropdown { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes stampin { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slidein { from { transform: translateX(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes fall { to { transform: translateY(112vh) rotate(400deg); } }
@keyframes pulse { to { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; } .fall { display: none; } }
@media (max-width: 380px) { .qtext { font-size: 1.4rem; } .codebox .code { font-size: 2.8rem; } .tape { font-size: 2.1rem; } .meter input { font-size: 1.8rem; } }
