/**
 * Stage 1 Subitizing — vivid forest playroom look
 */
:root {
  --s1-ink: #1a2b49;
  --s1-muted: #5b6b82;
  --s1-cream: #fff8ef;
  --s1-peach: #ffd4c2;
  --s1-mint: #b8f5de;
  --s1-lavender: #ddd6fe;
  --s1-sky: #bae6fd;
  --s1-lemon: #fde68a;
  --s1-coral: #ff6b4a;
  --s1-forest: #2f9e6a;
  --s1-empty: #94a3b8;
  --s1-radius: 22px;
  --s1-shadow: 0 18px 48px rgba(26, 43, 73, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255, 214, 120, 0.55), transparent 55%),
    radial-gradient(circle at 8% 20%, rgba(255, 160, 122, 0.35), transparent 36%),
    radial-gradient(circle at 92% 16%, rgba(125, 211, 252, 0.4), transparent 38%),
    radial-gradient(circle at 50% 100%, rgba(74, 222, 128, 0.28), transparent 42%),
    linear-gradient(180deg, #fff3e0 0%, #e8f8ef 48%, #dff3ff 100%);
  color: var(--s1-ink);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow-x: hidden;
}

.s1-wrap {
  position: relative;
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 16px 48px;
  min-height: 100vh;
  z-index: 1;
}

/* Floating forest décor */
.s1-decor {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.s1-decor span {
  position: absolute;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  opacity: 0.55;
  animation: s1-drift 9s ease-in-out infinite;
  filter: drop-shadow(0 6px 10px rgba(26, 43, 73, 0.12));
}

.s1-decor span:nth-child(1) { left: 4%; top: 12%; animation-delay: 0s; }
.s1-decor span:nth-child(2) { left: 88%; top: 18%; animation-delay: -2s; font-size: 1.6rem; }
.s1-decor span:nth-child(3) { left: 10%; top: 72%; animation-delay: -4s; }
.s1-decor span:nth-child(4) { left: 78%; top: 68%; animation-delay: -1.5s; }
.s1-decor span:nth-child(5) { left: 48%; top: 8%; animation-delay: -3s; font-size: 1.5rem; }
.s1-decor span:nth-child(6) { left: 62%; top: 82%; animation-delay: -5s; }

.s1-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  position: relative;
  z-index: 2;
}

.s1-nav a {
  font-size: 13px;
  font-weight: 800;
  color: var(--s1-muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 16px rgba(26, 43, 73, 0.08);
}

.s1-nav a:hover { color: var(--s1-coral); }

.s1-hero {
  text-align: center;
  margin-bottom: 16px;
  position: relative;
  z-index: 2;
}

.s1-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 900;
  padding: 7px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff, #ffe8dc);
  border: 2px solid #ffc9b0;
  box-shadow: 0 8px 20px rgba(255, 107, 74, 0.18);
  margin-bottom: 10px;
  color: #c2410c;
}

.s1-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.55rem, 5vw, 2.15rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(120deg, #c2410c 10%, #1a2b49 45%, #15803d 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.s1-hero p {
  margin: 0 auto;
  max-width: 26em;
  font-size: 15px;
  font-weight: 700;
  color: var(--s1-muted);
  line-height: 1.55;
  background: rgba(255, 255, 255, 0.65);
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
}

.s1-card {
  position: relative;
  z-index: 2;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.96), rgba(255, 248, 240, 0.92));
  backdrop-filter: blur(12px);
  border-radius: 28px;
  border: 3px solid rgba(255, 255, 255, 0.95);
  box-shadow:
    var(--s1-shadow),
    0 0 0 6px rgba(255, 186, 120, 0.18);
  padding: 20px 16px 24px;
  overflow: hidden;
}

.s1-card::before {
  content: "";
  position: absolute;
  inset: auto -20% -40% -20%;
  height: 55%;
  background: radial-gradient(ellipse at center, rgba(74, 222, 128, 0.18), transparent 65%);
  pointer-events: none;
}

.s1-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 800;
  color: var(--s1-muted);
  margin-bottom: 10px;
  position: relative;
}

.s1-item-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  background: linear-gradient(135deg, #fef3c7, #fdba74);
  color: #9a3412;
  border: 2px solid #fb923c;
  box-shadow: 0 6px 14px rgba(251, 146, 60, 0.28);
  animation: s1-pop 0.45s ease;
}

.s1-progress {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

.s1-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e2e8f0;
  transition: background 0.25s, transform 0.25s;
  border: 2px solid #fff;
}

.s1-dot.on {
  background: var(--s1-coral);
  transform: scale(1.3);
  box-shadow: 0 0 0 4px rgba(255, 107, 74, 0.28);
}

.s1-dot.done {
  background: #22c55e;
}

.s1-squirrel {
  text-align: center;
  font-size: clamp(2.8rem, 8vw, 3.6rem);
  line-height: 1;
  margin-bottom: 6px;
  animation: s1-float 2.8s ease-in-out infinite;
  filter: drop-shadow(0 10px 16px rgba(26, 43, 73, 0.18));
}

.s1-title {
  text-align: center;
  font-size: clamp(1.05rem, 3.2vw, 1.25rem);
  font-weight: 900;
  margin: 0 0 8px;
  color: var(--s1-ink);
}

.s1-prompt {
  text-align: center;
  font-size: clamp(1.15rem, 3.6vw, 1.35rem);
  font-weight: 900;
  line-height: 1.45;
  margin: 0 auto 18px;
  max-width: 22em;
  color: #9a3412;
  padding: 12px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
  border: 2px dashed #fb923c;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.7);
}

.s1-frames {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  position: relative;
}

@media (max-width: 560px) {
  .s1-frames {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

.s1-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.s1-vs span {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(145deg, #ff8a6a, #ef4444);
  box-shadow:
    0 8px 20px rgba(239, 68, 68, 0.35),
    0 0 0 4px rgba(255, 255, 255, 0.9);
  animation: s1-pulse-vs 1.8s ease-in-out infinite;
}

.s1-box {
  appearance: none;
  position: relative;
  border: 4px solid rgba(26, 43, 73, 0.1);
  background: linear-gradient(165deg, #fff, #fff7ed);
  border-radius: var(--s1-radius);
  padding: 16px 12px 14px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s ease, border-color 0.15s, box-shadow 0.15s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(26, 43, 73, 0.1);
}

.s1-box-glow {
  position: absolute;
  inset: -30% -20% auto;
  height: 70%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.7), transparent 70%);
  pointer-events: none;
}

.s1-box.theme-lemon { background: linear-gradient(165deg, #fffef5, #fde68a); border-color: #f59e0b; }
.s1-box.theme-mint { background: linear-gradient(165deg, #f0fdf4, #86efac); border-color: #22c55e; }
.s1-box.theme-peach { background: linear-gradient(165deg, #fff7ed, #fdba74); border-color: #f97316; }
.s1-box.theme-lavender { background: linear-gradient(165deg, #f5f3ff, #c4b5fd); border-color: #8b5cf6; }
.s1-box.theme-sky { background: linear-gradient(165deg, #f0f9ff, #7dd3fc); border-color: #0ea5e9; }
.s1-box.theme-coral { background: linear-gradient(165deg, #fff1f2, #fda4af); border-color: #f43f5e; }

.s1-box:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 16px 36px rgba(26, 43, 73, 0.16);
}

.s1-box:active { transform: scale(0.98); }

.s1-box.is-correct {
  border-color: #16a34a;
  box-shadow:
    0 0 0 5px rgba(34, 197, 94, 0.28),
    0 16px 36px rgba(22, 163, 74, 0.25);
  animation: s1-win-glow 0.7s ease;
}

.s1-box.is-wrong {
  border-color: #e11d48;
  animation: s1-shake 0.45s ease;
}

.s1-box-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  margin-bottom: 10px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 12px rgba(26, 43, 73, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.95);
}

.s1-tenframe {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 7px;
  width: 100%;
  max-width: 260px;
  margin: 0 auto;
  aspect-ratio: 5 / 2.2;
  padding: 8px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: inset 0 2px 8px rgba(26, 43, 73, 0.06);
}

.s1-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid rgba(26, 43, 73, 0.08);
  min-height: 0;
}

.s1-cell.is-filled {
  background: linear-gradient(160deg, #fff, #fff7ed);
  box-shadow: 0 3px 8px rgba(26, 43, 73, 0.1);
  animation: s1-item-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: var(--pop-delay, 0s);
}

.s1-cell.is-empty .s1-empty-ring {
  width: 58%;
  height: 58%;
  border-radius: 50%;
  border: 2.5px dashed var(--s1-empty);
  opacity: 0.9;
}

.s1-cell.is-hint .s1-empty-ring {
  animation: s1-blink 0.7s ease 3;
  border-color: var(--s1-coral);
}

.s1-item {
  width: 78%;
  height: 78%;
  display: block;
  transform-origin: center bottom;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.12));
}

.s1-box.is-bounce .s1-item {
  animation: s1-bounce 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.s1-cart {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 900;
  color: var(--s1-muted);
  min-height: 1.2em;
}

.s1-box.is-correct .s1-cart {
  color: #15803d;
  font-size: 13px;
}

.s1-feedback {
  text-align: center;
  min-height: 3.2em;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.55;
  color: var(--s1-ink);
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  background: transparent;
  transition: background 0.25s;
}

.s1-feedback.is-ok {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  color: #14532d;
  border: 2px solid #4ade80;
}

.s1-feedback.is-bad {
  background: linear-gradient(135deg, #ffe4e6, #ffedd5);
  color: #9f1239;
  border: 2px solid #fb7185;
}

.s1-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}

.s1-btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 13px 22px;
  font-weight: 900;
  font-size: 15px;
  cursor: pointer;
  background: linear-gradient(135deg, #ff8a6a, #ff4d2e);
  color: #fff;
  box-shadow: 0 10px 24px rgba(255, 77, 46, 0.35);
}

.s1-btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

.s1-btn-ghost {
  background: #fff;
  color: var(--s1-ink);
  border: 2px solid rgba(26, 43, 73, 0.12);
  box-shadow: none;
}

.s1-done {
  display: none;
  text-align: center;
  margin-top: 16px;
  padding: 20px 16px;
  border-radius: 22px;
  background: linear-gradient(135deg, #fde68a, #86efac 55%, #7dd3fc);
  border: 3px solid #fff;
  box-shadow: 0 14px 32px rgba(26, 43, 73, 0.12);
}

.s1-done.show {
  display: block;
  animation: s1-pop 0.45s ease;
}

.s1-done h2 {
  margin: 0 0 6px;
  font-size: 1.45rem;
}

.s1-done p {
  margin: 0 0 14px;
  font-size: 15px;
  color: #1a2b49;
  font-weight: 800;
}

.s1-note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--s1-muted);
  text-align: center;
  line-height: 1.5;
  position: relative;
  z-index: 2;
}

.s1-note a {
  color: var(--s1-coral);
  font-weight: 800;
}

@keyframes s1-bounce {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-12px) scale(1.12); }
  55% { transform: translateY(0) scale(0.94); }
  75% { transform: translateY(-5px) scale(1.05); }
  100% { transform: translateY(0) scale(1); }
}

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

@keyframes s1-blink {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; box-shadow: 0 0 0 4px rgba(255, 107, 74, 0.4); }
}

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

@keyframes s1-pop {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes s1-item-pop {
  from { opacity: 0; transform: scale(0.4) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes s1-drift {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-18px) rotate(8deg); }
}

@keyframes s1-pulse-vs {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes s1-win-glow {
  0% { transform: scale(0.98); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .s1-squirrel,
  .s1-box.is-bounce .s1-item,
  .s1-box.is-wrong,
  .s1-cell.is-hint .s1-empty-ring,
  .s1-cell.is-filled,
  .s1-done.show,
  .s1-decor span,
  .s1-vs span,
  .s1-box.is-correct {
    animation: none !important;
  }
}
