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

body {
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #1a1614;
  color: #f5ede4;
  width: 100vw;
  height: 100vh;
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Glassmorphism Panel */
.glass-panel {
  background: rgba(28, 22, 18, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(230, 200, 160, 0.22);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* Header */
#header {
  position: absolute;
  top: 18px;
  left: 22px;
  z-index: 10;
  padding: 12px 20px;
  pointer-events: auto;
}

#header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #ffdda1;
  display: flex;
  align-items: center;
  gap: 10px;
}

#header .subtitle {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: #c4b09b;
  text-transform: uppercase;
  margin-top: 3px;
}

/* Controls Panel */
#ui-container {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 320px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  z-index: 10;
  padding: 18px;
  pointer-events: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(220, 180, 130, 0.4) transparent;
}

#ui-container::-webkit-scrollbar {
  width: 5px;
}

#ui-container::-webkit-scrollbar-thumb {
  background: rgba(220, 180, 130, 0.4);
  border-radius: 4px;
}

.panel-section {
  margin-bottom: 18px;
}

.panel-section:last-child {
  margin-bottom: 0;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: #ffcaa0;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.btn-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

button.ui-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(240, 200, 160, 0.2);
  color: #e8d8c8;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}

button.ui-btn:hover {
  background: rgba(240, 180, 100, 0.25);
  border-color: rgba(255, 210, 140, 0.5);
  color: #fff;
  transform: translateY(-1px);
}

button.ui-btn.active {
  background: linear-gradient(135deg, #e08b34, #b86214);
  border-color: #ffd28c;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(224, 139, 52, 0.4);
}

/* Sliders */
.slider-group {
  margin-top: 10px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #d8c2ad;
  margin-bottom: 6px;
}

.slider-value {
  font-weight: 700;
  color: #ffcc88;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffaa44;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #ffbb66;
}

/* Switches / Toggles */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
  color: #d8c2ad;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.18);
  transition: 0.3s;
  border-radius: 20px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: #e08b34;
}

input:checked + .toggle-slider:before {
  transform: translateX(18px);
}

/* HUD Info Bar (Bottom Left) */
#hud {
  position: absolute;
  bottom: 18px;
  left: 22px;
  z-index: 10;
  padding: 12px 18px;
  display: flex;
  gap: 20px;
  font-size: 11px;
}

.hud-item {
  display: flex;
  flex-direction: column;
}

.hud-label {
  color: #9d8b79;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 9px;
  margin-bottom: 2px;
}

.hud-value {
  color: #ffd8a0;
  font-weight: 700;
  font-size: 13px;
}

/* Instructions / Hints (Bottom Center) */
#hints {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 8px 16px;
  font-size: 11px;
  color: #c2b19e;
  letter-spacing: 0.5px;
  pointer-events: none;
  opacity: 0.85;
}

/* Loading Overlay */
#loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #14100d;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.6s ease, visibility 0.6s;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(230, 160, 60, 0.2);
  border-top-color: #f59e0b;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

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

.loader-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #ffdda1;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.loader-status {
  font-size: 12px;
  color: #ad9a85;
}

/* Responsive tweaks */
@media (max-width: 768px) {
  #ui-container {
    width: calc(100vw - 32px);
    right: 16px;
    top: auto;
    bottom: 16px;
    max-height: 45vh;
  }
  #header {
    top: 12px;
    left: 12px;
  }
  #hud, #hints {
    display: none;
  }
}
