/**
 * DS4K Play Lab — 아이들이 빠져드는 미션 플레이
 */
:root {
  --pl-ink: #0f2744;
  --pl-muted: #5a7189;
  --pl-line: #c9daf0;
  --pl-blue: #2563eb;
  --pl-blue-deep: #1d4ed8;
  --pl-coral: #ff7a6b;
  --pl-gold: #f59e0b;
  --pl-purple: #a855f7;
  --pl-bg: #e8f1fb;
  --font-display: "Jua", "Comfortaa", sans-serif;
  --font-body: "Noto Sans KR", "Pretendard", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--pl-ink);
  background:
    radial-gradient(ellipse 70% 45% at 10% -5%, #bfdbfe 0%, transparent 55%),
    radial-gradient(ellipse 55% 40% at 95% 0%, #ddd6fe 0%, transparent 50%),
    var(--pl-bg);
  overflow-x: clip;
  max-width: 100%;
}

.pl-app { max-width: 960px; width: 100%; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-right)) 56px max(16px, env(safe-area-inset-left)); }

.pl-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(232, 241, 251, 0.92);
  backdrop-filter: blur(8px);
}

.pl-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  font-weight: 800;
}

.pl-brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #2563eb);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.35);
}

.pl-brand strong {
  font-family: var(--font-display);
  font-size: 1.35rem;
  display: block;
  line-height: 1.1;
}

.pl-brand small {
  display: block;
  font-size: 11px;
  color: var(--pl-muted);
  font-weight: 700;
}

.pl-nav a:not(.pl-brand) {
  text-decoration: none;
  font-weight: 800;
  font-size: 13px;
  color: var(--pl-muted);
  padding: 8px 12px;
  border-radius: 999px;
}

.pl-nav a:not(.pl-brand):hover { color: var(--pl-blue); background: #dbeafe; }

/* Hero */
.pl-hero {
  margin: 8px 0 22px;
  padding: 28px 24px 26px;
  border-radius: 28px;
  background: linear-gradient(135deg, #93c5fd 0%, #c4b5fd 45%, #fbcfe8 100%);
  border: 3px solid #fff;
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.2);
  position: relative;
  overflow: hidden;
}

.pl-hero::after {
  content: "🏁";
  position: absolute;
  right: 18px;
  bottom: 8px;
  font-size: 4rem;
  opacity: 0.25;
  transform: rotate(-12deg);
}

.pl-hero-kicker {
  display: inline-block;
  background: #fff;
  color: var(--pl-blue-deep);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.pl-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  margin: 0 0 8px;
  line-height: 1.15;
  color: #1e1b4b;
}

.pl-hero p {
  margin: 0;
  max-width: 480px;
  font-size: 15px;
  font-weight: 600;
  color: #312e81;
  line-height: 1.55;
}

.pl-stars-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-weight: 900;
  font-size: 15px;
  color: #78350f;
}

.pl-stars-bar .dots {
  display: flex;
  gap: 4px;
}

.pl-stars-bar .dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  display: grid;
  place-items: center;
  font-size: 12px;
}

.pl-stars-bar .dot.on { background: #fbbf24; box-shadow: 0 0 0 2px #fff; }

/* Mission pick */
.pl-section-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0 0 6px;
}

.pl-section-desc {
  margin: 0 0 14px;
  color: var(--pl-muted);
  font-size: 14px;
  font-weight: 600;
}

.pl-missions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.pl-mission {
  border: 3px solid #fff;
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 8px 18px rgba(15, 39, 68, 0.08);
  transition: transform 0.15s, border-color 0.15s;
}

.pl-mission:hover { transform: translateY(-3px); }

.pl-mission.active {
  border-color: var(--pl-purple);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.25);
}

.pl-mission.cleared { border-color: #fbbf24; }

.pl-mission-no {
  font-size: 11px;
  font-weight: 900;
  color: var(--pl-purple);
}

.pl-mission h3 {
  margin: 4px 0 6px;
  font-size: 1.05rem;
  font-family: var(--font-display);
}

.pl-mission p {
  margin: 0;
  font-size: 12.5px;
  color: var(--pl-muted);
  font-weight: 600;
  line-height: 1.45;
}

.pl-mission .cleared-badge {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 900;
  color: #b45309;
  background: #fef3c7;
  padding: 3px 8px;
  border-radius: 999px;
}

/* Game panel */
.pl-game {
  background: #fff;
  border: 3px solid #fff;
  border-radius: 26px;
  box-shadow: 0 14px 36px rgba(37, 99, 235, 0.15);
  overflow: hidden;
}

.pl-mission-banner {
  background: linear-gradient(90deg, #4c1d95, #2563eb);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.pl-mission-banner h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.pl-mission-banner .target {
  background: rgba(255, 255, 255, 0.18);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
}

.pl-controls {
  padding: 16px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
}

.pl-formula {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-weight: 700;
  font-size: 15px;
}

.pl-formula input {
  width: 64px;
  padding: 10px;
  border: 3px solid var(--pl-blue);
  border-radius: 12px;
  text-align: center;
  font: inherit;
  font-size: 1.2rem;
  color: var(--pl-blue);
  font-weight: 900;
}

.pl-stepper {
  display: flex;
  gap: 6px;
}

.pl-stepper button {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: #e0e7ff;
  color: var(--pl-blue-deep);
  font-size: 1.2rem;
  font-weight: 900;
  cursor: pointer;
}

.pl-stepper button:hover { background: #c7d2fe; }

.pl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1.05rem;
  padding: 12px 20px;
  border-radius: 999px;
  text-decoration: none;
  color: #fff;
  transition: transform 0.12s;
}

.pl-btn:hover { transform: scale(1.04); }

.pl-btn-go {
  background: linear-gradient(135deg, #ff7a6b, #f43f5e);
  box-shadow: 0 8px 0 #be123c, 0 12px 20px rgba(244, 63, 94, 0.35);
}

.pl-btn-go:active { transform: translateY(3px); box-shadow: 0 4px 0 #be123c; }

.pl-btn-blue {
  background: var(--pl-blue);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 14px;
}

.pl-btn-ghost {
  background: #fff;
  color: var(--pl-ink);
  border: 2px solid var(--pl-line);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 14px;
  box-shadow: none;
}

#p5-container {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #f0f9ff, #faf5ff);
  min-height: 220px;
  display: flex;
  justify-content: center;
}

#p5-container canvas {
  display: block;
  width: 100% !important;
  height: auto !important;
  max-width: 100%;
}

.pl-hud {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 16px 16px;
}

@media (max-width: 560px) {
  .pl-hud { grid-template-columns: 1fr; }
}

.pl-hud-card {
  background: #eff6ff;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.pl-hud-card span { color: var(--pl-blue); font-family: "JetBrains Mono", monospace; }

.pl-feedback {
  margin: 0 16px 16px;
  padding: 14px 16px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 15px;
  display: none;
  line-height: 1.5;
}

.pl-feedback.show { display: block; }

.pl-feedback.win {
  background: linear-gradient(135deg, #fef3c7, #fdba74);
  color: #7c2d12;
  border: 3px solid #f59e0b;
  animation: pop-in 0.35s ease;
}

.pl-feedback.lose {
  background: #fee2e2;
  color: #991b1b;
  border: 3px solid #fca5a5;
}

.pl-feedback.hint {
  background: #e0e7ff;
  color: #312e81;
  border: 3px solid #a5b4fc;
}

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

.pl-next {
  display: none;
  padding: 0 16px 18px;
  gap: 8px;
  flex-wrap: wrap;
}

.pl-next.show { display: flex; }

.pl-tip {
  margin-top: 18px;
  padding: 14px 16px;
  background: #fff;
  border-radius: 16px;
  border: 2px dashed #c4b5fd;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--pl-muted);
}

.pl-tip strong { color: var(--pl-purple); }

/* Confetti overlay */
.pl-confetti {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
}

.pl-confetti i {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  animation: fall linear forwards;
}

@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.2; }
}
