/* =============================================================================
   THYNK LAB — estilos globais (mobile-first, PWA, landing + play)
   ============================================================================= */

:root {
  --bg-deep: #06060a;
  --bg-elev: #0e0e16;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --text: #f2f2f8;
  --text-muted: rgba(242, 242, 248, 0.62);
  --accent: #e50914;
  --accent-2: #8b5cf6;
  --accent-3: #00d4aa;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Consolas", monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html.theme-light {
  --bg-deep: #e8e8f0;
  --bg-elev: #f4f4fa;
  --glass: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(20, 20, 40, 0.12);
  --text: #12121a;
  --text-muted: rgba(18, 18, 26, 0.62);
  --shadow: 0 12px 40px rgba(20, 20, 40, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-deep);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* Fundo: imagem opcional + gradiente (fallback se JPG em falta) */
body.page-landing {
  background-color: var(--bg-deep);
  background-image:
    linear-gradient(165deg, rgba(229, 9, 20, 0.12) 0%, transparent 42%),
    linear-gradient(320deg, rgba(139, 92, 246, 0.1) 0%, transparent 45%),
    url("background.jpg");
  background-size: cover;
  background-position: center top;
  background-attachment: scroll;
}

body.page-landing::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(139, 92, 246, 0.25), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 80%, rgba(229, 9, 20, 0.12), transparent 50%);
  z-index: 0;
}

html:has(body.page-play) {
  height: 100%;
  min-height: 100dvh;
}

body.page-play {
  background: radial-gradient(ellipse 120% 80% at 50% 0%, #1a1025 0%, var(--bg-deep) 55%);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Glass */
.glass-panel {
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.25rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(120deg, var(--accent), #b20710);
  box-shadow: 0 8px 28px rgba(229, 9, 20, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 10px 36px rgba(229, 9, 20, 0.45);
}

.btn-ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
}

.btn-small {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* CRT overlay (opcional) */
.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.35s ease;
}

body.crt-on .crt-overlay {
  opacity: 1;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.12) 0px,
    rgba(0, 0, 0, 0.12) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

body.crt-on::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.35) 100%);
}

/* ========== Landing ========== */
.page-landing > * {
  position: relative;
  z-index: 1;
}

.logo-link {
  color: inherit;
  text-decoration: none;
}

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.1rem 3rem;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 0.85rem) 0 1rem;
  gap: 1rem;
}

.logo-img {
  height: 40px;
  width: auto;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hero {
  padding: 2.5rem 0 2rem;
  text-align: center;
}

.hero h1 {
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 0.75rem;
}

.hero-gradient {
  background: linear-gradient(120deg, #fff 0%, #f0a8ff 40%, #7cdbff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

html.theme-light .hero-gradient {
  background: linear-gradient(120deg, #1a0a12 0%, #6b1a50 35%, #0a3d5c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-tagline {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 36ch;
  margin: 0 auto 1.5rem;
}

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.section {
  margin-top: 3rem;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
}

.section-lead {
  color: var(--text-muted);
  margin: 0 0 1.25rem;
  max-width: 60ch;
}

.nfc-banner {
  margin-top: 2rem;
  padding: 1.5rem 1.25rem;
  text-align: center;
}

.nfc-icon {
  font-size: 2rem;
  margin-bottom: 0.35rem;
}

.console-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.console-card {
  padding: 1.25rem 1rem;
  text-align: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.console-card:hover {
  transform: translateY(-4px);
  border-color: rgba(229, 9, 20, 0.35);
}

.console-card h3 {
  margin: 0.5rem 0 0.25rem;
  font-size: 1.1rem;
}

.console-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.console-chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: rgba(229, 9, 20, 0.15);
  color: #ff8a93;
}

.split-section {
  display: grid;
  gap: 1.25rem;
  margin-top: 2.5rem;
}

@media (min-width: 768px) {
  .split-section {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.info-card {
  padding: 1.35rem 1.25rem;
}

.info-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
}

.info-card p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.55;
  font-size: 0.95rem;
}

.footer {
  margin-top: 3.5rem;
  padding: 1.5rem 0 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ========== Boot + loading (play) ========== */
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #020204;
  font-family: var(--mono);
}

.boot-inner {
  text-align: left;
  min-width: min(90vw, 320px);
}

.boot-brand {
  font-size: 0.75rem;
  letter-spacing: 0.35em;
  color: #e50914;
  margin: 0 0 0.25rem;
  animation: boot-fade 0.6s ease forwards;
}

.boot-sub {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.45);
  margin: 0 0 1.5rem;
  animation: boot-fade 0.8s ease forwards;
}

.boot-line {
  margin: 0.35rem 0;
  font-size: 0.8rem;
  color: #7cff9e;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.boot-line--visible {
  opacity: 1;
  transform: translateY(0);
}

.boot-cursor {
  animation: boot-blink 0.9s step-end infinite;
}

.boot-dots {
  letter-spacing: 0.1em;
}

@keyframes boot-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes boot-blink {
  50% {
    opacity: 0;
  }
}

.console-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 4, 8, 0.92);
}

.loading-inner {
  padding: 1.5rem 1.25rem;
  max-width: 90vw;
}

.loading-ascii {
  margin: 0 0 1rem;
  font-family: var(--mono);
  font-size: clamp(0.55rem, 2.8vw, 0.75rem);
  color: #9ae6ff;
  line-height: 1.35;
}

.loading-blink {
  animation: boot-blink 0.8s step-end infinite;
}

.loading-msg {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: #c4ffd4;
  margin: 0 0 1rem;
  min-height: 1.25em;
}

.loading-bar {
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.loading-bar-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-3), var(--accent-2));
  animation: load-fill 1.8s ease-out forwards;
}

@keyframes load-fill {
  to {
    width: 100%;
  }
}

/* ========== Pré-jogo (capa + START) ========== */
.pre-play {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(5, 5, 10, 0.88);
  backdrop-filter: blur(8px);
}

.pre-play-card {
  width: min(420px, 100%);
  padding: 1.5rem 1.25rem 1.75rem;
  text-align: center;
  animation: card-in 0.45s ease forwards;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.cover-wrap {
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.cover-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 400 / 560;
  object-fit: cover;
  background: #111;
}

.pre-play-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0 0 0.5rem;
  line-height: 1.25;
}

.pre-play-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
  line-height: 1.4;
}

.btn-start {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1rem;
}

/* ========== Play layout ========== */
.play-top {
  position: fixed;
  top: calc(var(--safe-top) + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 8000;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
}

body.page-play.ejs-running .play-top {
  top: calc(var(--safe-top) + 0.25rem);
  padding: 0.25rem 0.5rem;
  opacity: 0.92;
}

.play-badge {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent-3);
}

.play-stage {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  padding: calc(var(--safe-top) + 3.25rem) max(0.5rem, env(safe-area-inset-right, 0px)) calc(var(--safe-bottom) + 0.25rem) max(0.5rem, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
}

body.page-play.ejs-running .play-stage {
  padding-top: calc(var(--safe-top) + 2.75rem);
  padding-bottom: var(--safe-bottom);
}

.game-host {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  border-radius: 0;
  overflow: hidden;
  touch-action: manipulation;
  background: #000;
}

.game-host:empty {
  min-height: 36dvh;
}

[hidden] {
  display: none !important;
}

/*
 * EmulatorJS coloca a classe .ejs_parent NO próprio #game (não é filho).
 * O vídeo fica em .ejs_canvas_parent → canvas.ejs_canvas.
 * Forçamos coluna flex para a área do jogo crescer até junto dos controlos (gamepad em position:absolute).
 */
#game.game-host {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  align-self: stretch;
  position: relative;
}

#game.ejs_parent {
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-width: none !important;
  overflow: hidden !important;
}

#game .ejs_canvas_parent {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  position: relative !important;
}

#game .ejs_canvas {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  margin: 0 auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
