/* ==========================================================================
   BOCÃO ARCADE — Estilos da aplicação
   Mobile-first: o jogo é feito para ser usado no celular, em pé, com uma mão.
   Só usa tokens do design system (--bc-*).
   ========================================================================== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bc-surface-canvas);
  color: var(--bc-text-primary);
  font-family: var(--bc-font-body);
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

/* durante a partida a página não rola: o polegar é do jogo */
body.is-playing { overflow: hidden; position: fixed; inset: 0; width: 100%; }

.arcade-bg {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 201, 30, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 201, 30, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* Manchas de luz desfocadas passeando ao fundo.
   Só `transform` é animado — a GPU cuida sozinha, sem repintura a cada quadro.
   O desfoque vem da própria suavidade do gradiente radial, não de `filter:blur`,
   que obrigaria o celular a rasterizar de novo o tempo todo. */
.arcade-bg::before,
.arcade-bg::after {
  content: "";
  position: absolute;
  width: 78vmax; height: 78vmax;
  border-radius: var(--bc-radius-full);
  will-change: transform;
}
.arcade-bg::before {
  top: -34vmax; left: -28vmax;
  background: radial-gradient(circle, rgba(255, 201, 30, 0.16) 0%, rgba(255, 201, 30, 0.05) 42%, transparent 68%);
  animation: brilho-a 34s ease-in-out infinite alternate;
}
.arcade-bg::after {
  bottom: -40vmax; right: -30vmax;
  background: radial-gradient(circle, rgba(225, 43, 30, 0.13) 0%, rgba(225, 43, 30, 0.04) 45%, transparent 70%);
  animation: brilho-b 46s ease-in-out infinite alternate;
}
@keyframes brilho-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(22vw, 16vh, 0) scale(1.18); }
}
@keyframes brilho-b {
  from { transform: translate3d(0, 0, 0) scale(1.1); }
  to   { transform: translate3d(-20vw, -14vh, 0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .arcade-bg::before, .arcade-bg::after { animation: none; }
}

.shell {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--bc-space-5);
  padding:
    calc(var(--bc-space-5) + env(safe-area-inset-top))
    var(--bc-space-4)
    calc(var(--bc-space-6) + env(safe-area-inset-bottom));
}

/* ---------- marca ---------- */
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--bc-space-1);
  text-align: center;
}
.brand__logo {
  width: 72px; height: 72px; object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(255, 201, 30, 0.45));
}
.brand__name {
  font-family: var(--bc-font-display);
  font-size: var(--bc-fs-2xl);
  text-transform: uppercase;
  letter-spacing: var(--bc-ls-tighter);
  line-height: var(--bc-lh-tight);
  margin: var(--bc-space-1) 0 0;
  color: var(--bc-yellow);
}
.brand__sub {
  font-size: var(--bc-fs-sm);
  color: var(--bc-text-secondary);
  margin: 0;
}
/* na partida a marca encolhe para sobrar tela para o labirinto */
body.is-playing .brand { display: none; }

/* ---------- telas ---------- */
.screen { display: none; width: 100%; max-width: 460px; }
.screen.is-active { display: block; animation: fade var(--bc-duration-slow) var(--bc-ease-entrance); }
.screen--game.is-active { display: flex; flex-direction: column; gap: var(--bc-space-3); }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  position: relative;
  background: var(--bc-surface-raised);
  border: 1px solid var(--bc-border-subtle);
  border-radius: var(--bc-radius-lg);
  padding: var(--bc-space-5);
  box-shadow: var(--bc-shadow-lg);
}

/* troféu: guarda a tabela de brindes sem roubar espaço de quem quer jogar */
.prize-btn {
  position: absolute;
  top: var(--bc-space-4);
  right: var(--bc-space-4);
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: rgba(255, 201, 30, 0.12);
  border: 1px solid var(--bc-border-strong);
  border-radius: var(--bc-radius-full);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.prize-btn:active { background: rgba(255, 201, 30, 0.28); }
/* o título não pode correr por baixo do troféu */
#screen-intro .title { padding-right: 56px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: var(--bc-z-modal); display: grid; place-items: center; padding: var(--bc-space-5); }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(5, 5, 5, 0.82); backdrop-filter: blur(3px); }
.modal__box {
  position: relative;
  width: 100%; max-width: 400px;
  max-height: 84dvh; overflow-y: auto;
  background: var(--bc-surface-raised);
  border: 1px solid var(--bc-border-strong);
  border-radius: var(--bc-radius-lg);
  padding: var(--bc-space-5);
  box-shadow: var(--bc-shadow-lg);
  animation: fade var(--bc-duration-normal) var(--bc-ease-entrance);
}

.title {
  font-family: var(--bc-font-display);
  text-transform: uppercase;
  font-size: var(--bc-fs-2xl);
  line-height: var(--bc-lh-snug);
  margin: 0 0 var(--bc-space-2);
}
.title--accent { color: var(--bc-yellow); }
.lede { color: var(--bc-text-secondary); margin: 0 0 var(--bc-space-5); font-size: var(--bc-fs-sm); }

.rules { list-style: none; padding: 0; margin: 0 0 var(--bc-space-5); display: grid; gap: var(--bc-space-3); }
.rules li { display: flex; gap: var(--bc-space-3); align-items: flex-start; font-size: var(--bc-fs-sm); color: var(--bc-text-secondary); line-height: var(--bc-lh-normal); }
.rules b { color: var(--bc-text-primary); }
.rules .ico {
  flex: 0 0 30px; height: 30px; display: grid; place-items: center;
  background: rgba(255, 201, 30, 0.12);
  border-radius: var(--bc-radius-full); font-size: 15px;
}

/* ---------- formulário ---------- */
.form { display: grid; gap: var(--bc-space-4); }
.consent {
  display: flex; gap: var(--bc-space-3); align-items: flex-start;
  font-size: var(--bc-fs-xs); color: var(--bc-text-muted); line-height: var(--bc-lh-normal);
}
.consent input { width: 24px; height: 24px; accent-color: var(--bc-yellow); flex: 0 0 auto; margin-top: 1px; }
.form-alert {
  display: none;
  background: rgba(225, 43, 30, 0.12);
  border: 1px solid var(--bc-danger);
  border-radius: var(--bc-radius-md);
  padding: var(--bc-space-3) var(--bc-space-4);
  font-size: var(--bc-fs-sm);
  margin-bottom: var(--bc-space-4);
}
.form-alert.is-visible { display: block; }

/* ---------- HUD + canvas ---------- */
.hud {
  display: flex; justify-content: space-between; align-items: center; gap: var(--bc-space-2);
  padding: var(--bc-space-3);
  background: var(--bc-surface-raised);
  border: 1px solid var(--bc-border-subtle);
  border-radius: var(--bc-radius-lg) var(--bc-radius-lg) 0 0;
  border-bottom: none;
}
.hud__block { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hud__label { font-size: 9px; text-transform: uppercase; letter-spacing: var(--bc-ls-wide); color: var(--bc-text-muted); white-space: nowrap; }
.hud__value { font-family: var(--bc-font-display); font-size: var(--bc-fs-lg); line-height: 1; color: var(--bc-yellow); }
.hud__lives { display: flex; gap: 3px; }
.hud__life { width: 15px; height: 15px; }

/* som e pausa moram aqui, fora do labirinto */
.hud__acoes { display: flex; gap: var(--bc-space-2); margin-left: auto; }
.hud__btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--bc-surface-overlay);
  border: 1px solid var(--bc-border-default);
  border-radius: var(--bc-radius-md);
  color: var(--bc-text-primary);
  font-size: 17px; line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.hud__btn:active { background: rgba(255, 201, 30, 0.20); }
.hud__btn[aria-pressed="false"] { opacity: 0.45; }

.stage {
  position: relative;
  background: var(--bc-black);
  border: 1px solid var(--bc-border-subtle);
  border-radius: 0 0 var(--bc-radius-lg) var(--bc-radius-lg);
  overflow: hidden;
  display: flex;
  justify-content: center;
}
#game-canvas {
  /* replaced element: com width/height auto + os dois máximos, o canvas
     encolhe mantendo a proporção 456x504 sem distorcer */
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  /* sobra da tela depois de HUD, analógico, dica, espaçamentos e safe-area */
  max-height: calc(100dvh - 330px);
  margin-inline: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- analógico ---------- */
.stick {
  --stick-size: 168px;
  position: relative;
  width: var(--stick-size);
  height: var(--stick-size);
  margin: var(--bc-space-2) auto 0;
  border-radius: var(--bc-radius-full);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 201, 30, 0.10), transparent 62%),
    var(--bc-surface-raised);
  box-shadow: inset 0 0 0 1px var(--bc-border-default), var(--bc-shadow-md);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.stick__seta {
  position: absolute;
  color: var(--bc-neutral-500);
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
}
.stick__seta--up { top: 10px; left: 50%; transform: translateX(-50%); }
.stick__seta--down { bottom: 10px; left: 50%; transform: translateX(-50%); }
.stick__seta--left { left: 10px; top: 50%; transform: translateY(-50%); }
.stick__seta--right { right: 10px; top: 50%; transform: translateY(-50%); }

.stick__knob {
  position: absolute;
  top: 50%; left: 50%;
  width: 74px; height: 74px;
  margin: -37px 0 0 -37px;
  border-radius: var(--bc-radius-full);
  background: var(--bc-gradient-gold-button);
  box-shadow: 0 4px 0 var(--bc-yellow-800), 0 8px 18px rgba(0, 0, 0, 0.55);
  /* sem transição enquanto o dedo arrasta: o movimento tem que ser imediato */
  will-change: transform;
  pointer-events: none;
}
.stick__knob::after {
  content: "";
  position: absolute;
  inset: 26px;
  border-radius: var(--bc-radius-full);
  background: rgba(5, 5, 5, 0.18);
}
.stick.is-idle .stick__knob { transition: transform var(--bc-duration-normal) var(--bc-ease-bounce); }
.stick.is-active { box-shadow: inset 0 0 0 1px var(--bc-border-strong), var(--bc-shadow-md); }

.hint { text-align: center; font-size: var(--bc-fs-xs); color: var(--bc-text-muted); margin: 0; }

/* telas baixas: encolhe o analógico em vez de cortar o labirinto */
@media (max-height: 700px) {
  .shell { gap: var(--bc-space-3); }
  .stick { --stick-size: 132px; }
  .stick__knob { width: 60px; height: 60px; margin: -30px 0 0 -30px; }
  .stick__knob::after { inset: 21px; }
  #game-canvas { max-height: calc(100dvh - 312px); }
}

/* ---------- voucher e resultado ---------- */
.voucher {
  border: 2px dashed var(--bc-yellow);
  border-radius: var(--bc-radius-lg);
  padding: var(--bc-space-5) var(--bc-space-4);
  text-align: center;
  background: rgba(255, 201, 30, 0.07);
}
.voucher__prize { font-family: var(--bc-font-display); font-size: var(--bc-fs-2xl); text-transform: uppercase; margin: var(--bc-space-2) 0; }
.voucher__code {
  font-family: ui-monospace, monospace; font-size: var(--bc-fs-xl); font-weight: 700;
  letter-spacing: 0.1em; color: var(--bc-yellow); margin: var(--bc-space-3) 0;
  user-select: all;
}
.voucher__meta { font-size: var(--bc-fs-xs); color: var(--bc-text-muted); margin: var(--bc-space-1) 0 0; }
.score-big {
  font-family: var(--bc-font-display); font-size: var(--bc-fs-4xl);
  line-height: 1; color: var(--bc-yellow); text-align: center; margin: var(--bc-space-2) 0 var(--bc-space-5);
}

.next-order {
  margin: var(--bc-space-5) 0 0;
  padding: var(--bc-space-4);
  border-radius: var(--bc-radius-md);
  background: rgba(255, 201, 30, 0.08);
  font-size: var(--bc-fs-sm);
  color: var(--bc-text-secondary);
  text-align: center;
}
.next-order b { color: var(--bc-yellow); }

.tier-list { display: grid; gap: var(--bc-space-2); margin: var(--bc-space-5) 0; }
.tier {
  display: flex; justify-content: space-between; align-items: center; gap: var(--bc-space-3);
  padding: var(--bc-space-3) var(--bc-space-4);
  border: 1px solid var(--bc-border-subtle); border-radius: var(--bc-radius-md);
  font-size: var(--bc-fs-sm);
}
.tier.is-won { border-color: var(--bc-yellow); background: rgba(255, 201, 30, 0.10); }
.tier__pts { font-family: var(--bc-font-display); color: var(--bc-text-muted); }
.tier.is-won .tier__pts { color: var(--bc-yellow); }

/* ---------- painel ---------- */
.admin-msg { font-size: var(--bc-fs-xs); margin: var(--bc-space-2) 0 0; min-height: 1em; }
.admin-msg.is-ok { color: var(--bc-success); }
.admin-msg.is-err { color: var(--bc-danger); }
.admin-total { font-size: var(--bc-fs-xs); color: var(--bc-text-muted); margin: var(--bc-space-1) 0 0; }
.table-wrap { overflow-x: auto; margin-top: var(--bc-space-3); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--bc-fs-xs); }
th, td { text-align: left; padding: var(--bc-space-2); border-bottom: 1px solid var(--bc-border-subtle); white-space: nowrap; }
th { color: var(--bc-text-muted); text-transform: uppercase; letter-spacing: var(--bc-ls-wide); }
.admin-total + .table-wrap td.pos { color: var(--bc-text-muted); font-variant-numeric: tabular-nums; }
td.pts { font-family: var(--bc-font-display); color: var(--bc-yellow); font-size: var(--bc-fs-sm); }
tr.grupo td {
  padding-top: var(--bc-space-4);
  border-bottom: none;
  display: flex; align-items: center; gap: var(--bc-space-2);
  white-space: normal;
}
.grupo__tag {
  font-family: var(--bc-font-display); text-transform: uppercase;
  font-size: var(--bc-fs-sm); color: var(--cor, var(--bc-yellow));
  border-left: 3px solid var(--cor, var(--bc-yellow)); padding-left: var(--bc-space-2);
}
.grupo__qtd { font-size: var(--bc-fs-xs); color: var(--bc-text-muted); }
.admin-nota { font-size: var(--bc-fs-xs); color: var(--bc-text-muted); text-align: center; margin: var(--bc-space-4) 0 0; }

/* ---------- rodapé ---------- */
.foot { margin-top: auto; padding-top: var(--bc-space-6); text-align: center; }
body.is-playing .foot { display: none; }
.foot__mode { font-size: 10px; color: var(--bc-neutral-600); margin: var(--bc-space-2) 0 0; }
.linkish {
  display: block; margin: var(--bc-space-4) auto 0;
  color: var(--bc-text-muted); font-size: var(--bc-fs-sm); text-decoration: none;
  background: none; border: none; cursor: pointer; font-family: inherit;
  min-height: 44px; padding: 0 var(--bc-space-4);
}
.linkish:active { color: var(--bc-yellow); }

/* ---------- desktop: só centraliza, sem virar outro produto ---------- */
@media (min-width: 720px) and (pointer: fine) {
  .shell { padding-top: var(--bc-space-8); }
  #game-canvas { max-height: calc(100dvh - 300px); }
}
