/* ============================================
   머니디깅클럽 시뮬레이터 - 스타일시트
   CSS 클래스명은 js/ui.js와 정확히 매칭됨
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Noto+Sans+KR:wght@400;700;900&display=swap');

/* ============================================
   CSS Variables
   ============================================ */
:root {
  --bg: #0a0a1a;
  --bg-card: #14142b;
  --gold: #FFD700;
  --gold-dark: #B8960F;
  --text: #e0e0e0;
  --text-dim: #888;
  --safe: #4CAF50;
  --bold: #FF9800;
  --funny: #E91E63;
  --pixel-font: 'Press Start 2P', monospace;
  --game-font: 'Noto Sans KR', sans-serif;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--game-font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ============================================
   Game Container
   ============================================ */
#game-container {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
}

#game-canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 100%;
  max-height: 45vh;
  object-fit: contain;
  background: #1a1a2e;
}

#ui-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
#ui-layer > * { pointer-events: auto; }

#overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
@keyframes fadeOut { from{opacity:1} to{opacity:0} }
@keyframes slideUp { from{transform:translateY(100%);opacity:0} to{transform:translateY(0);opacity:1} }
@keyframes slideDown { from{transform:translateY(-30px);opacity:0} to{transform:translateY(0);opacity:1} }
@keyframes blink { 0%,49%{opacity:1} 50%,100%{opacity:0} }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.05)} }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)} 40%{transform:translateX(6px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)} }
@keyframes flash { 0%{opacity:1} 50%{opacity:0} 100%{opacity:1} }
@keyframes bounceIn { 0%{transform:scale(0.3);opacity:0} 50%{transform:scale(1.05)} 100%{transform:scale(1);opacity:1} }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
@keyframes fall { 0%{transform:translateY(-20px) rotate(0deg);opacity:1} 100%{transform:translateY(100vh) rotate(720deg);opacity:0} }
@keyframes glowPulse { 0%,100%{text-shadow:0 0 10px rgba(255,215,0,0.5)} 50%{text-shadow:0 0 30px rgba(255,215,0,0.8), 0 0 60px rgba(255,215,0,0.3)} }

/* ============================================
   UI Screens (Title, Select, Result)
   ============================================ */
.ui-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.92);
  z-index: 50;
  animation: fadeIn 0.4s ease;
}

/* ---- Title Screen ---- */
.title-content {
  text-align: center;
  padding: 24px;
  max-width: 480px;
  width: 100%;
}
.game-title {
  font-family: var(--pixel-font);
  font-size: clamp(14px, 4vw, 22px);
  color: var(--gold);
  line-height: 1.8;
  animation: glowPulse 3s infinite;
  margin-bottom: 16px;
}
.game-subtitle {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 32px;
}
.title-graphic {
  font-size: 48px;
  margin-bottom: 32px;
  animation: float 3s ease-in-out infinite;
}
.button-start {
  display: inline-block;
  padding: 14px 48px;
  font-family: var(--pixel-font);
  font-size: 12px;
  color: #000;
  background: var(--gold);
  border: none;
  cursor: pointer;
  box-shadow: 0 0 0 3px #000, 0 0 0 5px var(--gold);
  transition: all 0.2s;
  animation: pulse 2s infinite;
}
.button-start:hover { transform: scale(1.08); box-shadow: 0 0 0 3px #000, 0 0 0 5px var(--gold), 0 0 20px rgba(255,215,0,0.5); }
.button-start:active { transform: scale(0.95); }
.game-info {
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-dim);
}

/* ---- Sound Toggle Button ---- */
.title-bottom-info {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
}
.channel-info {
  font-size: 11px;
  color: var(--text-dim);
}
.sound-toggle {
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  color: var(--text-dim);
  font-family: var(--game-font);
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 120px;
  text-align: center;
}
.sound-toggle.sound-on {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(255,215,0,0.1);
  box-shadow: 0 0 8px rgba(255,215,0,0.2);
}
.sound-toggle.sound-off {
  border-color: rgba(255,255,255,0.15);
  color: var(--text-dim);
  background: rgba(255,255,255,0.05);
}
.sound-toggle:hover {
  transform: scale(1.05);
  border-color: var(--gold);
}
.sound-toggle:active {
  transform: scale(0.95);
}

/* 게임 중 상단 HUD 사운드 토글 */
.sound-hud {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 9999;
  font-size: 11px;
  padding: 6px 12px;
  min-width: auto;
  opacity: 0.7;
  transition: opacity 0.2s, transform 0.2s;
}
.sound-hud:hover {
  opacity: 1;
}

/* ---- Character Select Screen ---- */
.select-content {
  text-align: center;
  padding: 20px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.select-content h2 {
  font-family: var(--pixel-font);
  font-size: clamp(11px, 3vw, 16px);
  color: var(--gold);
  margin-bottom: 8px;
}
.select-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 20px;
}
.character-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.character-card {
  background: var(--bg-card);
  padding: 18px 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  box-shadow: 0 0 0 2px #222, 0 0 0 4px #444;
}
.character-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--gold);
}
.character-card:active { transform: scale(0.97); }
.char-emoji { font-size: 36px; margin-bottom: 8px; }
.char-name {
  font-family: var(--pixel-font);
  font-size: 10px;
  color: var(--gold);
  margin-bottom: 4px;
}
.char-role {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.char-desc {
  font-size: 12px;
  color: var(--text);
}

/* ---- Result Screen ---- */
.result-content {
  text-align: center;
  padding: 20px;
  max-width: 450px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.result-title {
  font-family: var(--pixel-font);
  font-size: 14px;
  color: var(--gold);
  margin-bottom: 20px;
}
.result-card {
  background: var(--bg-card);
  padding: 24px 16px;
  box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--gold);
  margin-bottom: 20px;
}
.result-grade {
  font-family: var(--pixel-font);
  font-size: clamp(20px, 6vw, 36px);
  color: var(--gold);
  margin-bottom: 12px;
  animation: bounceIn 0.6s ease;
}
.result-character { margin-bottom: 12px; }
.result-emoji { font-size: 40px; }
.result-name { font-size: 16px; font-weight: 700; margin-top: 4px; }
.result-data { text-align: left; }
.result-title-large {
  font-size: 18px;
  font-weight: 900;
  color: var(--gold);
  text-align: center;
  margin-bottom: 8px;
}
.result-rating, .result-viewers {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.result-personality {
  margin: 12px 0;
  padding: 10px;
  background: rgba(255,215,0,0.1);
  font-size: 13px;
  text-align: center;
}
.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}
.stat-item {
  background: rgba(255,255,255,0.05);
  padding: 8px;
  text-align: center;
}
.stat-label { font-size: 11px; color: var(--text-dim); display: block; }
.stat-value { font-size: 16px; font-weight: 800; color: var(--gold); }
.result-comments {
  margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 12px;
}
.comment {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
  line-height: 1.5;
}
.button-restart {
  padding: 12px 36px;
  font-family: var(--pixel-font);
  font-size: 10px;
  color: var(--gold);
  background: transparent;
  border: 2px solid var(--gold);
  cursor: pointer;
  transition: all 0.2s;
}
.button-restart:hover { background: rgba(255,215,0,0.1); transform: scale(1.05); }

/* ============================================
   Dialogue Box
   ============================================ */
.dialogue-box {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10,10,26,0.95);
  border-top: 3px solid var(--gold);
  padding: 16px 20px 20px;
  min-height: 100px;
  z-index: 30;
  animation: slideUp 0.3s ease;
  cursor: pointer;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.5);
}
.speaker-label {
  display: inline-block;
  padding: 4px 14px;
  font-family: var(--pixel-font);
  font-size: 9px;
  color: #000;
  font-weight: 700;
  margin-bottom: 10px;
  box-shadow: 0 0 0 2px #000;
}
.dialogue-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  word-break: keep-all;
  min-height: 48px;
}
.dialogue-indicator {
  position: absolute;
  bottom: 8px;
  right: 16px;
  color: var(--gold);
  font-size: 14px;
  animation: blink 1s infinite;
}

/* ============================================
   Choice Buttons
   ============================================ */
.choices-container {
  position: fixed;
  bottom: 120px;
  left: 0;
  right: 0;
  padding: 0 12px 12px;
  z-index: 35;
}
.choices-content {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.choices-content.slide-in {
  animation: slideUp 0.4s ease;
}
.choice-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 2px solid #333;
  color: var(--text);
  font-family: var(--game-font);
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  word-break: keep-all;
}
.choice-button:hover {
  border-color: var(--gold);
  background: rgba(255,215,0,0.08);
  transform: translateX(4px);
}
.choice-button:active { transform: scale(0.98); }
.choice-safe:hover { border-color: var(--safe); }
.choice-bold:hover { border-color: var(--bold); }
.choice-funny:hover { border-color: var(--funny); }
.mood-indicator { font-size: 16px; flex-shrink: 0; }
.choice-text { flex: 1; }

/* ============================================
   Progress Bar & Viewer Count (HUD)
   ============================================ */
.progress-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255,255,255,0.1);
  z-index: 40;
}
.progress-bar {
  height: 100%;
  background: var(--gold);
  transition: width 0.5s ease;
  width: 0;
}
.viewer-count-container {
  position: fixed;
  top: 6px;
  right: 12px;
  z-index: 40;
}
.viewer-count {
  font-family: var(--pixel-font);
  font-size: 8px;
  color: var(--text-dim);
  background: rgba(0,0,0,0.6);
  padding: 4px 8px;
}

/* ============================================
   Scene Transition
   ============================================ */
.scene-transition {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  animation: fadeIn 0.3s ease;
  transition: opacity 0.6s ease;
}
.transition-content { text-align: center; animation: bounceIn 0.5s ease; }
.transition-frame {
  padding: 24px 40px;
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 4px rgba(255,215,0,0.2);
}
.transition-part {
  font-family: var(--pixel-font);
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 4px;
  margin-bottom: 8px;
}
.transition-title {
  font-size: 18px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 6px;
}
.transition-section {
  font-size: 12px;
  color: var(--text-dim);
}

/* ============================================
   System Message
   ============================================ */
.system-message {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  background: rgba(20,20,43,0.9);
  border: 1px solid #333;
  font-size: 13px;
  color: var(--text-dim);
  z-index: 45;
  animation: slideDown 0.3s ease;
  transition: opacity 0.3s ease;
  max-width: 90%;
  text-align: center;
  word-break: keep-all;
}
.system-message.event {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(255,215,0,0.1);
}

/* ============================================
   Event Overlay
   ============================================ */
.event-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 55;
  animation: fadeIn 0.3s ease;
  transition: opacity 0.3s ease;
}
.event-content {
  font-family: var(--pixel-font);
  font-size: clamp(11px, 3vw, 16px);
  color: var(--gold);
  text-align: center;
  padding: 20px;
  line-height: 2;
  animation: bounceIn 0.5s ease;
}
.event-shake { animation: shake 0.5s ease; }
.event-flash .event-content { animation: flash 0.3s ease 3; }

/* Confetti */
.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  top: 0;
  animation: fall 2.5s linear forwards;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 480px) {
  .dialogue-box { padding: 12px 14px 16px; min-height: 80px; }
  .dialogue-text { font-size: 13px; }
  .choice-button { font-size: 13px; padding: 10px 12px; }
  .choices-container { bottom: 96px; }
  .character-grid { gap: 8px; }
  .character-card { padding: 14px 8px; }
  .char-emoji { font-size: 28px; }
}

@media (min-width: 768px) {
  #game-canvas { max-height: 55vh; }
  .dialogue-box { max-width: 700px; left: 50%; transform: translateX(-50%); border-radius: 0; }
  .choices-container { max-width: 700px; left: 50%; transform: translateX(-50%); }
}
