/* Visual de "arena mobile": painéis escuros com brilho dourado, botões amarelos com volume,
   texto grosso com contorno. Tudo sobre a arte do cofre animada pelo Phaser. */
:root {
  color-scheme: dark;
  --gold: #ffc400;
  --gold-hi: #ffe066;
  --gold-lo: #e29400;
  --ink: #0c0a10;
  --night: #120d1c;
  --panel-hi: #2a2233;
  --panel-lo: #17121f;
  --line: rgba(255, 196, 0, 0.35);
  --text: #ffffff;
  --muted: #c9c1d6;
  --red: #ff4d5e;
  --green: #5be36b;
  --cyan: #34d1ff;
  --rc: #ffc400; /* cor da raridade (roleta e cartão do prêmio) */
  --font-title: "Lilita One", "Arial Black", sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
  --stroke: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink),
            2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink),
            0 5px 0 var(--ink);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body { position: fixed; inset: 0; }
#game { position: fixed; inset: 0; }
#game canvas { touch-action: none; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Telas ---------- */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  pointer-events: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
/* centraliza sem cortar o topo quando o conteúdo é maior que a tela (espaçadores flexíveis) */
.screen.center::before, .screen.center::after { content: ""; flex: 1 1 0; min-height: 0; }
.screen > * { flex-shrink: 0; max-width: 100%; }
.screen.dim { background: radial-gradient(ellipse at 50% 40%, rgba(18, 13, 28, 0.55), rgba(8, 6, 12, 0.88)); }
.spacer { flex: 1; min-height: 8px; }
#scr-boot { background: var(--night); gap: 18px; }

/* ---------- Logo e topo ---------- */
.logo { width: min(92%, 420px); height: auto; display: block; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.55)); }
.logo-home { margin-top: 2px; animation: float 3.2s ease-in-out infinite; }
.logo-boot { width: min(80%, 360px); }
.topbar { width: 100%; max-width: 460px; display: flex; justify-content: space-between; align-items: center; }
.brand-chip {
  font-family: var(--font-title);
  font-size: 14px;
  letter-spacing: 1.5px;
  color: var(--gold);
  background: rgba(12, 10, 16, 0.78);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
}
.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: rgba(12, 10, 16, 0.78);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg .spk { fill: #fff; }
.icon-btn .off { display: none; stroke: var(--red); }
.icon-btn.muted .on { display: none; }
.icon-btn.muted .off { display: inline; }

/* ---------- Cartões ---------- */
.card {
  position: relative;
  width: 100%;
  max-width: 440px;
  min-width: 0;
  background: linear-gradient(180deg, var(--panel-hi), var(--panel-lo));
  border: 3px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 10px 0 var(--ink), 0 18px 40px rgba(0, 0, 0, 0.55), inset 0 0 0 2px var(--line), inset 0 2px 0 rgba(255, 255, 255, 0.08);
}
.key-card { display: flex; flex-direction: column; gap: 12px; padding: 34px 18px 16px; margin-bottom: 6px; }
.ribbon {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%) rotate(-1.5deg);
  font-family: var(--font-title);
  font-size: 20px;
  letter-spacing: 1px;
  white-space: nowrap;
  color: #fff;
  text-shadow: var(--stroke);
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 50%, var(--gold-lo));
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 6px 20px 10px;
  box-shadow: 0 5px 0 var(--ink);
}
.card-title { margin: 0; font-family: var(--font-title); font-weight: 400; font-size: 32px; text-align: center; color: var(--gold); text-shadow: var(--stroke); text-wrap: balance; }
.card-title.red { color: var(--red); }

.key-input {
  width: 100%;
  font-family: var(--font-title);
  font-size: 26px;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
  padding: 14px 10px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background:
    linear-gradient(180deg, #fffdf4, #f1e9d2);
  color: var(--ink);
  outline: none;
  box-shadow: inset 0 4px 0 rgba(0, 0, 0, 0.12);
  -webkit-user-select: text;
  user-select: text;
}
.key-input::placeholder { color: #b9ad8f; }
.key-input:focus { box-shadow: inset 0 4px 0 rgba(0, 0, 0, 0.12), 0 0 0 4px var(--gold); }
.key-input.shake { animation: shake 0.4s; border-color: var(--red); }

.hint { margin: 0; font-size: 14px; line-height: 1.4; text-align: center; color: var(--muted); font-weight: 800; }
.hint b { color: var(--gold); }
.hint.mock, .hint.mock b { color: #9ad7ff; }
.hint.warn { color: #ffb3bb; }

/* ---------- Botões ---------- */
.btn {
  font-family: var(--font-title);
  font-size: 22px;
  letter-spacing: 1px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 12px 18px 14px;
  cursor: pointer;
  position: relative;
  color: #fff;
  transition: transform 0.06s, box-shadow 0.06s, filter 0.15s;
}
.btn span { text-shadow: var(--stroke); }
.btn-yellow {
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 48%, var(--gold-lo) 100%);
  box-shadow: 0 7px 0 var(--ink), inset 0 -6px 0 rgba(150, 70, 0, 0.35), inset 0 3px 0 rgba(255, 255, 255, 0.6);
}
.btn-yellow:hover { filter: brightness(1.06); }
.btn-yellow:active { transform: translateY(6px); box-shadow: 0 1px 0 var(--ink), inset 0 -3px 0 rgba(150, 70, 0, 0.35); }
.btn-xl { font-size: 32px; padding: 12px 18px 16px; }
.btn-ghost { background: rgba(0, 0, 0, 0.25); color: var(--muted); border-color: rgba(255, 255, 255, 0.15); font-size: 17px; padding: 9px; }
.btn-ghost:active { transform: translateY(2px); }
.btn:focus-visible, .icon-btn:focus-visible, .wheel-hub:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.btn:disabled { filter: grayscale(0.7) brightness(0.75); pointer-events: none; }

/* ---------- Briefing / derrota ---------- */
.brief-card, .lose-card { overflow: hidden; }
.map-banner { position: relative; aspect-ratio: 16 / 8.4; max-width: 100%; overflow: hidden; border-bottom: 3px solid var(--ink); }
.map-banner.short { aspect-ratio: 16 / 6; }
.map-banner img { width: 100%; max-width: 100%; height: 100%; object-fit: cover; display: block; }
.map-banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(12, 10, 16, 0.85)); }
.map-title { position: absolute; left: 14px; right: 14px; bottom: 10px; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.map-title h2 { margin: 0; font-family: var(--font-title); font-weight: 400; font-size: 28px; line-height: 1; text-shadow: var(--stroke); }
.diff-pill {
  font-family: var(--font-title);
  font-size: 15px;
  letter-spacing: 1px;
  padding: 3px 12px 5px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  background: var(--green);
  box-shadow: 0 3px 0 var(--ink);
}
.brief-body { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; }
.mission { margin: 0; text-align: center; font-size: 16px; font-weight: 800; }
.mission b { color: var(--gold); }
.stats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.stats li {
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 7px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.stats .v { font-family: var(--font-title); font-size: 20px; font-variant-numeric: tabular-nums; }
.stats .k { font-size: 10px; color: var(--muted); font-weight: 900; letter-spacing: 0.4px; text-transform: uppercase; text-align: center; }
.lose-card .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.howto { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.howto li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 800; line-height: 1.25; }
.howto b { color: var(--gold); }
.ico { flex: 0 0 34px; height: 34px; border-radius: 50%; border: 3px solid var(--ink); position: relative; }
.ico-joy { background: radial-gradient(circle, var(--cyan) 0 30%, #fff 31% 46%, rgba(255, 255, 255, 0.25) 47%); }
.ico-atk { background: var(--gold); }
.ico-atk::before, .ico-atk::after { content: ""; position: absolute; background: var(--ink); left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 2px; }
.ico-atk::before { width: 20px; height: 3px; }
.ico-atk::after { width: 3px; height: 20px; }
.ico-sup { background: #ffe14d; }
.ico-sup::before { content: ""; position: absolute; inset: 6px 8px; background: var(--ink); clip-path: polygon(60% 0, 10% 55%, 45% 55%, 35% 100%, 90% 40%, 55% 40%); }
.ico-bush { background: radial-gradient(circle at 35% 35%, #7ad26a, #2e8a3a 70%); }

/* ---------- Drop / prêmio ---------- */
.title-pop {
  margin: 0;
  font-family: var(--font-title);
  font-weight: 400;
  font-size: clamp(32px, 10vw, 50px);
  white-space: nowrap;
  color: var(--gold);
  text-shadow: var(--stroke);
  animation: pop 0.5s cubic-bezier(.2, 1.6, .4, 1) both;
}
.wheel-stage { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.wheel-wrap {
  --size: min(86vw, 360px, calc(100vh - 330px));
  position: relative;
  width: max(240px, var(--size));
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin-top: 8px;
}
.wheel-wrap .rays {
  position: absolute;
  width: 155%;
  height: 155%;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--rc) 55%, transparent) 0deg 9deg, transparent 9deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 0 30%, transparent 68%);
  mask: radial-gradient(circle, #000 0 30%, transparent 68%);
  animation: spin 14s linear infinite;
  pointer-events: none;
  transition: background 0.4s;
}
.wheel { position: relative; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 12px 0 var(--ink)) drop-shadow(0 18px 30px rgba(0, 0, 0, 0.6)); }
.wheel .slice { stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }
.wheel .slice.win { animation: slice-win 0.5s ease-in-out infinite alternate; }
.wheel .label { font-family: var(--font-title); fill: #fff; stroke: var(--ink); stroke-width: 4px; paint-order: stroke; letter-spacing: 0.3px; }
.wheel .bulb { fill: #fff3b0; }
.wheel .bulb.alt { fill: #ffb800; }
.wheel-wrap.spinning .wheel .bulb { animation: bulb 0.22s steps(2) infinite; }
.wheel-wrap.spinning .wheel .bulb.alt { animation-delay: 0.11s; }
.wheel-pointer {
  position: absolute;
  top: -14px;
  left: 50%;
  width: 46px;
  height: 56px;
  margin-left: -23px;
  transform-origin: 50% 12px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, var(--gold-lo));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 3px 0 var(--ink));
  z-index: 2;
}
.wheel-pointer::after { content: ""; position: absolute; inset: 6px 10px 14px; background: rgba(255, 255, 255, 0.55); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.wheel-pointer.flick { animation: flick 0.12s ease-out; }
.wheel-hub {
  position: absolute;
  width: 27%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px solid var(--ink);
  background: radial-gradient(circle at 35% 30%, #4a3f58, #17121f 70%);
  box-shadow: 0 5px 0 var(--ink), inset 0 0 0 3px var(--line);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  z-index: 2;
}
.wheel-hub img { width: 70%; height: auto; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.5)); }
.wheel-hub:active { transform: scale(0.95); }
.wheel-hint { margin: 0; font-family: var(--font-title); font-size: 20px; text-shadow: var(--stroke); text-align: center; }
.wheel-hint.big { font-size: 30px; color: var(--rc); animation: pop 0.4s cubic-bezier(.2, 1.6, .4, 1) both; }
#btn-spin { min-width: 220px; animation: nudge 1.6s ease-in-out infinite; }
#btn-spin:disabled { animation: none; }

/* lista de prêmios do briefing */
.loot { display: flex; flex-direction: column; gap: 6px; }
.loot-title { margin: 0; font-family: var(--font-title); font-size: 15px; letter-spacing: 1px; color: var(--gold); text-shadow: var(--stroke); text-align: center; }
.loot-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.loot-list li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 900;
  padding: 3px 9px 3px 5px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 0 0 1.5px var(--c);
  white-space: nowrap;
}
.loot-list li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); border: 2px solid var(--ink); flex: none; }

.prize-card { display: flex; flex-direction: column; gap: 12px; padding: 30px 18px 16px; margin-top: 16px; animation: pop 0.45s cubic-bezier(.2, 1.6, .4, 1) both; }
.rarity {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-title);
  font-size: 20px;
  letter-spacing: 1px;
  white-space: nowrap;
  padding: 5px 22px 8px;
  border-radius: 14px;
  border: 3px solid var(--ink);
  background: var(--rc);
  color: #fff;
  text-shadow: var(--stroke);
  box-shadow: 0 5px 0 var(--ink), 0 0 24px var(--rc);
}
.prize-block { display: flex; flex-direction: column; gap: 12px; }
.hint.small { font-size: 12px; }
.hint.small span { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: 1px; }
.prize-name { font-family: var(--font-title); font-size: 34px; text-align: center; text-shadow: var(--stroke); line-height: 1.05; text-wrap: balance; }
.code-box {
  background: repeating-linear-gradient(-45deg, #fffdf4 0 10px, #f6efd9 10px 20px);
  color: var(--ink);
  border: 3px dashed var(--ink);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 27px;
  font-weight: 900;
  letter-spacing: 2px;
  -webkit-user-select: all;
  user-select: all;
}

/* ---------- Carregando ---------- */
.progress { width: min(70%, 280px); height: 18px; border: 3px solid var(--ink); border-radius: 999px; background: #2a2233; overflow: hidden; box-shadow: 0 4px 0 var(--ink); }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(180deg, var(--gold-hi), var(--gold) 50%, var(--gold-lo)); transition: width 0.2s; }
.loading-text { font-family: var(--font-title); font-size: 22px; text-align: center; margin: 0; text-shadow: var(--stroke); max-width: 340px; }
.dial {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  border: 4px solid var(--ink);
  background: radial-gradient(circle, var(--ink) 0 20%, var(--gold) 21% 60%, var(--gold-lo) 61%);
  box-shadow: 0 6px 0 var(--ink);
  position: relative;
  animation: spin 1.2s cubic-bezier(.6, .1, .3, .9) infinite;
}
.dial span { position: absolute; left: 50%; top: 6px; width: 6px; height: 18px; margin-left: -3px; border-radius: 3px; background: var(--ink); }

/* ---------- Toast / rotação ---------- */
#toast {
  position: fixed;
  left: 50%;
  top: max(16px, env(safe-area-inset-top));
  transform: translate(-50%, calc(-100% - 60px));
  background: #fff;
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 10px 16px;
  font-family: var(--font-title);
  font-size: 17px;
  box-shadow: 0 5px 0 var(--ink);
  z-index: 50;
  transition: transform 0.25s cubic-bezier(.2, 1.4, .4, 1);
  max-width: calc(100% - 32px);
  text-align: center;
}
#toast.show { transform: translate(-50%, 0); }
#toast.error { background: var(--red); color: #fff; }

#rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--night);
  color: var(--gold);
  font-family: var(--font-title);
  font-size: 26px;
  text-align: center;
  place-content: center;
  gap: 18px;
  justify-items: center;
}
.rotate-phone { width: 46px; height: 76px; border: 4px solid var(--gold); border-radius: 10px; animation: turn 1.6s ease-in-out infinite; }
@media (orientation: landscape) and (max-height: 520px) {
  #rotate { display: grid; }
}

/* ---------- Animações ---------- */
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slice-win { from { filter: brightness(1); } to { filter: brightness(1.55); } }
@keyframes bulb { 50% { fill: #5a4a20; } }
@keyframes flick { 0% { transform: rotate(0); } 40% { transform: rotate(-16deg); } 100% { transform: rotate(0); } }
@keyframes nudge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes turn { 0%, 20% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0deg); } }

@media (max-height: 700px) {
  .logo-home { width: min(70%, 320px); }
  .howto li { font-size: 12.5px; }
  .map-banner { aspect-ratio: 16 / 7; }
  .btn-xl { font-size: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .rays, .dial, .logo-home, .rotate-phone, #btn-spin, .wheel .slice.win { animation: none; }
}
