/* ============================================================
   Design tokens — bảng màu "hộ chiếu / chứng chỉ": navy đậm + nhũ vàng
   ============================================================ */
:root {
  --ink: #0b121c;
  --ink-2: #0e1622;
  --surface: #141d29;
  --surface-raised: #1b2635;
  --surface-hover: #202c3d;
  --border: #263244;
  --border-soft: rgba(255,255,255,0.08);

  --text: #eef2f6;
  --text-muted: #93a2b3;
  --text-faint: #66748a;

  --gold: #c9a04e;
  --gold-strong: #ddb767;
  --gold-ink: #211705;

  --teal: #4fb3a9;
  --success: #4caf7d;
  --success-bg: rgba(76, 175, 125, 0.12);
  --danger: #d9695f;
  --danger-bg: rgba(217, 105, 95, 0.12);
  --info: #6b9bd1;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.45);
  --shadow-inset: inset 0 1px 0 rgba(255,255,255,0.06);
}

* { box-sizing: border-box; }

.hidden { display: none !important; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at top, #101a28 0%, var(--ink) 55%, #08101a 100%);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.icon-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, transform 0.1s ease;
}
.icon-btn:hover { background: var(--surface-hover); }
.icon-btn:active { transform: scale(0.94); }

.banner {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--gold);
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  text-align: center;
  flex: 1;
  margin: 0 10px;
  box-shadow: var(--shadow-inset);
}
.banner span { color: var(--text-muted); font-weight: 400; }

.topic-select {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text-muted);
}
.topic-select select {
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 14px;
}
.topic-select select option {
  background: var(--surface);
  color: var(--text);
}

.flags {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  width: fit-content;
  margin: 0 auto 20px auto;
  font-size: 22px;
}
.arrow { color: var(--gold); font-weight: bold; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  box-shadow: var(--shadow-md);
}

.meaning {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
}

.progress-track {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--gold), var(--teal));
  transition: width 1s linear;
}

.hint {
  font-size: 32px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 2px;
  min-height: 44px;
  font-family: 'Consolas', monospace;
}

.timer {
  font-size: 20px;
  font-weight: 700;
  color: var(--danger);
}

.due-banner {
  text-align: center;
  font-size: 12.5px;
  color: var(--gold);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  width: fit-content;
  margin: 0 auto 14px auto;
}

.type-row {
  display: flex;
  gap: 8px;
  margin: 14px 0 6px;
}
.type-row.hidden { display: none; }
.type-row input {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 16px;
}
.type-row input:focus {
  outline: none;
  border-color: var(--gold);
}
.type-row input:disabled { opacity: 0.6; }
.type-row button {
  background: var(--gold);
  color: var(--gold-ink);
  border: none;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.type-row button:hover { background: var(--gold-strong); }
.type-row button:disabled { opacity: 0.5; cursor: not-allowed; }

.type-feedback {
  text-align: center;
  font-weight: 700;
  font-size: 13.5px;
  min-height: 18px;
  margin-bottom: 4px;
}
.type-feedback.correct { color: var(--success); }
.type-feedback.wrong { color: var(--danger); }

.answer-box {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.answer-box.hidden { display: none; }

.answer-word-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

.answer-word {
  font-size: 26px;
  font-weight: 800;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.answer-phonetic {
  font-size: 14px;
  color: var(--teal);
  font-style: italic;
  margin-top: 2px;
  min-height: 18px;
}

.example-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}

.speak-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.speak-btn:hover { background: var(--surface-hover); }
.speak-btn:active { transform: scale(0.92); }
.speak-btn.small {
  width: 28px;
  height: 28px;
  font-size: 12px;
}
.speak-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.example-en {
  font-size: 16px;
}

.example-vi {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}

.pronounce-row {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  text-align: center;
}
.mic-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.mic-btn:hover { background: var(--surface-hover); border-color: var(--gold); }
.mic-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pronounce-result {
  margin-top: 10px;
  font-size: 13px;
  min-height: 18px;
  line-height: 1.5;
  color: var(--text-muted);
}
.pronounce-result.listening { color: var(--gold); }
.pronounce-result.great { color: var(--success); font-weight: 700; }
.pronounce-result.ok { color: var(--gold); font-weight: 700; }
.pronounce-result.poor { color: var(--danger); font-weight: 700; }

.controls {
  margin-top: auto;
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.score {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.next-btn {
  background: var(--gold);
  color: var(--gold-ink);
  border: none;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s ease, transform 0.1s ease;
}
.next-btn:hover { background: var(--gold-strong); }
.next-btn:active { transform: scale(0.97); }

.admin-link {
  display: block;
  text-align: center;
  color: var(--text-faint);
  text-decoration: none;
  font-size: 12px;
  margin-top: 16px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5,8,13,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: var(--radius-lg);
  width: 270px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.modal-content h3 {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
}
.modal-content input[type="number"],
.modal-content input[type="text"] {
  width: 100%;
  padding: 10px;
  margin: 10px 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 16px;
  text-align: center;
}
.modal-content select {
  width: 100%;
  padding: 10px;
  margin: 10px 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 14px;
  text-align: center;
}
.modal-content select option {
  background: var(--surface);
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-align: left;
}
.checkbox-row input {
  width: auto;
  margin: 0;
  accent-color: var(--gold);
}
.voice-hint {
  font-size: 11px;
  color: var(--text-faint);
  margin: -6px 0 8px;
  text-align: left;
}
input[type="range"] {
  width: 100%;
  margin: 8px 0 16px;
  accent-color: var(--gold);
}
.modal-actions {
  display: flex;
  gap: 10px;
}
.modal-actions button {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
}
#saveSettings { background: var(--gold); color: var(--gold-ink); }
#saveSettings:hover { background: var(--gold-strong); }
#closeSettings { background: var(--surface-raised); color: var(--text); border: 1px solid var(--border) !important; }
#closeSettings:hover { background: var(--surface-hover); }
