/* Global layout */
:root {
  --color-bg: #070707;
  --color-panel: #101015;
  --color-text: #f7f7ff;
  --color-muted: #c0c1ce;
  --color-accent-start: #a86dff;
  --color-accent-end: #76c4ff;
  --shadow-soft: 0 30px 80px rgba(0, 0, 0, 0.55);
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--color-text);
  background: radial-gradient(circle at 50% -20%, rgba(86, 91, 131, 0.32) 0%, rgba(7, 7, 7, 0) 65%) var(--color-bg);
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  border: none;
  cursor: pointer;
  background: none;
  color: inherit;
}

/* Header */
.site-header {
  padding: 1.5rem 6vw 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 6, 7, 0.88);
  backdrop-filter: blur(6px);
}

.nav-container {
  margin: 0 auto;
  max-width: 1024px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 2rem;
}

.brand {
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
}

.nav-links {
  display: flex;
  gap: 2rem;
  font-weight: 500;
  justify-content: center;
}

.nav-links a {
  position: relative;
  transition: color 0.3s ease;
}

.nav-links a::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: -0.5rem;
  height: 2px;
  background: linear-gradient(90deg, var(--color-accent-start), var(--color-accent-end));
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s ease;
}

.nav-links a:hover::after,
.nav-links a:focus-visible::after {
  transform: scaleX(1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.55rem 1.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease, color 0.25s ease;
}

.login-btn {
  color: var(--color-muted);
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: linear-gradient(135deg, rgba(20, 20, 26, 0.9), rgba(12, 12, 16, 0.9));
  padding-inline: 1.9rem;
}

.login-btn:hover,
.login-btn:focus-visible {
  color: var(--color-text);
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
}

/* Hero section */
.hero {
  flex: 1;
  padding: 4rem 6vw 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-inner {
  position: relative;
  width: min(90vw, 780px);
  min-height: 520px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.hero-panda {
  position: absolute;
  top: 12%;
  left: 50%;
  width: min(46vw, 320px);
  transform: translate(-50%, -12%);
  z-index: 0;
  opacity: 0.98;
  filter: drop-shadow(0 22px 55px rgba(0, 0, 0, 0.45));
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 1) 62%, rgba(0, 0, 0, 0.45) 80%, rgba(0, 0, 0, 0) 100%);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 1) 62%, rgba(0, 0, 0, 0.45) 80%, rgba(0, 0, 0, 0) 100%);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.hero-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  align-items: center;
  text-align: center;
  position: relative;
  z-index: 2;
  padding-top: 8rem;
}

.hero-intro {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(254, 254, 255, 0.95);
  text-shadow:
    0 10px 35px rgba(0, 0, 0, 0.65),
    0 0 22px rgba(0, 0, 0, 0.4);
  margin-bottom: -0.2rem;
}

.hero-title {
  margin: 0;
  font-size: clamp(3.5rem, 8vw, 5.5rem);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 0.95;
  background: linear-gradient(180deg, #ffffff 0%, #f6f6ff 45%, #d5d7ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow:
    0 16px 40px rgba(0, 0, 0, 0.6),
    0 0 18px rgba(227, 228, 255, 0.45);
}

.hero-title span {
  display: block;
}

.hero-subtitle {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: rgba(236, 237, 246, 0.94);
  letter-spacing: 0.02em;
  text-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
}

.hero-subtitle span {
  --grad-pos: 0%;
  background: linear-gradient(90deg, var(--color-accent-start), var(--color-accent-end));
  -webkit-background-clip: text;
  color: transparent;
  display: inline-block;
  background-size: 200% 100%;
  background-position: var(--grad-pos) 50%;
}

.cta-btn {
  --grad-pos: 0%;
  position: relative;
  padding: 0.8rem 2.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--color-text);
  background: linear-gradient(120deg, #272536, #1c1a29);
  box-shadow: 0 18px 40px rgba(26, 22, 49, 0.55);
  overflow: hidden;
}

.cta-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: linear-gradient(120deg, var(--color-accent-start), var(--color-accent-end));
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  background-size: 200% 100%;
  background-position: var(--grad-pos) 50%;
}

.cta-btn:hover,
.cta-btn:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 26px 55px rgba(26, 22, 49, 0.7);
}

/* Footer */
.site-footer {
  padding: 1.75rem 5vw 2.5rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.85rem;
}

/* Responsive tweaks */
@media (max-width: 640px) {
  .nav-container {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 1rem;
  }

  .nav-links {
    gap: 1rem;
    justify-content: center;
  }

  .hero-inner {
    min-height: 460px;
  }

  .hero-text {
    padding-top: 7rem;
  }
}

/* Typing test page */
body.typing-test-page {
  background: linear-gradient(180deg, #fdfdff 0%, #f7f9ff 35%, #ffffff 100%);
  color: #101420;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 3rem 1.5rem 6rem;
  position: relative;
  overflow: hidden;
}

.typing-test-main {
  width: min(700px, 90vw);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
  margin-top: 2.5rem;
  position: relative;
}

.typing-test-title {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.typing-settings {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 0;
  z-index: 10;
}

.typing-settings__handle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  background: #0f172a;
  color: #f8fafc;
  border: 2px solid #0f172a;
  border-radius: 14px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.typing-settings__handle:hover,
.typing-settings__handle:focus-visible {
  background: #1d4ed8;
  border-color: #1d4ed8;
  box-shadow: 0 14px 28px rgba(29, 78, 216, 0.28);
  transform: translateY(-1px);
}

.typing-settings__handle-text {
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.typing-settings__panel {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -10px);
  bottom: calc(100% + 10px);
  width: min(420px, 90vw);
  padding: 1rem;
  border-radius: 16px;
  border: 2px solid #0f172a;
  background: #f9fafb;
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 2;
}

.typing-settings:hover .typing-settings__panel,
.typing-settings:focus-within .typing-settings__panel {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.typing-settings__group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
  color: #0f172a;
  font-weight: 700;
  font-size: 0.95rem;
}

.typing-settings__group select {
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  border: 2px solid #e5e7eb;
  background: #fff;
  font-weight: 600;
  color: #0f172a;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.typing-settings__group select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.16);
}

.typing-settings__toggles {
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.typing-settings__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  color: #111827;
}

.typing-settings__toggle input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: #2563eb;
}

.typing-settings__hint {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: #6b7280;
}

.back-button {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: #f0f2f9;
  color: #4b5563;
  font-size: 1.5rem;
  text-decoration: none;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.back-button:hover,
.back-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.2);
}

.quote-card {
  position: relative;
  width: 100%;
  padding: clamp(1.75rem, 4vw, 2.5rem);
  background: linear-gradient(180deg, #f9f9fb 0%, #f1f2f7 100%);
  border: 3px solid #1f2937;
  border-radius: 18px;
  box-shadow: 0 25px 65px rgba(15, 23, 42, 0.12);
  min-height: clamp(220px, 32vh, 280px);
}

.quote-display {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.015em;
  line-height: 1.6;
  text-align: left;
  color: #6b7280;
  display: grid;
  gap: 0.55rem;
}

.quote-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.12em;
  align-items: flex-end;
}

.quote-line-preview {
  display: block;
  color: rgba(107, 114, 128, 0.65);
  font-weight: 600;
  opacity: 0.75;
  white-space: normal;
}

.quote-line-preview .quote-token,
.quote-line-preview .quote-space {
  display: inline;
  white-space: pre-wrap;
}

.quote-token {
  display: inline-flex;
  gap: 0.05em;
  white-space: nowrap;
  vertical-align: baseline;
}

.quote-token-space {
  display: inline-flex;
  gap: 0;
}

.quote-enter-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  margin-left: 0.35rem;
  border-radius: 8px;
  border: 2px solid #cbd5e1;
  background: #f8fafc;
  color: #1f2937;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.quote-enter-indicator.is-ready,
.quote-display.awaiting-enter .quote-enter-indicator {
  background: #e8f1ff;
  border-color: #2563eb;
  color: #0f172a;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.18);
  transform: translateY(-1px);
}

.quote-token-space .quote-char {
  display: block;
  width: 0.45em;
}

.quote-space {
  display: inline;
  white-space: pre;
}

.quote-char {
  color: #6b7280;
  transition: color 0.2s ease;
  position: relative;
}

.quote-char.is-correct {
  color: #34d399;
}

.quote-char.is-corrected {
  color: #facc15;
}

.quote-char.is-incorrect {
  color: #f87171;
  text-decoration: underline;
}

.quote-char.is-active {
  color: #0f172a;
  background: linear-gradient(120deg, #e0ecff, #e7f5ff);
  border-radius: 6px;
  box-shadow: inset 0 -0.12em 0 #c7d7ff;
}

.quote-char-space {
  display: block;
}

.typing-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: none;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: #2563eb;
  font-size: inherit;
  font-family: inherit;
  line-height: inherit;
  padding: clamp(1.75rem, 4vw, 2.5rem);
  box-sizing: border-box;
}

.results-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: clamp(1rem, 3vw, 1.75rem);
  width: 100%;
  padding-top: 1rem;
}

.results-panel[hidden] {
  display: none;
}

.result-card {
  background: linear-gradient(180deg, #f9f9fb 0%, #f1f2f7 100%);
  border: 3px solid #111827;
  border-radius: 18px;
  padding: 1.5rem 1.25rem;
  box-shadow: 0 25px 65px rgba(15, 23, 42, 0.12);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 156px;
}

.result-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 800;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0f172a;
}

.result-card-unit {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  letter-spacing: 0.22em;
  color: #64748b;
}

.result-card-unit-small {
  font-size: clamp(0.75rem, 1.5vw, 0.9rem);
  letter-spacing: 0.3em;
}

.result-card-message {
  margin: 0;
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  font-weight: 600;
  color: #374151;
}

.result-score-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.result-score-badge {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: transparent;
  box-shadow: inset 0 0 0 2px rgba(15, 23, 42, 0.12);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.result-score-badge.is-bronze {
  background: radial-gradient(circle at 30% 30%, #fcd9b6, #b7742a);
  box-shadow: 0 0 0 4px rgba(183, 116, 42, 0.12), inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.result-score-badge.is-silver {
  background: radial-gradient(circle at 30% 30%, #e3e9f5, #93a4be);
  box-shadow: 0 0 0 4px rgba(147, 164, 190, 0.2), inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.result-score-badge.is-gold {
  background: radial-gradient(circle at 30% 30%, #fff6d6, #f2c94c);
  box-shadow: 0 0 0 4px rgba(242, 201, 76, 0.16), inset 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.result-score-badge.is-mythic {
  background: conic-gradient(from 120deg, #a5b4fc, #f472b6, #fcd34d, #34d399, #60a5fa, #a5b4fc);
  box-shadow: 0 0 0 5px rgba(96, 165, 250, 0.18), 0 6px 18px rgba(15, 23, 42, 0.28);
  animation: mythic-spin 5s linear infinite;
}

@keyframes mythic-spin {
  to {
    transform: rotate(360deg);
  }
}

.result-customizations {
  grid-column: 1 / -1;
  background: #0f172a;
  color: #f9fafb;
  border-radius: 16px;
  padding: 1rem 1.25rem;
  text-align: left;
  font-weight: 600;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
}

.result-customizations strong {
  color: #bfdbfe;
}

.typing-input:focus {
  outline: none;
}

.timer-bar {
  width: min(520px, 80vw);
  height: 14px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(15, 23, 42, 0.12);
}

.timer-bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #22d3ee, #3b82f6 40%, #1d4ed8 100%);
  border-radius: inherit;
  transition: width 0.2s linear;
}

.typing-stats {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.restart-btn {
  margin-top: 0.75rem;
  padding: 0.7rem 2rem;
  background: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 15px 35px rgba(59, 130, 246, 0.35);
}

.restart-btn:hover,
.restart-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 22px 45px rgba(59, 130, 246, 0.45);
}

.mobile-blocked,
.typing-test-page.mobile-blocked {
  background: #000000;
  color: #9ca3af;
  min-height: 100vh;
  position: relative;
}

.mobile-blocked .typing-test-main,
.mobile-blocked .timer-bar,
.mobile-blocked .typing-stats,
.mobile-blocked #resultsPanel,
.mobile-blocked .view-report-btn,
.mobile-blocked .quote-card,
.mobile-blocked .restart-btn,
.mobile-blocked .mountain,
.mobile-blocked .site-footer {
  display: none !important;
}

.mobile-block {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: #000000;
  color: #9ca3af;
}

.mobile-block img {
  width: min(260px, 60vw);
  height: auto;
}

.mobile-block p {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  max-width: 520px;
  line-height: 1.55;
}

.view-report-btn {
  position: fixed;
  top: 1.25rem;
  right: 1.5rem;
  z-index: 20;
  padding: 0.5rem 1.6rem;
  font-weight: 600;
  background: #0f172a;
  color: #ffffff;
  border-radius: 999px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.25);
}

.view-report-btn[hidden] {
  display: none;
}

.view-report-btn:hover,
.view-report-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.35);
}

.mountain {
  position: absolute;
  bottom: -120px;
  width: min(440px, 48vw);
  user-select: none;
  pointer-events: none;
  filter: drop-shadow(0 20px 25px rgba(15, 23, 42, 0.25));
}

.mountain-left {
  left: -140px;
}

.mountain-right {
  right: -140px;
  transform: scaleX(-1);
}

.typing-test-footer {
  margin-top: auto;
  background: transparent;
  color: rgba(15, 23, 42, 0.55);
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.report-dialog[hidden] {
  display: none;
}

.report-dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.report-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
}

.report-dialog__panel {
  position: relative;
  z-index: 1;
  width: min(640px, 92vw);
  background: #ffffff;
  border-radius: 24px;
  padding: clamp(1.75rem, 4vw, 2.5rem);
  box-shadow: 0 40px 80px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.report-dialog__subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: #64748b;
}

.report-dialog__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #f3f4f6;
  color: #111827;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.report-dialog__close:hover,
.report-dialog__close:focus-visible {
  transform: scale(1.05);
}

#wpmChart {
  width: 100%;
  height: auto;
  border-radius: 18px;
  background: #f8fafc;
}

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

.report-metric {
  background: #f5f7ff;
  border-radius: 18px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
}

.report-metric-label {
  font-size: 0.9rem;
  color: #6b7280;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.report-metric-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: #111827;
}

@media (max-width: 640px) {
  .view-report-btn {
    top: 1rem;
    right: 1rem;
  }

  .report-dialog__panel {
    width: min(520px, 96vw);
    gap: 1.25rem;
  }
}

@media (max-width: 600px) {
  body.typing-test-page {
    padding-top: 4.5rem;
  }

  .back-button {
    top: 1rem;
    left: 1rem;
  }

  .typing-test-main {
    gap: 1.4rem;
  }

  .timer-bar {
    width: min(420px, 85vw);
  }

  .mountain {
    width: min(320px, 85vw);
    bottom: -90px;
  }

  .mountain-left {
    left: -120px;
  }

  .mountain-right {
    right: -120px;
  }
}
