/* ===================================================
   style.css - 바람의 나라 교육용 RPG 클래식 UI 테마
   다크모드 기반, 한국 전통 판타지 RPG 컨셉
   =================================================== */

/* --- Google Fonts 임포트 --- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700;900&family=Noto+Serif+KR:wght@700;900&display=swap');

/* --- CSS 변수 (디자인 토큰) --- */
:root {
  /* 컬러 팔레트 - 바람의 나라 감성 */
  --bg-dark: #0a0e1a;
  --bg-card: #141828;
  --bg-card-hover: #1c2240;
  --bg-modal: rgba(10, 14, 26, 0.95);
  --bg-input: #0d1120;
  --border-color: #2a3055;
  --border-accent: #4a5a9a;

  /* 액센트 컬러 */
  --gold: #f0c040;
  --gold-dark: #c49a20;
  --gold-glow: rgba(240, 192, 64, 0.3);
  --blue-accent: #4a8aff;
  --blue-light: #6aafff;
  --red-accent: #ff4a5a;
  --red-glow: rgba(255, 74, 90, 0.4);
  --green-accent: #40e080;
  --green-dark: #28a060;
  --purple-accent: #a070ff;

  /* 텍스트 */
  --text-primary: #e8e8f0;
  --text-secondary: #8890b0;
  --text-muted: #555a78;
  --text-gold: #f0c040;

  /* 사이즈 */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* 그림자 */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 0 20px rgba(240, 192, 64, 0.15);

  /* 트랜지션 */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* --- 글로벌 리셋 및 기본 스타일 --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* 배경 패턴 (동양 문양 느낌) */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(74, 138, 255, 0.03) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(240, 192, 64, 0.03) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 80%, rgba(160, 112, 255, 0.02) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--blue-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--blue-light);
  text-decoration: underline;
}

/* --- 버튼 시스템 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
}

.btn:active::after {
  width: 300px;
  height: 300px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #0a0e1a;
  border: none;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--gold), #ffe070);
  box-shadow: var(--shadow-gold);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: #555a78;
  color: #888;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
}

.btn-danger {
  background: transparent;
  color: var(--red-accent);
  border-color: var(--red-accent);
}

.btn-danger:hover {
  background: rgba(255, 74, 90, 0.1);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 36px;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
}

/* --- 입력 필드 --- */
.input-field {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 0.95rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.input-field:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.input-field::placeholder {
  color: var(--text-muted);
}

/* --- 카드 컴포넌트 --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition-normal);
}

.card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-md);
}

.card-title {
  font-family: 'Noto Serif KR', serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-gold);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- 테이블 --- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.data-table thead th {
  background: rgba(240, 192, 64, 0.08);
  color: var(--text-gold);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table tbody td {
  padding: 10px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(42, 48, 85, 0.5);
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover td {
  background: rgba(74, 138, 255, 0.05);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* --- 진행률 바 --- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width var(--transition-slow);
  background: linear-gradient(90deg, var(--blue-accent), var(--purple-accent));
}

.progress-bar-fill.good {
  background: linear-gradient(90deg, var(--green-accent), #80ff80);
}

.progress-bar-fill.warning {
  background: linear-gradient(90deg, #ffa040, var(--gold));
}

.progress-bar-fill.danger {
  background: linear-gradient(90deg, var(--red-accent), #ff8080);
}

/* --- 뱃지 --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-gold {
  background: rgba(240, 192, 64, 0.15);
  color: var(--gold);
  border: 1px solid rgba(240, 192, 64, 0.3);
}

.badge-green {
  background: rgba(64, 224, 128, 0.15);
  color: var(--green-accent);
  border: 1px solid rgba(64, 224, 128, 0.3);
}

.badge-red {
  background: rgba(255, 74, 90, 0.15);
  color: var(--red-accent);
  border: 1px solid rgba(255, 74, 90, 0.3);
}

/* ===================================================
   관리자 대시보드 (admin.html) 레이아웃
   =================================================== */

/* 네비게이션 바 */
.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: rgba(20, 24, 40, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-nav .logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-nav .logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.admin-nav .logo-text {
  font-family: 'Noto Serif KR', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-gold);
}

.admin-nav .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* 관리자 메인 콘텐츠 */
.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px;
  position: relative;
  z-index: 1;
}

.admin-header {
  text-align: center;
  margin-bottom: 40px;
}

.admin-header h1 {
  font-family: 'Noto Serif KR', serif;
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold), #ffe070);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.admin-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* 그리드 레이아웃 */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.admin-grid .full-width {
  grid-column: 1 / -1;
}

/* 엑셀 업로드 드래그앤드롭 영역 */
.upload-zone {
  border: 2px dashed var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--gold);
  background: rgba(240, 192, 64, 0.03);
  box-shadow: inset 0 0 30px rgba(240, 192, 64, 0.05);
}

.upload-zone .upload-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.7;
}

.upload-zone .upload-text {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.upload-zone .upload-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.upload-zone input[type="file"] {
  display: none;
}

/* 업로드 결과 미리보기 */
.preview-table-container {
  max-height: 300px;
  overflow-y: auto;
  margin-top: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.preview-table-container::-webkit-scrollbar {
  width: 6px;
}

.preview-table-container::-webkit-scrollbar-thumb {
  background: var(--border-accent);
  border-radius: 3px;
}

/* 통계 카드 */
.stat-number {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--text-gold);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stats-row {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
}

.stat-item {
  flex: 1;
  text-align: center;
  padding: 16px;
  background: rgba(240, 192, 64, 0.03);
  border-radius: var(--radius-md);
  border: 1px solid rgba(240, 192, 64, 0.1);
}

/* 로그인 폼 (admin + game 공용) */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 48px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: fadeInUp 0.5s ease;
}

.auth-box h2 {
  font-family: 'Noto Serif KR', serif;
  font-size: 1.6rem;
  color: var(--text-gold);
  margin-bottom: 8px;
}

.auth-box .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.auth-box .form-group {
  margin-bottom: 16px;
  text-align: left;
}

.auth-box label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.auth-box .auth-error {
  color: var(--red-accent);
  font-size: 0.85rem;
  margin-top: 12px;
  min-height: 20px;
}

.auth-box .auth-links {
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* 알림 메시지 (성공/에러) */
.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 9999;
  animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  box-shadow: var(--shadow-md);
}

.toast-success {
  background: rgba(64, 224, 128, 0.15);
  border: 1px solid rgba(64, 224, 128, 0.3);
  color: var(--green-accent);
}

.toast-error {
  background: rgba(255, 74, 90, 0.15);
  border: 1px solid rgba(255, 74, 90, 0.3);
  color: var(--red-accent);
}

.toast-info {
  background: rgba(74, 138, 255, 0.15);
  border: 1px solid rgba(74, 138, 255, 0.3);
  color: var(--blue-accent);
}

/* 스피너 / 로딩 */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 14, 26, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  z-index: 10;
}

/* ===================================================
   게임 페이지 (index.html) 레이아웃
   =================================================== */

/* 게임 시작 화면 */
.game-title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  position: relative;
  z-index: 1;
}

.game-title-screen .game-logo {
  margin-bottom: 16px;
}

.game-title-screen .game-logo h1 {
  font-family: 'Noto Serif KR', serif;
  font-size: 3.5rem;
  font-weight: 900;
  background: linear-gradient(180deg, #ffe070 0%, var(--gold) 40%, var(--gold-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 2px 4px rgba(240, 192, 64, 0.3));
  letter-spacing: 4px;
}

.game-title-screen .game-logo p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-top: 8px;
  letter-spacing: 2px;
}

/* 캐릭터 생성 폼 */
.character-create {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 32px 40px;
  width: 100%;
  max-width: 500px;
  margin-top: 32px;
  animation: fadeInUp 0.6s ease;
}

.character-create h3 {
  font-family: 'Noto Serif KR', serif;
  color: var(--text-gold);
  font-size: 1.2rem;
  margin-bottom: 20px;
}

/* 직업 선택 카드 */
.job-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.job-card {
  padding: 16px 8px;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.job-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
}

.job-card.selected {
  border-color: var(--gold);
  background: rgba(240, 192, 64, 0.08);
  box-shadow: 0 0 15px var(--gold-glow);
}

.job-card .job-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.job-card .job-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.job-card .job-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===================================================
   푸터
   =================================================== */
.app-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-color);
  margin-top: 48px;
  position: relative;
  z-index: 1;
}

.app-footer a {
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.app-footer a:hover {
  color: var(--gold);
}

/* ===================================================
   애니메이션
   =================================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes borderGlow {

  0%,
  100% {
    border-color: var(--red-accent);
  }

  50% {
    border-color: transparent;
  }
}

/* 퀴즈 오답 시 붉은 깜빡임 */
.quiz-error-flash {
  animation: borderGlow 0.5s ease 6;
}

/* ===================================================
   반응형 (모바일/태블릿)
   =================================================== */
@media (max-width: 768px) {
  .admin-nav {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .admin-container {
    padding: 16px;
  }

  .admin-header h1 {
    font-size: 1.5rem;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .stats-row {
    flex-wrap: wrap;
  }

  .stat-item {
    min-width: calc(50% - 10px);
  }

  .upload-zone {
    padding: 32px 16px;
  }

  .auth-box {
    margin: 16px;
    padding: 32px 24px;
  }

  .game-title-screen .game-logo h1 {
    font-size: 2.2rem;
  }

  .job-selector {
    grid-template-columns: repeat(2, 1fr);
  }

  .character-create {
    margin: 16px;
    padding: 24px;
  }
}

@media (max-width: 480px) {
  .stats-row {
    flex-direction: column;
  }

  .stat-item {
    min-width: 100%;
  }

  .game-title-screen .game-logo h1 {
    font-size: 1.8rem;
    letter-spacing: 2px;
  }
}

/* ===================================================
   Phase 2: 게임 컨테이너 및 HUD
   =================================================== */

/* 게임 컨테이너 (전체 화면) */
#game-container {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
  z-index: 500;
}

#game-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#game-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 10;
}

/* HUD 패널 (포인터 이벤트 활성화) */
.hud-panel {
  pointer-events: auto;
  position: absolute;
}

.hud-top-left {
  top: 12px;
  left: 12px;
  background: rgba(10, 14, 26, 0.85);
  border: 1px solid rgba(240, 192, 64, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  min-width: 180px;
  backdrop-filter: blur(4px);
}

.hud-top-right {
  top: 12px;
  right: 12px;
}

/* HUD 캐릭터 이름/레벨 행 */
.hud-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}

#hud-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.hud-level {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold);
  background: rgba(240, 192, 64, 0.12);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* HUD 바 (HP / MP) */
.hud-bar-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.hud-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-bar-label {
  font-size: 0.65rem;
  font-weight: 700;
  width: 18px;
  text-align: center;
}

.hp-bar .hud-bar-label {
  color: #ff6060;
}

.mp-bar .hud-bar-label {
  color: #6090ff;
}

.hud-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.hud-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.hp-fill {
  background: linear-gradient(90deg, #c04040, #ff6060);
}

.mp-fill {
  background: linear-gradient(90deg, #3050b0, #6090ff);
}

.hud-bar-text {
  font-size: 0.6rem;
  color: var(--text-secondary);
  min-width: 55px;
  text-align: right;
  white-space: nowrap;
}

/* HUD 금전 */
.hud-gold-row {
  font-size: 0.7rem;
  color: var(--gold);
  text-align: right;
}

/* HUD 메뉴 버튼 */
.hud-btn {
  width: 36px;
  height: 36px;
  background: rgba(10, 14, 26, 0.85);
  border: 1px solid rgba(240, 192, 64, 0.3);
  border-radius: var(--radius-md);
  color: var(--gold);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: all var(--transition-fast);
}

.hud-btn:hover {
  background: rgba(240, 192, 64, 0.15);
  border-color: var(--gold);
}

/* ===================================================
   대화 박스 (NPC 대화)
   =================================================== */
.dialog-box {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: min(500px, calc(100vw - 40px));
  background: rgba(10, 14, 26, 0.93);
  border: 2px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  pointer-events: auto;
  animation: fadeInUp 0.2s ease;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

.dialog-name {
  font-family: 'Noto Serif KR', serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 8px;
}

.dialog-text {
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.dialog-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
}

/* ===================================================
   모바일 컨트롤 (가상 조이스틱 + 액션 버튼)
   =================================================== */
.mobile-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 20px 24px;
  pointer-events: none;
}

/* 가상 조이스틱 */
.joystick-zone {
  pointer-events: auto;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.joystick-base {
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.joystick-knob {
  width: 40px;
  height: 40px;
  background: rgba(240, 192, 64, 0.5);
  border: 2px solid var(--gold);
  border-radius: 50%;
  transition: transform 0.05s ease;
  box-shadow: 0 0 10px rgba(240, 192, 64, 0.3);
}

/* 액션 버튼 영역 */
.action-buttons {
  pointer-events: auto;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.action-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  transition: all 0.1s ease;
}

.action-btn:active,
.action-btn.pressed {
  transform: scale(0.9);
  background: rgba(240, 192, 64, 0.3);
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(240, 192, 64, 0.4);
}

.attack-btn {
  border-color: rgba(255, 74, 90, 0.4);
  background: rgba(255, 74, 90, 0.1);
}

.attack-btn:active,
.attack-btn.pressed {
  background: rgba(255, 74, 90, 0.3);
  border-color: var(--red-accent);
  box-shadow: 0 0 15px var(--red-glow);
}

/* ===================================================
   Phase 3: EXP 바
   =================================================== */
.exp-bar .hud-bar-label {
  color: #a070ff;
}

.exp-fill {
  background: linear-gradient(90deg, #6040c0, #a070ff);
}

/* ===================================================
   Phase 3: 퀴즈 팝업 오버레이
   =================================================== */
.quiz-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.quiz-popup {
  background: var(--bg-card);
  border: 2px solid var(--gold);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: min(480px, calc(100vw - 32px));
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(240, 192, 64, 0.1);
  animation: fadeInUp 0.3s ease;
}

.quiz-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.quiz-icon {
  font-size: 1.8rem;
}

.quiz-header h3 {
  font-family: 'Noto Serif KR', serif;
  color: var(--gold);
  font-size: 1.1rem;
  flex: 1;
}

.quiz-category {
  font-size: 0.75rem;
  background: rgba(160, 112, 255, 0.15);
  color: var(--purple-accent);
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid rgba(160, 112, 255, 0.3);
}

.quiz-question {
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 20px;
  font-weight: 500;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.quiz-option {
  padding: 14px 18px;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--gold);
  background: rgba(240, 192, 64, 0.05);
}

.quiz-option:disabled {
  cursor: default;
  opacity: 0.7;
}

.quiz-option.correct {
  border-color: var(--green-accent);
  background: rgba(64, 224, 128, 0.1);
  color: var(--green-accent);
  font-weight: 600;
  opacity: 1;
}

.quiz-option.wrong {
  border-color: var(--red-accent);
  background: rgba(255, 74, 90, 0.1);
  color: var(--red-accent);
  animation: borderGlow 0.3s ease 3;
}

.quiz-result {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 24px;
  padding: 8px;
  border-radius: var(--radius-md);
}

.quiz-result.correct {
  color: var(--green-accent);
  background: rgba(64, 224, 128, 0.08);
}

.quiz-result.wrong {
  color: var(--red-accent);
  background: rgba(255, 74, 90, 0.08);
}

/* ====================================================
   Phase 4: 상점 팝업 스타일
   ==================================================== */

.shop-overlay,
.inventory-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

.shop-popup,
.inventory-popup {
  background: linear-gradient(160deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid var(--gold-primary, #c49a20);
  border-radius: 12px;
  padding: 20px;
  width: min(420px, 90vw);
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 40px rgba(196, 154, 32, 0.15);
}

/* 상점 헤더 */
.shop-header,
.inv-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(196, 154, 32, 0.3);
  padding-bottom: 8px;
}

.shop-header h3,
.inv-header h3 {
  flex: 1;
  margin: 0;
  color: #FFD700;
  font-family: 'Noto Serif KR', serif;
  font-size: 1.1rem;
}

.shop-icon,
.inv-icon {
  font-size: 1.4rem;
}

.shop-close-btn,
.inv-close-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.shop-close-btn:hover,
.inv-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* 상점 탭 */
.shop-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.shop-tab {
  flex: 1;
  padding: 6px 8px;
  border: none;
  background: rgba(255, 255, 255, 0.05);
  color: #aaa;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s;
}

.shop-tab.active {
  background: rgba(196, 154, 32, 0.2);
  color: #FFD700;
  border: 1px solid rgba(196, 154, 32, 0.4);
}

/* 보유 골드 */
.shop-gold {
  color: #FFD700;
  font-size: 0.85rem;
  margin-bottom: 10px;
  text-align: right;
}

/* 아이템 카드 */
.shop-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shop-item-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px;
  transition: all 0.2s;
}

.shop-item-card:hover {
  border-color: rgba(196, 154, 32, 0.4);
}

.shop-item-card.disabled {
  opacity: 0.5;
}

.shop-item-icon {
  font-size: 1.6rem;
  width: 36px;
  text-align: center;
}

.shop-item-info {
  flex: 1;
}

.shop-item-name {
  color: #e0e0e0;
  font-size: 0.85rem;
  font-weight: 600;
}

.shop-owned {
  color: #80ff80;
  font-size: 0.75rem;
  font-weight: 400;
}

.shop-item-stat {
  color: #80d0ff;
  font-size: 0.72rem;
  margin-top: 2px;
}

.shop-item-desc {
  color: #888;
  font-size: 0.7rem;
  margin-top: 1px;
}

.shop-item-req {
  color: #aaa;
  font-size: 0.7rem;
  margin-top: 2px;
}

.shop-item-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.shop-item-price {
  color: #FFD700;
  font-size: 0.8rem;
  font-weight: 600;
}

.shop-buy-btn,
.shop-sell-btn {
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 600;
}

.shop-buy-btn {
  background: linear-gradient(135deg, #c49a20, #ffe070);
  color: #1a1a2e;
}

.shop-buy-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.shop-sell-btn {
  background: rgba(255, 80, 80, 0.15);
  color: #ff8080;
  border: 1px solid rgba(255, 80, 80, 0.3);
}

/* 상점 메시지 */
.shop-message,
.inv-message {
  text-align: center;
  font-size: 0.8rem;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  min-height: 20px;
}

.shop-message.success,
.inv-message.success {
  color: #80ff80;
  background: rgba(64, 224, 128, 0.08);
}

.shop-message.error,
.inv-message.error {
  color: #ff8080;
  background: rgba(255, 74, 90, 0.08);
}

/* ====================================================
   Phase 4: 인벤토리 팝업 스타일
   ==================================================== */

/* 장비 패널 */
.inv-equipment {
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.inv-equipment h4 {
  margin: 0 0 8px 0;
  color: #FFD700;
  font-size: 0.85rem;
}

.inv-equip-slots {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.inv-equip-slot {
  flex: 1;
  padding: 6px;
  border-radius: 6px;
  text-align: center;
  font-size: 0.75rem;
}

.inv-equip-slot.equipped {
  background: rgba(196, 154, 32, 0.12);
  border: 1px solid rgba(196, 154, 32, 0.3);
}

.inv-equip-slot.empty {
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  color: #666;
}

.inv-equip-icon {
  font-size: 1.2rem;
}

.inv-equip-name {
  color: #ccc;
  font-size: 0.72rem;
  margin-top: 2px;
}

.inv-unequip-btn {
  margin-top: 4px;
  padding: 2px 8px;
  border: 1px solid rgba(255, 80, 80, 0.3);
  background: rgba(255, 80, 80, 0.1);
  color: #ff8080;
  border-radius: 4px;
  font-size: 0.68rem;
  cursor: pointer;
}

/* 스탯 표시 */
.inv-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  color: #aaa;
  font-size: 0.8rem;
}

.inv-stats .bonus {
  color: #80ff80;
  font-style: normal;
}

/* 아이템 그리드 (5×4) */
.inv-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.inv-cell {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}

.inv-cell:hover {
  border-color: rgba(196, 154, 32, 0.5);
}

.inv-cell.equipped {
  border-color: rgba(196, 154, 32, 0.5);
  background: rgba(196, 154, 32, 0.08);
}

.inv-cell.empty {
  cursor: default;
  border-style: dashed;
}

.inv-cell-icon {
  font-size: 1.2rem;
}

.inv-cell-name {
  font-size: 0.55rem;
  color: #ccc;
  text-align: center;
  line-height: 1.1;
}

.inv-cell-qty {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.6rem;
  color: #FFD700;
  font-weight: 700;
}

/* 인벤토리 모바일 버튼 */
.inventory-btn {
  background: linear-gradient(135deg, #5a3a1a 0%, #8a6030 100%) !important;
  font-size: 1.5rem !important;
}

/* =========================================
   Skill System Styles (Phase 5)
   ========================================= */

/* 스킬바 (하단 중앙) */
#hud-skillbar {
  display: flex;
  gap: 8px;
  background: rgba(14, 18, 25, 0.85);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  margin-top: 10px;
}

.hud-skill-slot {
  width: 44px;
  height: 44px;
  background: rgba(30, 40, 50, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.4rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
  cursor: pointer;
}

.hud-skill-slot:hover:not(.empty) {
  border-color: rgba(255, 215, 0, 0.8);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.3), inset 0 2px 4px rgba(0, 0, 0, 0.5);
  transform: translateY(-2px);
}

.hud-skill-slot.empty {
  opacity: 0.5;
  cursor: default;
}

.hud-skill-key {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.65rem;
  color: #fff;
  font-weight: 700;
  text-shadow: 1px 1px 0 #000;
  opacity: 0.8;
}

/* 쿨타임 어두운 오버레이 */
.hud-skill-slot.on-cooldown {
  opacity: 0.6;
}

.hud-skill-slot.on-cooldown::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
}

.hud-skill-cd {
  position: absolute;
  z-index: 2;
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
  text-shadow: 1px 1px 2px #000, -1px -1px 2px #000, 1px -1px 2px #000, -1px 1px 2px #000;
}

/* 스킬북 팝업 */
.skillbook-popup {
  background: var(--popup-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.sb-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid var(--border-color);
}

.sb-icon {
  font-size: 1.5rem;
  margin-right: 12px;
}

.sb-header h3 {
  margin: 0;
  color: var(--text-main);
  font-size: 1.2rem;
  font-weight: 600;
  flex: 1;
}

.sb-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.sb-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.sb-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 8px;
  margin: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.2);
}

.sb-skills {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

/* 스킬 카드 */
.sb-skill-card {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
  align-items: stretch;
  transition: all 0.2s ease;
}

.sb-skill-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.sb-skill-card.learned {
  border-color: rgba(64, 224, 128, 0.3);
  background: rgba(64, 224, 128, 0.05);
}

.sb-skill-card.locked {
  opacity: 0.6;
  filter: grayscale(0.8);
}

.sb-skill-icon {
  font-size: 2rem;
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.sb-skill-info {
  flex: 1;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sb-skill-name {
  color: var(--text-main);
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 2px;
}

.sb-skill-lv {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

.sb-skill-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.sb-skill-cost {
  font-size: 0.75rem;
  color: var(--blue-accent);
}

.sb-skill-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  min-width: 90px;
  text-align: right;
}

.sb-learn-cost {
  font-size: 0.75rem;
  color: #FFD700;
  margin-bottom: 6px;
}

.sb-learn-btn {
  background: var(--blue-accent);
  color: white;
  border: none;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.sb-learn-btn:hover:not(:disabled) {
  background: #4B9BEE;
}

.sb-learn-btn:disabled {
  background: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
}

.sb-learned-badge {
  color: #40E080;
  font-weight: bold;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.sb-equip-btn {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--text-muted);
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.sb-equip-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-main);
}

.sb-on-bar {
  background: rgba(255, 215, 0, 0.2);
  color: #FFD700;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  border: 1px solid rgba(255, 215, 0, 0.4);
}

.sb-message {
  text-align: center;
  margin: 0;
  padding: 8px;
  font-size: 0.9rem;
  min-height: 18px;
}

.sb-message.success {
  color: var(--green-accent);
}

.sb-message.error {
  color: var(--red-accent);
}

/* 스킬북 하단 스킬바 섹션 */
.sb-bar-section {
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding: 16px;
}

.sb-bar-section h4 {
  margin: 0 0 12px 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.sb-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.sb-bar-slot {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-height: 60px;
  justify-content: center;
}

.sb-bar-key {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sb-bar-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: none;
  border: none;
  color: var(--red-accent);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px;
  opacity: 0.5;
}

.sb-bar-remove:hover {
  opacity: 1;
}

.sb-bar-icon {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.sb-bar-name {
  font-size: 0.75rem;
  color: var(--text-main);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.sb-bar-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
}