@font-face {
  font-family: "Press Start 2P";
  src: url("fonts/PressStart2P.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Nunito";
  src: url("fonts/Nunito.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #050f1a;
  --panel: #0b2948;
  --panel-2: #10385b;
  --line: #2c5a7e;
  --line-soft: #1c3f5c;
  --text: #eaf4ff;
  --muted: #9fc0d8;
  --gold: #ffc34d;
  --cyan: #66d7ff;
  --green: #38d996;
  --green-deep: #147451;
  --red: #ff5d7a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background:
    radial-gradient(1100px 620px at 72% 12%, #123a5f 0%, #071a2c 55%, #050f1a 100%);
  color: var(--text);
  font-family: "Nunito", ui-sans-serif, system-ui, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(102, 215, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(102, 215, 255, 0.045) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
}

.screen {
  position: relative;
  z-index: 1;
}

.screen[hidden] { display: none; }

/* ---------- Home ---------- */

.home {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.home-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border: 2px solid var(--gold);
  background: var(--panel);
  box-shadow: inset 0 0 0 2px #071a2c;
  color: var(--gold);
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
}

.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.brand-text strong {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--gold);
  white-space: nowrap;
}

.brand-text small {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.badge {
  margin: 0;
  flex: none;
  padding: 6px 10px;
  border: 1px solid var(--line);
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  align-items: center;
  gap: clamp(28px, 5vw, 72px);
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 56px) clamp(16px, 4vw, 40px);
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--gold);
  font-family: "Press Start 2P", monospace;
  font-size: clamp(22px, 3.4vw, 38px);
  font-weight: 400;
  line-height: 1.35;
  text-shadow: 0 4px 0 #071a2c;
}

h1 span { display: block; }

.tagline {
  margin: 16px 0 18px;
  color: var(--cyan);
  font-size: clamp(13px, 1.4vw, 16px);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.lede {
  max-width: 56ch;
  margin: 0;
  color: var(--text);
  font-size: clamp(15px, 1.3vw, 17px);
  line-height: 1.65;
}

.features {
  display: grid;
  gap: 10px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.features li {
  position: relative;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.features li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  background: var(--gold);
  box-shadow: 0 0 0 2px #071a2c;
}

.features b { color: var(--text); }

.cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 28px;
}

.micro {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* ---------- Cartão de apresentação ---------- */

.hero-card {
  position: relative;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: 6px;
  background: linear-gradient(180deg, var(--panel), #0a2238);
  box-shadow: var(--shadow);
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(102, 215, 255, 0.08);
  border-radius: 3px;
  pointer-events: none;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--cyan);
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  letter-spacing: 0.06em;
  line-height: 1.6;
  text-transform: uppercase;
}

.card-hero {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 54px;
  height: 54px;
  flex: none;
  display: grid;
  place-items: center;
  border: 2px solid var(--gold);
  background: #071a2c;
  color: var(--gold);
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
}

.card-name { margin: 0 0 4px; font-weight: 700; font-size: 15px; }

.card-level { margin: 0; color: var(--muted); font-size: 12px; }

.hp {
  height: 10px;
  margin: 14px 0 6px;
  border: 1px solid #7a2b3d;
  background: #3a1620;
}

.hp span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff5d7a, #ff8a9d);
}

.card-meta { margin: 0; color: var(--muted); font-size: 12px; }

.card-mission {
  margin: 16px 0;
  padding: 9px 10px;
  border: 1px dashed var(--line);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
}

.card-mission span {
  margin-right: 6px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
  padding: 3px 7px;
  border: 1px solid var(--line-soft);
  color: var(--cyan);
  font-size: 11px;
}

.card-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.home-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px clamp(16px, 4vw, 40px);
  border-top: 1px solid rgba(44, 90, 126, 0.45);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}

/* ---------- Área do jogo ---------- */

body.playing { overflow: hidden; }

.play {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #050f1a;
}

.play-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px clamp(10px, 2.4vw, 20px);
  border-bottom: 1px solid var(--line-soft);
  background: #081c2f;
}

.brand-mini {
  flex: 1;
  margin: 0;
  overflow: hidden;
  color: var(--gold);
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.status {
  margin: 0;
  flex: none;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status[data-state="ready"] { color: var(--cyan); }
.status[data-state="error"] { color: var(--red); }

.play-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: clamp(8px, 1.6vw, 16px);
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: #02070d;
}

#canvas {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: block;
  object-fit: contain;
  touch-action: none;
  outline: none;
}

#canvas:focus { outline: none; }

.play-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.controls { margin: 0; color: var(--muted); font-size: 12px; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(4, 11, 18, 0.94);
}

.overlay[hidden] { display: none; }

.overlay-title { margin: 0; font-size: clamp(15px, 2.4vw, 20px); font-weight: 700; }

.track {
  width: min(420px, 80%);
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #1d2431;
}

.bar {
  width: 0;
  height: 100%;
  background: var(--gold);
  transition: width 120ms linear;
}

.bar.indeterminate {
  width: 40%;
  animation: slide 1.1s ease-in-out infinite alternate;
}

@keyframes slide {
  from { transform: translateX(-20%); }
  to { transform: translateX(160%); }
}

.pct {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hint { margin: 0; max-width: 46ch; color: var(--muted); font-size: 13px; line-height: 1.5; }

.error .overlay-title { color: var(--red); }

.error-msg {
  margin: 0;
  max-width: 52ch;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

.error-detail {
  margin: 0;
  max-width: 60ch;
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---------- Botões ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover { border-color: var(--cyan); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.btn.primary {
  border-color: var(--green);
  background: var(--green-deep);
  color: #fff;
}

.btn.primary:hover { background: #188a5f; border-color: #6ef0b8; }

.btn.big {
  min-height: 52px;
  padding: 16px 24px;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 0 #0a3d2a;
}

.btn.big:active { transform: translateY(2px); box-shadow: 0 2px 0 #0a3d2a; }
.btn.big:disabled { opacity: 0.6; cursor: progress; }

.btn.ghost {
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.btn.ghost:hover { color: var(--cyan); }

.noscript { padding: 16px; color: var(--red); }

/* ---------- Tela cheia ---------- */

.stage:fullscreen {
  width: 100vw;
  height: 100dvh;
  border: 0;
  border-radius: 0;
  background: #000;
}

/* ---------- Aviso de orientação ---------- */

.rotate {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(4, 11, 18, 0.97);
}

.rotate[hidden] { display: none; }

.rotate-title {
  margin: 0;
  color: var(--gold);
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.rotate-text {
  margin: 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.rotate-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---------- Responsivo ---------- */

@media (max-width: 900px) {
  .home-main {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 28px;
  }

  .hero-card { max-width: 520px; }
}

@media (max-width: 560px) {
  .home-top { padding: 12px 14px; }
  .badge { display: none; }
  .home-main { padding: 20px 14px 28px; }
  .features li { font-size: 13px; }
  .cta { align-items: flex-start; flex-direction: column; gap: 10px; }
  .btn { min-height: 44px; }
  .btn.big { width: 100%; }
  .home-foot { padding: 12px 14px; font-size: 10px; }
  .home-foot span:last-child { display: none; }
  .brand-text strong { font-size: 8px; }
  .brand-text small { font-size: 10px; }
  .card-head { font-size: 6px; }
  .play-top { padding: 6px 10px; }
  .brand-mini { display: none; }
  .play-wrap { padding: 8px; gap: 6px; }
  .controls { font-size: 11px; }
}

/* Telas baixas: celular deitado e janelas curtas */
@media (max-height: 620px) {
  .home-top { padding: 10px 16px; }
  .home-main {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 14px;
    padding: 12px 16px;
  }
  .hero-card, .features { display: none; }
  h1 { font-size: clamp(18px, 4.4vw, 26px); }
  .tagline { margin: 8px 0 10px; font-size: 13px; }
  .lede { font-size: 14px; line-height: 1.45; }
  .cta { margin-top: 14px; }
  .home-foot { display: none; }
}

@media (max-height: 620px) and (orientation: landscape) {
  .play-top .status { display: none; }
  .play-wrap { padding: 5px; gap: 0; }
  .play-actions {
    position: fixed;
    top: 4px;
    right: 8px;
    z-index: 4;
  }
  .play-actions .controls { display: none; }
  .play-actions .btn {
    min-height: 32px;
    padding: 5px 10px;
    font-size: 12px;
    background: rgba(8, 28, 47, 0.92);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bar { transition: none; }
  .bar.indeterminate { animation: none; width: 100%; opacity: 0.5; }
}
