/* ==========================================================================
   방벽 수호전 디자인 시스템 & 스타일 시트 (다크 SF 모던 스타일)
   ========================================================================== */

:root {
  --bg-color: #0b0d19;
  --panel-bg: rgba(18, 22, 41, 0.85);
  --neon-blue: #00f0ff;
  --neon-pink: #ff007f;
  --neon-red: #ff3b30;
  --neon-orange: #ff9500;
  --neon-yellow: #ffcc00;
  --neon-green: #34c759;
  --text-primary: #ffffff;
  --text-secondary: #a0aec0;
  --border-glow: rgba(0, 240, 255, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: #000;
  color: var(--text-primary);
  font-family: 'Noto Sans KR', sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 전체 게임 가로 컨테이너 (태블릿 가로 비율 고정형) */
#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 1366px;
  max-height: 768px;
  aspect-ratio: 16 / 9;
  background-color: var(--bg-color);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0, 240, 255, 0.15);
  border: 3px solid #1a1e36;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 게임 플레이 Canvas */
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* HUD Overlay */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
  font-family: 'Orbitron', sans-serif;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

#shield-hp {
  display: flex;
  gap: 6px;
  font-size: 24px;
  filter: drop-shadow(0 0 8px var(--neon-pink));
}

.heart {
  transition: transform 0.2s ease;
}

#timer-display {
  font-size: 18px;
  font-weight: 700;
  color: var(--neon-blue);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
  background: rgba(0, 0, 0, 0.45);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(0, 240, 255, 0.2);
}

#round-hud {
  font-size: 18px;
  font-weight: 900;
  color: var(--neon-yellow);
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.6);
  background: rgba(0, 0, 0, 0.45);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 204, 0, 0.2);
}

.hud-right {
  display: flex;
  gap: 10px;
}

#buff-indicator {
  display: flex;
  gap: 10px;
}

.buff-badge {
  font-size: 11px;
  font-weight: bold;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(11, 13, 25, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  text-transform: uppercase;
  transition: all 0.3s ease;
  font-family: 'Noto Sans KR', sans-serif;
}

.buff-badge.active-stream {
  border-color: var(--neon-green);
  color: #fff;
  background: rgba(52, 199, 89, 0.2);
  box-shadow: 0 0 10px rgba(52, 199, 89, 0.3);
}

.buff-badge.active-speed {
  border-color: var(--neon-orange);
  color: #fff;
  background: rgba(255, 149, 0, 0.2);
  box-shadow: 0 0 10px rgba(255, 149, 0, 0.3);
}

.buff-badge.active-expr {
  border-color: var(--neon-pink);
  color: #fff;
  background: rgba(255, 0, 127, 0.2);
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.3);
}

.buff-badge.active-freeze {
  border-color: var(--neon-blue);
  color: #fff;
  background: rgba(0, 240, 255, 0.2);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.buff-badge.locked {
  opacity: 0.4;
}

/* 오버레이 화면 기본형 */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 10, 20, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 20;
}

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

/* 퀴즈 정지 상태 흑백화 필터 적용 타겟 */
.grayscale-blur {
  filter: grayscale(1) blur(4px);
}

/* 메인 메뉴 */
#main-menu {
  flex-direction: column;
  padding: 40px;
}

.glow-bg {
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.15) 0%, rgba(0,0,0,0) 70%);
  filter: blur(40px);
  z-index: -1;
  pointer-events: none;
}

.game-title {
  font-family: 'Orbitron', 'Noto Sans KR', sans-serif;
  font-size: 52px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 0 20px rgba(0, 240, 255, 0.6), 0 0 40px rgba(0, 240, 255, 0.2);
  margin-bottom: 8px;
}

.game-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  letter-spacing: 4px;
  margin-bottom: 40px;
}

.menu-content {
  display: flex;
  width: 100%;
  max-width: 960px;
  gap: 40px;
  z-index: 2;
}

.menu-left {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.menu-right {
  flex: 1;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 14px;
  color: var(--neon-blue);
  font-weight: bold;
}

.input-group input {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(0, 240, 255, 0.3);
  padding: 14px 20px;
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  outline: none;
  transition: all 0.3s ease;
}

.input-group input:focus {
  border-color: var(--neon-blue);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

.glow-btn {
  background: linear-gradient(135deg, var(--neon-blue) 0%, rgba(0, 150, 255, 0.8) 100%);
  border: none;
  padding: 16px 32px;
  border-radius: 8px;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
  transition: all 0.2s ease;
}

.glow-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.6);
}

.glow-btn:active {
  transform: translateY(1px);
}

.instructions {
  background: var(--panel-bg);
  border: 1px solid rgba(255,255,255,0.05);
  padding: 16px 20px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.instructions h3 {
  color: var(--text-primary);
  margin-bottom: 8px;
}

.instructions ul {
  list-style: none;
}

.instructions li {
  margin-bottom: 4px;
}

/* 명예의 전당 패널 */
.leaderboard-panel {
  background: var(--panel-bg);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 12px;
  padding: 24px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.leaderboard-panel h2 {
  font-size: 18px;
  color: var(--neon-yellow);
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 10px;
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.3);
}

#leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#leaderboard-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  font-size: 14px;
  border-left: 3px solid var(--text-secondary);
}

#leaderboard-list li.rank-1 { border-left-color: var(--neon-yellow); font-weight: bold; }
#leaderboard-list li.rank-2 { border-left-color: #d1d1d1; }
#leaderboard-list li.rank-3 { border-left-color: #cd7f32; }

/* 퀴즈 팝업 스타일 */
.quiz-box {
  background: rgba(13, 17, 34, 0.95);
  border: 2px solid var(--neon-blue);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.3), inset 0 0 15px rgba(0, 240, 255, 0.1);
  border-radius: 16px;
  width: 90%;
  max-width: 580px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

#quiz-category {
  font-size: 14px;
  font-weight: bold;
  color: var(--neon-blue);
  background: rgba(0, 240, 255, 0.1);
  padding: 4px 10px;
  border-radius: 6px;
}

#quiz-timer {
  font-family: 'Orbitron', sans-serif;
  font-size: 18px;
  font-weight: bold;
  color: var(--neon-pink);
  text-shadow: 0 0 8px rgba(255, 0, 127, 0.5);
}

.quiz-timer-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

#quiz-timer-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--neon-pink) 0%, var(--neon-blue) 100%);
  transition: width 0.1s linear;
}

/* 수식 컨테이너 */
#quiz-question-container {
  background: rgba(0, 0, 0, 0.45);
  border-radius: 8px;
  padding: 16px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#quiz-question-text {
  font-size: 16px;
  line-height: 1.5;
  color: #fff;
  text-align: center;
}

#quiz-math-formula {
  font-size: 22px;
  color: var(--neon-yellow);
  text-align: center;
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.25);
  padding: 4px 0;
}

.input-display {
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  font-size: 28px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  color: var(--neon-yellow);
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
  text-align: center;
  padding: 12px;
  letter-spacing: 2px;
  min-height: 58px;
}

/* 가상 키패드 */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.key-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  padding: 14px 0;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: 'Orbitron', sans-serif;
}

.key-btn:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.95);
}

.delete-btn {
  font-size: 14px;
  color: var(--neon-pink);
  font-family: 'Noto Sans KR', sans-serif;
}

.pass-btn {
  font-size: 14px;
  color: var(--neon-orange);
  background: rgba(255, 149, 0, 0.08);
  border-color: rgba(255, 149, 0, 0.2);
  font-family: 'Noto Sans KR', sans-serif;
}

.confirm-btn {
  grid-column: span 2;
  background: linear-gradient(135deg, var(--neon-green) 0%, #28a745 100%);
  border-color: var(--neon-green);
  font-family: 'Noto Sans KR', sans-serif;
}

.confirm-btn:active {
  background: #218838;
}

/* 게임오버 박스 */
.game-over-box {
  background: rgba(20, 10, 15, 0.95);
  border: 2px solid var(--neon-pink);
  box-shadow: 0 0 35px rgba(255, 0, 127, 0.3);
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  max-width: 450px;
  width: 90%;
  animation: scaleUp 0.3s ease;
}

.danger-title {
  font-size: 32px;
  color: var(--neon-pink);
  text-shadow: 0 0 15px rgba(255, 0, 127, 0.5);
  margin-bottom: 16px;
}

.final-score-text {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

#final-score {
  font-family: 'Orbitron', sans-serif;
  color: #fff;
  font-size: 24px;
  font-weight: bold;
}

/* 이펙트/애니메이션 유틸리티 */
.camera-shake {
  animation: shake 0.3s ease-in-out;
}

.red-flash::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 0, 0, 0.25);
  pointer-events: none;
  z-index: 100;
  animation: flashFade 0.4s ease-out forwards;
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  10%, 90% { transform: translate(-4px, 2px); }
  20%, 80% { transform: translate(4px, -2px); }
  30%, 70% { transform: translate(-4px, -2px); }
  40%, 60% { transform: translate(4px, 2px); }
  50% { transform: translate(-2px, 2px); }
}

@keyframes flashFade {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes scaleUp {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.animate-pulse {
  animation: pulse 1.5s infinite;
}
