/* ============================================================================
   ΣΤΥΛ  —  «Μαθηματικά Δ΄ Δημοτικού»
   Χαρούμενη, καθαρή, φιλική για παιδιά αισθητική. Responsive (tablet & PC).
   Χρησιμοποιεί system fonts με πλήρη ελληνική υποστήριξη (δουλεύει offline).
   ========================================================================== */

:root {
  /* Κοινή παλέτα με τη Γλώσσα/Αγγλικά (περγαμηνή/μελάνι) — ίδια ονόματα μεταβλητών */
  --bg1: #fffdf6;
  --bg2: #fdeccd;
  --card: #fffdf8;
  --ink: #1f2a44;
  --ink-soft: #41507a;
  --primary: #d9694a;
  --primary-d: #b8543a;
  --accent: #0f7d7d;
  --good: #5fa34a;
  --good-d: #3f7e2e;
  --bad: #d9534f;
  --gold: #e8a838;
  --shadow: 0 8px 22px rgba(31, 42, 68, .16);
  --radius: 18px;
  --font: "Baloo 2","Quicksand","Segoe UI","Helvetica Neue",-apple-system,
          "Noto Sans Greek","DejaVu Sans",system-ui,sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, #fffdf6 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #fdeccd 0%, transparent 55%),
    #fff8ec;
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app { max-width: 880px; margin: 0 auto; padding: 14px; min-height: 100vh; }

/* ---------- Γενικά κουμπιά ---------- */
.btn {
  font-family: var(--font);
  font-size: 1.15rem;
  font-weight: 700;
  border: none;
  border-radius: 16px;
  padding: 14px 20px;
  background: #f3ece0;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .12);
  transition: transform .08s, box-shadow .08s, filter .1s;
  user-select: none;
}
.btn:hover { filter: brightness(1.03); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .12); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-big { font-size: 1.4rem; padding: 18px 28px; width: 100%; }
.btn-hint { background: var(--gold); }

.icon-btn {
  font-size: 1.3rem; background: rgba(255, 255, 255, .85); border: none;
  width: 46px; height: 46px; border-radius: 14px; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .12);
}
.icon-btn:active { transform: translateY(2px); }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}

.screen { animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.mt { margin-top: 22px; }
.muted { color: var(--ink-soft); font-style: italic; }

/* ---------- Οθόνη έναρξης ---------- */
.start-screen { text-align: center; padding-top: 18px; color: var(--ink); }
.logo { font-size: 4.2rem; animation: pop .6s ease; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
.start-screen h1 { font-size: 2.4rem; line-height: 1.05; margin-bottom: 4px; }
.start-screen h1 small { font-size: 1.3rem; font-weight: 600; opacity: .95; }
.tag { font-size: 1.1rem; margin-bottom: 18px; opacity: .95; }
.start-card { text-align: left; max-width: 460px; margin: 0 auto; }
.field-label { display: block; font-weight: 700; color: var(--ink); margin: 12px 0 8px; }
.name-input {
  width: 100%; font-family: var(--font); font-size: 1.3rem; padding: 14px 16px;
  border: 3px solid #e7d9bd; border-radius: 14px; outline: none;
}
.name-input:focus { border-color: var(--accent); }
.name-input.shake { animation: shake .4s; border-color: var(--bad); }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px)} 75%{transform:translateX(7px)} }

.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 18px; }
.avatar-pick {
  font-size: 1.8rem; aspect-ratio: 1; border: 3px solid #e7d9bd; border-radius: 14px;
  background: #fffdf6; cursor: pointer; transition: transform .1s;
}
.avatar-pick:hover { transform: scale(1.08); }
.avatar-pick.sel { border-color: var(--primary); background: #fbe7df; transform: scale(1.08); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: rgba(255, 255, 255, .92); border-radius: 18px; padding: 8px 12px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.topbar.slim { padding: 6px 10px; }
.player { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.player-av { font-size: 1.6rem; }
.player-name { font-size: 1.1rem; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.coins { background: #fff7e0; padding: 8px 12px; border-radius: 12px; font-weight: 700; white-space: nowrap; }
.counter { font-weight: 800; font-size: 1.2rem; background:#f3ece0; padding:6px 12px; border-radius:12px; }
.timer { font-weight: 800; font-size: 1.2rem; background:#ffe3e3; padding:6px 12px; border-radius:12px; }
.combo { font-weight: 800; background:#f0f0f0; padding:6px 12px; border-radius:12px; transition: all .2s; }
.combo.hot { background: var(--gold); transform: scale(1.1); }

/* ---------- Μενού αποστολών ---------- */
.menu-screen h2, .setup-screen h2 { color: var(--ink); margin-bottom: 12px; }
.mission-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.mission-card {
  background: var(--card); border: none; border-radius: 18px; padding: 16px 10px;
  cursor: pointer; box-shadow: var(--shadow); transition: transform .12s;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.mission-card:hover { transform: translateY(-4px); }
.mission-card:active { transform: translateY(0); }
.mission-emoji { font-size: 2.4rem; }
.mission-title { font-weight: 700; font-size: .95rem; line-height: 1.15; text-align: center; min-height: 2.3em; display:flex; align-items:center; }
.mission-meta { display: flex; gap: 8px; align-items: center; font-size: .9rem; color: var(--ink-soft); }
.badge-mini { font-size: 1.1rem; }

.badges-bar {
  margin-top: 18px; background: rgba(255,255,255,.92); border-radius: 16px; padding: 12px 16px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; box-shadow: var(--shadow);
}
.badges-label { font-weight: 800; }
.badge-chip { background: #fff3cf; border:2px solid var(--gold); border-radius: 999px; padding: 4px 12px; font-weight:700; font-size:.9rem; }

/* ---------- Setup δυσκολίας ---------- */
.level-row, .special-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.special-row { grid-template-columns: repeat(2, 1fr); }
.level-btn { background: #fff; font-size: 1.3rem; padding: 22px 10px; line-height: 1.4; }
.level-btn[data-level="easy"]   { border-bottom: 6px solid var(--good); }
.level-btn[data-level="medium"] { border-bottom: 6px solid var(--accent); }
.level-btn[data-level="hard"]   { border-bottom: 6px solid var(--bad); }
.btn-special { background: #fff; padding: 20px 14px; line-height: 1.4; }
.btn-special small { font-weight: 600; color: var(--ink-soft); font-size: .8rem; }

/* ---------- Ράβδος προόδου ---------- */
.progress { height: 14px; background: rgba(31,42,68,.08); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--good), var(--accent)); transition: width .4s; border-radius: 999px; }

/* ---------- Άσκηση ---------- */
.play-screen { display: flex; flex-direction: column; gap: 14px; }
.q-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; position: relative; }
.boss-tag { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--bad); color:#fff; font-weight:800; padding: 4px 16px; border-radius: 999px; font-size:.9rem; box-shadow: var(--shadow); }
.prompt { font-size: 1.3rem; font-weight: 600; line-height: 1.5; text-align: center; }
.big-number { display: inline-block; font-size: 2.1rem; font-weight: 800; letter-spacing: 1px; margin-top: 8px; color: var(--primary-d); }
.hl-digit { background: var(--gold); border-radius: 6px; padding: 0 4px; color: var(--ink); }
.visual { display: flex; justify-content: center; margin: 16px 0; }
.fig { max-width: 100%; height: auto; }
.frac-pair { display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* εισαγωγή */
.input-area { margin-top: 18px; }
.num-display {
  width: 100%; font-family: var(--font); font-size: 2rem; font-weight: 800; text-align: center;
  border: 3px solid #e7d9bd; border-radius: 14px; padding: 12px; background: #fffdf6; color: var(--ink);
}
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; max-width: 360px; margin-left:auto; margin-right:auto; }
.key {
  font-family: var(--font); font-size: 1.6rem; font-weight: 800; padding: 16px 0;
  border: none; border-radius: 14px; background: #f3ece0; cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.12);
}
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.12); }
.key-back { background: #ffe3e3; }

.frac-input { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 200px; margin: 0 auto; }
.frac-box { width: 160px; }
.frac-box.active { border-color: var(--primary); background: #fbe7df; }
.frac-bar { width: 160px; height: 5px; background: var(--ink); border-radius: 3px; }

.two-field { display: flex; gap: 16px; justify-content: center; }
.tf-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tf-col label { font-weight: 700; color: var(--ink-soft); }
.tf-box { width: 130px; }
.tf-box.active { border-color: var(--primary); background: #fbe7df; }

.choices { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.choice-btn { min-width: 110px; font-size: 1.5rem; padding: 18px 22px; background: #f3ece0; }
.choice-btn.sel { background: var(--accent); color: #fff; }

.actions { display: flex; gap: 12px; }
.actions .btn { flex: 1; }
.btn-hint { flex: 0 0 auto; }

/* ---------- Feedback & λύση ---------- */
.feedback { margin-top: 14px; }
.feedback:empty { display: none; }
.result-line { font-size: 1.2rem; font-weight: 700; text-align: center; padding: 10px; border-radius: 12px; }
.feedback.correct .result-line { background: #d8fff2; color: var(--good-d); }
.feedback.wrong .result-line { background: #ffe1e8; color: var(--bad); }
.plus { color: var(--good-d); }
.combo-flash { display: inline-block; margin-left: 8px; color: var(--primary-d); animation: pop .4s; }
.hint-box { background: #fff7e0; border: 2px dashed var(--gold); border-radius: 12px; padding: 12px; font-weight: 600; }
.solution { margin-top: 12px; background: #fbf4e6; border-radius: 12px; padding: 12px 16px; }
.sol-title { font-weight: 800; margin-bottom: 6px; }
.solution ol { margin-left: 20px; line-height: 1.6; }
.solution li { margin-bottom: 4px; }

.flash-ok { animation: flashOk .5s; }
.flash-no { animation: flashNo .5s; }
@keyframes flashOk { 0% { box-shadow: 0 0 0 0 rgba(6,214,160,.6); } 100% { box-shadow: var(--shadow); } }
@keyframes flashNo { 0% { box-shadow: 0 0 0 0 rgba(239,71,111,.6); } 100% { box-shadow: var(--shadow); } }

/* ---------- Αποτελέσματα ---------- */
.result-screen { text-align: center; color: var(--ink); padding-top: 20px; }
.result-emoji { font-size: 5rem; }
.result-emoji.bounce { animation: bounce 1s ease infinite; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-16px)} }
.result-screen h1 { font-size: 2rem; margin-bottom: 14px; }
.badge-won { background: var(--gold); color: var(--ink); border-radius: 16px; padding: 14px; font-size: 1.1rem; margin: 0 auto 16px; max-width: 360px; box-shadow: var(--shadow); animation: pop .6s; }
.result-card { max-width: 420px; margin: 0 auto 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: #fbf4e6; border-radius: 12px; padding: 12px; color: var(--ink); }
.stat span { display: block; font-size: .85rem; color: var(--ink-soft); }
.stat b { font-size: 1.5rem; }
.result-actions { display: flex; gap: 12px; justify-content: center; max-width: 420px; margin: 0 auto; }
.result-actions .btn { flex: 1; }

/* ---------- Κομφετί ---------- */
.confetti-wrap { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti-wrap i {
  position: absolute; top: -20px; width: 11px; height: 16px; border-radius: 3px;
  animation: fall 2.4s linear forwards;
}
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .85; } }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .mission-grid { grid-template-columns: repeat(2, 1fr); }
  .mission-title { font-size: 1rem; }
  .start-screen h1 { font-size: 2rem; }
  .prompt { font-size: 1.15rem; }
  .big-number { font-size: 1.8rem; }
}
@media (max-width: 420px) {
  .level-row { grid-template-columns: 1fr; }
  .result-card { grid-template-columns: 1fr; }
  .avatar-grid { grid-template-columns: repeat(4, 1fr); }
}
