:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background: #1a1a2e;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

#gameContainer {
  position: relative;
  width: 100%;
  height: calc(100vh - 70px);
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === SPONSORS BAR === */
#sponsors-bar {
  width: 100%;
  background: #111;
  border-top: 1px solid #333;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  min-height: 70px;
  flex-shrink: 0;
}

#sponsors-label {
  color: #666;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

#sponsors-logos {
  display: flex;
  align-items: center;
  gap: 20px;
  overflow-x: auto;
  flex: 1;
  padding: 5px 0;
  scrollbar-width: none;
}

#sponsors-logos::-webkit-scrollbar {
  display: none;
}

#sponsors-logos a {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.2s;
  opacity: 0.6;
}

#sponsors-logos a:hover {
  opacity: 1;
  transform: scale(1.05);
}

#sponsors-logos img {
  height: 40px;
  max-width: 120px;
  object-fit: contain;
  filter: grayscale(30%);
  transition: filter 0.2s;
}

#sponsors-logos a:hover img {
  filter: grayscale(0%);
}

/* Placeholder when no sponsors added yet */
#sponsors-logos:empty::after {
  content: 'Wrzuć logo do folderu sponsors/ i dodaj w index.html';
  color: #444;
  font-size: 12px;
  font-style: italic;
}

/* === BRANDING (AnimatOlka logo) === */
#branding {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 20;
  pointer-events: auto;
  transition: opacity 0.4s ease;
}

#branding-logo {
  height: 36px;
  width: auto;
  opacity: 0.9;
  transition: opacity 0.2s, transform 0.2s;
  cursor: pointer;
  filter: drop-shadow(1px 1px 3px rgba(0,0,0,0.5));
}

#branding-logo:hover {
  opacity: 1;
  transform: scale(1.05);
}

#branding-score {
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.6);
  text-align: left;
  margin-top: 2px;
  min-height: 18px;
}

#branding-lives {
  font-size: 14px;
  text-align: left;
  margin-top: 1px;
  min-height: 16px;
  letter-spacing: 1px;
}

canvas {
  display: block;
  image-rendering: pixelated;
  cursor: pointer;
}

#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#score {
  display: none;
}

#highscore {
  display: none;
}

#eggs-count {
  display: none;
}

#player-name {
  position: absolute;
  top: 12px;
  right: 15px;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.6);
  z-index: 12;
  pointer-events: none;
}

/* === REGISTRATION MODAL === */
#register-overlay, #leaderboard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
}

#register-form-container, #leaderboard-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #1a2a3a;
  border: 2px solid #4CAF50;
  border-radius: 16px;
  padding: 28px 32px;
  z-index: 101;
  width: min(420px, 90vw);
  max-height: 90vh;
  overflow-y: auto;
  color: #fff;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

#register-form-container h2, #leaderboard-container h2 {
  text-align: center;
  color: #4CAF50;
  margin: 0 0 4px 0;
  font-size: 22px;
}

.register-subtitle {
  text-align: center;
  color: #888;
  font-size: 13px;
  margin: 0 0 18px 0;
}

#register-form input[type="text"],
#register-form input[type="email"] {
  display: block;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 10px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #0d1b2a;
  color: #fff;
  font-size: 15px;
  outline: none;
  box-sizing: border-box;
}

#register-form input:focus {
  border-color: #4CAF50;
}

.terms-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #aaa;
  margin: 12px 0;
  cursor: pointer;
}

.terms-label a {
  color: #4FC3F7;
  text-decoration: underline;
}

#register-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: #4CAF50;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.2s;
}

#register-btn:hover {
  background: #388E3C;
}

#register-error {
  color: #F44336;
  text-align: center;
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

/* === GAME OVER + LEADERBOARD PANEL === */
#gameover-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
}

#gameover-container {
  background: #1a2a3a;
  border: 2px solid #F44336;
  border-radius: 16px;
  width: min(480px, 92vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #fff;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

#gameover-header {
  text-align: center;
  padding: 16px 20px 10px;
  border-bottom: 1px solid #333;
}

#gameover-title {
  color: #F44336;
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 6px;
}

#gameover-score {
  font-size: 22px;
  font-weight: bold;
  color: #fff;
}

#gameover-rank {
  font-size: 14px;
  margin-top: 6px;
  min-height: 20px;
}

#gameover-rank.qualified {
  color: #4CAF50;
  font-weight: bold;
}

#gameover-rank.not-qualified {
  color: #FF9800;
}

#gameover-leaderboard {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}

#gameover-leaderboard h3 {
  text-align: center;
  color: #4FC3F7;
  font-size: 14px;
  margin: 4px 0 8px;
}

#leaderboard-list {
  font-size: 13px;
}

#leaderboard-list table {
  width: 100%;
  border-collapse: collapse;
}

#leaderboard-list th {
  text-align: left;
  color: #4FC3F7;
  padding: 5px 6px;
  border-bottom: 1px solid #333;
  font-size: 11px;
  text-transform: uppercase;
}

#leaderboard-list td {
  padding: 5px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

#leaderboard-list tr.highlight td {
  background: rgba(76,175,80,0.15);
  font-weight: bold;
  color: #4CAF50;
}

#leaderboard-list tr:nth-child(1) td { color: #FFD700; }
#leaderboard-list tr:nth-child(2) td { color: #C0C0C0; }
#leaderboard-list tr:nth-child(3) td { color: #CD7F32; }
#leaderboard-list tr.highlight td { color: #4CAF50 !important; }

#gameover-footer {
  padding: 12px 20px;
  border-top: 1px solid #333;
  text-align: center;
}

#gameover-retry {
  width: 100%;
  padding: 12px;
  background: #4CAF50;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 17px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

#gameover-retry:hover {
  background: #388E3C;
}

