/* CSS Variables */
:root {
  --bg1: #0a0a0f;
  --bg2: #1a1a2e;
  --bg3: #16213e;
  --ink: #ffffff;
  --muted: #a0a0a0;
  --border: rgba(255, 255, 255, 0.2);
  --glass: rgba(255, 255, 255, 0.08);

  /* NEON COLORS */
  --neon-pink: #ff0080;
  --neon-blue: #00ffff;
  --neon-purple: #8000ff;
  --neon-green: #00ff80;
  --neon-yellow: #ffff00;
  --neon-orange: #ff8000;

  /* VIOLET/LILA COLORS */
  --violet-600: #7c3aed;
  --violet-500: #8b5cf6;
  --violet-400: #a855f7;
  --violet-300: #c084fc;

  /* ENHANCED GREEN COLORS */
  --green-600: #059669;
  --green-500: #10b981;
  --green-400: #34d399;
  --green-300: #6ee7b7;

  --card: rgba(255, 255, 255, 0.07);
  --ring: rgba(255, 0, 128, 0.6);
  --shadow: rgba(0, 0, 0, 0.8);

  /* Fallbacks first */
  --vh: 1vh;
}
@supports (height: 1dvh) {
  :root {
    --vh: 1dvh;
  }
}

/* Backdrop blur needs the webkit prefix on iOS */
.glass,
.card {
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: #f5f7fb;
  background: radial-gradient(
      circle at 20% 80%,
      rgba(255, 0, 128, 0.15) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(0, 255, 255, 0.15) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 40% 40%,
      rgba(128, 0, 255, 0.1) 0%,
      transparent 50%
    ),
    linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 50%, var(--bg3) 100%);
  min-height: calc(100 * var(--vh));
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(
      2px 2px at 20px 30px,
      var(--neon-pink),
      transparent
    ),
    radial-gradient(2px 2px at 40px 70px, var(--neon-blue), transparent),
    radial-gradient(1px 1px at 90px 40px, var(--neon-purple), transparent),
    radial-gradient(1px 1px at 130px 80px, var(--neon-green), transparent),
    radial-gradient(2px 2px at 160px 30px, var(--neon-yellow), transparent);
  background-repeat: repeat;
  background-size: 200px 100px;
  animation: float 20s linear infinite;
  opacity: 0.3;
  pointer-events: none;
  z-index: 1;
}
@keyframes float {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  100% {
    transform: translateY(-100px) rotate(360deg);
  }
}

/* --- iOS Safari sanity kit --- */
html,
body {
  height: 100%;
  /* Prevent Safari from auto “helpfully” enlarging text */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.container {
  max-width: 820px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* === Gaming Title === */
.title-game {
  font-family: "Orbitron", monospace;
  font-weight: 900;
  letter-spacing: 0.2ch;
  font-size: clamp(2.6rem, 1.4rem + 5vw, 5rem);
  margin: 1rem 0 0.75rem;
  background: linear-gradient(
    45deg,
    var(--neon-pink) 0%,
    var(--neon-purple) 25%,
    var(--neon-blue) 50%,
    var(--neon-green) 75%,
    var(--neon-yellow) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 300% 300%;
  animation: tg-gradient 3.2s ease-in-out infinite;
  text-shadow: 0 0 24px rgba(255, 255, 255, 0.12);
  position: relative;
  isolation: isolate;
}
@keyframes tg-gradient {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}
/* scanline shine */
.title-game::after {
  content: "";
  position: absolute;
  inset: 0 0 0 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    transparent 30%,
    rgba(255, 255, 255, 0.08) 50%,
    transparent 70%
  );
  mix-blend-mode: screen;
  animation: tg-scan 2.6s linear infinite;
}
@keyframes tg-scan {
  0% {
    transform: translateY(-120%);
  }
  100% {
    transform: translateY(120%);
  }
}
/* tiny glitch on hover */
.title-game:hover {
  animation-duration: 2.2s;
}
.title-game:hover::before {
  content: attr(
    data-glitch
  ); /* optional, use same text if you set data-glitch */
  position: absolute;
  inset: 0;
  left: 2px;
  top: -1px;
  color: var(--neon-pink);
  mix-blend-mode: screen;
  filter: blur(0.3px);
  clip-path: inset(0 0 45% 0);
  animation: tg-glitch 800ms steps(2, end) infinite;
  opacity: 0.7;
}
@keyframes tg-glitch {
  0% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-1px, 1px);
  }
  40% {
    transform: translate(1px, -1px);
  }
  60% {
    transform: translate(-2px, 0);
  }
  80% {
    transform: translate(2px, 1px);
  }
  100% {
    transform: translate(0, 0);
  }
}
.muted {
  color: #a4adbd;
}

.controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

button {
  border: 0;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  background: #2a73ff;
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
}
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
audio {
  width: 100%;
  margin-top: 0.5rem;
}
.status {
  margin: 0.5rem 0;
  min-height: 1.2rem;
  color: #ffd06b;
}
.result {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  font-size: 1rem;
  padding: 1rem 1.1rem;
  min-height: 360px;
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.25);
}

/* expanded content */
.expand-shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 0.9rem;
}
.expand-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.result.expanded {
  margin-top: 0.7rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  line-height: 1.55;
  font-size: 1.05rem;
  height: 100%;
  max-height: none;
  overflow: auto;
}

/* optional: dim underlying content a bit while expanded */
.transcript-card.is-expanded > *:not(.card-expand) {
  filter: blur(1px) brightness(0.8);
  transition: filter 0.15s ease;
}

/* Reader modal */
.reader-close {
  justify-self: end;
  margin: 0.6rem 0.6rem 0 0;
  border: 1px solid var(--border);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.05)
  );
  color: var(--ink);
  border-radius: 10px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}
.reader-close:hover {
  border-color: var(--neon-blue);
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.25);
}
.reader-text {
  margin: 0.4rem 0 1rem;
  padding: 1.2rem 1.4rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  line-height: 1.55;
  font-size: 1.05rem;
  border-top: 1px solid var(--border);
}

/* === Footer decoration: comet style + spark burst === */
.footer-decoration {
  position: fixed;
  bottom: 18px;
  right: 18px; /* move to bottom-right for thumb reach */
  transform: none;
  left: auto;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.05)
  );
  border: 1px solid var(--border);
  box-shadow: 0 12px 28px var(--shadow);
  cursor: pointer;
  pointer-events: auto; /* ignore if a parent has pointer-events:none */
  z-index: 9999;
}
.footer-decoration::before {
  content: "";
  position: absolute;
  inset: 0;
  left: -140%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.22),
    transparent
  );
  filter: blur(1px);
  animation: comet-sweep 2.2s ease-in-out infinite;
}
@keyframes comet-sweep {
  0% {
    left: -140%;
  }
  100% {
    left: 140%;
  }
}
.footer-decoration span {
  display: inline-block;
  font-size: 1.15rem;
  animation: footerSparkle 1.8s ease-in-out infinite;
}
.footer-decoration span:nth-child(1) {
  color: var(--neon-blue);
}
.footer-decoration span:nth-child(2) {
  animation-delay: 0.25s;
  color: var(--neon-pink);
}
.footer-decoration span:nth-child(3) {
  animation-delay: 0.5s;
  color: var(--neon-purple);
}
.footer-decoration span:nth-child(4) {
  animation-delay: 0.75s;
  color: var(--neon-green);
}
.footer-decoration:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), 0 0 22px rgba(0, 255, 255, 0.18);
}
.footer-decoration:active {
  transform: translateY(0) scale(0.99);
}

/* Sticky/fixed footers with safe area – useful for your floating footer icons */
.footer-decoration,
.sticky-bottom {
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

/* footer button reachable on phones */
@media (max-width: 640px) {
  .footer-decoration {
    bottom: 12px;
    right: 12px;
  }
}

@media (max-width: 640px) {
  .container {
    margin: 1.2rem auto;
  }
  .footer-decoration {
    bottom: 12px;
    right: 12px;
  }
}
