/* ===================================================
   AUTKO BRUM BRUM 🚗💨 - STYLIZACJA CSS
   Kolorowy, wesoły i responsywny styl gry dla dzieci
=================================================== */

:root {
  --primary-color: #ff3366;
  --secondary-color: #ffb703;
  --accent-color: #06d6a0;
  --sky-blue: #4cc9f0;
  --dark-road: #343a40;
  --bg-gradient: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
  --font-family: 'Fredoka', 'Lilita One', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --panel-bg: rgba(255, 255, 255, 0.94);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.15);
  --shadow-hard: 0 6px 0 rgba(0, 0, 0, 0.2);
}

* {
  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: var(--bg-gradient);
  font-family: var(--font-family);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Główny kontener gry */
#gameWrapper {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  max-height: 850px;
  background: #2b2d42;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.35);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (max-width: 500px), (max-height: 860px) {
  #gameWrapper {
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}

/* Płótno gry */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* Górny pasek HUD */
#hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.hud-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-bg);
  padding: 6px 14px;
  border-radius: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  border: 3px solid #fff;
  pointer-events: auto;
}

/* Życia / Serduszka */
#livesContainer {
  display: flex;
  gap: 3px;
  font-size: 1.4rem;
}

.heart-icon {
  display: inline-block;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.heart-icon.lost {
  filter: grayscale(100%) opacity(30%);
  transform: scale(0.8);
}

.heart-icon.bounce {
  animation: heartPulse 0.4s ease;
}

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

/* Statystyki w HUD */
.hud-stat {
  font-size: 1rem;
  font-weight: 700;
  color: #2b2d42;
  display: flex;
  align-items: center;
  gap: 5px;
}

.hud-stat .val {
  color: #d90429;
  font-weight: 800;
}

/* Przyciski w HUD (Dźwięki, Pauza) */
.hud-buttons {
  display: flex;
  gap: 6px;
}

.hud-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--panel-bg);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  pointer-events: auto;
}

.hud-btn:hover {
  transform: scale(1.08);
  background: #ffffff;
}

.hud-btn:active {
  transform: scale(0.92);
}

/* Pasek Nitro / Turbo */
#nitroContainer {
  position: absolute;
  top: 72px;
  left: 14px;
  right: 14px;
  z-index: 10;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nitro-icon {
  font-size: 1.3rem;
  animation: floatSmall 2s infinite ease-in-out;
}

.nitro-bar-bg {
  flex: 1;
  height: 14px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

#nitroBarFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffb703, #fb8500, #ff0054);
  border-radius: 8px;
  transition: width 0.1s linear;
}

#nitroBarFill.ready {
  background: linear-gradient(90deg, #06d6a0, #118ab2, #ffd166);
  box-shadow: 0 0 10px #06d6a0;
  animation: nitroGlow 0.8s infinite alternate;
}

@keyframes nitroGlow {
  from { filter: brightness(1); }
  to { filter: brightness(1.4); }
}

/* Floating info / Powiadomienia w trakcie gry */
#floatingNotes {
  position: absolute;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.popup-toast {
  background: rgba(255, 255, 255, 0.95);
  color: #2b2d42;
  font-weight: 800;
  padding: 6px 16px;
  border-radius: 20px;
  border: 3px solid #ffb703;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
  animation: toastPop 1.2s forwards;
  white-space: nowrap;
}

@keyframes toastPop {
  0% { transform: translateY(10px) scale(0.7); opacity: 0; }
  20% { transform: translateY(0) scale(1.1); opacity: 1; }
  80% { transform: translateY(-10px) scale(1); opacity: 1; }
  100% { transform: translateY(-25px) scale(0.9); opacity: 0; }
}

/* Dolne przyciski dotykowe (Dla telefonów / ekranów dotykowych) */
#touchControls {
  position: absolute;
  bottom: 16px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 10;
  pointer-events: none;
}

.touch-cluster {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.touch-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 4px solid #ffffff;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25), inset 0 2px 4px rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #2b2d42;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, background 0.08s ease;
}

.touch-btn:active, .touch-btn.pressed {
  transform: scale(0.88);
  background: #ffb703;
  color: #fff;
}

.touch-btn-horn {
  width: 58px;
  height: 58px;
  background: #ffe66d;
  border-color: #ffd166;
}

.touch-btn-turbo {
  width: 70px;
  height: 70px;
  background: #ff3366;
  color: #fff;
}

/* Modale / Ekrany menu, gry i pauzy */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(20, 24, 38, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.25s ease;
}

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

.modal-card {
  width: 100%;
  max-width: 400px;
  background: #ffffff;
  border-radius: 28px;
  border: 5px solid #ffb703;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  animation: cardBounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow-y: auto;
  max-height: 90vh;
}

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

.game-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: #d90429;
  text-shadow: 2px 2px 0 #ffd166;
  margin-bottom: 6px;
  line-height: 1.1;
}

.game-subtitle {
  font-size: 1.05rem;
  font-weight: 600;
  color: #495057;
  margin-bottom: 18px;
}

/* Wybór autka (Garaż) */
.car-selection-title {
  font-size: 1rem;
  font-weight: 700;
  color: #2b2d42;
  margin-bottom: 8px;
}

.car-picker {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.car-option {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  border: 3px solid #e9ecef;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.6rem;
  transition: all 0.2s ease;
}

.car-option.selected {
  border-color: #ff3366;
  background: #ffe3e8;
  transform: translateY(-4px) scale(1.1);
  box-shadow: 0 6px 15px rgba(255, 51, 102, 0.3);
}

.car-name-display {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ff3366;
  margin-bottom: 14px;
}

/* Instrukcja / Zasady */
.rules-box {
  background: #f1f8fe;
  border: 2px dashed #90e0ef;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 20px;
  text-align: left;
  font-size: 0.9rem;
  color: #333;
}

.rule-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.rule-row:last-child {
  margin-bottom: 0;
}

.rule-icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
}

/* Przyciski akcji */
.btn-primary {
  width: 100%;
  padding: 14px 20px;
  font-size: 1.35rem;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(180deg, #ff3366 0%, #d90429 100%);
  border: none;
  border-radius: 20px;
  box-shadow: 0 6px 0 #9b001d, 0 10px 20px rgba(217, 4, 41, 0.35);
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: var(--font-family);
  letter-spacing: 0.5px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #9b001d, 0 14px 25px rgba(217, 4, 41, 0.45);
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #9b001d, 0 4px 10px rgba(217, 4, 41, 0.3);
}

.btn-secondary {
  margin-top: 10px;
  width: 100%;
  padding: 10px 16px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #495057;
  background: #f1f3f5;
  border: 2px solid #dee2e6;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-family);
}

.btn-secondary:hover {
  background: #e9ecef;
}

/* Statystyki końca gry */
.game-over-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0 20px 0;
}

.stat-card {
  background: #f8f9fa;
  padding: 12px 8px;
  border-radius: 16px;
  border: 2px solid #e9ecef;
}

.stat-card .label {
  font-size: 0.8rem;
  color: #6c757d;
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.stat-card .number {
  font-size: 1.4rem;
  font-weight: 800;
  color: #2b2d42;
}

.badge-tag {
  background: #ffeedb;
  border: 2px solid #ffb703;
  color: #d97706;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 6px 12px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 14px;
}

/* Klakson shockwave animacja na ekranie */
.horn-ripple {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 5px solid rgba(255, 214, 10, 0.8);
  pointer-events: none;
  z-index: 5;
  animation: hornExpand 0.5s ease-out forwards;
}

@keyframes hornExpand {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}
