:root {
  --bg-dark: #0a0e1a;
  --panel-bg: rgba(12, 16, 28, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --accent: #22d3ee;
  --accent-hover: #06b6d4;
  --accent-glow: rgba(34, 211, 238, 0.4);
  --text-main: #f0f4f8;
  --text-muted: #8892a4;
  --card-bg: rgba(12, 15, 24, 0.9);
  --card-border: rgba(255, 255, 255, 0.08);
  --font-family: 'Noto Sans KR', sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

.app-container {
  width: 100%;
  max-width: 1600px;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 16px;
}

/* Header Styles */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-family);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.principle-btn {
  background: rgba(34, 211, 238, 0.08);
  color: var(--accent);
  border-color: rgba(34, 211, 238, 0.3);
}

.principle-btn:hover {
  background: rgba(34, 211, 238, 0.15);
  border-color: rgba(34, 211, 238, 0.5);
  box-shadow: 0 0 15px rgba(34, 211, 238, 0.2);
}

.title-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  background-color: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-glow), 0 0 20px var(--accent-glow);
}

.title-container h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Tabs */
.tab-group {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 4px;
  border: 1px solid var(--panel-border);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 24px;
  border-radius: 6px;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--accent);
  color: #0a0e1a;
  font-weight: 700;
  box-shadow: 0 4px 15px var(--accent-glow);
}

/* Main Content */
.main-content {
  display: flex;
  flex: 1;
  gap: 16px;
  height: calc(100% - 80px);
}

/* Simulation Panel (Left) */
.simulation-panel {
  flex: 1;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.canvas-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#spaceCanvas {
  cursor: grab;
}

#spaceCanvas:active {
  cursor: grabbing;
}

.hint-overlay {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--panel-border);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
  backdrop-filter: blur(4px);
}

.hint-dot {
  width: 6px;
  height: 6px;
  background-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
}

/* Observer View Overlay */
.observer-view {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 320px;
  height: 240px;
  background: #020308;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 20;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
}

.observer-view.expanded {
  top: 16px;
  left: 16px;
  right: 16px;
  bottom: 16px;
  width: auto;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
  border-color: rgba(34, 211, 238, 0.3);
}

.observer-header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 8px 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.85), transparent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: auto;
}

.observer-expand-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.observer-expand-btn:hover {
  background: rgba(34, 211, 238, 0.2);
  border-color: rgba(34, 211, 238, 0.5);
}

/* Control Panel (Right) */
.control-panel {
  width: 380px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-card, .info-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 20px;
  backdrop-filter: blur(10px);
}

.card-header {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid rgba(34, 211, 238, 0.3);
}

/* Slider Controls */
.control-group {
  margin-bottom: 20px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.val-text {
  color: var(--text-main);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  margin-top: -6px;
  box-shadow: 0 0 10px var(--accent-glow);
}

input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

input[type=range]:focus {
  outline: none;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.action-btn {
  flex: 1;
  padding: 10px 0;
  border: none;
  border-radius: 6px;
  font-family: var(--font-family);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn.primary {
  background: var(--accent);
  color: #0a0e1a;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.action-btn.primary:hover {
  background: var(--accent-hover);
}

.action-btn.secondary {
  background: transparent;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.action-btn.secondary:hover {
  background: rgba(34, 211, 238, 0.06);
  border-color: rgba(34, 211, 238, 0.25);
}

/* Info Card */
.info-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.info-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.info-row:first-child {
  padding-top: 0;
}

.info-row .highlight {
  color: #fff;
  font-weight: 700;
}

/* Principle Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 7, 15, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: rgba(14, 18, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  padding: 28px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6),
              inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transform: translateY(0) scale(1);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
}

.modal-backdrop.hidden .modal-content {
  transform: translateY(30px) scale(0.95);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 14px;
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  transition: color 0.2s, transform 0.2s;
  line-height: 1;
}

.close-btn:hover {
  color: #fff;
  transform: rotate(90deg);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.modal-body h3 {
  color: var(--accent);
  font-size: 1.05rem;
  margin-bottom: 4px;
  font-weight: 700;
}

.modal-body p {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.7;
  font-weight: 400;
}

.modal-body hr {
  border: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
}

.btn-toggle-panel {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle-panel:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* RESPONSIVE SCALING */
@media (max-width: 1024px) {
  body {
    overflow-y: auto;
    height: auto;
    padding: 8px;
  }
  
  .app-container {
    height: auto;
    padding: 8px;
    gap: 8px;
  }
  
  .app-header {
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    text-align: center;
  }
  
  .header-left {
    width: 100%;
    justify-content: space-between;
  }
  
  .header-center {
    width: 100%;
    display: flex;
    justify-content: center;
  }
  
  .tab-group {
    width: 100%;
  }
  
  .tab-btn {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.85rem;
  }
  
  .header-right {
    width: 100%;
  }
  
  .principle-btn {
    width: 100%;
    justify-content: center;
  }
  
  .main-content {
    flex-direction: column;
    height: auto;
    gap: 8px;
  }
  
  .simulation-panel {
    height: 380px;
    flex: none;
  }
  
  .observer-view {
    width: 160px;
    height: 120px;
    bottom: 8px;
    right: 8px;
  }
  
  .observer-view.expanded {
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    height: auto;
  }
  
  .hint-overlay {
    font-size: 0.72rem;
    padding: 4px 10px;
    top: 12px;
    width: 90%;
    justify-content: center;
  }
  
  .control-panel {
    width: 100%;
    gap: 8px;
  }
  
  .control-card, .info-card {
    padding: 16px;
  }
  
  .btn-toggle-panel {
    display: block;
  }
  
  .control-card.collapsed .card-body {
    display: none !important;
  }
  
  .control-card.collapsed {
    padding-bottom: 12px;
  }
  
  input[type=range] {
    touch-action: none;
  }
}
