/* ===========================
   Math Snake — Styles
   haciendotareas.com / Lab
   =========================== */

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

:root {
  --purple:   #a855f7;
  --purple-d: #7c3aed;
  --orange:   #f97316;
  --orange-d: #ea580c;
  --red:      #ef4444;
  --red-d:    #dc2626;
  --green:    #22c55e;
  --green-d:  #16a34a;
  --yellow-bg:#fef9c3;
  --white:    #ffffff;
  --gray:     #6b7280;
  --gray-lt:  #9ca3af;
  --navy:     #1e1b4b;
  --border-r: 16px;
}

html, body {
  min-height: 100%;
  width: 100%;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--yellow-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 12px 40px;
  gap: 14px;
}

/* --- Header --- */
h1 {
  font-family: 'Fredoka One', cursive;
  font-size: 2.2rem;
  color: var(--purple-d);
  letter-spacing: 1px;
  text-align: center;
  line-height: 1.1;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--gray);
  font-weight: 600;
  text-align: center;
}

/* --- Game wrapper --- */
.game-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 500px;
}

/* --- Top bar --- */
.top-bar {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: space-between;
  align-items: center;
}

.pill {
  background: var(--white);
  border-radius: 99px;
  padding: 6px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  border: 2px solid;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pill.score { border-color: var(--orange);  color: var(--orange-d); }
.pill.lives { border-color: var(--red);     color: var(--red-d); }

select {
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--purple-d);
  background: var(--white);
  border: 2px solid var(--purple);
  border-radius: 99px;
  padding: 6px 14px;
  cursor: pointer;
  outline: none;
}

/* --- Canvas --- */
.canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 4px solid var(--green-d);
  touch-action: none;
}

/* --- Overlay (start / game over) --- */
.overlay {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.overlay h2 {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  color: var(--white);
}

.overlay p {
  color: #fde68a;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  padding: 0 12px;
}

.start-btn {
  font-family: 'Fredoka One', cursive;
  font-size: 1.1rem;
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: 99px;
  padding: 10px 30px;
  cursor: pointer;
  margin-top: 6px;
  transition: transform 0.15s;
}
.start-btn:hover { transform: scale(1.08); }

/* --- Question box --- */
.question-box {
  width: 100%;
  background: var(--white);
  border-radius: var(--border-r);
  border: 3px solid var(--purple);
  padding: 18px 16px;
  text-align: center;
  display: none;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 0 #a855f730;
}
.question-box.active { display: flex; }

.q-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.q-text {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  color: var(--navy);
}

/* --- Answer choices --- */
.choices {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.choice-btn {
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  padding: 8px 24px;
  border-radius: 99px;
  border: 2px solid;
  cursor: pointer;
  transition: transform 0.1s;
}
.choice-btn:hover { transform: scale(1.07); }

.choice-btn.a { background: #dbeafe; border-color: #3b82f6; color: #1d4ed8; }
.choice-btn.b { background: #fce7f3; border-color: #ec4899; color: #9d174d; }
.choice-btn.c { background: #dcfce7; border-color: #22c55e; color: #15803d; }
.choice-btn.d { background: #fef3c7; border-color: #f59e0b; color: #92400e; }

.choice-btn.correct {
  background: #22c55e !important;
  border-color: #15803d !important;
  color: var(--white) !important;
}
.choice-btn.wrong {
  background: var(--red) !important;
  border-color: var(--red-d) !important;
  color: var(--white) !important;
  animation: shake 0.3s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-5px); }
  75%       { transform: translateX(5px); }
}

/* --- Result flash message --- */
.result-flash {
  font-size: 1.1rem;
  font-weight: 700;
  min-height: 24px;
}
.result-flash.good { color: var(--green-d); }
.result-flash.bad  { color: var(--red-d); }

/* --- Footer hints --- */
.swipe-hint {
  font-size: 0.75rem;
  color: var(--gray-lt);
  text-align: center;
}

.back-link {
  font-size: 0.85rem;
  color: var(--purple-d);
  font-weight: 700;
  text-decoration: none;
  margin-top: 4px;
}
.back-link:hover { text-decoration: underline; }
