/* ========================================
   구슬 굴리기 미궁 (Marble Maze) - Styles
   ======================================== */

@font-face {
  font-family: 'Galmuri11';
  src: url('assets/fonts/Galmuri11.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Galmuri11';
  src: url('assets/fonts/Galmuri11-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0a0e1a;
  --panel-bg: rgba(15, 23, 42, 0.95);
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.4);
  --gold: #fbbf24;
  --gold-glow: rgba(251, 191, 36, 0.4);
  --success: #10b981;
  --danger: #ef4444;
  --text: #f1f5f9;
  --subtext: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Galmuri11', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Canvas */
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Back Button */
.back-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--subtext);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.back-btn:hover {
  color: #fff;
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--accent);
  transform: translateX(-2px);
}

/* WebGL Error */
#webgl-error {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.error-card {
  max-width: 480px;
  padding: 40px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  text-align: center;
}

.error-card h2 {
  color: var(--danger);
  margin-bottom: 16px;
}

.error-card p {
  color: var(--subtext);
  margin-bottom: 20px;
}

.error-card ul {
  text-align: left;
  color: var(--subtext);
  margin-bottom: 24px;
  padding-left: 24px;
}

.error-card li {
  margin-bottom: 8px;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.back-link:hover {
  text-decoration: underline;
}

/* Overlay Base */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 14, 26, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Menu Panel */
.menu-panel {
  max-width: 520px;
  width: 100%;
  padding: 40px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.menu-badge {
  display: inline-block;
  padding: 6px 14px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.menu-title {
  font-size: 36px;
  font-weight: 900;
  background: linear-gradient(135deg, #fff 30%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
}

.menu-sub {
  color: var(--subtext);
  font-size: 15px;
  margin-bottom: 28px;
}

.menu-controls {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 24px;
  text-align: left;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--subtext);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.control-row:last-child {
  border-bottom: none;
}

.key-group {
  display: inline-flex;
  gap: 4px;
}

kbd {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.control-desc {
  margin-left: auto;
  color: var(--text);
  font-weight: 600;
}

.menu-stats {
  margin-bottom: 24px;
  padding: 16px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 12px;
  font-size: 14px;
  color: var(--gold);
}

.menu-stats:empty {
  display: none;
}

.menu-btn {
  width: 100%;
  padding: 16px 24px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.menu-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.menu-btn.ghost {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--subtext);
}

.menu-btn.ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent);
  color: #fff;
  box-shadow: none;
}

.menu-note {
  font-size: 12px;
  color: #64748b;
  margin-top: 8px;
}

/* Stage Select */
.stage-select-panel {
  max-width: 700px;
  width: 100%;
  padding: 32px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  text-align: center;
}

.stage-select-panel h2 {
  font-size: 24px;
  margin-bottom: 24px;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stage-card {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stage-card:hover:not(.locked) {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
  transform: translateY(-2px);
}

.stage-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.stage-card.cleared {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

.stage-card .stage-num {
  font-size: 24px;
  font-weight: 900;
}

.stage-card .stage-stars {
  font-size: 12px;
  color: var(--gold);
}

.stage-card .stage-time {
  font-size: 10px;
  color: var(--subtext);
}

/* Clear Panel */
.clear-panel {
  max-width: 440px;
  width: 100%;
  padding: 40px;
  background: var(--panel-bg);
  border: 1px solid var(--success);
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 0 40px rgba(16, 185, 129, 0.2);
}

.clear-badge {
  display: inline-block;
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--success), #059669);
  border-radius: 99px;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 1px;
  margin-bottom: 16px;
  animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 0 40px rgba(16, 185, 129, 0.6); }
}

.clear-panel h2 {
  font-size: 28px;
  margin-bottom: 24px;
}

.clear-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}

.stat-item {
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--subtext);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
}

.new-record {
  grid-column: span 2;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 16px;
  font-weight: 800;
  animation: bounce 0.5s ease;
}

@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.clear-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Complete Panel */
.complete-panel {
  max-width: 500px;
  width: 100%;
  padding: 48px;
  background: var(--panel-bg);
  border: 2px solid var(--gold);
  border-radius: 28px;
  text-align: center;
  box-shadow: 0 0 60px var(--gold-glow);
}

.complete-badge {
  font-size: 18px;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 16px;
  animation: pulse-glow-gold 1.5s ease-in-out infinite;
}

@keyframes pulse-glow-gold {
  0%, 100% { text-shadow: 0 0 20px var(--gold-glow); }
  50% { text-shadow: 0 0 40px var(--gold-glow); }
}

.complete-panel h1 {
  font-size: 40px;
  margin-bottom: 12px;
}

.complete-sub {
  color: var(--subtext);
  margin-bottom: 32px;
}

.complete-stats {
  margin-bottom: 32px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
}

.stat-row span:last-child {
  font-weight: 700;
  color: var(--gold);
}

.complete-buttons {
  display: flex;
  gap: 12px;
}

.complete-buttons .menu-btn {
  flex: 1;
}

/* Pause Panel */
.pause-panel {
  max-width: 360px;
  width: 100%;
  padding: 40px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  text-align: center;
}

.pause-panel h2 {
  font-size: 28px;
  margin-bottom: 28px;
}

.pause-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Gameover Panel */
.gameover-panel {
  max-width: 380px;
  width: 100%;
  padding: 40px;
  background: var(--panel-bg);
  border: 1px solid var(--danger);
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.2);
}

.gameover-panel h2 {
  font-size: 32px;
  color: var(--danger);
  margin-bottom: 12px;
}

.gameover-panel p {
  color: var(--subtext);
  margin-bottom: 28px;
}

.gameover-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Responsive */
@media (max-width: 600px) {
  .menu-panel, .clear-panel, .complete-panel {
    padding: 28px 20px;
  }

  .menu-title {
    font-size: 28px;
  }

  .clear-stats {
    grid-template-columns: 1fr;
  }

  .complete-buttons {
    flex-direction: column;
  }

  .back-btn {
    top: 10px;
    left: 10px;
    padding: 8px 12px;
    font-size: 12px;
  }
}
