/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* SkyDash-inspired palette */
  --indigo:      #4B49AC;
  --indigo-lt:   #E8E9FE;
  --indigo-dk:   #3C3AA0;
  --coral:       #F3797E;
  --coral-lt:    #FCDFE0;
  --green:       #34C38F;
  --green-lt:    #D6F5EC;
  --amber:       #F1B44C;
  --amber-lt:    #FDEFC3;
  --gray-50:     #F8F8FD;
  --gray-100:    #F0F0F7;
  --gray-200:    #E2E2EF;
  --gray-400:    #A9A9C8;
  --gray-600:    #6B6B8A;
  --text:        #2C2C54;
  --text-light:  #6B6B8A;
  --radius:      20px;
  --radius-sm:   12px;
  --shadow:      0 8px 40px rgba(75, 73, 172, 0.18);
  --shadow-sm:   0 2px 12px rgba(75, 73, 172, 0.10);
}

/* Vibrant SkyDash canvas gradient */
body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 40%, #A78BFA 70%, #60A5FA 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  color: var(--text);
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  width: 80vw;
  max-width: 900px;
  min-width: 0;
  animation: fadeIn 0.35s ease;
}

.screen.active {
  display: flex;
  justify-content: center;
}

@media (max-width: 768px) { .screen { width: 92vw; } }
@media (max-width: 480px) { .screen { width: 98vw; } body { padding: 8px; } }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== CARD ===== */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  overflow: hidden;
}

/* Card banner — gradient header strip used on welcome/login/end */
.card-banner {
  background: linear-gradient(135deg, var(--indigo) 0%, #6366F1 100%);
  padding: 32px 40px 28px;
  text-align: center;
  color: #fff;
  position: relative;
}

.card-body {
  padding: 32px 40px 36px;
}

@media (max-width: 768px) {
  .card-banner { padding: 24px 28px 20px; }
  .card-body   { padding: 24px 28px 28px; }
}
@media (max-width: 480px) {
  .card-banner { padding: 20px 16px 16px; }
  .card-body   { padding: 18px 16px 22px; }
}

/* ===== MASCOT & TITLE ===== */
.mascot {
  font-size: clamp(52px, 8vw, 72px);
  margin-bottom: 8px;
  animation: float 3s ease-in-out infinite;
  display: block;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

.title {
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: clamp(0.9rem, 1.5vw, 1.05rem);
  color: rgba(255,255,255,0.75);
  margin-top: 4px;
}

/* ===== WELCOME SCREEN ===== */
.welcome-card .card-body { text-align: center; }

.welcome-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.user-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

#user-greeting {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
}

.btn-logout {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-logout:hover { background: rgba(255,255,255,0.35); }

.difficulty-section { margin-bottom: 20px; }

.label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}

.difficulty-buttons { display: flex; gap: 12px; }

.diff-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 12px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Nunito', sans-serif;
}

.diff-btn:hover {
  border-color: var(--indigo);
  background: var(--indigo-lt);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.diff-btn.selected {
  border-color: var(--indigo);
  background: var(--indigo-lt);
  box-shadow: 0 0 0 3px rgba(75, 73, 172, 0.2);
}

@media (max-width: 480px) { .diff-btn { padding: 14px 8px; } }

.diff-icon { font-size: clamp(1.4rem, 2.5vw, 2rem); }
.diff-name { font-size: clamp(0.85rem, 1.5vw, 1rem); font-weight: 800; color: var(--indigo); }
.diff-desc { font-size: clamp(0.68rem, 1vw, 0.8rem); color: var(--gray-400); line-height: 1.3; }

/* ===== BUTTONS ===== */
.btn-primary {
  display: block;
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--indigo) 0%, #6366F1 100%);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s, box-shadow 0.2s;
  margin-top: 12px;
  box-shadow: 0 4px 14px rgba(75, 73, 172, 0.35);
  letter-spacing: 0.3px;
}

.btn-primary:hover  { opacity: 0.9; box-shadow: 0 6px 20px rgba(75, 73, 172, 0.45); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  display: block;
  width: 100%;
  padding: 12px 24px;
  background: transparent;
  color: var(--indigo);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid var(--indigo);
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  margin-top: 10px;
}

.btn-secondary:hover { background: var(--indigo-lt); }

.btn-back {
  background: none;
  border: none;
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  cursor: pointer;
  padding: 6px 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-back:hover { color: #fff; }

.btn-danger-small {
  background: none;
  border: 1px solid var(--coral);
  color: var(--coral);
  font-family: 'Nunito', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-danger-small:hover { background: var(--coral-lt); }

/* ===== GAME SCREEN ===== */
.game-card .card-body { padding: 24px 32px 28px; }

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

/* SkyDash-style colored stat boxes */
.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--indigo-lt);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  min-width: 80px;
}

.stat-label {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--indigo);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.stat-value {
  font-size: clamp(1.3rem, 2.5vw, 1.7rem);
  font-weight: 900;
  color: var(--indigo-dk);
  line-height: 1.1;
}

/* Progress dots */
.progress-dots { display: flex; gap: 8px; }

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gray-200);
  transition: background 0.3s, transform 0.3s;
}

.dot.correct { background: var(--green); transform: scale(1.2); }
.dot.wrong   { background: var(--coral); transform: scale(1.2); }
.dot.current { background: var(--amber); box-shadow: 0 0 0 3px rgba(241,180,76,0.35); }

/* Question area */
.question-area { text-align: center; margin-bottom: 24px; }

.q-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
}

/* Dark indigo equation card — SkyDash dark stat card style */
.equation {
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, var(--indigo-dk) 0%, #6366F1 100%);
  border-radius: var(--radius-sm);
  padding: 28px 20px;
  letter-spacing: 2px;
  margin-bottom: 10px;
  transition: background 0.3s;
  box-shadow: 0 4px 16px rgba(75, 73, 172, 0.3);
}

.find-x {
  font-size: 0.9rem;
  color: var(--gray-600);
}

/* Input area */
.input-area { margin-bottom: 16px; }

.input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 12px;
}

.input-label {
  font-size: clamp(1.3rem, 2vw, 1.6rem);
  font-weight: 900;
  color: var(--indigo);
}

.answer-input {
  width: clamp(110px, 14vw, 170px);
  height: clamp(54px, 7vw, 70px);
  font-family: 'Nunito', sans-serif;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  font-weight: 800;
  text-align: center;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  background: var(--gray-50);
  transition: border-color 0.2s, box-shadow 0.2s;
  -moz-appearance: textfield;
}

.answer-input::-webkit-inner-spin-button,
.answer-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.answer-input:focus {
  border-color: var(--indigo);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(75, 73, 172, 0.15);
}

.answer-input.correct-anim {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 195, 143, 0.3);
  animation: bounceInput 0.5s ease;
}

.answer-input.wrong-anim {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(243, 121, 126, 0.3);
  animation: shakeInput 0.4s ease;
}

@keyframes bounceInput {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.12); }
  60%  { transform: scale(0.96); }
  100% { transform: scale(1); }
}

@keyframes shakeInput {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-6px); }
  80%       { transform: translateX(6px); }
}

/* ===== FEEDBACK ===== */
.feedback {
  border-top: 2px solid var(--gray-100);
  padding-top: 16px;
  animation: fadeIn 0.25s ease;
}

.feedback.hidden { display: none; }

.feedback-correct,
.feedback-wrong {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.feedback-correct.hidden,
.feedback-wrong.hidden { display: none; }

.feedback-correct { background: var(--green-lt);  color: #0A6448; }
.feedback-wrong   { background: var(--coral-lt);  color: #9B2226; }

.feedback-icon { font-size: 1.3rem; }

/* Steps panel */
.steps-panel {
  background: var(--amber-lt);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 12px;
  border-left: 4px solid var(--amber);
}

.steps-panel.hidden { display: none; }

.steps-title {
  font-size: 0.78rem;
  font-weight: 800;
  color: #7A4F03;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}

.steps-list { padding-left: 18px; }
.steps-list li {
  font-size: 0.92rem;
  color: #6D4000;
  line-height: 1.7;
  font-weight: 600;
}

/* ===== END SCREEN ===== */
.end-card .card-banner { padding: 40px 40px 32px; }

.end-stars {
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: 8px;
  letter-spacing: 4px;
  animation: starPop 0.5s ease both;
  display: block;
}

@keyframes starPop {
  0%   { transform: scale(0.5); opacity: 0; }
  70%  { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.end-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 900;
  color: #fff;
}

/* SkyDash-style stat row — 3 colored mini-cards */
.end-stats {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 28px;
}

.end-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--indigo-lt);
  border-radius: var(--radius-sm);
  padding: 16px 8px;
}

.end-stat:nth-child(2) { background: linear-gradient(135deg, var(--indigo) 0%, #6366F1 100%); }
.end-stat:nth-child(2) .end-stat-value,
.end-stat:nth-child(2) .end-stat-label { color: #fff; }

.end-stat-value {
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  font-weight: 900;
  color: var(--indigo-dk);
}

.end-stat-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.end-actions { display: flex; flex-direction: column; gap: 4px; }

/* ===== HISTORY SCREEN ===== */
.history-card {
  max-height: 88vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--indigo-lt) transparent;
}

.history-card .card-body { padding: 24px 32px 28px; }

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

.history-title {
  font-size: 1.2rem;
  font-weight: 900;
  color: #fff;
}

.trend-section { margin-bottom: 24px; }

.section-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

.trend-chart {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 8px;
  height: 200px;
}

/* History list */
.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-item {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.history-item:hover {
  border-color: var(--indigo);
  box-shadow: var(--shadow-sm);
}

.history-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  background: #fff;
  gap: 10px;
}

.hi-left  { display: flex; flex-direction: column; gap: 4px; }
.hi-date  { font-size: 0.78rem; color: var(--gray-400); font-weight: 600; }

.hi-diff {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 50px;
}

.hi-diff.easy   { background: var(--green-lt);  color: #0A6448; }
.hi-diff.medium { background: var(--indigo-lt); color: var(--indigo-dk); }
.hi-diff.hard   { background: var(--coral-lt);  color: #9B2226; }

.hi-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.hi-stars { font-size: 0.95rem; letter-spacing: 1px; }
.hi-score { font-size: 0.78rem; color: var(--gray-400); font-weight: 700; }
.hi-time  { font-size: 0.72rem; color: var(--gray-400); }

.hi-chevron {
  color: var(--gray-400);
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.history-item.expanded .hi-chevron { transform: rotate(180deg); }

.history-details {
  display: none;
  background: var(--gray-50);
  padding: 10px 16px 14px;
  border-top: 1px solid var(--gray-200);
}

.history-item.expanded .history-details { display: block; }

.hd-question {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--gray-200);
}

.hd-question:last-child { border-bottom: none; }
.hd-num { width: 20px; font-weight: 800; color: var(--gray-400); flex-shrink: 0; }
.hd-eq  { flex: 1; font-weight: 700; color: var(--indigo-dk); font-size: 0.92rem; }

.hd-result {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 50px;
  flex-shrink: 0;
}

.hd-result.ok  { background: var(--green-lt); color: #0A6448; }
.hd-result.bad { background: var(--coral-lt); color: #9B2226; }

.no-history { text-align: center; padding: 32px 16px; color: var(--gray-400); }
.no-history.hidden { display: none; }
.no-history-icon { font-size: 3rem; display: block; margin-bottom: 8px; }

/* ===== LOGIN SCREEN ===== */
.login-card .card-banner { padding: 36px 40px 28px; }
.login-card .card-body   { padding: 28px 40px 32px; }

/* Tabs */
.login-tabs {
  display: flex;
  background: var(--gray-100);
  border-radius: 50px;
  padding: 4px;
  margin-bottom: 22px;
}

.tab-btn {
  flex: 1;
  padding: 9px 12px;
  border: none;
  background: transparent;
  font-family: 'Nunito', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--gray-600);
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.tab-btn.active {
  background: #fff;
  color: var(--indigo);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tab-panel { text-align: left; }
.tab-panel.hidden { display: none; }

.field { margin-bottom: 16px; }

.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--gray-600);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.field-input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--gray-50);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field-input::placeholder {
  color: var(--gray-400);
  font-weight: 400;
  opacity: 1;
}

.field-input:focus {
  border-color: var(--indigo);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(75, 73, 172, 0.12);
}

.auth-error {
  font-size: 0.85rem;
  font-weight: 700;
  color: #9B2226;
  background: var(--coral-lt);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 10px;
  text-align: center;
}

.btn-ghost {
  display: block;
  width: 100%;
  padding: 10px;
  background: transparent;
  border: none;
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--gray-400);
  cursor: pointer;
  margin-top: 8px;
  transition: color 0.2s;
}

.btn-ghost:hover { color: var(--indigo); }

/* Guest banner */
.guest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--amber-lt);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.83rem;
  font-weight: 700;
  color: #7A4F03;
  flex-wrap: wrap;
  border-left: 4px solid var(--amber);
}

.guest-banner.hidden { display: none; }

.btn-create-account {
  background: var(--amber);
  border: none;
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  font-weight: 800;
  color: #4A2F00;
  padding: 5px 14px;
  border-radius: 50px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.btn-create-account:hover { opacity: 0.85; }

/* ===== CONFETTI ===== */
.confetti-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 999;
}

.confetti-piece {
  position: absolute;
  top: -12px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg);   opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

/* ===== UTILITY ===== */
.hidden { display: none !important; }
