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

body {
  overflow: hidden;
  background: #0a0a1a;
  font-family: 'Inter', sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* ── HUD ── */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  pointer-events: none;
  z-index: 10;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100vh;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.hud-stat {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.5);
}

.hud-value {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
}

/* ── Fill Bar ── */
.hud-fill {
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.fill-bar {
  width: 8px;
  height: 200px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.fill-bar-inner {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, #44ff88, #88ffcc);
  border-radius: 4px;
  transition: height 0.3s ease;
  box-shadow: 0 0 12px rgba(68, 255, 136, 0.5);
}

.fill-text {
  font-size: 12px;
  font-weight: 600;
  color: #44ff88;
}

/* ── Bottom Controls ── */
.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: auto;
}

.type-selector {
  display: flex;
  gap: 8px;
}

.type-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 8px 14px;
  color: rgba(255, 255, 255, 0.6);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.type-btn.selected {
  border-color: #44ff88;
  color: #fff;
  background: rgba(68, 255, 136, 0.15);
}

.type-btn:active {
  transform: scale(0.95);
}

.type-icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.steel-icon { background: #8899aa; border-radius: 2px; }
.glass-icon { background: #88ccff; opacity: 0.7; }
.jelly-icon { background: #ff66aa; }

/* ── Upgrades ── */
.upgrade-bar {
  display: flex;
  gap: 8px;
}

.upgrade-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upgrade-btn:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.1);
}

.upgrade-btn:active {
  transform: scale(0.9);
}

/* ── Current Type Badge ── */
.current-type-badge {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
}

.current-type-badge[data-type="steel"] { color: #8899aa; }
.current-type-badge[data-type="glass"] { color: #88ccff; }
.current-type-badge[data-type="jelly"] { color: #ff66aa; }

/* ── Danger Overlay ── */
.danger-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.danger-overlay.active {
  opacity: 1;
  animation: danger-pulse 0.5s ease-in-out infinite alternate;
}

.danger-label {
  font-size: 36px;
  font-weight: 800;
  color: #ff4444;
  text-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
  margin-bottom: 12px;
}

.danger-bar {
  width: 200px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 auto 8px;
}

.danger-bar-inner {
  width: 0%;
  height: 100%;
  background: linear-gradient(to right, #ff4444, #ff8844);
  border-radius: 3px;
  transition: width 0.1s linear;
}

.danger-text {
  font-size: 14px;
  color: rgba(255, 68, 68, 0.8);
  font-weight: 600;
}

@keyframes danger-pulse {
  from { transform: translate(-50%, -50%) scale(1); }
  to { transform: translate(-50%, -50%) scale(1.05); }
}

/* ── Game Overlay (Win/Lose) ── */
.game-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.game-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.overlay-title {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: 4px;
  text-align: center;
}

.overlay-title.win {
  color: #44ff88;
  text-shadow: 0 0 30px rgba(68, 255, 136, 0.5);
}

.overlay-title.lose {
  color: #ff4444;
  text-shadow: 0 0 30px rgba(255, 68, 68, 0.5);
}

.overlay-score {
  font-size: 20px;
  margin-top: 16px;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
}

.overlay-subtext {
  font-size: 14px;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
}

/* ── Loading ── */
.loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0a0a1a;
  gap: 20px;
  transition: opacity 0.5s ease;
}

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

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #44ff88;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loader-text {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
}

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

/* ── Mobile Adjustments ── */
@media (max-width: 640px) {
  .hud-value { font-size: 18px; }
  .type-btn { padding: 6px 10px; font-size: 11px; }
  .upgrade-btn { width: 38px; height: 38px; font-size: 16px; }
  .overlay-title { font-size: 32px; }
  .fill-bar { height: 150px; }
}
