*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  image-rendering: pixelated;
}

body {
  font-family: 'DotGothic16', monospace;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: #151330;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Scene ──────────────────────────────── */
#scene {
  width: 1280px;
  height: 720px;
  flex-shrink: 0;
  transform-origin: center center;
  background: #1d1b42;
  border: 3px solid #ed72ab;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg,
      transparent,
      transparent 3px,
      rgba(0, 0, 0, 0.18) 3px,
      rgba(0, 0, 0, 0.18) 4px);
  pointer-events: none;
  z-index: 65;
}

/* ── Main row ───────────────────────────── */
#main-row {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
}

/* ── Character panel (left ~38%) ────────── */
#char-panel {
  width: 38%;
  height: 100%;
  flex-shrink: 0;
  background: #1a1840;
  border-right: 2px solid #ed72ab;
  position: relative;
  overflow: hidden;
}

#char-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, #090720 0%, rgba(26, 24, 64, 0) 55%);
  pointer-events: none;
  z-index: 0;
}

#char-panel::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -20%;
  right: -20%;
  height: 55%;
  background:
    linear-gradient(rgba(0, 210, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 210, 255, 0.18) 1px, transparent 1px);
  background-size: 40px 40px;
  transform: perspective(220px) rotateX(42deg);
  transform-origin: bottom;
  pointer-events: none;
  z-index: 0;
}

#neon-sign {
  position: absolute;
  top: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-family: 'DotGothic16', monospace;
  font-size: 28px;
  letter-spacing: 7px;
  color: #ff6bb5;
  white-space: nowrap;
  padding: 12px 28px;
  border: 3px solid rgba(0, 210, 255, 0.85);
  background: rgba(8, 6, 28, 0.65);
  text-shadow:
    0 0 4px #ff6bb5,
    0 0 12px #ff6bb5,
    0 0 24px #ff4da6,
    0 0 48px rgba(255, 77, 166, 0.45);
  box-shadow:
    0 0 6px rgba(0, 210, 255, 0.75),
    0 0 16px rgba(0, 210, 255, 0.4),
    inset 0 0 8px rgba(0, 210, 255, 0.07);
  animation: neon-flicker 7s step-end infinite;
}

@keyframes neon-flicker {

  0%,
  88%,
  90%,
  92%,
  95%,
  100% {
    opacity: 1;
  }

  89% {
    opacity: 0.65;
  }

  91% {
    opacity: 0.85;
  }

  93%,
  94% {
    opacity: 0.5;
  }
}

#char-sprite {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateZ(0);

  height: 65vh;
  width: auto;

  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: 1;
  will-change: transform;
}

#sweat-overlay {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);

  height: 65vh;
  width: auto;

  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: 2;
  pointer-events: none;
  display: none;
}

#char-panel:has(#close-btn:hover) #sweat-overlay {
  display: block;
}


/* ── Game panel (right column) ──────────── */
#game-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* ── Title bar ──────────────────────────── */
#title-bar {
  height: 34px;
  flex-shrink: 0;
  background: #222050;
  border-bottom: 2px solid #ed72ab;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

#game-title {
  font-size: 9px;
  color: rgba(237, 114, 171, 0.6);
  letter-spacing: 2px;
}

#title-stats {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 2px;
}

#title-stats span span {
  color: #ffffff;
  font-size: 16px;
}

#close-btn {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 10;
  font-family: 'DotGothic16', monospace;
  font-size: 11px;
  letter-spacing: 3px;
  text-decoration: none;
  padding: 5px 12px;
  color: #00d2ff;
  border: 2px solid rgba(0, 210, 255, 0.7);
  background: rgba(8, 6, 28, 0.6);
  text-shadow:
    0 0 4px #00d2ff,
    0 0 10px #00d2ff,
    0 0 20px rgba(0, 210, 255, 0.5);
  box-shadow:
    0 0 6px rgba(0, 210, 255, 0.6),
    0 0 14px rgba(0, 210, 255, 0.25),
    inset 0 0 6px rgba(0, 210, 255, 0.06);
  animation: neon-flicker 7s step-end infinite;
  transition: color 0.15s, border-color 0.15s, text-shadow 0.15s, box-shadow 0.15s;
}

#close-btn:hover {
  color: #ffffff;
  border-color: rgba(0, 210, 255, 1);
  text-shadow:
    0 0 4px #ffffff,
    0 0 14px #00d2ff,
    0 0 28px rgba(0, 210, 255, 0.7);
  box-shadow:
    0 0 10px rgba(0, 210, 255, 0.9),
    0 0 22px rgba(0, 210, 255, 0.45),
    inset 0 0 8px rgba(0, 210, 255, 0.12);
  animation: none;
}

/* ── Top area (correct words + lives) ──── */
#top-area {
  flex: 1;
  display: flex;
  border-bottom: 2px solid #ed72ab;
  min-height: 0;
}

#correct-words-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #1d1b42;
}

.panel-header {
  background: #48c6d2;
  padding: 6px 0;
  font-size: 14px;
  color: #ffffff;
  flex-shrink: 0;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
  overflow: hidden;
  white-space: nowrap;
}

.marquee-inner {
  display: flex;
}

.marquee-inner span {
  flex-shrink: 0;
  padding-right: 2.5em;
}

.marquee-inner.ready {
  animation: marquee-scroll 10s linear infinite;
}

@keyframes marquee-scroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(var(--marquee-offset));
  }
}

#correct-words-list {
  flex: 1;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
}

.correct-word-entry {
  font-size: 16px;
  color: #ffffff;
  letter-spacing: 1px;
}

.correct-word-entry::before {
  content: '► ';
  opacity: 0.45;
}

#lives-panel {
  width: 80px;
  flex-shrink: 0;
  border-left: 2px solid #fb9974;
  background: #fb9974;
  display: flex;
  flex-direction: column;
}

#hearts {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  padding: 14px 0;
}

.heart {
  display: flex;
  align-items: center;
  justify-content: center;
}

.heart img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

.heart.off img {
  filter: grayscale(1) brightness(0.5);
}

.heart.glow img {
  animation: heart-glow-pulse 1.2s ease-in-out infinite;
}

@keyframes heart-glow-pulse {
  0%, 100% { filter: drop-shadow(0 0 3px #ff4da6) drop-shadow(0 0 6px rgba(255, 77, 166, 0.5)); }
  50%       { filter: drop-shadow(0 0 7px #ff4da6) drop-shadow(0 0 14px rgba(255, 77, 166, 0.8)) drop-shadow(0 0 22px rgba(255, 100, 200, 0.4)); }
}

/* ── Terminal panel ─────────────────────── */
.video-panel {
  flex: 1;
  background: #181640;
  border-bottom: 2px solid #ed72ab;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 14px 20px;
  overflow: hidden;
}

#submitted-words {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.submitted-word {
  font-family: 'DotGothic16', monospace;
  font-size: 16px;
  letter-spacing: 1px;
  text-transform: lowercase;
  color: rgba(255, 255, 255, 0.4);
}

.submitted-word::before {
  content: '> ';
  opacity: 0.5;
}

.submitted-word.correct {
  color: #ffffff;
}

.submitted-word.missed {
  color: rgba(236, 232, 255, 0.15);
  text-decoration: line-through;
}

#typing-area {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(237, 114, 171, 0.15);
  padding-top: 10px;
}

.terminal-prompt {
  color: rgba(255, 255, 255, 0.6);
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
}

#word-input {
  background: transparent;
  border: none;
  color: #ffffff;
  font-family: 'DotGothic16', monospace;
  font-size: 18px;
  flex: 1;
  outline: none;
  caret-color: #ffffff;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  padding: 0;
}

/* ── Timer bar ──────────────────────────── */
#timer-bar-wrap {
  height: 5px;
  flex-shrink: 0;
  background: rgba(237, 114, 171, 0.12);
}

#timer-bar {
  height: 100%;
  width: 100%;
  background: #ffffff;
}

@keyframes timer-color {
  0% {
    background: #ffffff;
  }

  50% {
    background: #ffffff;
  }

  100% {
    background: #ff6b6b;
  }
}

/* ── Dialogue box ───────────────────────── */
#char-area {
  height: 100px;
  flex-shrink: 0;
  background: #cb4790;
  border-top: 3px solid #cb4790;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  position: relative;
}

#char-text-area {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: hidden;
  padding: 0 24px;
}

#skip-intro-btn {
  flex-shrink: 0;
  font-family: 'DotGothic16', monospace;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 5px 12px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: color 0.2s, border-color 0.2s;
}

#skip-intro-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.8);
}

#char-arrow {
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  flex-shrink: 0;
}

#char-bubble {
  font-size: 28px;
  color: rgba(29, 27, 66, 0);
  transition: color 0.2s;
  line-height: 1.4;
  letter-spacing: 0.5px;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.15);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#char-bubble.visible {
  color: #ffffff;
}

#char-bubble.word-display {
  letter-spacing: 0;
}

.cursor {
  display: none;
  width: 10px;
  height: 20px;
  background: #ffffff;
  animation: blink 1s step-end infinite;
  flex-shrink: 0;
  vertical-align: middle;
}

#char-bubble.visible~.cursor {
  display: inline-block;
}


/* ── Overlay screens ────────────────────── */
#ready-screen,
#gameover-screen {
  position: absolute;
  inset: 0;
  background: rgba(29, 27, 66, 0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 30;
}

/* Ready-screen: hidden by default via opacity (not display:none so transitions work) */
#ready-screen {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@keyframes ready-enter {
  0%   { opacity: 0; transform: scale(0.88); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes ready-exit {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.06); }
}

#ready-screen.ready-enter {
  visibility: visible;
  pointer-events: auto;
  animation: ready-enter 0.4s ease-out forwards;
}

#ready-screen.ready-exit {
  animation: ready-exit 0.35s ease-in forwards;
}

/* CRT flash on scanlines element */
@keyframes crt-flash {
  0%   { opacity: 0; }
  12%  { opacity: 1; }
  100% { opacity: 0; }
}

.scanlines.crt-flash {
  animation: crt-flash 0.55s ease-out forwards !important;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.12) 2px,
    rgba(255, 255, 255, 0.12) 4px
  );
}

#ready-eyebrow {
  font-size: 16px;
  letter-spacing: 6px;
  color: rgba(237, 114, 171, 0.5);
  text-transform: uppercase;
}

#ready-text {
  font-size: 72px;
  color: #ece8ff;
  letter-spacing: 4px;
  text-transform: uppercase;
  position: relative;
  display: inline-block;
  overflow: visible;
}

.ready-digit {
  display: inline-block;
  min-width: 0.62em;
  text-align: center;
}

/* Glitch effect on round number */
@keyframes glitch-jitter {
  0%, 85%, 100% {
    text-shadow: 0 0 8px #ff6bb5, 0 0 22px rgba(255, 77, 166, 0.5);
    transform: translate(0);
  }
  87% {
    text-shadow: -3px 0 #00d2ff, 3px 0 #ff6bb5;
    transform: translate(2px, -1px);
  }
  89% {
    text-shadow: 3px 0 #00d2ff, -2px 0 #ff6bb5;
    transform: translate(-2px, 1px);
  }
  91% {
    text-shadow: -1px 2px #00d2ff, 1px -1px #ff4da6;
    transform: translate(1px, 2px);
  }
  93% {
    text-shadow: 2px -1px #00d2ff, -1px 1px #ff6bb5;
    transform: translate(-1px, -1px);
  }
}

#ready-text.glitch {
  animation: glitch-jitter 1.8s step-end infinite;
}

#ready-text.glitch::before,
#ready-text.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#ready-text.glitch::before {
  color: #00d2ff;
  clip-path: inset(20% 0 60% 0);
  transform: translateX(-3px);
  opacity: 0.7;
  animation: glitch-jitter 1.8s step-end infinite reverse;
}

#ready-text.glitch::after {
  color: #ff4da6;
  clip-path: inset(60% 0 10% 0);
  transform: translateX(3px);
  opacity: 0.7;
  animation: glitch-jitter 1.8s step-end infinite 0.9s;
}

#ready-hint {
  font-size: 13px;
  letter-spacing: 3px;
  color: rgba(0, 210, 255, 0.55);
  text-transform: uppercase;
  margin-top: 2px;
}

#ready-recap {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-top: 18px;
  font-size: 12px;
  letter-spacing: 2px;
  color: rgba(236, 232, 255, 0.45);
  text-transform: uppercase;
}

#ready-score span {
  color: #ece8ff;
  font-size: 15px;
}

#ready-lives img {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
  vertical-align: middle;
  margin: 0 2px;
}

#ready-taunt {
  font-size: 17px;
  color: rgba(237, 114, 171, 0.75);
  letter-spacing: 1px;
  margin-top: 14px;
  min-height: 1.4em;
  font-style: italic;
}

#ready-choices {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 24px;
  align-items: flex-start;
}

@keyframes choice-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.ready-choice {
  font-family: 'DotGothic16', monospace;
  font-size: 15px;
  letter-spacing: 1px;
  text-align: left;
  color: rgba(236, 232, 255, 0.45);
  background: transparent;
  border: none;
  padding: 5px 0;
  cursor: pointer;
  transition: color 0.12s;
  animation: choice-in 0.28s ease-out both;
}

.ready-choice::before {
  content: '▷  ';
  color: rgba(237, 114, 171, 0.35);
  transition: color 0.12s;
}

.ready-choice:hover {
  color: #ece8ff;
}

.ready-choice:hover::before {
  content: '▶  ';
  color: #ed72ab;
}

#gameover-title {
  font-size: 40px;
  color: #ed72ab;
  letter-spacing: 4px;
}

#final-score {
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(236, 232, 255, 0.4);
  text-transform: uppercase;
}

#final-score strong {
  color: #ece8ff;
  font-size: 16px;
}

#restart-btn {
  font-family: 'DotGothic16', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  color: #ed72ab;
  background: transparent;
  border: 2px solid #ed72ab;
  padding: 12px 36px;
  cursor: pointer;
  text-transform: uppercase;
  margin-top: 10px;
  animation: blink 1.4s step-end infinite;
  transition: background 0.1s, color 0.1s;
}

#restart-btn:hover {
  background: #ed72ab;
  color: #1d1b42;
  animation: none;
}

/* ── Start overlay ──────────────────────── */
#start-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 60%, rgba(203, 71, 144, 0.1) 0%, transparent 70%),
    #0d0b28;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  overflow: hidden;
}

/* Subtle perspective grid — pink-tinted to match the scene border */
#start-overlay::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: -30%;
  right: -30%;
  height: 45%;
  background:
    linear-gradient(rgba(237, 114, 171, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(237, 114, 171, 0.1) 1px, transparent 1px);
  background-size: 48px 48px;
  transform: perspective(280px) rotateX(52deg);
  transform-origin: bottom;
  pointer-events: none;
}

#start-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  border: 3px solid #ed72ab;
  padding: 56px 80px;
  background: rgba(13, 11, 40, 0.82);
  backdrop-filter: blur(6px);
  position: relative;
  z-index: 1;
  box-shadow:
    0 0 40px rgba(237, 114, 171, 0.15),
    inset 0 0 30px rgba(0, 0, 0, 0.4);
}

#start-box::after {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(237, 114, 171, 0.22);
  pointer-events: none;
}

#start-title {
  font-size: 52px;
  letter-spacing: 8px;
  text-transform: lowercase;
  margin-bottom: 14px;
  color: #ff6bb5;
  text-shadow:
    0 0 4px #ff6bb5,
    0 0 14px #ff6bb5,
    0 0 28px #ff4da6,
    0 0 60px rgba(255, 77, 166, 0.4);
  animation: neon-flicker 6s step-end infinite;
}

#start-btn {
  font-family: 'DotGothic16', monospace;
  font-size: 18px;
  letter-spacing: 5px;
  color: #ed72ab;
  background: transparent;
  border: 2px solid #ed72ab;
  padding: 20px 70px;
  cursor: pointer;
  animation: blink 1.4s step-end infinite;
  text-transform: uppercase;
  transition: background 0.1s, color 0.1s;
}

#start-btn:hover {
  background: #ed72ab;
  color: #1d1b42;
  animation: none;
}

#start-hint {
  font-size: 14px;
  letter-spacing: 3px;
  color: rgba(236, 232, 255, 0.2);
  margin-top: 6px;
}

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

.hidden {
  display: none !important;
}