* { box-sizing: border-box; }
body { margin: 0; color: #e2e8f0; font-family: 'Nunito', sans-serif; background: #0c0726; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .42; }
button:active:not(:disabled) { transform: scale(.96); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #FFE66D; outline-offset: 4px; }
button, a { transition: background .15s, transform .15s; }
.app { min-height: 100dvh; background: linear-gradient(150deg,#0c0726 0%,#170e42 35%,#251660 65%,#170e42 100%); padding: calc(18px + env(safe-area-inset-top,0px)) 16px calc(28px + env(safe-area-inset-bottom,0px)); position: relative; overflow: hidden; }
.content { width: 100%; max-width: 500px; margin: 0 auto; position: relative; z-index: 1; }
.menu { max-width: 570px; }
.back { color: #c4b5fd; text-decoration: none; font-weight: 700; font-size: 14px; padding: 8px 0; display: inline-block; }
.hero { text-align: center; margin: 14px 0 24px; }
h1 { font-family: 'Fredoka',sans-serif; font-size: clamp(36px,8vw,52px); line-height: 1.12; margin: 8px 0; background: linear-gradient(135deg,#FFE66D,#FF6B6B,#A78BFA,#4ECDC4); background-clip: text; -webkit-background-clip: text; color: transparent; }
h2 { font: 600 24px 'Fredoka',sans-serif; margin: 0 0 10px; }
p { margin: 8px 0; line-height: 1.45; }
.muted { color: #c4b5fd; }
.small { font-size: 13px; }
.panel { background: linear-gradient(150deg,rgba(255,255,255,.06),rgba(255,255,255,.015)); border: 2px solid rgba(167,139,250,.2); border-radius: 26px; padding: 22px; box-shadow: 0 14px 44px rgba(0,0,0,.18); }
.settings { margin-bottom: 16px; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { font: 600 21px 'Fredoka',sans-serif; padding: 0; margin-bottom: 5px; }
.setting-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.setting-heading h2 { font-size: 21px; margin: 0; }
.tables { display: grid; grid-template-columns: repeat(5,1fr); gap: 10px; margin-top: 16px; }
.table-button { color: #ddd6fe; border: 2px solid rgba(167,139,250,.25); background: rgba(167,139,250,.07); border-radius: 16px; min-height: 54px; font: 600 24px 'Fredoka',sans-serif; }
.table-button[aria-pressed=true] { color: #fff; border-color: #4ECDC4; background: linear-gradient(135deg,rgba(78,205,196,.28),rgba(59,130,246,.2)); box-shadow: 0 0 14px rgba(78,205,196,.1); }
.all-button { min-width: 68px; font-size: 17px; min-height: 42px; }
.difficulties { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin-top: 14px; }
.difficulty { background: rgba(167,139,250,.06); border: 2px solid rgba(167,139,250,.2); border-radius: 18px; color: #e2e8f0; text-align: center; padding: 14px 8px; }
.difficulty[aria-pressed=true] { border-color: #a78bfa; background: rgba(167,139,250,.18); }
.difficulty strong { display: block; font: 600 20px 'Fredoka',sans-serif; }
.difficulty-icon { display: block; font-size: 28px; margin-bottom: 5px; }
.primary { display: block; width: 100%; background: linear-gradient(135deg,#4ECDC4,#3B82F6); color: white; border: 0; border-radius: 18px; min-height: 56px; padding: 14px 20px; font: 600 22px 'Fredoka',sans-serif; box-shadow: 0 6px 24px rgba(78,205,196,.2); }
.primary:disabled { background: rgba(255,255,255,.1); box-shadow: none; }
.secondary { background: rgba(167,139,250,.08); color: #c4b5fd; border: 1px solid rgba(167,139,250,.25); border-radius: 12px; padding: 9px 13px; font: 500 15px 'Fredoka',sans-serif; min-height: 40px; }
.warm { color: #FDBA74; background: rgba(251,146,60,.08); border-color: rgba(251,146,60,.25); }
.center { text-align: center; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.difficulty-control { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.mode-select { color: #e2e8f0; background: #251660; border: 1px solid rgba(167,139,250,.35); border-radius: 12px; padding: 8px; min-height: 40px; font: 500 14px 'Fredoka',sans-serif; cursor: pointer; }
.queued-difficulty { font-size: 11px; color: #FFE66D; }
.journey { padding: 14px 16px; margin-bottom: 12px; border-color: rgba(78,205,196,.3); }
.journey-heading { display: flex; gap: 10px; align-items: center; justify-content: space-between; font-family: 'Fredoka',sans-serif; font-size: 17px; }
.journey-heading strong { color: #FFE66D; font-weight: 500; white-space: nowrap; }
.progress-track { margin-top: 10px; background: rgba(255,255,255,.1); height: 12px; border-radius: 20px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg,#4ECDC4,#a78bfa); border-radius: inherit; transition: width .45s ease; }
.next-badge { color: #ddd6fe; font-size: 13px; margin: 8px 0 0; }
.scorebar { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.score { background: rgba(167,139,250,.1); border: 1px solid rgba(167,139,250,.25); border-radius: 40px; padding: 5px 12px; font: 500 15px 'Fredoka',sans-serif; color: #c4b5fd; }
.score.correct { color: #6ee7b7; background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.2); }
.score.wrong { color: #FDA4AF; background: rgba(251,113,133,.1); border-color: rgba(251,113,133,.2); }
.score.streak { color: #FDBA74; }
.score[title] { cursor: help; }
.score-help { margin: 0 0 8px; }
.trophies { text-align: center; font-size: 25px; min-height: 0; display: flex; justify-content: center; gap: 7px; flex-wrap: wrap; margin-bottom: 6px; }
.problem-card { padding: 20px; animation: cardIn .35s ease; }
.equation { display: flex; align-items: center; justify-content: center; gap: clamp(6px,2vw,16px); font: 700 clamp(32px,7vw,52px) 'Fredoka',sans-serif; margin: 0 0 18px; white-space: nowrap; }
.equation .operator { color: #a78bfa; font-size: .75em; }
.equation .unknown { color: #FFE66D; background: rgba(255,230,100,.07); border: 2px dashed rgba(255,230,100,.3); border-radius: 14px; min-width: 52px; padding: 3px 9px; text-align: center; }
.equation .revealed { color: #6ee7b7; border-style: solid; }
.hint { background: rgba(251,146,60,.06); border: 1px solid rgba(251,146,60,.22); border-radius: 18px; padding: 14px 10px; margin-bottom: 16px; text-align: center; }
.hint-title { color: #FDBA74; font: 500 16px 'Fredoka',sans-serif; margin: 0 0 10px; }
.hint .equation { font-size: clamp(25px,6vw,34px); margin-bottom: 8px; }
.hint .unknown { min-width: 39px; border-radius: 10px; padding: 2px 7px; }
.choices { display: flex; gap: 10px; justify-content: center; margin: 12px 0; }
.choice { min-height: 54px; min-width: 62px; padding: 6px 12px; font: 600 27px 'Fredoka',sans-serif; border: 2px solid rgba(167,139,250,.3); border-radius: 15px; background: rgba(167,139,250,.14); color: #e2e8f0; }
.answer-input { display: block; width: 180px; max-width: 100%; height: 64px; margin: 0 auto 18px; color: #29134b; caret-color: #29134b; background: #fff8d6; border: 3px solid #FBBF24; border-radius: 18px; text-align: center; font: 600 38px 'Fredoka',sans-serif; box-shadow: 0 4px 18px rgba(255,230,109,.18); }
.answer-input:focus { outline: none; border-color: #FFE66D; box-shadow: 0 0 0 4px rgba(255,230,109,.24), 0 0 28px rgba(255,230,109,.3); }
.answer-input::placeholder { color: #6d5590; opacity: .65; }
.answer-input:disabled { opacity: .7; box-shadow: none; }
.answer-row { display: flex; gap: 12px; align-items: stretch; max-width: 360px; margin: 0 auto 18px; }
.answer-row .answer-input { width: 0; min-width: 0; flex: 1; margin: 0; }
.answer-row .primary { width: auto; min-width: 108px; min-height: 64px; padding: 10px 14px; font-size: 20px; }
.pad { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 8px; }
.pad button { min-width: 0; height: 52px; font: 600 26px 'Fredoka',sans-serif; border: 2px solid rgba(167,139,250,.2); border-radius: 14px; background: linear-gradient(145deg,rgba(167,139,250,.18),rgba(167,139,250,.06)); color: #e2e8f0; }
.pad .delete-key { grid-column: span 2; color: #FDA4AF; background: rgba(251,113,133,.1); border-color: rgba(251,113,133,.25); }
.hint-button { margin-top: 12px; }
.feedback { text-align: center; font: 600 22px 'Fredoka',sans-serif; margin-top: 15px; color: #6ee7b7; }
.feedback.wrong { color: #FDA4AF; font-size: 19px; }
.feedback.reveal { color: #FDE68A; }
.feedback p { font: 500 13px 'Nunito',sans-serif; margin: 5px 0 0; }
.skip { display: block; margin: 12px auto 0; padding: 10px 20px; border: none; background: none; color: #c4b5fd; font-size: 14px; }
.recap { text-align: center; padding-top: 30px; }
.destination { font-size: 74px; animation: popIn .5s ease; margin: 12px 0; }
.mission-label { text-transform: uppercase; letter-spacing: 2px; color: #4ECDC4; font-size: 12px; font-weight: 800; }
.recap h1 { font-size: clamp(32px,7vw,44px); }
.recap-stats { display: flex; gap: 12px; justify-content: center; margin: 22px 0; }
.recap-stat { flex: 1; background: rgba(167,139,250,.07); border-radius: 18px; padding: 14px 7px; }
.recap-stat strong { display: block; font: 600 30px 'Fredoka',sans-serif; color: #FFE66D; }
.recap-stat span { font-size: 12px; color: #ddd6fe; }
.route { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 22px 0; }
.route span { font-size: 26px; background: rgba(167,139,250,.1); border: 1px solid rgba(167,139,250,.2); border-radius: 14px; padding: 8px; }
.recap .primary { margin: 16px 0 12px; }
.earned { background: rgba(255,230,100,.07); border: 1px solid rgba(255,230,100,.24); padding: 14px; border-radius: 18px; margin: 12px 0; color: #FFE66D; }
.sparkle { position: absolute; pointer-events: none; opacity: .1; animation: float 5s ease-in-out infinite; }
@keyframes popIn { 0% { transform: scale(.3) rotate(-8deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes bounceY { from { transform: translateY(0); } to { transform: translateY(-10px); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes cardIn { from { transform: scale(.95) translateY(8px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
@media (max-width: 360px) { .app { padding-left: 10px; padding-right: 10px; } .panel { padding: 16px; } .difficulty { padding: 12px 4px; } .difficulty strong { font-size: 18px; } .journey-heading { font-size: 15px; } .equation { font-size: 31px; gap: 6px; } .score { padding: 5px 9px; } }
@media (pointer: coarse) {
  .secondary, .mode-select, .all-button, .skip, .score, .back { min-height: 48px; }
  .mode-select { font-size: 16px; }
  .back { display: inline-flex; align-items: center; }
}
@media (pointer: coarse) and (max-width: 430px) {
  .app { padding-left: 8px; padding-right: 8px; }
  .problem-card { padding: 16px 8px; }
  .pad { gap: 4px; }
  .pad button { height: 56px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
