:root {
  --ink: #f7fbff;
  --muted: rgba(247, 251, 255, 0.72);
  --glass: rgba(7, 19, 33, 0.68);
  --glass-strong: rgba(7, 19, 33, 0.88);
  --border: rgba(255, 255, 255, 0.16);
  --accent: #6fe7ff;
  --accent-2: #9dffb7;
  --danger: #ff7b8b;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

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

body {
  overflow-x: hidden;
  color: var(--ink);
  background: #06111d;
  font-family: Inter, "Noto Sans Devanagari", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.game-page {
  min-height: 100vh;
  padding: 24px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(50, 145, 191, 0.22), transparent 30%),
    radial-gradient(circle at 85% 5%, rgba(126, 220, 165, 0.16), transparent 28%),
    #06111d;
}

.game-shell {
  width: min(1220px, 100%);
  border: 1px solid var(--border);
  border-radius: 28px;
  overflow: hidden;
  background: rgba(4, 13, 24, 0.86);
  box-shadow: var(--shadow);
}

.game-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(4, 13, 24, 0.95);
}

.brand-block h1,
.brand-block p {
  margin: 0;
}

.brand-block h1 {
  margin-top: 2px;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  letter-spacing: -0.04em;
}

.eyebrow,
.panel-kicker {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.tagline {
  margin-top: 4px !important;
  color: var(--muted);
  font-size: 0.9rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(82px, 1fr));
  gap: 10px;
}

.stat {
  min-width: 82px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  text-align: center;
}

.stat span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stat strong {
  font-size: 1.03rem;
}

.game-stage {
  position: relative;
  min-height: 540px;
  overflow: hidden;
  outline: none;
  isolation: isolate;
}

#sceneCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
}

.game-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(2, 10, 18, 0.02), rgba(2, 10, 18, 0.12) 65%, rgba(2, 10, 18, 0.42)),
    linear-gradient(to right, rgba(2, 10, 18, 0.22), transparent 25%, transparent 75%, rgba(2, 10, 18, 0.2));
}

.scene-label {
  position: absolute;
  top: 18px;
  left: 20px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(3, 15, 26, 0.44);
  backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.destination {
  position: absolute;
  right: 34px;
  top: 50%;
  width: 108px;
  height: 160px;
  transform: translateY(-52%);
  display: grid;
  place-items: center;
  color: #ffffff;
  font-weight: 900;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.portal-ring {
  position: absolute;
  inset: 12px 20px;
  border: 5px solid rgba(147, 242, 255, 0.86);
  border-radius: 50%;
  box-shadow:
    0 0 10px rgba(111, 231, 255, 0.9),
    0 0 30px rgba(111, 231, 255, 0.65),
    inset 0 0 28px rgba(111, 231, 255, 0.35);
  animation: portalPulse 1.8s ease-in-out infinite;
}

.destination::before,
.destination::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 14px white;
  animation: sparkle 2.2s linear infinite;
}

.destination::before {
  top: 18px;
  left: 15px;
}

.destination::after {
  right: 11px;
  bottom: 28px;
  animation-delay: -1.1s;
}

.word-flyer {
  --typed-width: 0%;
  position: absolute;
  left: 0;
  top: 0;
  min-width: 96px;
  min-height: 52px;
  padding: 12px 18px 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(111, 231, 255, 0.24) var(--typed-width), rgba(7, 22, 37, 0.74) var(--typed-width));
  backdrop-filter: blur(9px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28), 0 0 28px rgba(111, 231, 255, 0.16);
  color: white;
  font-size: clamp(1.18rem, 2.6vw, 1.7rem);
  font-weight: 850;
  letter-spacing: 0.075em;
  text-transform: lowercase;
  white-space: nowrap;
  transform-origin: center;
  will-change: transform;
}

.word-flyer::before,
.word-flyer::after {
  content: "";
  position: absolute;
  left: -15px;
  width: 24px;
  height: 8px;
  border-radius: 100% 0 0 100%;
  background: linear-gradient(to left, rgba(111, 231, 255, 0.7), transparent);
  opacity: 0.72;
}

.word-flyer::before {
  top: 13px;
}

.word-flyer::after {
  bottom: 11px;
  width: 34px;
  opacity: 0.45;
}

.letter {
  transition: color 120ms ease, transform 120ms ease, text-shadow 120ms ease;
}

.letter.typed {
  color: var(--accent-2);
  text-shadow: 0 0 12px rgba(157, 255, 183, 0.75);
  transform: translateY(-1px);
}

.letter.current {
  border-bottom: 2px solid var(--accent);
}

.word-flyer.wrong {
  animation: wrongShake 220ms ease;
  border-color: rgba(255, 123, 139, 0.85);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28), 0 0 25px rgba(255, 123, 139, 0.5);
}

.word-flyer.completed {
  animation: finishBurst 420ms cubic-bezier(.2, .9, .25, 1) forwards;
}

.word-flyer.crashed {
  animation: crashBounce 540ms ease forwards;
}

.feedback {
  position: absolute;
  left: 50%;
  top: 90px;
  transform: translateX(-50%);
  min-height: 32px;
  padding: 7px 13px;
  border-radius: 999px;
  color: white;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
}

.feedback.show {
  animation: feedbackFloat 900ms ease forwards;
}

.feedback.good {
  background: rgba(23, 120, 79, 0.72);
}

.feedback.bad {
  background: rgba(147, 38, 58, 0.78);
}

.ground-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 54px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  box-shadow: 0 4px 24px rgba(255, 255, 255, 0.14);
}

.start-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 11, 20, 0.5);
  backdrop-filter: blur(7px);
  z-index: 6;
  transition: opacity 250ms ease, visibility 250ms ease;
}

.start-panel.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-card {
  width: min(560px, 100%);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--glass-strong);
  box-shadow: var(--shadow);
  text-align: center;
}

.start-card h2 {
  margin: 7px 0 10px;
  font-size: clamp(1.65rem, 4vw, 2.6rem);
  letter-spacing: -0.04em;
}

.start-card > p:not(.panel-kicker):not(.keyboard-tip) {
  margin: 0 auto;
  max-width: 470px;
  color: var(--muted);
  line-height: 1.65;
}

.language-row {
  display: grid;
  gap: 7px;
  width: min(300px, 100%);
  margin: 20px auto 0;
  text-align: left;
}

.language-row label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.language-row select {
  width: 100%;
  min-height: 43px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font: inherit;
  font-weight: 800;
}

.difficulty-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
  margin: 18px 0 18px;
}

.difficulty-button,
.primary-button,
.pause-button {
  border: 0;
  cursor: pointer;
}

.difficulty-button {
  min-width: 92px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.065);
  color: var(--muted);
  font-weight: 750;
}

.difficulty-button.active {
  border-color: rgba(111, 231, 255, 0.65);
  background: rgba(111, 231, 255, 0.16);
  color: white;
  box-shadow: 0 0 0 3px rgba(111, 231, 255, 0.08);
}

.primary-button {
  width: min(260px, 100%);
  padding: 14px 22px;
  border-radius: 14px;
  background: linear-gradient(135deg, #6fe7ff, #84f0b2);
  color: #062033;
  font-weight: 900;
  letter-spacing: 0.025em;
  box-shadow: 0 14px 30px rgba(76, 212, 225, 0.24);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(76, 212, 225, 0.32);
}

.keyboard-tip {
  margin: 13px 0 0 !important;
  color: rgba(255, 255, 255, 0.53) !important;
  font-size: 0.78rem;
}

.pause-button {
  position: absolute;
  top: 17px;
  right: 17px;
  z-index: 4;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(3, 15, 26, 0.62);
  backdrop-filter: blur(10px);
  font-weight: 900;
}

.typing-console {
  position: relative;
  padding: 18px 24px 22px;
  border-top: 1px solid var(--border);
  background: rgba(4, 13, 24, 0.97);
}

.typing-console label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#typingInput {
  width: 100%;
  padding: 15px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  outline: none;
  background: rgba(255, 255, 255, 0.055);
  color: white;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0;
  caret-color: var(--accent);
}

#typingInput:focus {
  border-color: rgba(111, 231, 255, 0.72);
  box-shadow: 0 0 0 4px rgba(111, 231, 255, 0.09);
}

#typingHint {
  margin: 8px 0 11px;
  color: rgba(255, 255, 255, 0.52);
  font-size: 0.76rem;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6fe7ff, #9dffb7);
  transition: width 130ms ease;
}

@keyframes portalPulse {
  0%, 100% { transform: scale(0.96); opacity: 0.72; }
  50% { transform: scale(1.04); opacity: 1; }
}

@keyframes sparkle {
  0% { transform: translateY(18px) scale(0.7); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateY(-50px) scale(1.25); opacity: 0; }
}

@keyframes wrongShake {
  0%, 100% { margin-left: 0; }
  25% { margin-left: -8px; }
  75% { margin-left: 8px; }
}

@keyframes finishBurst {
  0% { filter: brightness(1); opacity: 1; }
  70% { filter: brightness(1.8); opacity: 1; }
  100% { filter: brightness(2); opacity: 0; transform: scale(0.2) rotate(7deg); }
}

@keyframes crashBounce {
  0% { transform: translateY(0) rotate(0); }
  45% { transform: translateY(8px) rotate(-5deg) scaleY(0.8); }
  70% { transform: translateY(-7px) rotate(4deg); }
  100% { transform: translateY(0) rotate(0); opacity: 0; }
}

@keyframes feedbackFloat {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.92); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -18px) scale(0.98); }
}

@media (max-width: 820px) {
  .game-page {
    padding: 0;
  }

  .game-shell {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .game-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .stats {
    width: 100%;
    grid-template-columns: repeat(4, 1fr);
  }

  .stat {
    min-width: 0;
    padding: 8px 5px;
  }

  .stat strong {
    font-size: 0.9rem;
  }

  .game-stage {
    min-height: 510px;
  }

  .destination {
    right: 4px;
    width: 84px;
    transform: translateY(-55%) scale(0.84);
  }

  .start-card {
    padding: 25px 18px;
  }
}

@media (max-width: 520px) {
  .game-header,
  .typing-console {
    padding-left: 16px;
    padding-right: 16px;
  }

  .tagline {
    display: none;
  }

  .stats {
    gap: 6px;
  }

  .stat span {
    font-size: 0.59rem;
  }

  .game-stage {
    min-height: 470px;
  }

  .word-flyer {
    padding: 10px 13px 11px;
    border-radius: 14px;
    font-size: 1.06rem;
  }

  .scene-label {
    left: 12px;
    top: 13px;
  }

  .pause-button {
    top: 11px;
    right: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
