* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #120e28;
  font-family: 'Fredoka', 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #ffffff;
  touch-action: none; /* Prevents iOS Safari pull-to-refresh & pinch zoom */
  -webkit-tap-highlight-color: transparent;
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* Top HUD Bar */
.hud-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  padding: env(safe-area-inset-top, 8px) 16px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(18, 14, 40, 0.85), transparent);
}

.hud-bar * {
  pointer-events: auto;
}

.hud-left, .hud-right, .hud-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-badge {
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 10px rgba(108, 92, 231, 0.4);
}

.hud-hearts {
  font-size: 18px;
  letter-spacing: 2px;
  filter: drop-shadow(0 2px 4px rgba(255, 118, 117, 0.5));
}

.hud-shield {
  font-size: 20px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-label {
  font-size: 11px;
  color: #fdcb6e;
  font-weight: 700;
  letter-spacing: 1px;
}

.score-value {
  font-size: 22px;
  font-weight: 700;
  color: #ffeaa7;
  text-shadow: 0 2px 6px rgba(253, 203, 110, 0.5);
}

.hi-score-box {
  font-size: 12px;
  color: #b2bec3;
  margin-left: 6px;
}

.hi-value {
  color: #dfe6e9;
  font-weight: 600;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.icon-btn:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.3);
}

/* Touch Controls Bar at bottom */
.touch-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0 20px calc(env(safe-area-inset-bottom, 15px) + 10px) 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 10;
  pointer-events: none;
}

.control-dpad, .control-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  pointer-events: auto;
}

.control-actions {
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.touch-btn {
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: white;
  border-radius: 24px;
  font-size: 26px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.dpad-btn {
  width: 68px;
  height: 68px;
}

.fire-btn {
  width: 120px;
  height: 64px;
  background: linear-gradient(135deg, #ff7675, #e17055);
  border-color: #fab1a0;
  font-size: 18px;
  letter-spacing: 1px;
}

.touch-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.35);
}

.fire-btn:active {
  background: linear-gradient(135deg, #d63031, #e17055);
}

.touch-pill {
  background: rgba(9, 132, 227, 0.3);
  border: 1px solid rgba(116, 185, 255, 0.4);
  color: #74b9ff;
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(6px);
}

.touch-pill.active {
  background: rgba(85, 239, 196, 0.3);
  border-color: #55efc4;
  color: #55efc4;
}

/* Modals */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(14, 10, 30, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-card {
  background: linear-gradient(160deg, #24194f, #181135);
  border: 3px solid #6c5ce7;
  border-radius: 28px;
  padding: 30px 24px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), 0 0 25px rgba(108, 92, 231, 0.3);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-emoji {
  font-size: 48px;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 10px rgba(255, 255, 255, 0.2));
}

.modal-title {
  font-size: 28px;
  font-weight: 700;
  color: #ffeaa7;
  letter-spacing: 1px;
  margin-bottom: 6px;
  text-shadow: 0 2px 10px rgba(253, 203, 110, 0.4);
}

.modal-subtitle {
  font-size: 15px;
  color: #a29bfe;
  margin-bottom: 20px;
}

.card-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 22px;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #dfe6e9;
}

.f-icon {
  font-size: 20px;
}

.score-recap {
  font-size: 20px;
  color: #dfe6e9;
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.07);
  padding: 12px;
  border-radius: 14px;
}

.recap-num {
  font-size: 28px;
  font-weight: 700;
  color: #ffeaa7;
}

.action-btn {
  width: 100%;
  padding: 16px 20px;
  border-radius: 20px;
  border: none;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 1px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s;
}

.action-btn:active {
  transform: scale(0.96);
}

.start-btn {
  background: linear-gradient(135deg, #00cec9, #0984e3);
  color: #ffffff;
  border: 2px solid #81ecec;
}

.victory-card {
  border-color: #f9ca24;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), 0 0 35px rgba(249, 202, 36, 0.4);
}

.victory-title {
  color: #f9ca24;
}

.victory-btn {
  background: linear-gradient(135deg, #f9ca24, #f0932b);
  color: #2d3436;
  border: 2px solid #ffeaa7;
}
