:root {
  --ink: #0c1219;
  --ink-soft: #151d28;
  --fog: #9aa8b8;
  --paper: #e8eef4;
  --paper-dim: #c5d0db;
  --amber: #d4a017;
  --amber-soft: #f0c75e;
  --line: rgba(232, 238, 244, 0.12);
  --ok: #3ecf8e;
  --danger: #ff6b6b;
  --radius: 18px;
  --font-brand: "Fraunces", Georgia, serif;
  --font-body: "Outfit", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(212, 160, 23, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 80%, rgba(70, 110, 160, 0.15), transparent 50%),
    radial-gradient(ellipse 50% 35% at 0% 60%, rgba(40, 70, 90, 0.25), transparent 45%),
    linear-gradient(165deg, #0c1219 0%, #121a24 45%, #0a1016 100%);
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(0.75rem + var(--safe-top)) 1.25rem 0.75rem;
  max-width: 720px;
  margin: 0 auto;
  min-height: 3rem;
  gap: 0.75rem;
}

.ghost {
  background: transparent;
  border: none;
  color: var(--fog);
  font-family: var(--font-body);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.55rem 0.35rem;
  min-height: 44px;
}

.ghost:hover {
  color: var(--paper);
}

main {
  width: min(100% - 1.5rem, 640px);
  margin: 0 auto;
  padding-bottom: calc(2.5rem + var(--safe-bottom));
}

.screen {
  display: none;
  animation: rise 0.45s ease both;
}

.screen.active {
  display: block;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero {
  padding: clamp(4rem, 12vh, 9rem) 0 2rem;
  text-align: center;
}

.brand {
  font-family: var(--font-brand);
  font-size: clamp(2.4rem, 11vw, 4.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 1.25rem;
  background: linear-gradient(120deg, var(--paper) 30%, var(--amber-soft) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.05;
}

.brand.mini {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

h1 {
  font-family: var(--font-brand);
  font-size: clamp(1.35rem, 4.5vw, 1.85rem);
  font-weight: 500;
  margin: 0 0 0.85rem;
  color: var(--paper);
}

h2 {
  font-family: var(--font-brand);
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

h3 {
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--amber-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lead,
.sub {
  color: var(--fog);
  font-size: clamp(0.98rem, 2.8vw, 1.05rem);
  font-weight: 300;
  margin: 0 auto 1.75rem;
  max-width: 28rem;
}

.sub {
  margin-bottom: 1.5rem;
}

.cta-row {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.sticky-cta {
  position: sticky;
  bottom: calc(0.75rem + var(--safe-bottom));
  margin-top: 1.5rem;
  padding: 0.65rem 0 0.25rem;
  background: linear-gradient(to top, rgba(12, 18, 25, 0.96) 55%, transparent);
  z-index: 5;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  padding: 0.9rem 1.5rem;
  min-height: 48px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(135deg, var(--amber) 0%, #e8b84a 100%);
  color: #1a1408;
  box-shadow: 0 8px 28px rgba(212, 160, 23, 0.28);
  width: min(100%, 320px);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #e0ac20 0%, #f0c75e 100%);
}

.btn.secondary {
  background: var(--ink-soft);
  color: var(--paper);
  border: 1px solid var(--line);
}

.btn.ghost-btn {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.35);
}

.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.choice-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 560px) {
  .choice-grid {
    grid-template-columns: 1fr 1fr;
  }

  .btn.primary {
    width: auto;
  }
}

.choice {
  text-align: left;
  background: rgba(21, 29, 40, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.15rem;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.15s ease, background 0.2s ease;
  font-family: inherit;
  min-height: 120px;
  touch-action: manipulation;
}

.choice:hover,
.choice:focus-visible {
  border-color: rgba(212, 160, 23, 0.55);
  background: rgba(28, 38, 52, 0.95);
  outline: none;
}

.choice:active {
  transform: scale(0.985);
}

.choice-title {
  display: block;
  font-family: var(--font-brand);
  font-size: clamp(1.2rem, 4vw, 1.35rem);
  margin-bottom: 0.45rem;
}

.choice-desc {
  display: block;
  color: var(--fog);
  font-size: 0.92rem;
  font-weight: 300;
}

.party {
  margin: 1.25rem 0;
  padding: clamp(1rem, 3vw, 1.25rem);
  border-radius: var(--radius);
  background: rgba(21, 29, 40, 0.7);
  border: 1px solid var(--line);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.actions .btn {
  padding: 0.7rem 1.05rem;
  font-size: 0.92rem;
  min-height: 44px;
  flex: 1 1 auto;
}

.status {
  min-height: 1.25rem;
  margin: 0 0 0.75rem;
  color: var(--amber-soft);
  font-size: 0.88rem;
}

.status.recording {
  color: var(--danger);
  animation: pulse 1.2s ease infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

.field {
  display: block;
  margin-bottom: 0.75rem;
}

.field span {
  display: block;
  font-size: 0.8rem;
  color: var(--fog);
  margin-bottom: 0.35rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 4rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 12, 18, 0.65);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 16px; /* evita zoom iOS */
  padding: 0.85rem 1rem;
  line-height: 1.45;
}

textarea:focus {
  outline: none;
  border-color: rgba(212, 160, 23, 0.5);
}

.error-banner {
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: #ffb4b4;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.loading-box {
  text-align: center;
  padding: clamp(1.5rem, 6vh, 3rem) 0 1rem;
}

.wait-banner {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: rgba(212, 160, 23, 0.12);
  border: 1px solid rgba(212, 160, 23, 0.35);
  color: var(--amber-soft);
  font-size: clamp(0.92rem, 3.2vw, 1rem);
  line-height: 1.45;
}

.loading-text {
  color: var(--fog);
  font-size: 1.02rem;
  margin: 0.35rem 0 1.25rem;
  min-height: 1.5em;
}

.game-wrap {
  margin: 0 auto;
  width: 100%;
  max-width: 640px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(12, 18, 25, 0.85);
  touch-action: manipulation;
  user-select: none;
}

.game-hud {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  color: var(--fog);
  background: rgba(0, 0, 0, 0.25);
}

.game-hint {
  opacity: 0.85;
}

#jump-game {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
  touch-action: manipulation;
}

#result-veredicto {
  margin-top: 0.25rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-block;
  margin: 0.5rem 0 1rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(212, 160, 23, 0.15);
  color: var(--amber-soft);
  font-size: 0.85rem;
}

.resumen {
  color: var(--fog);
  font-size: 1.05rem;
  margin: 0 0 1.25rem;
  overflow-wrap: anywhere;
}

.explicacion {
  white-space: pre-wrap;
  background: rgba(21, 29, 40, 0.75);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 1.25rem);
  margin-bottom: 1rem;
  font-weight: 300;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.puntos {
  margin: 0 0 2rem;
  padding-left: 1.2rem;
  color: var(--paper-dim);
}

.puntos li {
  margin-bottom: 0.45rem;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + var(--safe-bottom));
  transform: translateX(-50%);
  background: #1e2836;
  color: var(--paper);
  padding: 0.75rem 1.2rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 0.92rem;
  z-index: 50;
  max-width: min(92vw, 380px);
  text-align: center;
  animation: rise 0.25s ease;
  overflow-wrap: anywhere;
}

[hidden] {
  display: none !important;
}

@media (max-width: 380px) {
  main {
    width: min(100% - 1rem, 640px);
  }

  .actions .btn {
    width: 100%;
  }

  .game-hud {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .hero {
    padding: 1.5rem 0 1rem;
  }

  .brand {
    font-size: clamp(1.8rem, 8vw, 2.6rem);
    margin-bottom: 0.5rem;
  }

  .loading-box {
    padding-top: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
