:root {
  --space-dark: #020617;
  --star-blue: #3b82f6;
  --star-red: #ef4444;
  --gold: #fbbf24;
  --bg-panel: rgba(15, 23, 42, 0.75);
}

@keyframes drift1 { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(5vw, -5vh) scale(1.3); } }
@keyframes drift2 { 0% { transform: translate(0, 0) scale(1.1); } 100% { transform: translate(-5vw, 5vh) scale(1); } }
@keyframes drift3 { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(-3vw, -4vh) scale(1.4); } }
@keyframes twinkle {
  0%, 100% { opacity: 0.1; transform: scale(0.5); }
  50% { opacity: 1; transform: scale(1.3); box-shadow: 0 0 12px white; }
}
@keyframes shootingStar {
  0% { transform: translateX(0) translateY(0) rotate(45deg); opacity: 1; }
  10% { transform: translateX(150vw) translateY(150vh) rotate(45deg); opacity: 0; }
  100% { opacity: 0; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}
@keyframes popIn {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes heartBeat {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 5px #ef4444); }
  50% { transform: scale(1.2); filter: drop-shadow(0 0 15px #ef4444); }
}
@keyframes floatTitle {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-8px) rotate(1deg); }
}

body {
  margin: 0; font-family: 'Nanum Gothic', sans-serif;
  background-color: var(--space-dark); color: white;
  display: flex; justify-content: center; align-items: center; height: 100vh; overflow: hidden;
  position: relative;
}

.aurora-bg { position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; pointer-events: none; z-index: -4; filter: blur(60px); mix-blend-mode: screen; opacity: 0.85; }
.aurora-1 { position: absolute; width: 60%; height: 60%; top: 10%; left: 10%; border-radius: 50%; background: radial-gradient(circle, rgba(255, 0, 128, 0.45), transparent 60%); animation: drift1 18s infinite alternate ease-in-out; }
.aurora-2 { position: absolute; width: 70%; height: 70%; bottom: 10%; right: 10%; border-radius: 50%; background: radial-gradient(circle, rgba(0, 242, 254, 0.45), transparent 65%); animation: drift2 20s infinite alternate ease-in-out; }
.aurora-3 { position: absolute; width: 60%; height: 60%; top: 40%; left: 30%; border-radius: 50%; background: radial-gradient(circle, rgba(161, 140, 209, 0.45), transparent 60%); animation: drift3 25s infinite alternate ease-in-out; }
.aurora-4 { position: absolute; width: 50%; height: 50%; top: 0%; right: 30%; border-radius: 50%; background: radial-gradient(circle, rgba(254, 214, 227, 0.35), transparent 65%); animation: drift2 22s infinite alternate-reverse ease-in-out; }
.aurora-5 { position: absolute; width: 60%; height: 60%; bottom: 20%; left: 20%; border-radius: 50%; background: radial-gradient(circle, rgba(67, 233, 123, 0.3), transparent 60%); animation: drift1 28s infinite alternate ease-in-out; }

.stars, .stars2, .stars3 { position: absolute; top:0; left:0; right:0; bottom:0; pointer-events:none; z-index: -3; }
.stars { background-image: radial-gradient(#ffffff, transparent 3px), radial-gradient(#fbcfe8, transparent 4px), radial-gradient(#fef08a, transparent 3px); background-size: 200px 200px, 350px 350px, 150px 150px; background-position: 0 0, 40px 60px, 130px 40px; animation: twinkle 4s infinite alternate; }
.stars2 { background-image: radial-gradient(#a78bfa, transparent 5px), radial-gradient(#6ee7b7, transparent 3px), radial-gradient(#93c5fd, transparent 4px); background-size: 300px 300px, 400px 400px, 250px 250px; background-position: 50px 50px, 200px 150px, 80px 200px; animation: twinkle 5s infinite alternate-reverse; }
.stars3 { background-image: radial-gradient(#fcd34d, transparent 4px), radial-gradient(#f472b6, transparent 4px), radial-gradient(#38bdf8, transparent 3px); background-size: 150px 150px, 280px 280px, 320px 320px; background-position: 100px 100px, 50px 200px, 180px 90px; animation: twinkle 3.5s infinite alternate; }

.shooting-star { position: absolute; width: 120px; height: 2px; z-index: -2; background: linear-gradient(90deg, rgba(255,255,255,1), transparent); box-shadow: 0 0 10px white; top: -10%; left: 30%; animation: shootingStar 8s infinite linear; border-radius: 50%; }
.shooting-star:nth-child(2) { top: 20%; left: -20%; animation: shootingStar 12s infinite linear; animation-delay: 4s; }

h1, h2, h3, button, input { font-family: 'Jua', sans-serif; }
.neon-text { text-shadow: 0 0 10px rgba(251, 191, 36, 0.8), 0 0 20px rgba(251, 191, 36, 0.4); }

.overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(2, 6, 23, 0.82); z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; box-sizing: border-box; backdrop-filter: blur(10px); overflow-y: auto; }
.hidden { display: none !important; }

.story-card { background: linear-gradient(135deg, rgba(255,255,255,0.97) 0%, rgba(224,242,254,0.95) 100%); color: #0f172a; padding: 45px 50px; border-radius: 40px; max-width: 750px; position: relative; animation: popIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275); margin: auto; }

/* 시작 화면 애니메이션 설정 */
.start-card { border: 8px solid transparent; position: relative; background-clip: padding-box; }
.start-card::before {
  content: ''; position: absolute; top: -8px; left: -8px; right: -8px; bottom: -8px;
  background: linear-gradient(45deg, #ff007f, #7928ca, #3b82f6, #10b981, #fbbf24, #ff007f);
  background-size: 300%; z-index: -1; border-radius: 45px; animation: rainbowGlow 5s linear infinite;
  box-shadow: 0 0 30px rgba(255, 0, 127, 0.5), 0 0 50px rgba(121, 40, 202, 0.4);
}
@keyframes rainbowGlow { 0% { background-position: 0% 50%; } 100% { background-position: 300% 50%; } }

.story-title { color: #fff; font-size: 4.2rem; margin-top: 10px; margin-bottom: 25px; text-shadow: 0 0 10px #c084fc, 0 0 20px #c084fc, 0 0 40px #e9d5ff, 4px 4px 0px #4c1d95; animation: floatTitle 3s ease-in-out infinite; }
.story-desc { font-size: 1.4rem; line-height: 1.75; color: #334155; word-break: keep-all; font-weight: bold; background: rgba(255,255,255,0.5); padding: 20px; border-radius: 20px; border: 2px dashed #93c5fd; }

.speech-bubble { position: absolute; top: -90px; left: 50%; transform: translateX(-50%); background: #fff; color: #be185d; padding: 15px 30px; border-radius: 30px; font-size: 1.6rem; box-shadow: 0 15px 25px rgba(0,0,0,0.25); white-space: nowrap; border: 5px solid #fbcfe8; animation: float 2.5s infinite ease-in-out; z-index: 10; }
.speech-bubble::after { content: ''; position: absolute; bottom: -12px; left: 50%; transform: translateX(-50%); border-width: 12px 12px 0; border-style: solid; border-color: #fff transparent transparent transparent; }
.speech-bubble::before { content: ''; position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); border-width: 16px 16px 0; border-style: solid; border-color: #fbcfe8 transparent transparent transparent; z-index: -1; }

.deco-star { position: absolute; width: 30px; height: 30px; background: radial-gradient(circle, #fef08a, transparent); filter: blur(2px); animation: twinkle 2s infinite alternate; }
.ds-1 { top: -20px; left: -20px; width: 50px; height: 50px; animation-delay: 0.5s; }
.ds-2 { bottom: 30px; right: -30px; width: 60px; height: 60px; background: radial-gradient(circle, #a78bfa, transparent); animation-delay: 1.2s; }
.ds-3 { top: 40px; right: -10px; width: 40px; height: 40px; background: radial-gradient(circle, #93c5fd, transparent); border-radius: 50%; }

.certificate-card { background: linear-gradient(to bottom right, #fffcf8, #fdf6e3); padding: 40px 50px; border-radius: 10px; max-width: 850px; box-shadow: 0 30px 60px rgba(0,0,0,0.6), inset 0 0 50px rgba(212, 175, 55, 0.2); border: 20px solid transparent; border-image: repeating-linear-gradient(45deg, #d4af37, #fde08b 10%, #d4af37 20%) 20; position: relative; animation: popIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); margin: auto; }
.certificate-title { font-size: 4rem; color: #b45309; text-shadow: 2px 2px 0px #fef3c7; margin: 0 0 10px 0; border-bottom: 4px double #d4af37; padding-bottom: 10px; }
.certificate-body { font-size: 1.55rem; color: #451a03; line-height: 1.8; margin-top: 20px; text-align: center; font-family: 'Nanum Gothic', sans-serif; font-weight: bold; word-break: keep-all; }
.gold-seal { position: absolute; bottom: 30px; right: 40px; width: 80px; height: 80px; background: radial-gradient(circle, #fde08b, #d4af37); border-radius: 50%; border: 4px dashed #92400e; box-shadow: 0 5px 15px rgba(0,0,0,0.4); display: flex; justify-content: center; align-items: center; color: #78350f; font-weight: bold; transform: rotate(-15deg); }
.reunion-scene { display: flex; justify-content: center; align-items: center; margin: 30px 0; background: rgba(255,255,255,0.6); border-radius: 40px; padding: 30px; border: 4px dashed #fcd34d; box-shadow: inset 0 0 20px rgba(251, 191, 36, 0.4); }

.btn-action { background: linear-gradient(to bottom, #10b981, #059669); color: white; padding: 18px 45px; font-size: 1.7rem; border: 2px solid #34d399; border-radius: 20px; cursor: pointer; transition: all 0.3s; box-shadow: 0 8px 0 #047857, 0 15px 20px rgba(0,0,0,0.3); }
.btn-action:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 11px 0 #047857; filter: brightness(1.1); }
.btn-action:active { transform: translateY(5px); box-shadow: 0 0px 0 #047857; }
.btn-guide-open { background: linear-gradient(to bottom, #8b5cf6, #6d28d9); border-color: #c4b5fd; box-shadow: 0 8px 0 #5b21b6; }

.guide-box { background: rgba(248,250,252,0.9); padding: 20px; border-radius: 20px; margin: 15px 0; font-size: 1.25rem; border: 3px dashed #94a3b8; }
.highlight { color: var(--star-red); font-weight: bold; }
.highlight-blue { color: var(--star-blue); font-weight: bold; }

.quiz-box { background: linear-gradient(135deg, #f3e8ff, #fdf4ff); padding: 30px; border-radius: 30px; border: 4px solid #d8b4fe; margin-bottom: 20px; }
.quiz-q { font-size: 1.7rem; color: #581c87; margin-bottom: 25px; font-weight: bold; word-break: keep-all;}
.quiz-btn-group { display: flex; gap: 15px; justify-content: center; margin-bottom: 20px; }
.btn-quiz {flex: 1; padding: 18px; font-size: 1.5rem; border:2px solid rgba(255,255,255,0.5); border-radius:18px; cursor:pointer; color:white; transition:0.3s;}
.btn-quiz-o { background: linear-gradient(to bottom, #3b82f6, #2563eb); box-shadow: 0 6px 0 #1d4ed8; }
.btn-quiz-x { background: linear-gradient(to bottom, #ef4444, #dc2626); box-shadow: 0 6px 0 #b91c1c; }
.btn-quiz:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-3px); }
.btn-quiz:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.quiz-feedback { font-size: 1.35rem; font-weight: bold; padding: 15px; border-radius: 15px; display: none; margin-top: 10px; }

.game-wrapper {
  display: none; width: 95vw; max-width: 1200px; height: 90vh; max-height: 800px; gap: 20px; background: var(--bg-panel);
  padding: 25px; border-radius: 30px; border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), inset 0 0 30px rgba(255,255,255,0.05);
  backdrop-filter: blur(25px); animation: popIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.canvas-container { flex: 2.2; position: relative; display: flex; flex-direction: column; min-width: 0; }
.canvas-scalable-wrapper { width: 100%; flex-grow: 1; display: flex; justify-content: center; align-items: center; overflow: hidden; position: relative; background: radial-gradient(circle at center, rgba(15,23,42,0.8) 0%, rgba(2,6,23,0.9) 100%); border-radius: 20px; border: 4px solid #475569; box-shadow: inset 0 0 50px rgba(0,0,0,0.8); }
canvas { width: 100%; height: 100%; object-fit: contain; cursor: crosshair; }

.side-panel { flex: 1; display: flex; flex-direction: column; gap: 15px; min-width: 300px; }
.glass-card { background: rgba(255,255,255,0.08); color: white; padding: 18px; border-radius: 20px; border: 1px solid rgba(255,255,255,0.15); backdrop-filter: blur(15px); display: flex; flex-direction: column; box-shadow: 0 10px 20px rgba(0,0,0,0.2); }
.mission-tag { background: rgba(251, 191, 36, 0.15); border: 2px dashed rgba(251, 191, 36, 0.7); padding: 12px; border-radius: 12px; font-size: 1.15rem; color: #fdf6e3; line-height: 1.5; }

.energy-group { display: flex; gap: 10px; margin-top: 10px; }
.btn-energy { padding: 12px; border: 2px solid transparent; border-radius: 15px; cursor: pointer; flex: 1; color: white; font-size: 1.2rem; font-weight: bold; transition: all 0.2s;}
.btn-n { background: linear-gradient(135deg, #60a5fa, #2563eb); box-shadow: 0 5px 0 #1d4ed8; }
.btn-s { background: linear-gradient(135deg, #f87171, #dc2626); box-shadow: 0 5px 0 #b91c1c; }
.btn-erase { background: linear-gradient(135deg, #94a3b8, #475569); color: white; flex: 0.5; box-shadow: 0 5px 0 #334155; }
.btn-energy:hover { filter: brightness(1.15); transform: translateY(-2px); }
.btn-energy:active { transform: translateY(4px); box-shadow: none; }
.btn-energy.selected { outline: 4px solid var(--gold); outline-offset: 3px; border-color: white; transform: scale(1.05); }

.btn-play { background: linear-gradient(to bottom, #ec4899, #be185d); color: white; font-size: 1.7rem; padding: 16px; border-radius: 18px; border: 3px solid #fbcfe8; cursor: pointer; box-shadow: 0 8px 0 #831843, 0 10px 20px rgba(0,0,0,0.4); transition: 0.2s; flex-shrink: 0; }
.btn-play:hover { filter: brightness(1.1); transform: scale(1.03); box-shadow: 0 10px 0 #831843; }
.btn-play:active { transform: translateY(6px); box-shadow: 0 2px 0 #831843; }
.btn-play:disabled { background: #475569; border-color: #64748b; box-shadow: none; cursor: default; filter: grayscale(1); transform: none; }

.log-container { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 120px; }
#science-log { flex-grow: 1; overflow-y: auto; background: rgba(0,0,0,0.6); border-radius: 12px; padding: 15px; font-size: 1.05rem; color: #e9d5ff; border: 1px solid rgba(192, 132, 252, 0.3); line-height: 1.6; }

.status-bar { display: flex; justify-content: space-between; margin-bottom: 10px; font-family: 'Jua'; font-size: 1.6rem; color: var(--gold); align-items: center; }
.badge { background: linear-gradient(135deg, #c084fc, #9333ea); color: white; padding: 6px 14px; border-radius: 20px; font-size: 1.2rem; border: 2px solid #e9d5ff;}

.char-badge { width: 110px; height: 110px; margin: 10px auto 25px; border-radius: 50%; display: flex; justify-content: center; align-items: center; animation: float 3s ease-in-out infinite; }
