@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&display=swap');

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Fredoka', sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

canvas {
  display: block;
  width: 100%; height: 100%;
  cursor: pointer;
}

#ui-overlay {
  position: absolute; top: 0; left: 0; right: 0;
  pointer-events: none;
  z-index: 10;
  padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: flex-start;
}
#ui-overlay > * { pointer-events: auto; }

.ui-panel {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 8px 16px;
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 18px;
  transition: background .4s, color .4s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.day .ui-panel { background: rgba(255,255,255,0.85); color: #333; }
.night .ui-panel { background: rgba(30,30,60,0.85); color: #E8E0F0; }

#level-display { font-size: 20px; font-weight: 700; }

.heart { font-size: 22px; transition: transform .2s, opacity .2s; }
.heart.lost { opacity: 0.25; transform: scale(0.8); }

.icon-btn {
  width: 42px; height: 42px;
  border: none; border-radius: 12px;
  font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.day .icon-btn { background: rgba(255,255,255,0.85); color: #333; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.night .icon-btn { background: rgba(30,30,60,0.85); color: #E8E0F0; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.icon-btn:active { transform: scale(0.9); }
.icon-btn.active-toggle { box-shadow: 0 0 0 2px #4CAF50 inset; }

#right-controls { display: flex; flex-direction: column; gap: 8px; }

.popup-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.popup-overlay.show { display: flex; }

.popup {
  border-radius: 24px;
  padding: 32px 28px;
  text-align: center;
  max-width: 340px; width: 90%;
  transform: scale(0.85);
  animation: popIn .3s ease forwards;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
}
.day .popup { background: #fff; color: #333; }
.night .popup { background: #2A2A4A; color: #E8E0F0; }

@keyframes popIn { to { transform: scale(1); } }

.popup h2 { font-size: 28px; margin-bottom: 8px; }
.popup p { font-size: 16px; opacity: 0.7; margin-bottom: 20px; }

.popup-btn {
  border: none; border-radius: 14px;
  padding: 12px 32px;
  font-family: 'Fredoka', sans-serif;
  font-size: 18px; font-weight: 600;
  cursor: pointer;
  margin: 4px;
  transition: transform .15s;
}
.popup-btn:active { transform: scale(0.95); }
.popup-btn.primary { background: #4CAF50; color: #fff; }
.popup-btn.secondary { background: #FF6B6B; color: #fff; }

#damage-flash {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(255,50,50,0.5) 100%);
  pointer-events: none; opacity: 0;
  z-index: 50;
  transition: opacity .15s;
}
#damage-flash.active { opacity: 1; }

#confetti-canvas {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none; z-index: 40;
}

#tutorial-hand {
  position: fixed;
  font-size: 40px;
  pointer-events: none;
  z-index: 30;
  animation: tapBounce 1s ease-in-out infinite;
  display: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
@keyframes tapBounce {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(0.85); opacity: 0.7; }
}

#loading-screen {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: #1A1A2E;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 200; color: #E8E0F0;
  font-family: 'Fredoka', sans-serif;
}
#loading-screen h1 { font-size: 36px; margin-bottom: 16px; }
#loading-screen p { font-size: 16px; opacity: 0.7; }
.loader-bar { width: 200px; height: 6px; background: rgba(255,255,255,0.15); border-radius: 3px; margin-top: 20px; overflow: hidden; }
.loader-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #4CAF50, #6BCB77); border-radius: 3px; transition: width .3s; }
