:root {
  --bg-deep: #07111b;
  --bg-mid: #10233a;
  --panel: rgba(8, 19, 31, 0.78);
  --panel-strong: rgba(8, 19, 31, 0.92);
  --panel-border: rgba(147, 230, 255, 0.18);
  --text-main: #f7fbff;
  --text-soft: #aac2d9;
  --text-dim: #7590aa;
  --accent-cyan: #7ce7ff;
  --accent-warm: #ff7a59;
  --accent-lime: #c8ff7a;
  --accent-gold: #ffd166;
  --success: #62f5a6;
  --danger: #ff6d7f;
  --shadow-xl: 0 30px 80px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 16px 40px rgba(0, 0, 0, 0.2);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --font-display: "Chakra Petch", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  position: relative;
  overflow: hidden;
  color: var(--text-main);
  font-family: var(--font-display);
  background:
    radial-gradient(circle at 18% 18%, rgba(124, 231, 255, 0.17), transparent 22%),
    radial-gradient(circle at 82% 20%, rgba(255, 122, 89, 0.2), transparent 24%),
    linear-gradient(160deg, #08111c 0%, #0d1d2f 42%, #050b13 100%);
}

button,
textarea {
  font: inherit;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
}

.aurora,
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.aurora {
  filter: blur(90px);
  opacity: 0.58;
  z-index: 0;
}

.aurora-a {
  background: radial-gradient(circle at 20% 25%, rgba(124, 231, 255, 0.24), transparent 28%);
  animation: drift-a 12s ease-in-out infinite alternate;
}

.aurora-b {
  background: radial-gradient(circle at 72% 72%, rgba(255, 122, 89, 0.22), transparent 28%);
  animation: drift-b 16s ease-in-out infinite alternate;
}

.noise {
  z-index: 2;
  opacity: 0.06;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.7) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.7) 1px, transparent 1px);
  background-size: 120px 120px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), transparent 80%);
}

.floating-panel,
.main-shell {
  background: linear-gradient(180deg, rgba(9, 23, 38, 0.78), rgba(7, 17, 27, 0.88));
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.main-shell {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 10;
  width: min(1100px, calc(100vw - 32px));
  min-height: min(720px, calc(100vh - 48px));
  max-height: calc(100vh - 48px);
  border-radius: var(--radius-xl);
  padding: 32px;
  overflow: auto;
  transition: min-height 400ms ease, max-height 400ms ease, padding 400ms ease;
}

.main-shell.game-mode {
  min-height: 0;
  max-height: none;
  padding: 16px;
  overflow: visible;
  background: linear-gradient(180deg, rgba(9, 23, 38, 0.65), rgba(7, 17, 27, 0.8));
}

.screen {
  display: none;
  min-height: 100%;
}

.screen.active {
  display: flex;
  animation: screen-in 320ms ease forwards;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-cyan);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.hero {
  text-align: center;
}

.hero-title {
  margin: 0;
  font-size: clamp(2.6rem, 5vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
}

.hero-copy {
  max-width: 760px;
  margin: 12px auto 0;
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1.7;
}

#loading-screen {
  align-items: center;
  justify-content: center;
}

.loading-content {
  width: min(440px, 100%);
  margin: auto;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
}

.brand-burst {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 30% 35%, #fff, rgba(255, 255, 255, 0.2) 30%, transparent 32%),
    linear-gradient(135deg, var(--accent-cyan), var(--accent-warm));
  box-shadow: 0 0 40px rgba(124, 231, 255, 0.3);
}

.brand-mark h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
}

.loading-bar-wrap {
  width: 100%;
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.loading-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-warm));
  box-shadow: 0 0 30px rgba(255, 122, 89, 0.35);
}

#loading-text {
  margin: 16px 0 0;
  font-family: var(--font-mono);
  color: var(--text-soft);
}

#start-screen {
  flex-direction: column;
  justify-content: center;
  gap: 20px;
}

.section-block {
  display: grid;
  gap: 14px;
}

.section-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.section-title {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section-tip {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.role-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(16, 35, 56, 0.92), rgba(10, 20, 33, 0.96)),
    linear-gradient(120deg, rgba(124, 231, 255, 0.2), transparent 50%);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.role-card::after {
  content: "";
  position: absolute;
  inset: auto -20% -55% auto;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08), transparent 68%);
}

.role-card:hover,
.role-card.selected {
  transform: translateY(-4px);
  border-color: rgba(124, 231, 255, 0.34);
  box-shadow: var(--shadow-md);
}

.role-card.selected {
  outline: 2px solid rgba(124, 231, 255, 0.36);
}

.card-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.candidate-tag {
  background: rgba(98, 245, 166, 0.14);
  color: var(--success);
}

.examiner-tag {
  background: rgba(255, 109, 127, 0.14);
  color: var(--danger);
}

.avatar-badge,
.result-icon {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  margin: 14px 0 12px;
  color: #051017;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 18px 28px rgba(0, 0, 0, 0.25);
}

.candidate-avatar {
  background: linear-gradient(135deg, var(--accent-lime), var(--success));
}

.examiner-avatar {
  background: linear-gradient(135deg, var(--accent-warm), var(--accent-gold));
}

.role-card h3 {
  margin: 0 0 8px;
  font-size: 1.45rem;
}

.role-card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.7;
}

.difficulty-buttons,
.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.record-board {
  display: grid;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.record-board-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.context-chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(124, 231, 255, 0.08);
  border: 1px solid rgba(124, 231, 255, 0.18);
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.record-stat {
  padding: 16px;
  border-radius: 16px;
  background: rgba(6, 14, 24, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: grid;
  gap: 10px;
}

.record-label {
  color: var(--text-dim);
  font-size: 0.82rem;
}

.record-stat strong {
  font-size: 1.42rem;
  font-family: var(--font-mono);
}

.record-hint {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.mode-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.mode-select-btn {
  display: grid;
  gap: 8px;
  text-align: left;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 18, 29, 0.62);
  color: var(--text-main);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.mode-select-btn strong {
  font-size: 0.98rem;
}

.mode-select-btn span {
  color: var(--text-dim);
  line-height: 1.5;
  font-size: 0.84rem;
}

.mode-select-btn:hover,
.mode-select-btn.selected {
  transform: translateY(-2px);
  border-color: rgba(124, 231, 255, 0.28);
  box-shadow: var(--shadow-md);
}

.recent-runs-block {
  display: grid;
  gap: 12px;
}

.recent-runs-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.recent-title {
  margin: 0;
  font-size: 1rem;
}

.recent-note {
  color: var(--text-dim);
  font-size: 0.82rem;
}

.recent-runs-list {
  display: grid;
  gap: 10px;
}

.recent-run-item,
.recent-empty {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(6, 14, 24, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.recent-run-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.recent-run-main {
  display: grid;
  gap: 4px;
}

.recent-run-title {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.recent-run-meta {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.recent-run-band {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--accent-cyan);
}

.diff-btn,
.chip-btn,
.secondary-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(10, 24, 39, 0.82);
  color: var(--text-main);
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.diff-btn:hover,
.chip-btn:hover,
.secondary-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 231, 255, 0.3);
  background: rgba(16, 35, 56, 0.95);
}

.diff-btn.selected {
  background: linear-gradient(135deg, rgba(124, 231, 255, 0.18), rgba(255, 122, 89, 0.18));
  border-color: rgba(124, 231, 255, 0.42);
  box-shadow: inset 0 0 0 1px rgba(124, 231, 255, 0.18);
}

.start-actions {
  display: flex;
  justify-content: center;
}

.primary-btn {
  min-width: 280px;
  border: none;
  border-radius: 999px;
  padding: 16px 26px;
  cursor: pointer;
  color: #07111b;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-warm));
  box-shadow: 0 16px 36px rgba(255, 122, 89, 0.26);
  transition: transform 180ms ease, filter 180ms ease, opacity 180ms ease;
}

.primary-btn:hover:not(.disabled) {
  transform: translateY(-2px);
  filter: saturate(1.08);
}

.primary-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.top-right-controls {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 12;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.chip-btn {
  min-width: 52px;
  padding: 11px 14px;
}

.stats-bar,
.article-preview {
  border-radius: var(--radius-lg);
}

.stats-bar {
  display: none;
  width: min(420px, calc(100vw - 48px));
  padding: 16px;
  margin-left: 6px;
}

.stats-row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.progress-row {
  margin-top: 14px;
}

.stat-box {
  flex: 1;
  min-width: 0;
  padding: 12px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  text-align: center;
}

.stat-label,
.hud-label {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.stat-value,
.hud-value {
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 1.6rem;
}

.combo-value {
  color: var(--accent-gold);
  display: inline-block;
}

.combo-value.pop {
  animation: combo-pop 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.combo-value.boosting {
  color: var(--accent-lime);
  text-shadow: 0 0 16px rgba(200, 255, 122, 0.7);
}

.progress-copy {
  width: 100%;
  display: grid;
  gap: 10px;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.hud-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.hud-bar-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-warm));
  transition: width 200ms ease;
}

.hud-bar-fill.boosting {
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-lime));
  animation: boost-pulse 0.6s infinite alternate;
}

.article-preview {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 12;
  display: none;
  width: min(360px, calc(100vw - 48px));
  max-height: 36vh;
  padding: 18px;
  overflow: auto;
}

.preview-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.article-preview h2 {
  margin: 8px 0 14px;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-main);
}

#full-text-content {
  color: var(--text-soft);
  line-height: 1.75;
  font-size: 0.94rem;
}

.hud-done {
  color: rgba(170, 194, 217, 0.45);
}

.hud-current {
  color: #fff;
  background: rgba(124, 231, 255, 0.16);
  box-shadow: 0 0 0 1px rgba(124, 231, 255, 0.12);
  border-radius: 6px;
  padding: 2px 4px;
}

.hud-current.hotspot {
  background: rgba(255, 122, 89, 0.18);
  box-shadow: 0 0 0 1px rgba(255, 122, 89, 0.12);
}

.hud-upcoming {
  color: var(--text-soft);
}

#game-screen {
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.game-mode .typing-header {
  display: none;
}

.game-mode .mode-strip {
  display: none;
}

.game-mode .chase-strip {
  margin-bottom: 10px;
  padding: 10px 14px;
  gap: 8px;
}

.game-mode .typing-panel {
  padding: 14px 20px;
}

.game-layout {
  width: min(940px, 100%);
}

.typing-panel {
  position: relative;
  border-radius: 28px;
  padding: 26px;
  background: linear-gradient(180deg, rgba(8, 19, 31, 0.82), rgba(10, 24, 39, 0.94));
  border: 1px solid rgba(124, 231, 255, 0.18);
  box-shadow: var(--shadow-md);
}

.game-mode .typing-panel {
  background: linear-gradient(180deg, rgba(8, 19, 31, 0.7), rgba(10, 24, 39, 0.82));
}

.typing-panel.focused {
  box-shadow: 0 0 0 1px rgba(124, 231, 255, 0.24), var(--shadow-md);
}

.typing-panel.error-shake {
  animation: shake 400ms cubic-bezier(.36, .07, .19, .97) both;
  background: rgba(255, 109, 127, 0.06);
}

.mode-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.mode-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.accent-chip {
  color: #07111b;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-warm));
  border: none;
}

@keyframes shake {
  10%,
  90% {
    transform: translate3d(-1px, 0, 0);
  }

  20%,
  80% {
    transform: translate3d(2px, 0, 0);
  }

  30%,
  50%,
  70% {
    transform: translate3d(-4px, 0, 0);
  }

  40%,
  60% {
    transform: translate3d(4px, 0, 0);
  }
}

@keyframes cursor-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 1px rgba(124, 231, 255, 0.2), 0 0 10px rgba(124, 231, 255, 0.2);
  }

  100% {
    transform: scale(1.08);
    box-shadow: 0 0 0 1px rgba(124, 231, 255, 0.4), 0 0 22px rgba(124, 231, 255, 0.6);
  }
}

@keyframes road-move {
  from {
    background-position: 0 0;
  }

  to {
    background-position: -30px 0;
  }
}

@keyframes flicker {
  0% {
    transform: translateY(-50%) scaleX(1);
    opacity: 0.7;
  }

  100% {
    transform: translateY(-50%) scaleX(1.4);
    opacity: 1;
  }
}

@keyframes boost-pulse {
  0% {
    opacity: 0.8;
    box-shadow: 0 0 8px rgba(124, 231, 255, 0.3);
  }

  100% {
    opacity: 1;
    box-shadow: 0 0 18px rgba(124, 231, 255, 0.7);
  }
}

@keyframes combo-pop {
  0% {
    transform: scale(1);
  }

  40% {
    transform: scale(1.45);
  }

  70% {
    transform: scale(0.92);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes result-bounce {
  0% {
    opacity: 0;
    transform: scale(0.55) translateY(18px);
  }

  60% {
    opacity: 1;
    transform: scale(1.08) translateY(-6px);
  }

  80% {
    transform: scale(0.96) translateY(2px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.typing-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
  margin-bottom: 18px;
}

.typing-title {
  margin: 0;
  font-size: 1.55rem;
}

.chase-strip {
  margin-bottom: 18px;
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.chase-strip-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.strip-copy {
  color: var(--text-soft);
  font-size: 0.92rem;
}

.chase-track {
  position: relative;
  height: 56px;
}

.track-line {
  position: absolute;
  inset: 24px 0 auto;
  height: 8px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(255, 109, 127, 0.14), rgba(124, 231, 255, 0.18), rgba(98, 245, 166, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.track-line::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 3px;
  transform: translateY(-50%);
  background-image: linear-gradient(to right, rgba(255, 255, 255, 0.3) 50%, transparent 50%);
  background-size: 30px 3px;
  animation: road-move 1s linear infinite;
}

.track-finish {
  position: absolute;
  right: 0;
  top: 14px;
  width: 2px;
  height: 28px;
  background: linear-gradient(180deg, transparent, rgba(255, 209, 102, 0.95), transparent);
}

.track-marker {
  position: absolute;
  top: 7px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  color: #08111c;
  transform: translateX(-50%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  transition: left 200ms ease;
}

.candidate-marker {
  background: linear-gradient(135deg, var(--accent-lime), var(--success));
}

.examiner-marker {
  background: linear-gradient(135deg, var(--accent-warm), var(--accent-gold));
}

.track-marker.boosting {
  animation: shake 0.5s infinite;
  z-index: 3;
}

.track-marker.boosting::after {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 14px;
  background: linear-gradient(to right, transparent, var(--accent-gold), var(--accent-warm));
  border-radius: 50%;
  filter: blur(3px);
  animation: flicker 0.1s infinite alternate;
}

.track-gap-badge {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(10, 24, 39, 0.96);
  border: 1px solid rgba(124, 231, 255, 0.18);
  color: var(--text-main);
  transition: left 200ms ease;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: nowrap;
}

.focus-hint {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: right;
}

.text-display {
  min-height: 0;
  max-height: calc(3.5em * 2);
  overflow: auto;
  padding-right: 8px;
  font-size: 1.14rem;
  line-height: 2;
  color: var(--text-soft);
  font-family: var(--font-mono);
  white-space: normal;
  word-break: break-word;
}

.text-display span.correct {
  color: rgba(124, 231, 255, 0.65);
}

.text-display span.correct.corrected {
  color: rgba(255, 209, 102, 0.96);
  text-decoration: underline;
  text-decoration-style: wavy;
  text-decoration-color: rgba(255, 209, 102, 0.72);
  text-underline-offset: 0.18em;
}

.text-display span.cursor {
  color: #051017;
  background: linear-gradient(135deg, var(--accent-cyan), #a4f7ff);
  border-radius: 5px;
  box-shadow: 0 0 0 1px rgba(124, 231, 255, 0.2), 0 0 18px rgba(124, 231, 255, 0.16);
  display: inline-block;
  animation: cursor-pulse 0.8s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 800;
}

.text-display span.cursor.cursor-hot {
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.96), rgba(255, 122, 89, 0.92));
  box-shadow: 0 0 0 1px rgba(255, 209, 102, 0.24), 0 0 18px rgba(255, 122, 89, 0.24);
}

.text-display span.cursor.space-cursor {
  padding-inline: 6px;
}

.text-display span.wrong {
  color: #fff;
  background: rgba(255, 109, 127, 0.3);
  border-radius: 5px;
  animation: wrong-flash 260ms ease;
}

@keyframes wrong-flash {
  0% {
    background: rgba(255, 109, 127, 0.6);
    transform: scale(1.15);
  }

  100% {
    background: rgba(255, 109, 127, 0.3);
    transform: scale(1);
  }
}

.text-display span.newline-hint {
  opacity: 0.6;
}

.focus-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: rgba(5, 14, 23, 0.68);
  color: var(--text-main);
  text-align: center;
  padding: 20px;
  transition: opacity 180ms ease;
  cursor: text;
}

.focus-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.session-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 12, 20, 0.56);
  border-radius: inherit;
  transition: opacity 180ms ease;
  z-index: 4;
}

.session-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.session-card {
  min-width: 220px;
  padding: 22px 24px;
  border-radius: 24px;
  text-align: center;
  background: rgba(9, 23, 38, 0.92);
  border: 1px solid rgba(124, 231, 255, 0.18);
  box-shadow: var(--shadow-md);
}

.session-overlay-label {
  margin: 0;
  font-size: 3rem;
  font-family: var(--font-mono);
}

.session-overlay-copy {
  margin: 8px 0 0;
  color: var(--text-soft);
}

.session-btn {
  margin-top: 16px;
}

.session-btn.hidden {
  display: none;
}

#hidden-input {
  position: fixed;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  width: 1px;
  height: 1px;
  resize: none;
}

#result-screen {
  align-items: center;
  justify-content: center;
}

.result-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 140px);
  overflow: auto;
  padding: 28px 28px 24px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(8, 19, 31, 0.86), rgba(8, 19, 31, 0.96));
  border: 1px solid rgba(124, 231, 255, 0.16);
  text-align: center;
  box-shadow: var(--shadow-md);
}

.result-icon {
  margin-inline: auto;
  width: 72px;
  height: 72px;
  margin-bottom: 8px;
}

.result-icon.pop-in {
  animation: result-bounce 480ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#result-title {
  margin: 0 0 8px;
  font-size: 2.15rem;
}

#result-title.victory {
  color: var(--success);
}

#result-title.defeat {
  color: var(--danger);
}

#result-msg {
  margin: 0 auto 14px;
  max-width: 420px;
  color: var(--text-soft);
  line-height: 1.65;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 11px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.result-row strong {
  font-family: var(--font-mono);
  font-size: 1.2rem;
}

.record-badge {
  min-height: 24px;
  margin: 0 0 12px;
  color: var(--text-dim);
}

.record-badge.highlight {
  color: var(--accent-cyan);
}

.result-diagnosis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.diagnosis-card {
  display: grid;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.diagnosis-wide {
  grid-column: span 2;
}

.diagnosis-label {
  color: var(--text-dim);
  font-size: 0.82rem;
}

.diagnosis-card strong {
  font-family: var(--font-mono);
  font-size: 0.96rem;
  line-height: 1.45;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(18px);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(8, 19, 31, 0.96);
  border: 1px solid rgba(124, 231, 255, 0.22);
  box-shadow: var(--shadow-md);
  color: var(--text-main);
  font-family: var(--font-mono);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes drift-a {
  from {
    transform: translate3d(-2%, -2%, 0) scale(1);
  }

  to {
    transform: translate3d(5%, 3%, 0) scale(1.08);
  }
}

@keyframes drift-b {
  from {
    transform: translate3d(2%, -3%, 0) scale(1);
  }

  to {
    transform: translate3d(-4%, 4%, 0) scale(1.08);
  }
}

@media (max-width: 980px) {
  .main-shell {
    padding: 24px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .mode-buttons {
    grid-template-columns: 1fr;
  }

  .section-title-row,
  .typing-header {
    grid-template-columns: 1fr;
    display: grid;
    align-items: start;
  }

  .record-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-bar {
    width: min(380px, calc(100vw - 32px));
  }
}

@media (max-width: 720px) {
  .main-shell {
    bottom: 12px;
    width: calc(100vw - 16px);
    max-height: calc(100vh - 24px);
    min-height: calc(100vh - 24px);
    padding: 20px;
  }

  .top-right-controls {
    top: 10px;
    right: 10px;
    left: 10px;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .article-preview {
    display: none !important;
  }

  .stats-bar {
    width: 100%;
    order: 4;
    margin-left: 0;
  }

  .stats-row {
    flex-wrap: wrap;
  }

  .stat-box {
    min-width: calc(50% - 8px);
  }

  .typing-panel {
    padding: 20px;
  }

  .record-board-head,
  .chase-strip-head,
  .recent-runs-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  .record-grid {
    grid-template-columns: 1fr;
  }

  .result-stats {
    grid-template-columns: 1fr;
  }

  .result-diagnosis {
    grid-template-columns: 1fr;
  }

  .diagnosis-wide {
    grid-column: span 1;
  }

  .text-display {
    min-height: 0;
    max-height: calc(3em * 2);
    font-size: 1rem;
  }

  .result-card {
    padding: 24px;
  }
}
