* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --correct: #4ade80;
  --incorrect: #f87171;
  --current-bg: #334155;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}

.container {
  width: 100%;
  max-width: 820px;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
}

h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--muted);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.controls label {
  color: var(--muted);
}

select,
button {
  font-size: 1rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--current-bg);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

button {
  background: var(--accent);
  color: #082f49;
  font-weight: 600;
  border: none;
  transition: opacity 0.15s;
}

button:hover {
  opacity: 0.85;
}

.stats-bar {
  display: flex;
  justify-content: space-around;
  background: var(--panel);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.test-area {
  margin-bottom: 1.5rem;
}

.passage {
  background: var(--panel);
  border-radius: 12px;
  padding: 1.5rem;
  font-size: 1.35rem;
  line-height: 2.2rem;
  margin-bottom: 1rem;
  user-select: none;
  max-height: 11rem;
  overflow: hidden;
}

.passage .word {
  display: inline-block;
  padding: 0 0.2rem;
  border-radius: 4px;
  margin: 0 0.05rem;
}

.passage .word.current {
  background: var(--current-bg);
  outline: 2px solid var(--accent);
}

.passage .word.current.typo {
  outline-color: var(--incorrect);
  background: rgba(248, 113, 113, 0.2);
}

.passage .word.correct {
  color: var(--correct);
}

.passage .word.incorrect {
  color: var(--incorrect);
  text-decoration: underline wavy var(--incorrect);
}

#word-input {
  width: 100%;
  font-size: 1.35rem;
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  border: 2px solid var(--current-bg);
  background: var(--panel);
  color: var(--text);
  outline: none;
}

#word-input:focus {
  border-color: var(--accent);
}

#word-input:disabled {
  opacity: 0.5;
}

.results {
  background: var(--panel);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
}

.results h2 {
  margin-bottom: 1rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.result-card {
  background: var(--bg);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.result-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.result-label {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.word-counts {
  color: var(--muted);
  margin-bottom: 1rem;
}

.misspelled-section {
  text-align: left;
  background: var(--bg);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.misspelled-section h3 {
  margin-bottom: 0.75rem;
  color: var(--incorrect);
}

.misspelled-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 14rem;
  overflow-y: auto;
}

.misspelled-list li {
  font-family: "Consolas", "Menlo", monospace;
  font-size: 1rem;
}

.misspelled-list .expected {
  color: var(--correct);
}

.misspelled-list .typed {
  color: var(--incorrect);
  text-decoration: line-through;
}

.hidden {
  display: none;
}

/* ── Navigation ─────────────────────────────────────────────────────────── */
#site-nav {
  background: var(--panel);
  border-bottom: 1px solid var(--current-bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nc {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  height: 52px;
  gap: 0.25rem;
}

.nbrand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
  white-space: nowrap;
}

.nlinks {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: nowrap;
}

.nd { position: relative; }

.nb, .nlink {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  border-radius: 6px;
  text-decoration: none;
  display: block;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
  font-family: inherit;
}

.nb:hover, .nlink:hover, .nb-active {
  color: var(--text);
  background: var(--current-bg);
}

.nm {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--panel);
  border: 1px solid var(--current-bg);
  border-radius: 8px;
  padding: 0.4rem;
  min-width: 155px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.nd.open .nm { display: block; }

.nm a {
  display: block;
  padding: 0.45rem 0.7rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}

.nm a:hover, .nm a.na { color: var(--accent); background: var(--current-bg); }
.nlink.na { color: var(--accent); }

.ntoggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.4rem;
}

@media (max-width: 680px) {
  .ntoggle { display: block; }
  .nlinks {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    background: var(--panel);
    border-bottom: 1px solid var(--current-bg);
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
    gap: 0.25rem;
    z-index: 99;
    max-height: calc(100vh - 52px);
    overflow-y: auto;
  }
  .nlinks.open { display: flex; }
  .nm { position: static; border: none; box-shadow: none; padding-left: 1rem; }
  .nd.open .nm { display: block; }
}

/* ── Info / SEO sections ─────────────────────────────────────────────────── */
.info-section {
  margin-top: 2rem;
  background: var(--panel);
  border-radius: 12px;
  padding: 1.5rem;
  color: var(--muted);
  line-height: 1.75;
}

.info-section h2 { color: var(--text); margin-bottom: 0.75rem; font-size: 1.2rem; }
.info-section h3 { color: var(--text); margin: 1rem 0 0.4rem; font-size: 1rem; }
.info-section p  { margin-bottom: 0.75rem; }
.info-section ul { margin: 0.4rem 0 0.75rem 1.25rem; }
.info-section ul li { margin-bottom: 0.25rem; }

/* ── Mode selector pills ─────────────────────────────────────────────────── */
.mode-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  justify-content: center;
}

.mode-pill {
  padding: 0.45rem 1rem;
  background: var(--panel);
  border: 1px solid var(--current-bg);
  border-radius: 20px;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.mode-pill:hover { color: var(--text); border-color: var(--accent); }
.mode-pill.active { background: var(--accent); color: #082f49; border-color: var(--accent); font-weight: 600; }

/* ── Calculator pages ────────────────────────────────────────────────────── */
.calc-card {
  background: var(--panel);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-group input[type="number"],
.form-group input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 2px solid var(--current-bg);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.1rem;
  outline: none;
  font-family: inherit;
}

.form-group input:focus { border-color: var(--accent); }

.calc-result {
  text-align: center;
  background: var(--bg);
  border-radius: 10px;
  padding: 1.25rem;
  margin-top: 1rem;
}

.calc-result-value { font-size: 2.75rem; font-weight: 700; color: var(--accent); display: block; }
.calc-result-label { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; }

.calc-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.calc-breakdown .result-card { background: var(--bg); border-radius: 8px; padding: 0.75rem; display: flex; flex-direction: column; align-items: center; }
.calc-breakdown .result-value { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.calc-breakdown .result-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Typing Game ─────────────────────────────────────────────────────────── */
.game-arena {
  background: var(--panel);
  border-radius: 12px;
  padding: 2rem 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}

.game-word-display {
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  min-height: 3.5rem;
  display: flex;
  align-items: center;
}

.game-word-display.gw-ok   { color: var(--correct); }
.game-word-display.gw-bad  { color: var(--incorrect); }

.game-timer-bar {
  width: 100%;
  max-width: 320px;
  height: 6px;
  background: var(--current-bg);
  border-radius: 3px;
  overflow: hidden;
}

.game-timer-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.1s linear, background 0.3s;
}

.game-timer-fill.urgent { background: var(--incorrect); }

.game-hearts { font-size: 1.4rem; letter-spacing: 0.3rem; }

.game-meta {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.game-meta-stat { text-align: center; }
.game-meta-value { font-size: 1.5rem; font-weight: 700; color: var(--accent); display: block; }
.game-meta-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

