:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

html, body {
  width: 600px;
  height: 600px;
  overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

.screen {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.screen.hidden,
.hidden {
  display: none !important;
}

.focusable {
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
  border: 2px solid transparent;
  cursor: pointer;
  outline: none;
}

.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* ===== Header ===== */
.header {
  margin-bottom: 20px;
  text-align: center;
}

.header h1 {
  font-size: 38px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-top: 6px;
  letter-spacing: 0.5px;
}

/* ===== Home stats ===== */
.home-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}

.stat-value {
  color: var(--accent);
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
}

/* ===== Menu ===== */
.menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}

.btn {
  width: 100%;
  min-height: 72px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  letter-spacing: 0.3px;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

/* ===== Game ===== */
#game {
  padding: 16px;
}

.game-header {
  height: 64px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-bottom: 12px;
}

.game-stat {
  text-align: center;
  flex: 1;
}

.game-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.game-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.phrase-container {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phrase {
  font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 22px;
  line-height: 1.5;
  text-align: center;
  word-wrap: break-word;
  letter-spacing: 0.5px;
}

.phrase .char {
  display: inline-block;
  padding: 2px 1px;
  border-radius: 3px;
  min-width: 14px;
  text-align: center;
}

.phrase .char.pending {
  color: var(--text-secondary);
}

.phrase .char.correct {
  color: var(--accent-secondary);
}

.phrase .char.wrong {
  color: var(--danger);
  background: rgba(255, 68, 102, 0.18);
}

.phrase .char.current {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 12px var(--focus-glow);
}

.keyboard {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  flex: 1;
}

.key {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  text-transform: uppercase;
  min-height: 44px;
}

.key.key-action {
  background: var(--bg-tertiary);
  color: var(--accent);
  font-size: 24px;
}

/* ===== Result ===== */
.result-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin-bottom: 16px;
}

.result-wpm-display {
  text-align: center;
}

.result-value {
  font-size: 104px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -2px;
}

.result-label {
  font-size: 18px;
  color: var(--text-secondary);
  letter-spacing: 4px;
  margin-top: 6px;
  text-transform: uppercase;
}

.result-row {
  display: flex;
  gap: 16px;
  width: 100%;
}

.result-mini {
  flex: 1;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.result-mini-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
}

.result-mini-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ===== How to ===== */
.how-content {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.how-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.how-icon {
  background: var(--bg-tertiary);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  min-width: 80px;
  text-align: center;
  font-family: 'Menlo', monospace;
}

.how-text {
  color: var(--text-primary);
  font-size: 16px;
}
