* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', Verdana, Arial, sans-serif;
  background: #1b2430;
  color: #eef2f8;
}

#scene-container {
  position: fixed;
  inset: 0;
  cursor: grab;
}
#scene-container canvas { display: block; }

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

#title-bar {
  pointer-events: none;
  text-align: center;
  padding: 14px 0 4px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
.title-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

#scoreboard {
  pointer-events: auto;
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(15, 20, 30, 0.72);
  border: 1px solid rgba(120,160,220,0.35);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 150px;
  backdrop-filter: blur(4px);
}
.score-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  padding: 2px 0;
}
.score-label { opacity: 0.85; }

.corner-btn {
  pointer-events: auto;
  position: absolute;
  top: 14px;
  right: 14px;
  background: linear-gradient(#3a6ea5, #2a5484);
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,0.35);
}
.corner-btn:hover { background: linear-gradient(#4a7eb5, #3a6494); }

#narration {
  pointer-events: none;
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,20,30,0.75);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  min-height: 14px;
  opacity: 0;
  transition: opacity 0.25s;
}
#narration:not(:empty) { opacity: 1; }
#narration.flash { opacity: 1; }

#processing {
  pointer-events: none;
  position: absolute;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: 260px;
}
#processing.hidden { display: none; }
#processing-label {
  font-size: 14px;
  font-weight: 600;
  color: #ffd866;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
  margin-bottom: 6px;
  animation: blinker 1s linear infinite;
}
@keyframes blinker { 50% { opacity: 0.35; } }
.dots span { animation: dotfade 1.2s infinite; opacity: 0; }
.dots span:nth-child(1) { animation-delay: 0s; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotfade { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }

#progress-bar {
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.2);
}
#progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #66ffcc, #3a9dff);
  transition: width 0.15s linear;
}

#manual-hint {
  pointer-events: none;
  position: absolute;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  opacity: 0.45;
  transition: opacity 0.2s, color 0.2s;
}
#manual-hint.active {
  opacity: 1;
  color: #66ffcc;
  font-weight: 600;
}

#taskbar {
  pointer-events: auto;
  position: absolute;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
}
.task-btn {
  background: linear-gradient(#eef2f8, #cfd8e6);
  color: #182233;
  border: none;
  border-radius: 12px;
  padding: 14px 22px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: transform 0.1s;
}
.task-btn:hover { transform: translateY(-2px); }
.task-btn:active { transform: translateY(1px); }

#controls-hint {
  pointer-events: none;
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  opacity: 0.55;
  text-align: center;
  width: 90%;
}

#shop-panel {
  pointer-events: auto;
  position: absolute;
  top: 70px;
  right: 14px;
  width: 300px;
  max-height: 70vh;
  overflow-y: auto;
  background: rgba(15, 20, 30, 0.92);
  border: 1px solid rgba(120,160,220,0.35);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
#shop-panel.hidden { display: none; }
#shop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
#shop-close {
  background: none;
  border: none;
  color: #eef2f8;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.7;
}
#shop-close:hover { opacity: 1; }

.shop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.shop-row:last-child { border-bottom: none; }
.shop-name { font-weight: 600; font-size: 13px; }
.shop-level { opacity: 0.6; font-size: 11px; font-weight: 400; }
.shop-desc { font-size: 11px; opacity: 0.65; margin-top: 2px; max-width: 170px; }
.buy-btn {
  background: linear-gradient(#66ffcc, #33cc9a);
  color: #0a2a20;
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.buy-btn:disabled {
  background: #445;
  color: #99a;
  cursor: default;
}

@media (max-width: 640px) {
  #shop-panel { width: 86vw; right: 7vw; }
  .task-btn { padding: 12px 14px; font-size: 14px; }
  #taskbar { gap: 8px; }
}
