/* Reset and Base Layout */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #141a16;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #f8fafc;
}

/* 3D WebGL Canvas Layer */
#webgl-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
  touch-action: none;
  cursor: grab;
}

#webgl-canvas:active {
  cursor: grabbing;
}

/* 2D Impact Comic Popup Overlay */
#popup-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.comic-popup {
  position: absolute;
  font-family: "Impact", "Arial Black", sans-serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 
    3px 3px 0 #000,
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    0 4px 15px rgba(0, 0, 0, 0.7);
  animation: comicExplode 0.55s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  pointer-events: none;
  will-change: transform, opacity;
}

@keyframes comicExplode {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.35);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -75%) scale(0.85);
  }
}

/* HUD Overlay */
#hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 1.5rem;
  z-index: 5;
  pointer-events: none;
}

/* Top Bar */
.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(12px);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.brand-icon {
  font-size: 1.3rem;
}

.brand-title {
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.45rem 0.9rem;
  border-radius: 9999px;
  backdrop-filter: blur(8px);
}

/* Slap Counter Card - Positioned in Bottom-Left Corner for 100% face visibility */
.counter-card {
  position: absolute;
  bottom: 1.5rem;
  left: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: rgba(15, 23, 42, 0.84);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 1.25rem;
  padding: 0.95rem 1.35rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 35px rgba(56, 189, 248, 0.12);
  pointer-events: auto;
  z-index: 10;
  min-width: 210px;
}

.counter-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #94a3b8;
  margin-bottom: 0.15rem;
}

.counter-number {
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: transform 0.1s ease;
  will-change: transform;
}

.counter-number.bump {
  animation: counterBump 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes counterBump {
  0% { transform: scale(1); }
  50% { transform: scale(1.22); color: #38bdf8; }
  100% { transform: scale(1); }
}

/* Stress Relief Progress Meter */
.stress-meter-container {
  width: 100%;
  margin-top: 0.55rem;
}

.stress-bar {
  width: 100%;
  height: 7px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  overflow: hidden;
}

.stress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #f43f5e, #fbbf24, #10b981);
  border-radius: 9999px;
  transition: width 0.35s ease;
}

.stress-text {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 0.3rem;
  text-align: left;
  font-weight: 600;
}

/* Bottom Controls - Positioned in Bottom-Right Corner */
.hud-footer {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.7rem;
  pointer-events: none;
  z-index: 10;
}

.instruction-pill {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(12px);
  padding: 0.55rem 1rem;
  border-radius: 9999px;
  font-size: 0.82rem;
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hud-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  pointer-events: auto;
}

.hud-btn {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f8fafc;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
  backdrop-filter: blur(8px);
}

.hud-btn:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.hud-btn:active {
  transform: translateY(1px);
}

.hud-btn.active {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.hud-btn-subtle {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

/* Splash / Start Screen Overlay - True Ice Slush Aesthetic */
.splash-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 15% 15%, rgba(255, 255, 255, 0.92) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(56, 189, 248, 0.78) 0%, transparent 45%),
    radial-gradient(circle at 50% 40%, rgba(186, 230, 253, 0.7) 0%, transparent 55%),
    radial-gradient(circle at 20% 80%, rgba(14, 165, 233, 0.58) 0%, transparent 50%),
    linear-gradient(135deg, #dbeafe 0%, #bae6fd 25%, #7dd3fc 50%, #38bdf8 75%, #0284c7 100%);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 50;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  padding: 1.5rem;
}

.splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-card {
  max-width: 460px;
  width: 100%;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.82) 0%, rgba(240, 249, 255, 0.65) 50%, rgba(224, 242, 254, 0.78) 100%);
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 1.8rem;
  padding: 2.2rem;
  text-align: center;
  box-shadow: 
    0 25px 60px rgba(2, 132, 199, 0.35), 
    0 0 50px rgba(255, 255, 255, 0.65), 
    inset 0 2px 4px rgba(255, 255, 255, 1.0),
    inset 0 -2px 4px rgba(56, 189, 248, 0.3);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.splash-icon {
  font-size: 3.2rem;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 0 16px rgba(56, 189, 248, 0.6));
}

.splash-title {
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #0369a1 0%, #0284c7 45%, #075985 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.6rem;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.splash-desc {
  font-size: 0.96rem;
  color: #0c4a6e;
  line-height: 1.55;
  font-weight: 500;
  margin-bottom: 1.5rem;
}

.tech-specs {
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 1rem;
  padding: 0.9rem 1.2rem;
  margin-bottom: 1.75rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.8), 0 4px 15px rgba(2, 132, 199, 0.08);
}

.spec-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.84rem;
  color: #075985;
  font-weight: 600;
}

.spec-dot {
  width: 8px;
  height: 8px;
  background: #0284c7;
  border-radius: 9999px;
  box-shadow: 0 0 8px #38bdf8;
}

.start-button {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  background: linear-gradient(135deg, #0284c7 0%, #0ea5e9 50%, #38bdf8 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 1px;
  padding: 1.05rem 1.6rem;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 1rem;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(2, 132, 199, 0.45), inset 0 2px 2px rgba(255, 255, 255, 0.6);
  transition: all 0.2s ease;
}

.start-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(14, 165, 233, 0.6), 0 0 25px rgba(56, 189, 248, 0.5);
  filter: brightness(1.06);
}

.start-button:active {
  transform: translateY(1px);
}

.arrow-icon {
  font-size: 1.2rem;
  transition: transform 0.2s ease;
}

.start-button:hover .arrow-icon {
  transform: translateX(4px);
}

/* Responsive queries */
@media (max-width: 640px) {
  #hud-overlay {
    padding: 0.8rem;
  }
  .hud-header {
    flex-direction: row;
    justify-content: space-between;
  }
  .brand {
    padding: 0.35rem 0.75rem;
  }
  .brand-title {
    font-size: 0.82rem;
  }
  .badge {
    font-size: 0.7rem;
    padding: 0.35rem 0.65rem;
  }
  .counter-card {
    bottom: 0.8rem;
    left: 0.8rem;
    padding: 0.65rem 0.9rem;
    min-width: 150px;
    border-radius: 0.9rem;
  }
  .counter-number {
    font-size: 2.1rem;
  }
  .stress-text {
    font-size: 0.65rem;
  }
  .hud-footer {
    bottom: 0.8rem;
    right: 0.8rem;
    gap: 0.4rem;
  }
  .instruction-pill {
    display: none;
  }
  .hud-actions {
    gap: 0.4rem;
  }
  .hud-btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
  }
}
