:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --brand: #4f46e5;
  --brand-light: #818cf8;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  min-height: 100vh;
}

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

[hidden] { display: none !important; }

.brand {
  font-size: 28px;
  font-weight: 800;
  color: var(--brand-light);
  text-align: center;
  margin: 12px 0 28px;
  letter-spacing: 0.5px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label { font-size: 13px; color: var(--text-dim); }

.field input {
  background: var(--surface-2);
  border: none;
  border-radius: 10px;
  padding: 14px;
  color: var(--text);
  font-size: 16px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  padding: 14px;
  min-height: 48px;
  min-width: 48px;
}

.btn-primary {
  width: 100%;
  background: var(--brand);
  color: white;
}

.btn-primary:active { background: var(--brand-light); }

.btn-secondary {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--surface-2);
  width: 100%;
  margin-top: 10px;
}

.error-text {
  color: var(--danger);
  font-size: 14px;
  min-height: 20px;
  margin-top: 4px;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.profile-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.profile-type-badge {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.icon-btn {
  background: var(--surface);
  color: var(--text);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.ad-banner {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  text-decoration: none;
  color: var(--text);
}

.ad-banner img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
.ad-banner .ad-tag { font-size: 10px; color: var(--text-dim); text-transform: uppercase; }

/* ---- Kids mode: Zero-Text UI ---- */
.kids-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 24px;
}

.kids-tile {
  background: var(--surface);
  border-radius: 24px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  transition: transform 0.1s ease;
}

.kids-tile:active { transform: scale(0.94); }
.kids-tile.correct { background: var(--success); }
.kids-tile.wrong { background: var(--danger); }

.balloon-tile {
  background: linear-gradient(160deg, var(--brand-light), var(--brand));
  border-radius: 50%;
  width: 220px;
  height: 220px;
  margin: 40px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 84px;
}

.balloon-tile.popped { animation: pop 0.3s ease forwards; }

@keyframes pop {
  to { transform: scale(1.4); opacity: 0; }
}

.replay-audio-btn {
  display: block;
  margin: 20px auto 0;
  background: var(--surface);
  color: var(--text);
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 22px;
}

/* ---- Standard mode: chunks / bubble sentence ---- */
.context-clue {
  text-align: center;
  font-size: 56px;
  margin: 8px 0 4px;
}

.native-translation {
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.answer-row {
  min-height: 56px;
  background: var(--surface);
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  margin-bottom: 20px;
}

.bubble-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.word-bubble {
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 15px;
}

.word-bubble.used { opacity: 0.35; }

.feedback-banner {
  text-align: center;
  font-weight: 700;
  margin-top: 16px;
  min-height: 24px;
}

.feedback-banner.correct { color: var(--success); }
.feedback-banner.wrong { color: var(--danger); }

.progress-bar-track {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--brand-light);
  transition: width 0.3s ease;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
}

.pin-input {
  font-size: 28px;
  letter-spacing: 12px;
  text-align: center;
  width: 100%;
  background: var(--surface-2);
  border: none;
  border-radius: 10px;
  padding: 14px;
  color: var(--text);
  margin: 16px 0;
}

.offline-screen {
  max-width: 420px;
  margin: 80px auto;
  text-align: center;
  padding: 0 20px;
}

.stats-bar {
  display: flex;
  justify-content: center;
  gap: 20px;
  background: var(--surface);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 16px;
  font-weight: 700;
}

.lesson-map {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.lesson-node {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
}

.lesson-node.done {
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.15), var(--surface));
}

.lesson-node-icon {
  font-size: 28px;
}

.lesson-node-count {
  font-size: 12px;
  color: var(--text-dim);
}

.lang-picker {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.lang-chip {
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  min-height: auto;
}

.lang-chip.active { background: var(--brand); }
