:root {
  --green: #16a34a;
  --white: #f8fafc;
  --red: #dc2626;
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #22c55e;
  --wrong: #ef4444;
  --locked: #334155;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(160deg, var(--bg), #1e1b4b);
  color: var(--text);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.screen { display: none; flex: 1; flex-direction: column; }
.screen.active { display: flex; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

.welcome-card {
  margin: auto 0;
  text-align: center;
}

.flag-bar {
  height: 8px;
  border-radius: 4px;
  margin-bottom: 24px;
  background: linear-gradient(90deg, var(--green) 0 33%, var(--white) 33% 66%, var(--red) 66% 100%);
}

.welcome-card h1 { margin: 0 0 8px; font-size: 1.8rem; }
.subtitle { color: var(--muted); margin-bottom: 28px; }

.btn {
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.btn-primary {
  background: var(--accent);
  color: #05230f;
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary:active:not(:disabled) { transform: scale(0.98); }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

#screen-map .topbar { justify-content: space-between; }
#screen-map h2 { margin: 0; }
.stars-total { color: #fbbf24; font-weight: 600; }

.level-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 70px;
}

.reset-footer {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  right: max(20px, calc((100vw - 480px) / 2 + 20px));
  z-index: 10;
}

.btn-secondary {
  background: var(--card-bg);
  border: 2px solid var(--wrong);
  color: var(--wrong);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  width: auto;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.btn-secondary:hover { background: rgba(239, 68, 68, 0.12); }

.level-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card-bg);
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.level-item:hover { border-color: var(--accent); }
.level-item.locked {
  cursor: not-allowed;
  opacity: 0.5;
}
.level-item.locked:hover { border-color: transparent; }

.level-emoji {
  font-size: 1.8rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--locked);
  border-radius: 50%;
  flex-shrink: 0;
}

.level-info { flex: 1; }
.level-info h3 { margin: 0 0 2px; font-size: 1.05rem; }
.level-info p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.level-stars { color: #fbbf24; font-size: 0.9rem; }

.progress-track {
  flex: 1;
  height: 10px;
  background: var(--locked);
  border-radius: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.hearts { font-size: 1.1rem; white-space: nowrap; }

.exercise-card { margin-top: 8px; text-align: center; }
.exercise-emoji { font-size: 3rem; margin-bottom: 8px; }
.exercise-prompt { font-size: 1.15rem; font-weight: 600; margin-bottom: 4px; min-height: 3rem; }
#exercise-hint { margin-bottom: 20px; }

.choice-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  padding: 14px;
  border-radius: 12px;
  border: 2px solid var(--locked);
  background: #263449;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  text-align: left;
}
.choice-btn:hover:not(:disabled) { border-color: var(--accent); }
.choice-btn.correct {
  border-color: var(--accent);
  background: rgba(34,197,94,0.2);
}
.choice-btn.wrong {
  border-color: var(--wrong);
  background: rgba(239,68,68,0.2);
}
.choice-btn:disabled { cursor: default; }

.type-area { display: none; flex-direction: column; gap: 10px; }
.type-area.active { display: flex; }
.type-area input {
  padding: 14px;
  border-radius: 12px;
  border: 2px solid var(--locked);
  background: #263449;
  color: var(--text);
  font-size: 1rem;
}
.type-area input:focus { outline: none; border-color: var(--accent); }
.hint { color: var(--muted); font-size: 0.85rem; min-height: 1.2em; }

.feedback {
  min-height: 1.4em;
  font-weight: 600;
  margin: 16px 0 8px;
}
.feedback.correct { color: var(--accent); }
.feedback.wrong { color: var(--wrong); }

.hidden { display: none !important; }

.results-card { margin: auto 0; text-align: center; }
.results-emoji { font-size: 3.5rem; margin-bottom: 8px; }
.results-score { color: var(--muted); margin-bottom: 12px; }
.results-stars { font-size: 2rem; margin-bottom: 24px; letter-spacing: 4px; }

.btn-skip {
  background: transparent;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 10px;
  padding: 6px;
}
.btn-skip:hover { color: var(--text); }

.exercise-badge {
  display: inline-block;
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}

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

.modal-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.modal-title { font-size: 1.2rem; font-weight: 700; margin: 0 0 8px; }
.modal-body { color: var(--muted); font-size: 0.95rem; margin: 0 0 20px; }
.modal-actions { display: flex; gap: 10px; }

.btn-danger {
  flex: 1;
  background: var(--wrong);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}
.btn-neutral {
  flex: 1;
  background: var(--locked);
  color: var(--text);
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}
