/* Italiano — Duolingo-inspired styling */

:root {
  --green: #58cc02;
  --green-dark: #46a302;
  --green-shadow: #58a700;
  --blue: #1cb0f6;
  --blue-shadow: #1899d6;
  --red: #ff4b4b;
  --red-shadow: #d33131;
  --yellow: #ffc800;
  --purple: #ce82ff;
  --bg: #ffffff;
  --card: #ffffff;
  --line: #e5e5e5;
  --text: #3c3c3c;
  --muted: #afafaf;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

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

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
}

.topbar .spacer { flex: 1; }

.stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 17px;
}

.stat.streak { color: #ff9600; }
.stat.hearts { color: var(--red); }
.stat.xp { color: var(--yellow); }

.progress-track {
  height: 16px;
  background: var(--line);
  border-radius: 8px;
  overflow: hidden;
  flex: 1;
  max-width: 220px;
  margin: 0 auto;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 8px;
  transition: width 0.3s ease;
  min-width: 0;
}

/* ---------- Buttons ---------- */

.btn {
  display: block;
  width: 100%;
  padding: 15px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--green);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--green-shadow);
  transition: transform 0.06s, box-shadow 0.06s;
  font-family: inherit;
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--green-shadow);
}

.btn:disabled {
  background: var(--line);
  color: var(--muted);
  box-shadow: 0 4px 0 #cfcfcf;
  cursor: default;
}

.btn:disabled:active {
  transform: none;
  box-shadow: 0 4px 0 #cfcfcf;
}

.btn.secondary {
  background: #fff;
  color: var(--blue);
  border: 2px solid var(--line);
  box-shadow: 0 4px 0 var(--line);
}

.btn.secondary:active { box-shadow: 0 0 0 var(--line); }

.btn.danger {
  background: var(--red);
  box-shadow: 0 4px 0 var(--red-shadow);
}

.btn.danger:active { box-shadow: 0 0 0 var(--red-shadow); }

.btn.small {
  width: auto;
  padding: 10px 16px;
  font-size: 14px;
}

/* ---------- Screens ---------- */

.screen {
  padding: 16px;
  flex: 1;
  animation: fadein 0.18s ease;
}

@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.15; }
h1 { font-size: 30px; font-weight: 900; }
h2 { font-size: 23px; font-weight: 800; }
h3 { font-size: 18px; font-weight: 800; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); font-weight: 600; }
.center { text-align: center; }

/* ---------- Home ---------- */

.hero {
  text-align: center;
  padding: 20px 0 8px;
}

.hero .flag { font-size: 72px; line-height: 1; }

.profile-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px 0;
  -webkit-overflow-scrolling: touch;
}

.profile-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: #fff;
  font-weight: 800;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.profile-chip.active {
  border-color: var(--green);
  background: #eaffd6;
}

.profile-chip .avatar { font-size: 20px; }

/* ---------- Unit path ---------- */

.unit {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  margin-bottom: 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 17px;
  color: var(--text);
  transition: transform 0.08s;
}

.unit:active { transform: scale(0.985); }

.unit .badge {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: #f7f7f7;
  display: grid;
  place-items: center;
  font-size: 28px;
}

.unit .body { flex: 1; min-width: 0; }

.unit .title {
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.unit .sub {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  margin-top: 2px;
}

.unit .pct {
  font-size: 13px;
  font-weight: 800;
  color: var(--green);
}

.unit.locked { opacity: 0.5; }

.unit .crown { font-size: 18px; }

.mini-track {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}

.mini-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
}

/* ---------- Quiz ---------- */

.prompt-label {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 14px;
}

.big-term {
  font-size: 32px;
  font-weight: 900;
  margin: 8px 0 4px;
  word-break: break-word;
}

.big-term .emoji-big { font-size: 44px; display: block; margin-bottom: 6px; }

.speak-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 2px solid var(--blue);
  background: #ddf4ff;
  color: var(--blue-shadow);
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  margin: 10px 0 4px;
  font-family: inherit;
}

.speak-btn:active { transform: scale(0.97); }

.choices { display: grid; gap: 10px; margin-top: 18px; }

.choice {
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--line);
  font-family: inherit;
}

.choice:active { transform: translateY(3px); box-shadow: none; }
.choice.correct { border-color: var(--green); background: #d7ffb8; box-shadow: 0 3px 0 var(--green-shadow); }
.choice.wrong { border-color: var(--red); background: #ffdfe0; box-shadow: 0 3px 0 var(--red-shadow); }
.choice.dim { opacity: 0.45; }

/* ---------- Word bank ---------- */

.answer-area {
  min-height: 84px;
  border-bottom: 2px solid var(--line);
  border-top: 2px solid var(--line);
  padding: 12px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  margin: 18px 0;
}

.bank { display: flex; flex-wrap: wrap; gap: 8px; }

.token {
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--line);
  font-family: inherit;
  color: var(--text);
}

.token:active { transform: translateY(3px); box-shadow: none; }
.token.used { opacity: 0.25; pointer-events: none; }

/* ---------- Typing ---------- */

input[type="text"].typebox {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font-size: 17px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  margin-top: 18px;
}

input[type="text"].typebox:focus {
  outline: none;
  border-color: var(--blue);
}

/* ---------- Feedback bar ---------- */

.feedback {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  background: #d7ffb8;
  border-top: 2px solid var(--line);
  z-index: 40;
  animation: slideup 0.2s ease;
}

.feedback.wrong { background: #ffdfe0; }

@keyframes slideup {
  from { transform: translateY(100%); }
  to { transform: none; }
}

.feedback .inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.feedback .verdict { flex: 1; }
.feedback .verdict .head {
  font-size: 20px;
  font-weight: 900;
  color: #46a302;
}
.feedback.wrong .verdict .head { color: var(--red-shadow); }
.feedback .verdict .detail { font-size: 15px; font-weight: 700; margin-top: 4px; }
.feedback .btn { width: auto; min-width: 130px; }

/* ---------- Results ---------- */

.results-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.result-card {
  border: 2px solid var(--yellow);
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center;
}

.result-card .val { font-size: 24px; font-weight: 900; color: var(--yellow); }
.result-card .lbl { font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--yellow); }

.result-card.green { border-color: var(--green); }
.result-card.green .val, .result-card.green .lbl { color: var(--green); }
.result-card.blue { border-color: var(--blue); }
.result-card.blue .val, .result-card.blue .lbl { color: var(--blue); }

/* ---------- Misc ---------- */

.row { display: flex; gap: 10px; align-items: center; }
.gap { height: 12px; }
.gap-lg { height: 24px; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.switch {
  width: 52px;
  height: 32px;
  border-radius: 999px;
  background: var(--line);
  border: none;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}

.switch.on { background: var(--green); }

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.switch.on::after { transform: translateX(20px); }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 90px;
  background: rgba(60,60,60,0.95);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  z-index: 60;
  animation: fadein 0.15s ease;
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131f24;
    --card: #1c2b32;
    --line: #37464f;
    --text: #f1f7fb;
    --muted: #8fa3ad;
  }
  .choice, .token, .profile-chip, .btn.secondary { background: var(--card); }
  .unit { background: var(--card); }
  .unit .badge { background: #26383f; }
  input[type="text"].typebox { background: var(--card); }
  .speak-btn { background: #10343f; }
  .choice.correct { background: #2b4a1d; }
  .choice.wrong { background: #4a2024; }
  .feedback { background: #2b4a1d; }
  .feedback.wrong { background: #4a2024; }
  .profile-chip.active { background: #26381a; }
  .btn:disabled { box-shadow: 0 4px 0 #2a3a41; }
}