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

:root {
  --bg:          #EEF2F7;
  --surface:     #FFFFFF;
  --primary:     #2255CC;
  --primary-dk:  #1A44AA;
  --text:        #0F1923;
  --text-muted:  #5A6A7A;
  --text-light:  #9AAABB;
  --border:      #DDE4EE;
  --red:         #CC2222;
  --shadow-s:    0 1px 3px rgba(0,0,20,.07), 0 1px 2px rgba(0,0,20,.05);
  --shadow-m:    0 3px 10px rgba(0,0,20,.08), 0 1px 3px rgba(0,0,20,.05);
  --r:           14px;
  --r-sm:        9px;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Screens ─────────────────────────────────────────── */
.screen { min-height: 100vh; }

/* ── Container (lesson + feedback) ──────────────────── */
.container {
  max-width: 580px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

/* ── Page header ─────────────────────────────────────── */
.page-header { margin-bottom: 20px; }

.lesson-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 6px;
}

.page-header h1 {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 6px;
}

.subtitle {
  font-size: 15px;
  color: var(--text-muted);
}

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-s);
  border: 1px solid var(--border);
}

.card p {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 12px;
}
.card p:last-child { margin-bottom: 0; }

.card h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}

.tip {
  font-size: 13px !important;
  color: var(--text-muted) !important;
  font-style: italic;
}

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

/* ── Question list ───────────────────────────────────── */
.question-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.question-list li {
  padding: 11px 14px;
  background: #F4F7FB;
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 14px;
  font-style: italic;
  color: var(--text);
}

/* ── Intro card ──────────────────────────────────────── */
.card-intro, .card-scenario { border-color: #C8D6F0; background: #F6F9FF; }

.intro-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 6px;
}

.card-intro h2, .card-scenario h2 { margin-bottom: 10px; }
.card-intro p,  .card-scenario p  { font-size: 14px; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  padding: 15px 28px;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dk); }

.btn-block {
  width: 100%;
  border-radius: var(--r);
  margin-top: 6px;
}

.btn-end {
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
}
.btn-end:hover { background: var(--bg); }

/* ── Roleplay layout ─────────────────────────────────── */
.roleplay-wrap {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 580px;
  margin: 0 auto;
  position: relative; /* anchors the absolute overlays */
}

/* ── Chat header right-side group ───────────────────── */
.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.journey-tally {
  display: flex;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Stage bar (objective + timer) ──────────────────── */
.stage-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  background: #F6F9FF;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.stage-bar-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--primary);
  flex-shrink: 0;
}

.stage-objective-text {
  flex: 1;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-timer {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 36px;
  text-align: right;
}

.stage-timer.timer--warning { color: #b06000; }
.stage-timer.timer--danger  { color: var(--red); animation: pulse-timer 1s ease-in-out infinite; }

@keyframes pulse-timer {
  0%, 100% { opacity: 1; }
  50%       { opacity: .45; }
}

/* ── Stage overlays ──────────────────────────────────── */
.stage-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 25, 35, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}

.overlay-card {
  background: var(--surface);
  border-radius: var(--r);
  padding: 28px 24px 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-m);
}

.overlay-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  margin: 0 auto 14px;
}

.overlay-badge--pass { background: #d4edda; color: #2a8a3e; }
.overlay-badge--fail { background: #fde8e8; color: var(--red); }

.overlay-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.overlay-meta {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 8px;
}

.overlay-reason {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 20px;
}

.overlay-actions { display: flex; flex-direction: column; gap: 8px; }

/* ── Chat header ─────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.persona {
  display: flex;
  align-items: center;
  gap: 11px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #DDE8FF;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 800;
  flex-shrink: 0;
}

.persona-name  { font-weight: 700; font-size: 15px; }
.persona-role  { font-size: 12px; color: var(--text-muted); }

/* ── Transcript ──────────────────────────────────────── */
.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg);
}

.transcript-hint {
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  margin-top: 24px;
  font-style: italic;
}

/* Chat bubbles */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  gap: 3px;
}

.msg-you  { align-self: flex-end;  align-items: flex-end; }
.msg-dana { align-self: flex-start; align-items: flex-start; }

.msg-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 4px;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
}

.msg-you .msg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-dana .msg-bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-s);
}

/* ── Controls ────────────────────────────────────────── */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.status-text {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
  min-height: 20px;
  text-align: center;
}

/* Big mic button */
.speak-btn {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  transition: background .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 4px 14px rgba(34, 85, 204, .38);
}

.speak-btn:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 6px 20px rgba(34, 85, 204, .48);
}

.speak-btn:active:not(:disabled) { transform: scale(.93); }

.speak-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.speak-btn.listening {
  background: var(--red);
  box-shadow: 0 4px 14px rgba(204, 34, 34, .38);
}

.icon-mic  { width: 30px; height: 30px; }
.icon-stop { width: 22px; height: 22px; }

/* Pulse ring while listening */
.pulse-ring {
  position: absolute;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 2px solid rgba(204, 34, 34, .5);
  animation: ripple 1.4s ease-out infinite;
  pointer-events: none;
}

@keyframes ripple {
  0%   { transform: scale(1);   opacity: 1; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* ── Feedback screen ─────────────────────────────────── */
.center {
  text-align: center;
  padding: 32px 20px;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .75s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.feedback-body {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
}

/* ── Login screen ────────────────────────────────────── */
.screen-login {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrap {
  width: 100%;
  max-width: 360px;
  padding: 0 20px;
  text-align: center;
}

.login-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.login-form {
  text-align: left;
}

.login-input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  margin-bottom: 12px;
  transition: border-color .15s, box-shadow .15s;
}

.login-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34,85,204,.1);
}

.login-privacy {
  font-size: 12px;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 4px;
  margin-top: -4px;
}

.login-error {
  text-align: center;
  font-size: 14px;
  color: var(--red);
  margin-top: 10px;
}

/* ── Section label ───────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Character selector ──────────────────────────────── */
.character-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.char-loading {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  padding: 20px 0;
}

.character-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
  box-shadow: var(--shadow-s);
  transition: border-color .15s, box-shadow .15s, transform .1s;
}

.character-card:hover {
  border-color: var(--primary);
}

.character-card:active { transform: scale(.98); }

.character-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34,85,204,.12), var(--shadow-s);
}

.char-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #DDE8FF;
  color: var(--primary);
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.char-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.char-tagline {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.char-difficulty {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.diff-beginner     { color: #2a8a3e; }
.diff-intermediate { color: #b06a00; }
.diff-hard         { color: #c02020; }

/* ── Back link ───────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-bottom: 20px;
  font-family: inherit;
}
.back-link:hover { color: var(--primary-dk); }

/* ── Stage selection list ────────────────────────────── */
.stage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stage-list-loading {
  display: flex;
  justify-content: center;
  padding: 40px 0;
}

.stage-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
  box-shadow: var(--shadow-s);
  transition: border-color .15s, box-shadow .15s, transform .1s;
}

.stage-item:hover:not(:disabled) {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34,85,204,.08), var(--shadow-s);
}

.stage-item:active:not(:disabled) { transform: scale(.99); }

.stage-item:disabled {
  opacity: .45;
  cursor: default;
}

.stage-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stage-item--locked .stage-num,
.stage-item:disabled .stage-num {
  background: var(--text-light);
}

.stage-name {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.stage-cta {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  flex-shrink: 0;
}

.stage-item--locked .stage-cta,
.stage-item:disabled .stage-cta {
  color: var(--text-light);
}

/* ── Carousel overlay ────────────────────────────────── */
.overlay-card--carousel {
  padding: 20px 20px 18px;
}

.overlay-compact-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.overlay-badge-inline {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}

.overlay-title-inline {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

.feedback-carousel {
  overflow: hidden;
}

.carousel-track {
  display: flex;
  transition: transform 0.28s ease;
  will-change: transform;
}

.carousel-panel {
  min-width: 100%;
  box-sizing: border-box;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.panel-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}

.panel-label--pass    { color: #2a8a3e; }
.panel-label--improve { color: var(--primary); }

.panel-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  flex: 1;
}

.panel-text--loading {
  color: var(--text-light);
  font-style: italic;
}

.carousel-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 0 12px;
}

.carousel-arrow {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  line-height: 1;
  transition: border-color .15s, color .15s;
  flex-shrink: 0;
}
.carousel-arrow:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.carousel-arrow:disabled { opacity: .3; cursor: default; }

.carousel-dots { display: flex; gap: 7px; align-items: center; }

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  cursor: pointer;
  padding: 0;
  transition: background .2s, transform .2s;
}
.carousel-dot.active { background: var(--primary); transform: scale(1.25); }

/* ── Overlay stars ───────────────────────────────────── */
.overlay-stars {
  font-size: 32px;
  letter-spacing: 6px;
  margin: 4px 0 10px;
  line-height: 1;
}

.overlay-stars .star-filled { color: #f5a623; }
.overlay-stars .star-empty  { color: var(--border); }

/* ── Scorecard screen ────────────────────────────────── */
.scorecard-rank-card {
  background: var(--primary);
  border-radius: var(--r);
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 14px;
  color: #fff;
}

.sc-rank-emoji {
  font-size: 40px;
  margin-bottom: 8px;
  line-height: 1;
}

.sc-rank-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .02em;
  margin-bottom: 6px;
}

.sc-rank-score {
  font-size: 15px;
  opacity: .85;
  font-weight: 600;
}

.scorecard-breakdown {
  padding: 8px 20px;
}

.sc-stage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.sc-stage-row:last-child { border-bottom: none; }

.sc-stage-row--incomplete .sc-stage-name { color: var(--text-light); }

.sc-stage-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.sc-stage-stars {
  font-size: 18px;
  color: #f5a623;
  flex-shrink: 0;
  letter-spacing: 3px;
  line-height: 1;
}

.sc-star-empty { color: var(--border); }

/* ── Responsive tweaks ───────────────────────────────── */
@media (max-width: 400px) {
  .page-header h1 { font-size: 26px; }
  .speak-btn { width: 68px; height: 68px; }
  .pulse-ring { width: 68px; height: 68px; }
}
