:root {
  --naranja: #FFA35C;
  --menta: #5FE1C0;
  --cielo: #63C4FF;
  --amarillo: #FFD35C;
  --rosa: #FF8FBF;
  --lila: #B08CFF;
  --bg: #FBF9F4;
  --card: #FFFFFF;
  --ink: #4A4460;
  --ink-soft: #8B85A3;
  --shadow: 0 10px 24px rgba(74, 68, 96, 0.12);
  --shadow-soft: 0 4px 10px rgba(74, 68, 96, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: 'Quicksand', sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(rgba(95, 225, 192, 0.18) 3px, transparent 3px),
    radial-gradient(rgba(99, 196, 255, 0.16) 3px, transparent 3px),
    radial-gradient(rgba(255, 163, 92, 0.14) 3px, transparent 3px);
  background-size: 60px 60px, 60px 60px, 60px 60px;
  background-position: 0 0, 20px 30px, 40px 10px;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

h1, h2 {
  font-family: 'Baloo 2', 'Quicksand', sans-serif;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--cielo);
  outline-offset: 2px;
}

/* ---------- Overlays / cards ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 68, 96, 0.35);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.card {
  background: var(--card);
  border-radius: 32px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  animation: popIn 0.35s ease-out;
}

.mascot {
  width: 100px;
  height: 100px;
  margin: 0 auto 12px;
  display: block;
}

.card h1 {
  font-size: 1.8rem;
  margin: 8px 0 18px;
  color: var(--ink);
}

.card p {
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin-bottom: 20px;
}

#name-input {
  width: 100%;
  font-family: 'Quicksand', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  padding: 14px 18px;
  border-radius: 999px;
  border: 3px solid var(--cielo);
  text-align: center;
  color: var(--ink);
  margin-bottom: 18px;
}

.big-button {
  display: inline-block;
  width: 100%;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--menta), var(--cielo));
  padding: 16px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.big-button:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow);
}

.big-button:active {
  transform: translateY(0) scale(0.98);
}

/* ---------- Header ---------- */

.app-header {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 10px;
}

.header-top {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  text-align: center;
}

.app-title {
  font-size: 2rem;
  margin: 0;
  color: var(--naranja);
  text-shadow: 2px 2px 0 rgba(255, 163, 92, 0.2);
}

.greeting {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0;
}

.progress-track {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.progress-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #E4DFF0;
  transition: all 0.3s ease;
}

.progress-dot.filled {
  background: linear-gradient(135deg, var(--amarillo), var(--naranja));
  border-color: var(--naranja);
  animation: popIn 0.4s ease-out;
}

/* ---------- Game area ---------- */

.game-area {
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 20px 60px;
}

.prompt {
  text-align: center;
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  margin: 10px 0 24px;
  line-height: 1.35;
}

.stage {
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 30px;
}

.stage:empty {
  min-height: 0;
  margin-bottom: 12px;
}

.icon {
  width: 72px;
  height: 72px;
  display: block;
}

/* Series */
.series-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  background: #fff;
  border-radius: 24px;
  padding: 18px 22px;
  box-shadow: var(--shadow-soft);
}

.series-row .icon {
  width: 56px;
  height: 56px;
}

.series-blank {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 3px dashed var(--lila);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--lila);
}

/* Equivalencias / tren */
.equiv-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow-soft);
}

.equiv-row .icon {
  width: 58px;
  height: 58px;
}

.train-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  justify-content: center;
  flex-wrap: wrap;
}

.wagon-svg {
  width: 92px;
  height: 84px;
}

.wagon-number {
  font-family: 'Baloo 2', sans-serif;
  font-size: 32px;
  font-weight: 700;
  fill: #fff;
}

.option-number {
  font-family: 'Baloo 2', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
}

/* Balanza */
.balance-scale {
  position: relative;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 280 / 230;
  margin: 0 auto;
}

.balance-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.balance-pan {
  position: absolute;
  top: 51.3%;
  width: 34.3%;
  min-height: 56px;
  background: linear-gradient(160deg, #FFFFFF, #EDEAF7);
  clip-path: polygon(12% 100%, 88% 100%, 100% 0%, 0% 0%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
  padding: 14px 8px 10px;
  filter: drop-shadow(0 6px 8px rgba(74, 68, 96, 0.2));
}

.balance-pan.left {
  left: 2.86%;
}

.balance-pan.right {
  right: 2.86%;
}

.balance-pan .icon {
  width: 30px;
  height: 30px;
}

.balanza-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
}

.balanza-option .icon {
  width: 28px;
  height: 28px;
}

.balanza-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
}

.balanza-option .icon {
  width: 28px;
  height: 28px;
}

/* Engranajes */
.engranaje-chain {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  background: #fff;
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow-soft);
}

.piece-icon {
  width: 76px;
  height: 76px;
}

.piece-gap {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  border: 3px dashed var(--lila);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--lila);
  flex-shrink: 0;
}

.bulb-icon {
  width: 78px;
  height: 78px;
}

.bulb-glow {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.bulb-glass {
  transition: fill 0.4s ease;
}

.stage-engranajes.lit .bulb-glow {
  opacity: 0.55;
}

.stage-engranajes.lit .bulb-glass {
  fill: #FFE27A !important;
}

/* ---------- Options ---------- */

.options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  max-width: 560px;
  margin: 0 auto;
}

.option {
  background: #fff;
  border: 3px solid #ECE8F5;
  border-radius: 22px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.25s ease;
}

.option:hover:not(.disabled) {
  transform: translateY(-4px) scale(1.03);
  border-color: var(--cielo);
  box-shadow: var(--shadow);
}

.option:active:not(.disabled) {
  transform: translateY(0) scale(0.97);
}

.option.correct-flash {
  border-color: var(--menta);
  background: #EFFCF7;
  animation: correctPulse 0.9s ease;
}

.option.correct-flash .piece-icon {
  animation: wiggle 0.6s ease;
  transform-origin: 50% 50%;
}

.option.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.option.shake {
  animation: shake 0.45s ease;
}

@media (min-width: 640px) {
  .options {
    grid-template-columns: repeat(4, 1fr);
    max-width: 720px;
  }
}

/* ---------- Animations ---------- */

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes correctPulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(95, 225, 192, 0.25); }
  100% { transform: scale(1); }
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-8deg) scale(1.05); }
  75% { transform: rotate(8deg) scale(1.05); }
}

.hidden {
  display: none !important;
}
