@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300;400;500&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {

  --bg: #fff;
  --surface: #ffffff;
  --border: #e0e0e0;
  --muted: #d0d0d0;
  --sub: #999;
  --text: #1a1a1a;
  --accent: #B2222b;
  --correct: #16a34a;
  --wrong: #dc2626;
  --caret: #B2222b;
  --key-bg: #efefef;
  --key-active: #e6121288;
  --radius:    10px;
  --font-mono: 'Roboto Mono', monospace;
  --font-ui:   'DM Sans', sans-serif;
}

[data-theme="light"] {
  --bg:        #0f0f0f;
  --surface:   #181818;
  --border:    #2a2a2a;
  --muted:     #3a3a3a;
  --sub:       #555;
  --text:      #d4d4d4;
  --accent:    #e2b96f;
  --correct:   #6fcf97;
  --wrong:     #eb5757;
  --caret:     #e2b96f;
  --key-bg:    #202020;
  --key-active:#e26f6f;

}

[data-theme="green"] {
  --bg: #0a0f0a;
  --surface: #0f1a0f;
  --border: #1a3a1a;
  --muted: #1f2f1f;
  --sub: #3a6b3a;
  --text: #a3d9a3;
  --accent: #4ade80;
  --correct: #86efac;
  --wrong: #f87171;
  --caret: #4ade80;
  --key-bg: #0f1a0f;
  --key-active: #4ade80;
}

[data-theme="dark-lime"] {
  --bg: #0f0f0f;
  --surface: #181818;
  --border: #2a2a2a;
  --muted: #3a3a3a;
  --sub: #555;
  --text: #d4d4d4;
  --accent: #a3e635;
  --correct: #6fcf97;
  --wrong: #eb5757;
  --caret: #a3e635;
  --key-bg: #202020;
  --key-active: #a3e635;
}

[data-theme="hacker"] {
  --bg: #000000;
  --surface: #0a0a0a;
  --border: #003300;
  --muted: #002200;
  --sub: #005500;
  --text: #00ff00;
  --accent: #00ff00;
  --correct: #00cc00;
  --wrong: #ff0000;
  --caret: #00ff00;
  --key-bg: #001100;
  --key-active: #00ff00;
}



html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ─── Navbar ─── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background:var(--surface);
  backdrop-filter: blur(14px);
  padding: 0 2rem;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.nav-brand {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 300;
  color: var(--text);
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
}
.nav-brand span { color: var(--accent); font-weight: 500; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}
.nav-links a {
  color: var(--sub);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  transition: color 0.18s, background 0.18s;
}
.nav-links a:hover { color: var(--text); background: var(--surface); }

.typingway-name a
{
  color: var(--accent);
}
.typingway-name a:hover { color: #fff; background: var(--accent); }


/* ─── Main Layout ─── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1.5rem 5rem;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

/* ─── Timer Picker ─── */
.timer-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.timer-btn {
  background: none;
  border: none;
  color: var(--sub);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.timer-btn:hover { color: var(--text); background: var(--muted); }
.timer-btn.active { background: var(--accent); color: #0f0f0f; font-weight: 600; }
.timer-btn.active-lang { background: var(--accent); color: #0f0f0f; font-weight: 600; }
/* ─── Typing Area ─── */
.typing-area {
  width: 100%;
  padding: 2rem 2rem 0.2rem 2rem;
}

/* Stats row */
.stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.stat-item { color: var(--sub); }
.stat-item strong { color: var(--accent); font-weight: 500; }
.stat-timer { font-size: 1.1rem; color: var(--text); font-weight: 500; }
.stat-timer.urgent { color: var(--wrong); animation: pulse 0.6s infinite alternate; }

@keyframes pulse { from { opacity: 1; } to { opacity: 0.5; } }

/* Paragraph */
.paragraph-box {
  font-family: var(--font-mono);
  font-size: 1.12rem;
  line-height: 2;
  letter-spacing: 0.01em;
  word-break: break-word;
  position: relative;
  user-select: none;
}

.char {
  position: relative;
  color: var(--sub);
  transition: color 0.07s;
}
.char.correct { color: var(--text); }
.char.wrong { color: var(--wrong); text-decoration: underline wavy var(--wrong); }
.char.current {
  color: var(--text);
}
.char.current::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 0.1em;
  height: 1.2em;
  width: 2px;
  background: var(--caret);
  border-radius: 2px;
  animation: blink 1s step-end infinite;
}

@keyframes blink { 0%,100%{ opacity:1 } 50%{ opacity:0 } }

/* Done overlay */
.result-overlay {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 0;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  text-align: center;
}
.result-overlay.visible { display: flex; }
.result-big { font-size: 2.4rem; color: var(--accent); font-weight: 500; }
.result-label { font-size: 0.75rem; color: var(--sub); letter-spacing: 0.08em; text-transform: uppercase; }
.result-row { display: flex; gap: 2.5rem; margin-top: 0.5rem; }
.result-stat { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }

/* ─── Control Buttons ─── */
.controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 10px;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 1.3rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  letter-spacing: 0.02em;
}
.btn:hover { background: var(--muted); border-color: var(--sub); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #d4a55a; border-color: #d4a55a; }

/* ─── Keyboard ─── */
.keyboard-wrap {
  width: 100%;
  position: relative;
}

.keyboard-header {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  padding: 0 0.2rem;
}
.keyboard-label {
  font-size: 0.7rem;
  color: var(--sub);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.hide-kb-btn {
  position: absolute;
  top:1%;
  right: 17%;
  background: none;
  border: none;
  color: var(--sub);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.hide-kb-btn:hover { color: var(--text); background: var(--surface); }

.keyboard {
  padding: 1.1rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  transition: opacity 0.2s;
}

.kb-row {
  display: flex;
  gap: 0.38rem;
  justify-content: center;
}

.key {
  width: 42px;
  height: 30px;
  border-radius: 7px;
  background: var(--key-bg);
  border: 1px solid var(--border);
  color: var(--sub);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.08s;
  user-select: none;
  position: relative;
}
.key.space-key { width: 200px; border-radius: 7px; }

.key.next-key {
  background: var(--accent);
  color: #0f0f0f;
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(226,185,111,0.25);
  animation: key-pulse 1.2s ease-in-out infinite;
}

@keyframes key-pulse {
  0%,100% { box-shadow: 0 0 8px rgba(226,185,111,0.2); }
  50% { box-shadow: 0 0 18px rgba(226,185,111,0.5); }
}

.key.pressed {
  background: var(--muted);
  transform: scale(0.92);
  border-color: var(--sub);
}

.key.wrong-press {
  background: rgba(235,87,87,0.2);
  border-color: var(--wrong);
  color: var(--wrong);
}

/* Show keyboard toggle */
.show-kb-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--sub);
  font-size: 0.76rem;
  font-family: var(--font-mono);
  padding: 0.3rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  display: none;
}
.show-kb-btn:hover { color: var(--text); border-color: var(--sub); }

.theme-picker {
  position: relative;
}

.theme-toggle-btn {
  font-size: 0.78rem;
  padding: 0.35rem 0.85rem;
}

.theme-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-width: 140px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
/* --- Theme button----- */
.theme-dropdown.open { display: block; }

.theme-dropdown button {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  background: none;
  border: none;
  color: var(--sub);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.theme-dropdown button:hover { background: var(--muted); color: var(--text); }
.theme-dropdown button.active { color: var(--accent); font-weight: 600; }


/* Result charts */
.result-charts {
  display: flex;
  gap: 1.5rem;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.chart-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.chart-label {
  font-size: 0.7rem;
  color: var(--sub);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
  main { padding: 1.5rem 1rem 4rem; gap: 1.4rem; }

  .nav-links { display: none; }

  .typing-area { padding: 1.2rem; }
  .paragraph-box { font-size: 0.95rem; line-height: 1.9; }

  .keyboard-wrap { display: none; }
  .keyboard-wrap.hidden { display: none !important; }

  .show-kb-btn { display: inline-flex; }

  .key { width: 32px; height: 36px; font-size: 0.62rem; }
  .key.space-key { width: 140px; }
  .kb-row { gap: 0.25rem; }
  .keyboard { padding: 0.8rem 0.6rem; gap: 0.32rem; }
}
