/* 다크 네온 RPG 게이밍 테마 CSS */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&family=Nanum+Pen+Script&family=Gowun+Dodum&display=swap');

:root {
  --bg-dark: #0b0f19;
  --bg-panel: rgba(20, 28, 45, 0.7);
  --neon-blue: #00f2fe;
  --neon-cyan: #00e5ff;
  --neon-purple: #d500f9;
  --neon-pink: #ff007f;
  --neon-green: #00e676;
  --neon-orange: #ff9100;
  --border-neon: rgba(0, 229, 255, 0.2);
  --text-main: #f1f2f6;
  --text-muted: #a4b0be;
  --panel-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --neon-glow-cyan: 0 0 15px rgba(0, 229, 255, 0.6);
  --neon-glow-purple: 0 0 15px rgba(213, 0, 249, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Gowun Dodum', sans-serif;
  user-select: none;
}

body {
  background: radial-gradient(circle at 50% 50%, #151e33 0%, var(--bg-dark) 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  color: var(--text-main);
}

/* 전체 감싸는 게임 메인 보드 */
.app-container {
  width: 98vw;
  max-width: 1200px;
  height: 92vh;
  max-height: 850px;
  background: var(--bg-panel);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 2px solid rgba(0, 229, 255, 0.25);
  border-radius: 24px;
  box-shadow: 0 0 30px rgba(0, 229, 255, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* 상단 정보 패널 */
header {
  padding: 15px 30px;
  background: rgba(11, 15, 25, 0.8);
  border-bottom: 2px solid rgba(0, 229, 255, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.game-title h1 {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 1px;
  background: linear-gradient(95deg, var(--neon-cyan) 0%, var(--neon-purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

.user-status {
  display: flex;
  align-items: center;
  gap: 15px;
}

.level-badge {
  background: rgba(213, 0, 249, 0.15);
  border: 1px solid var(--neon-purple);
  color: #f3d1ff;
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: bold;
  box-shadow: var(--neon-glow-purple);
}

.selected-char-avatar {
  font-size: 2rem;
  width: 45px;
  height: 45px;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid var(--neon-cyan);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--neon-glow-cyan);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.selected-char-avatar:hover {
  transform: scale(1.15) rotate(15deg);
}

/* 메인 프레임 워크스페이스: 사이드바 + 우측 컨텐츠 */
.game-viewport {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* 좌측 카테고리 네온 사이드바 */
.left-sidebar {
  width: 260px;
  background: rgba(8, 12, 21, 0.95);
  border-right: 2px solid rgba(0, 229, 255, 0.15);
  padding: 20px 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  transition: all 0.3s;
}

@media (max-width: 768px) {
  .left-sidebar {
    display: none; /* 모바일 대응 시 숨기거나 토글 */
  }
}

.sidebar-title {
  font-size: 0.8rem;
  color: var(--neon-cyan);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: bold;
  margin-bottom: 5px;
  text-shadow: 0 0 5px rgba(0, 229, 255, 0.4);
}

.sidebar-item {
  background: rgba(20, 28, 45, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 12px 15px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-item:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.15);
  transform: translateX(4px);
}

.sidebar-item.active {
  background: rgba(0, 229, 255, 0.1);
  border-color: var(--neon-cyan);
  box-shadow: var(--neon-glow-cyan);
}

.sidebar-item h4 {
  font-size: 0.95rem;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 사이드바 미니 체력게이지(HP) 스타일 진척바 */
.mini-hp-bar {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
  overflow: hidden;
}

.mini-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-blue));
  width: 0%;
  transition: width 0.5s;
}

/* 우측 메인 콘텐츠 존 */
.screen-area {
  flex: 1;
  overflow-y: auto;
  position: relative;
  background: #0f172a;
}

.screen {
  display: none;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  height: 100%;
  padding: 20px;
}

.screen.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0);
}

/* 로비 / 캐릭터 선택창 */
.lobby-screen {
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.welcome-text {
  text-align: center;
}

.welcome-text h2 {
  font-size: 1.8rem;
  margin-bottom: 8px;
  background: linear-gradient(90deg, #fff 0%, var(--neon-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-text p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 15px;
  width: 100%;
  max-width: 900px;
}

@media (max-width: 992px) {
  .character-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.char-card {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 15px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.char-card:hover {
  transform: translateY(-5px);
  border-color: var(--neon-purple);
  box-shadow: var(--neon-glow-purple);
}

.char-card.selected {
  border-color: var(--neon-cyan);
  box-shadow: var(--neon-glow-cyan);
  background: rgba(0, 229, 255, 0.05);
  transform: scale(1.05);
}

.char-emoji {
  font-size: 2.8rem;
  margin-bottom: 8px;
  display: inline-block;
  transition: transform 0.3s;
}

.char-card:hover .char-emoji {
  transform: scale(1.15) rotate(-5deg);
}

.char-name {
  font-weight: bold;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.char-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.start-btn {
  background: linear-gradient(135deg, var(--neon-purple) 0%, var(--neon-pink) 100%);
  color: white;
  border: none;
  padding: 12px 40px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(213, 0, 249, 0.4);
  transition: all 0.25s ease;
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(213, 0, 249, 0.7);
}

/* 징검다리 전투 맵 (Battle Map) */
.battle-map-container {
  background: rgba(8, 12, 21, 0.8);
  border: 1px solid var(--border-neon);
  border-radius: 18px;
  padding: 15px;
  margin-bottom: 15px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.8);
}

/* 징검다리 횡스크롤 트랙 */
.step-stone-track {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 5px;
  overflow-x: auto;
}

.step-stone {
  min-width: 40px;
  height: 40px;
  background: #1e293b;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.3);
  position: relative;
  transition: all 0.3s;
}

.step-stone.active {
  background: var(--neon-cyan);
  border-color: #fff;
  color: #0f172a;
  box-shadow: var(--neon-glow-cyan);
}

.step-stone.completed {
  background: rgba(0, 230, 176, 0.2);
  border-color: var(--neon-green);
  color: var(--neon-green);
}

/* 징검다리 트랙 위의 활성 캐릭터 토큰 */
.char-token {
  font-size: 2.2rem;
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 5;
  filter: drop-shadow(0 0 8px var(--neon-cyan));
  animation: idleFloat 1.8s infinite ease-in-out;
  pointer-events: none;
}

@keyframes idleFloat {
  0%, 100% { transform: translate(-55%, 0px); }
  50% { transform: translate(-55%, -8px); }
}

/* 캐릭터 점프 격돌 애니메이션 */
.char-token.jump-attack {
  animation: jumpAttack 0.8s forwards ease-in-out;
}

@keyframes jumpAttack {
  0% { transform: translate(-55%, 0) scale(1); }
  40% { transform: translate(50px, -40px) scale(1.3) rotate(15deg); }
  70% { transform: translate(100px, 0) scale(1.1) rotate(0deg); }
  100% { transform: translate(-55%, 0) scale(1); }
}

/* 우측 몬스터 현황 타일 */
.monster-battle-zone {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 10px 30px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  margin-top: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.05);
}

.combatant {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.combatant-emoji {
  font-size: 3rem;
  filter: drop-shadow(0 0 10px rgba(0,0,0,0.5));
}

.monster-hp-bar {
  width: 100px;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  overflow: hidden;
}

.monster-hp-fill {
  height: 100%;
  background: var(--neon-pink);
  width: 100%;
  transition: width 0.5s ease;
}

.monster-battle-zone .versus {
  font-family: 'Outfit', sans-serif;
  font-style: italic;
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--neon-pink);
  text-shadow: 0 0 8px rgba(255, 0, 127, 0.6);
}

/* 2단계 퀴즈 레이아웃 */
.quiz-split-view {
  display: flex;
  gap: 20px;
  flex: 1;
}

@media (max-width: 768px) {
  .quiz-split-view {
    flex-direction: column;
  }
}

.learn-panel {
  flex: 1;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
}

.target-jeju-word {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--neon-cyan);
  text-shadow: var(--neon-glow-cyan);
  margin-bottom: 10px;
}

.target-word-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 20px;
  max-width: 80%;
  line-height: 1.4;
}

.combat-panel {
  flex: 1.2;
  background: rgba(20, 28, 45, 0.9);
  border: 1px solid var(--border-neon);
  border-radius: 20px;
  padding: 25px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.stage-badge {
  background: var(--neon-purple);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: bold;
  align-self: flex-start;
  margin-bottom: 15px;
}

.step-indicator {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 15px;
}

.step-indicator span.active {
  color: var(--neon-cyan);
  font-weight: bold;
  text-shadow: 0 0 5px var(--neon-cyan);
}

/* 1단계 객관식 문항 버튼 리스트 */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 15px;
}

.choice-btn {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px;
  color: white;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.choice-btn:hover {
  background: rgba(0, 229, 255, 0.1);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

.choice-btn.ox-btn {
  font-size: 1.8rem;
  font-weight: bold;
}

/* 2단계 입력창 서서히 나타남 */
.input-block-zone {
  display: none;
  animation: slideUp 0.3s ease forwards;
}

.input-block-zone.active {
  display: block;
}

.sentence-input {
  width: 100%;
  padding: 15px;
  background: #0f172a;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: white;
  font-size: 0.95rem;
  outline: none;
  margin-bottom: 15px;
  transition: all 0.3s;
}

.sentence-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

/* 피드백 박스 */
.feedback-box {
  display: none;
  padding: 15px;
  border-radius: 14px;
  margin-bottom: 15px;
  font-size: 0.85rem;
  line-height: 1.4;
  animation: slideUp 0.3s ease;
}

.feedback-box.success {
  background: rgba(0, 230, 118, 0.1);
  border: 1px solid var(--neon-green);
  color: var(--neon-green);
}

.feedback-box.error {
  background: rgba(255, 23, 68, 0.1);
  border: 1px solid var(--neon-pink);
  color: var(--neon-pink);
}

.feedback-tip {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

/* 업적 화면 */
.achievements-screen {
  gap: 15px;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  overflow-y: auto;
  flex: 1;
}

@media (max-width: 600px) {
  .badges-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.badge-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  padding: 15px;
  text-align: center;
  filter: grayscale(1);
  opacity: 0.4;
  transition: all 0.4s ease;
}

.badge-card.unlocked {
  filter: grayscale(0);
  opacity: 1;
  border-color: var(--neon-cyan);
  box-shadow: var(--neon-glow-cyan);
}

.badge-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.badge-name {
  font-weight: bold;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.badge-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* 모달 및 폭죽 오버레이 */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: #111a2e;
  border: 2px solid var(--neon-cyan);
  box-shadow: var(--neon-glow-cyan);
  border-radius: 24px;
  padding: 35px;
  text-align: center;
  max-width: 400px;
  width: 85%;
  transform: scale(0.85);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.overlay.active .modal-content {
  transform: scale(1);
}

.modal-emoji {
  font-size: 4rem;
  margin-bottom: 15px;
  animation: float 2s infinite ease-in-out;
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--neon-cyan);
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 25px;
  line-height: 1.4;
}

/* Canvas 폭죽 */
#confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 99;
}

/* 키프레임 */
@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.shake {
  animation: shake 0.4s ease;
}

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

.monster-hurt {
  animation: hurtRed 0.4s ease;
}

@keyframes hurtRed {
  0%, 100% { filter: brightness(1) drop-shadow(0 0 0 red); }
  50% { filter: brightness(1.5) invert(0.2) sepia(1) saturate(100) hue-rotate(320deg) drop-shadow(0 0 15px red); }
}

.monster-die {
  animation: dieFade 0.5s forwards ease-in;
}

@keyframes dieFade {
  0% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.2) rotate(45deg); opacity: 0.5; }
  100% { transform: scale(0) rotate(90deg); opacity: 0; }
}

/* 스크롤바 커스텀 */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: var(--neon-cyan);
  border-radius: 3px;
}

/* 실시간 리더보드 애니메이션 */
.race-leaderboard ol li {
  animation: pulseLight 2s infinite ease-in-out;
}

@keyframes pulseLight {
  0%, 100% { text-shadow: 0 0 0px transparent; }
  50% { text-shadow: 0 0 4px rgba(0, 229, 255, 0.4); }
}

/* 관리자 패널 인풋 포커스 보완 */
.admin-lobby-panel input {
  transition: all 0.3s;
}
.admin-lobby-panel input:focus {
  border-color: var(--neon-green) !important;
  box-shadow: 0 0 12px rgba(0, 230, 118, 0.3) !important;
}
