/* --- RESET I BAZA --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

:root {
  --bg-deep: #060713;
  --panel-bg: rgba(15, 23, 42, 0.75);
  --panel-border: rgba(255, 255, 255, 0.12);
  --gold-glow: #f59e0b;
  --star-yellow: #facc15;
  --cyan-accent: #38bdf8;
  --font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
}

body {
  background: radial-gradient(circle at 50% 10%, #171b38 0%, #080a14 70%, #030408 100%);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family);
  color: #f8fafc;
  overflow: hidden;
  touch-action: none;
  padding: 12px;
}

/* --- GŁÓWNY KONTENER GRY --- */
.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 520px;
}

/* --- GÓRNY PASEK HUD --- */
.hud-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 16px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  margin-bottom: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hud-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #e2e8f0;
}

.hud-stat .icon {
  font-size: 1.15rem;
  filter: drop-shadow(0 0 6px rgba(250, 204, 21, 0.5));
}

.hud-stat strong {
  font-size: 1.25rem;
  font-weight: 800;
  color: #ffffff;
  display: inline-block;
  transition: transform 0.15s ease;
}

.hud-stat strong.pop {
  animation: scoreBounce 0.25s ease-out;
}

@keyframes scoreBounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.4) translateY(-2px); color: #fde047; }
  100% { transform: scale(1); }
}

/* Serduszka żyć */
.hearts-container {
  display: flex;
  gap: 4px;
  align-items: center;
}

.heart-item {
  font-size: 1.25rem;
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  filter: drop-shadow(0 0 5px rgba(239, 68, 68, 0.6));
}

.heart-item.active {
  animation: heartPulse 2.4s infinite ease-in-out;
}

.heart-item.lost {
  opacity: 0.3;
  transform: scale(0.8);
  filter: grayscale(1);
}

@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.3);
}

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

/* --- OBSZAR CANVAS --- */
.canvas-container {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: calc(100vh - 130px);
  background: #090a1a;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.7), 0 0 35px rgba(120, 119, 198, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.12);
}

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

canvas:active {
  cursor: grabbing;
}

/* --- OVERLAYE (START, PAUZA, GAME OVER) --- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 11, 24, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 20;
}

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

.modal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 380px;
  animation: modalPopIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.game-title {
  font-size: 2.2rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #fef08a 0%, #facc15 50%, #f97316 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 12px rgba(250, 204, 21, 0.4));
  line-height: 1.15;
}

.game-subtitle {
  font-size: 1rem;
  color: #94a3b8;
  line-height: 1.4;
}

.record-badge {
  background: linear-gradient(135deg, #ffd700, #f59e0b);
  color: #0f172a;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 5px 14px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.6);
  animation: pulseBadge 1.2s infinite alternate ease-in-out;
}

@keyframes pulseBadge {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

.score-display-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 14px 24px;
  width: 100%;
}

.score-display-box .big-score {
  font-size: 2.6rem;
  font-weight: 900;
  color: #fef08a;
  text-shadow: 0 0 18px rgba(250, 204, 21, 0.5);
}

.score-display-box .best-info {
  font-size: 0.95rem;
  color: #94a3b8;
  margin-top: 4px;
}

.game-over-quote {
  font-size: 0.95rem;
  color: #cbd5e1;
  font-style: italic;
  padding: 0 8px;
}

/* Wskazówki sterowania */
.controls-guide {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 16px;
  width: 100%;
  font-size: 0.85rem;
  color: #94a3b8;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.controls-guide .row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.controls-guide kbd {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 7px;
  border-radius: 6px;
  font-family: monospace;
  font-weight: bold;
  color: #f8fafc;
}

/* Przycisk akcji */
.btn-primary {
  background: linear-gradient(135deg, #facc15 0%, #f59e0b 50%, #d97706 100%);
  color: #0b0f19;
  border: none;
  padding: 14px 36px;
  font-size: 1.15rem;
  font-weight: 800;
  border-radius: 35px;
  cursor: pointer;
  box-shadow: 0 6px 25px rgba(245, 158, 11, 0.45);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.btn-primary:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.65);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.98);
}

/* Stopka */
.game-footer {
  margin-top: 10px;
  font-size: 0.8rem;
  color: #64748b;
  text-align: center;
}

/* --- RWD / MOBILE --- */
@media (max-width: 480px) {
  body {
    padding: 6px;
  }
  .hud-bar {
    padding: 8px 12px;
    border-radius: 12px;
  }
  .hud-stat strong {
    font-size: 1.1rem;
  }
  .game-title {
    font-size: 1.8rem;
  }
  .score-display-box .big-score {
    font-size: 2.2rem;
  }
  .btn-primary {
    padding: 12px 28px;
    font-size: 1.05rem;
  }
}
