:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1d212a;
  --text: #e9ebf0;
  --muted: #8a90a0;
  --accent: #5b8cff;
  --good: #35c26a;
  --bad: #e5484d;
  --border: #2a2f3a;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-start {
  background: var(--accent);
  color: white;
}

.btn-start.is-playing {
  background: var(--bad);
}

.timer-select {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.timer-select select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 14px;
}

.score-box {
  display: flex;
  gap: 14px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.score-box b {
  color: var(--text);
  font-size: 16px;
}

/* ---------- footer ---------- */

.app-footer {
  padding: 10px 20px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

#sparkline {
  display: block;
  width: 100%;
  height: 48px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* ---------- main layout ---------- */

.app-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 40px 20px;
}

.game-panel {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.timer-bar-wrap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--panel-2);
}

.timer-bar {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transition: width 0.1s linear, background 0.2s;
}

.timer-bar.is-low {
  background: var(--bad);
}

.timer-num {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 18px;
  min-height: 20px;
}

.question {
  font-size: 46px;
  font-weight: 700;
  line-height: 1.25;
}

.feedback {
  margin-top: 22px;
  font-size: 18px;
  min-height: 26px;
  font-weight: 600;
}

.feedback.correct {
  color: var(--good);
}

.feedback.wrong {
  color: var(--bad);
}

.answers-grid {
  margin-top: 32px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
}

.answer-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 22px 14px;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  line-height: 1.3;
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.freeform-row {
  margin-top: 32px;
  display: flex;
  gap: 12px;
  width: 100%;
}

.freeform-input {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 20px;
  font-family: inherit;
}

.freeform-input.is-correct {
  border-color: var(--good);
}

.freeform-input.is-wrong {
  border-color: var(--bad);
}

.btn-submit {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}

.answer-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.answer-btn:disabled {
  cursor: default;
}

.answer-btn.is-correct {
  background: var(--good);
  border-color: var(--good);
  color: #08210f;
}

.answer-btn.is-wrong {
  background: var(--bad);
  border-color: var(--bad);
  color: #2a0708;
}
