:root {
  --bg: #1B1A17;
  --surface: #242220;
  --surface-raised: #2C2A26;
  --border: #3A362F;
  --text: #EDE6D6;
  --text-dim: #A79E8C;
  --gold: #D4A73B;
  --gold-dim: #8C7431;
  --red: #9E2B25;
  --red-bright: #C1554A;
  --green: #6E9C5E;
  --ridge-line: #3A362F;
  --radius: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
}

h1, h2, h3, .brand {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 12px;
  max-width: 900px;
  margin: 0 auto;
  flex-wrap: wrap;
  gap: 12px;
}

.brand { font-size: 1.4rem; }
.brand-mark { color: var(--text); }
.brand-mark-accent { color: var(--gold); }

.topnav { display: flex; align-items: center; gap: 18px; font-size: 0.92rem; }
.topnav a { color: var(--text-dim); }
.topnav a.active, .topnav a:hover { color: var(--gold); }
.nav-points {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--gold);
  padding: 3px 10px;
  border-radius: var(--radius);
  font-size: 0.85rem;
}
.nav-logout { color: var(--text-dim); }

.ridge {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 28px;
}
.ridge svg { width: 100%; height: 36px; display: block; }

.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 28px 60px;
}

.flashes { margin-bottom: 20px; }
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 0.92rem;
  border-left: 3px solid var(--gold);
  background: var(--surface);
}
.flash-error { border-left-color: var(--red-bright); }
.flash-success { border-left-color: var(--green); }
.flash-info { border-left-color: var(--gold-dim); }

/* ---- Auth forms ---- */
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-top: 20px;
}
.auth-card h1 { margin-top: 0; font-size: 1.6rem; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}
textarea { resize: vertical; min-height: 70px; }

button, .btn {
  display: inline-block;
  background: var(--gold);
  color: #1B1A17;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover, .btn:hover { background: #e2ba50; text-decoration: none; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:disabled:hover { background: var(--gold); }
.btn-secondary {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-secondary:hover { color: var(--text); background: var(--surface-raised); }
.btn-danger { background: var(--red); color: var(--text); }
.btn-danger:hover { background: var(--red-bright); }

.auth-switch { margin-top: 16px; font-size: 0.9rem; color: var(--text-dim); }

/* ---- Practice card ---- */
.practice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  text-align: center;
}
.practice-eyebrow { color: var(--text-dim); font-size: 0.82rem; margin-bottom: 10px; }
.de-sentence {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.7rem;
  line-height: 1.3;
  margin: 6px 0 26px;
}
.hint-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 12px;
  margin-bottom: 14px;
  cursor: pointer;
}
.hint-toggle:hover { color: var(--text); border-color: var(--gold-dim); }
.hint-text {
  display: none;
  color: var(--text-dim);
  font-size: 0.95rem;
  font-style: italic;
  margin: -6px 0 20px;
}
.hint-text.show { display: block; }

.answer-form { display: flex; gap: 10px; margin-top: 4px; }

.prompt-controls { display: flex; gap: 8px; justify-content: center; margin-bottom: 4px; flex-wrap: wrap; }
.audio-toggle { color: var(--gold); border-color: var(--gold-dim); }

.sort-instructions { color: var(--text-dim); font-size: 0.85rem; margin: 22px 0 10px; }

.answer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  min-height: 46px;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 22px;
}
.chip {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 18px;
  font-family: inherit;
  font-size: 0.98rem;
  cursor: pointer;
}
.chip:hover { border-color: var(--gold-dim); }
.chip.used { opacity: 0.25; pointer-events: none; }
.chip-answer {
  background: rgba(212,167,59,0.14);
  border-color: var(--gold-dim);
  color: var(--gold);
}
.sort-controls { display: flex; gap: 10px; justify-content: center; }
.answer-form input { font-size: 1.05rem; text-align: center; }

.feedback { margin-top: 22px; padding: 16px; border-radius: var(--radius); display: none; }
.feedback.show { display: block; }
.feedback-correct { background: rgba(110,156,94,0.15); border: 1px solid var(--green); }
.feedback-close { background: rgba(212,167,59,0.15); border: 1px solid var(--gold-dim); }
.feedback-incorrect { background: rgba(158,43,37,0.15); border: 1px solid var(--red); }
.feedback-label { font-weight: 600; margin-bottom: 4px; }
.feedback-answer { color: var(--text-dim); font-size: 0.95rem; }
.feedback-answer strong { color: var(--text); }
.feedback-bonus { color: var(--text-dim); font-size: 0.88rem; margin-top: 6px; font-style: italic; }
.feedback-audio { margin-top: 12px; }
.feedback-audio audio { height: 32px; width: 100%; }
.feedback-meta { margin-top: 10px; font-size: 0.85rem; color: var(--text-dim); }

.next-btn { margin-top: 18px; display: none; }
.next-btn.show { display: inline-block; }

.no-cards {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

/* ---- Dashboard ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin: 24px 0 32px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-value {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.9rem;
  color: var(--gold);
}
.stat-label { font-size: 0.8rem; color: var(--text-dim); margin-top: 4px; }

.box-bars { margin-top: 20px; }
.box-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 0.85rem; }
.box-row-label { width: 70px; color: var(--text-dim); flex-shrink: 0; }
.box-row-track { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); height: 18px; overflow: hidden; }
.box-row-fill { height: 100%; background: var(--gold-dim); }
.box-row-count { width: 26px; text-align: right; color: var(--text-dim); }

/* ---- Admin tables ---- */
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--text-dim); font-weight: 500; font-size: 0.8rem; text-transform: none; }
td.actions { white-space: nowrap; }
td.actions form { display: inline; }
.page-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.tag { background: var(--surface-raised); border: 1px solid var(--border); padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; color: var(--text-dim); margin-left: 6px; }
.tag-warn { color: var(--gold); border-color: var(--gold-dim); }
.small-note { color: var(--text-dim); font-size: 0.85rem; margin-top: 6px; }

.translate-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 16px 0 20px;
  font-size: 0.92rem;
}

.checkbox-field label { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: 0.9rem; }
.checkbox-field input { width: auto; }

.audio-recorder {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  text-align: left;
}
.field-label-row { display: flex; align-items: center; margin-bottom: 10px; }
.field-label-row label { font-size: 0.85rem; color: var(--text-dim); }
.recorder-controls { display: flex; align-items: center; gap: 12px; }
#record-btn { color: var(--red-bright); border-color: var(--red-bright); }

/* ---- Games hub ---- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.game-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text);
}
.game-card:hover { border-color: var(--gold-dim); text-decoration: none; }
.game-card-title { font-family: 'Fraunces', Georgia, serif; font-size: 1.2rem; color: var(--gold); margin-bottom: 6px; }
.game-card-desc { color: var(--text-dim); font-size: 0.88rem; margin-bottom: 10px; }
.game-card-meta { font-size: 0.78rem; color: var(--text-dim); }

/* ---- Wördle ---- */
.wordle-board { display: flex; flex-direction: column; gap: 6px; align-items: center; margin: 20px 0; }
.wordle-row { display: flex; gap: 6px; }
.wordle-tile {
  width: 42px; height: 42px;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.2rem; font-weight: 600;
  border-radius: 3px;
  text-transform: uppercase;
}
.tile-correct { background: var(--green); border-color: var(--green); color: #12160f; }
.tile-present { background: var(--gold); border-color: var(--gold); color: #1B1A17; }
.tile-absent { background: var(--surface-raised); color: var(--text-dim); }
.wordle-input-row { display: flex; gap: 10px; justify-content: center; }
.wordle-input-row input { max-width: 240px; text-align: center; text-transform: uppercase; }

/* ---- Crossword ---- */
.crossword-wrap { overflow-x: auto; margin: 20px 0; }
.crossword-grid { border-collapse: collapse; margin: 0 auto; }
.crossword-grid td { padding: 0; border: none; }
.cw-block { width: 30px; height: 30px; background: transparent; }
.cw-cell { width: 30px; height: 30px; position: relative; }
.cw-input {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: center;
  text-transform: uppercase;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  padding: 0;
  border-radius: 0;
}
.cw-number {
  position: absolute; top: 1px; left: 2px;
  font-size: 0.55rem; color: var(--gold-dim);
  pointer-events: none;
}
.clue-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
  text-align: left;
}
.clue-columns h3 { font-size: 1rem; margin-bottom: 8px; }
.clue-list { list-style: none; padding: 0; margin: 0; font-size: 0.88rem; }
.clue-list li { padding: 4px 0; color: var(--text-dim); }
.clue-correct { color: var(--green) !important; }
.clue-incorrect { color: var(--red-bright) !important; }

/* ---- Crossclimb ---- */
.ladder { display: flex; flex-direction: column; gap: 6px; }
.ladder-rung {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.92rem;
  text-align: left;
  color: var(--text-dim);
}
.ladder-rung.filled {
  border-style: solid;
  border-color: var(--gold-dim);
  background: rgba(212,167,59,0.1);
  color: var(--text);
  cursor: pointer;
}

/* ---- Pinpoint ---- */
.pinpoint-list { text-align: left; padding-left: 22px; margin: 10px 0 20px; }
.pinpoint-list li { padding: 4px 0; font-size: 1.05rem; }

@media (max-width: 480px) {
  .topbar { padding: 16px 18px 8px; }
  .content { padding: 20px 18px 50px; }
  .de-sentence { font-size: 1.4rem; }
  .answer-form { flex-direction: column; }
}
