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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
  background: #1a1a2e;
  color: #fff;
  width: 100vw;
  height: 100vh;
}

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Menu */
.menu-content {
  text-align: center;
}
.menu-content h1 {
  font-size: 48px;
  margin-bottom: 8px;
  text-shadow: 0 4px 20px rgba(255,100,50,0.4);
}
.menu-subtitle {
  font-size: 18px;
  color: #aaa;
  margin-bottom: 32px;
}
.level-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 900px;
}
.level-btn {
  width: 160px;
  padding: 20px 16px;
  border: 2px solid #444;
  border-radius: 12px;
  background: #222;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.level-btn:hover:not(.locked) {
  border-color: #ff5722;
  background: #2a1a1a;
  transform: translateY(-2px);
}
.level-btn.locked {
  opacity: 0.4;
  cursor: not-allowed;
}
.level-btn .level-num { font-size: 28px; display: block; margin-bottom: 4px; }
.level-btn .level-name { font-size: 14px; color: #aaa; }
.level-btn.free-mode-btn {
  border-color: #4caf50;
  background: linear-gradient(135deg, #1b2e1b, #1a3a2a);
}
.level-btn.free-mode-btn:hover {
  border-color: #81c784;
  background: linear-gradient(135deg, #2b3e2b, #1a4a3a);
  transform: translateY(-2px);
}

/* Top bar */
#top-bar {
  position: absolute;
  top: 0; left: 164px; right: 0;
  height: 40px;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 20px;
  z-index: 10;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.btn-top-back {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 7px;
  color: #fff;
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  line-height: 1.1;
  transition: background 0.15s, border-color 0.15s;
}
.btn-top-back:hover {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.3);
}
.stat { font-size: 14px; white-space: nowrap; }
.stat span { font-weight: 600; }
.stat.timer { margin-left: auto; color: #ff9800; }
.btn-audio {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: #fff;
  font-size: 16px;
  width: 30px;
  height: 26px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: background 0.15s;
}
.btn-audio:hover { background: rgba(255,255,255,0.1); }

/* Speed controls */
#speed-controls {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-left: 8px;
}
.btn-speed {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 5px;
  color: #ccc;
  font-size: 12px;
  padding: 2px 7px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-speed:hover { background: rgba(255,255,255,0.15); color: #fff; }
.btn-speed.active { background: #ff6b35; border-color: #ff6b35; color: #fff; font-weight: 600; }

/* Data panel categories */
.data-category {
  font-size: 11px;
  color: #ff9800;
  font-weight: 600;
  padding: 6px 0 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 2px;
}
.data-category:first-child { border-top: none; margin-top: 0; padding-top: 0; }

/* Sidebar */
#sidebar {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 164px;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  z-index: 10;
  padding: 8px;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,0.1);
}
.sidebar-section { margin-bottom: 14px; }
.sidebar-title {
  font-size: 10px;
  color: #ffcc80;
  text-align: left;
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding-left: 4px;
}
.facility-group { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.facility-item {
  width: 100%;
  min-height: 52px;
  border: 2px solid #444;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(52,52,73,0.95), rgba(34,34,48,0.95));
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  padding: 7px 9px;
}
.facility-item:hover { border-color: #ff8a65; background: linear-gradient(180deg, rgba(66,44,42,0.98), rgba(50,30,30,0.98)); }
.facility-item.selected { border-color: #ff5722; background: linear-gradient(180deg, rgba(92,44,40,0.98), rgba(68,34,30,0.98)); box-shadow: 0 0 12px rgba(255,87,34,0.32); }
.facility-item .icon { font-size: 24px; line-height: 1; flex: 0 0 auto; }
.facility-item.disabled { opacity: 0.3; pointer-events: none; }
.facility-main {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
}
.facility-name {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

/* Scene container */
#scene-container {
  position: absolute;
  top: 40px; left: 164px; right: 0; bottom: 0;
}

/* Panels */
.panel {
  position: absolute;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  z-index: 10;
}
.panel-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toggle {
  font-size: 11px;
  color: #888;
  cursor: pointer;
}
.toggle:hover { color: #fff; }

#objectives-panel {
  top: 52px; right: 12px;
  min-width: 180px;
}
.objective-item {
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.objective-item.done { color: #4caf50; }
.objective-item .check { width: 14px; }

#data-panel {
  bottom: 12px; right: 12px;
  min-width: 240px;
  max-height: 300px;
  overflow-y: auto;
}

#satisfaction-debug-panel {
  left: 176px;
  bottom: 12px;
  min-width: 220px;
  max-width: 280px;
  max-height: 320px;
  overflow: auto;
  resize: both;
}

.debug-panel {
  user-select: none;
}

.debug-panel-header {
  cursor: default;
  margin-bottom: 0;
  gap: 12px;
}

.debug-panel.collapsed {
  padding-bottom: 10px;
}

.debug-panel.collapsed #satisfaction-debug-content {
  display: none !important;
}

.debug-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  font-size: 12px;
}

.debug-line .debug-label {
  color: #cfd8dc;
}

.debug-line .debug-value.pos {
  color: #81c784;
}

.debug-line .debug-value.neg {
  color: #ef9a9a;
}

.debug-line.total {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-weight: 700;
}
.data-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.data-row .label { color: #aaa; }

/* Controls */
#controls {
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 10;
}

/* Buttons */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
  background: #444;
}
.btn:hover { filter: brightness(1.2); transform: translateY(-1px); }
.btn-primary { background: #ff5722; }
.btn-warning { background: #ff9800; }
.btn-danger { background: #f44336; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-content {
  background: #1e1e2e;
  border: 1px solid #444;
  border-radius: 12px;
  padding: 24px;
  min-width: 320px;
  max-width: 400px;
  text-align: center;
}
.modal-content h2 { font-size: 24px; margin-bottom: 16px; }
.modal-content h3 { font-size: 18px; margin-bottom: 12px; }
.modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}
.price-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #aaa;
  margin-bottom: 12px;
}
.price-slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.price-slider-wrap input[type="range"] {
  flex: 1;
  accent-color: #ff5722;
}
.price-current { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.price-willingness { font-size: 13px; color: #aaa; }

/* Result modal */
#result-title.win { color: #4caf50; }
#result-title.lose { color: #f44336; }
#result-details { text-align: left; padding: 0 8px; }
#result-details .result-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #333;
}

/* Guide overlay */
#guide-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
#guide-box {
  background: #1e1e2e;
  border: 2px solid #ff5722;
  border-radius: 12px;
  padding: 24px 32px;
  max-width: 400px;
  text-align: center;
}
#guide-text { font-size: 16px; line-height: 1.6; margin-bottom: 16px; }

/* Floating text animation */
.float-text {
  position: absolute;
  font-size: 14px;
  font-weight: 700;
  color: #4caf50;
  pointer-events: none;
  animation: floatUp 1s ease-out forwards;
  z-index: 50;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-40px); }
}

/* Stat change animation */
.stat-bump {
  animation: bump 0.3s ease;
}
@keyframes bump {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); color: #ff5722; }
  100% { transform: scale(1); }
}
