* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', sans-serif;
  background: #11162d;
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(102, 126, 234, 0.3), transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(118, 75, 162, 0.3), transparent 40%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  color: white;
}

h1 {
  color: white;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
  margin-bottom: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}

.game-container {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
  overflow: hidden; /* Zajistí, že Hocke nebude vidět mimo pole */
}

#gameCanvas {
  display: block;
  background: #1a1a2e;
  border-radius: 10px;
  cursor: none;
  box-shadow: 0 0 20px rgba(0,0,0,0.5) inset;
}

.hud {
  display: flex;
  justify-content: space-around;
  margin-top: 15px;
  gap: 10px;
  flex-wrap: wrap;
}

.hud-item {
  background: rgba(0,0,0,0.2);
  color: white;
  padding: 8px 18px;
  border-radius: 25px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
}

.controls {
  text-align: center;
  margin-top: 15px;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.contained-overlay {
  position: absolute;
  border-radius: 20px; /* Match game-container */
  overflow: hidden; /* Ensure content stays within rounded corners */
}

.overlay:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  /* Allow transition before hiding completely */
  transition: opacity 0.3s, visibility 0s linear 0.3s;
}

.overlay-content {
  background: linear-gradient(145deg, #2c3e50, #1a2533);
  color: white;
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  transform: scale(0.9);
  transition: transform 0.3s;
}
.overlay:not(.hidden) .overlay-content {
  transform: scale(1);
}

.overlay-content h2 {
  color: white;
  text-shadow: 0 0 10px #667eea;
  margin-bottom: 20px;
  font-size: 32px;
}

.overlay-content .nickname-input {
  width: 100%;
  padding: 12px 20px;
  margin-bottom: 20px;
  border-radius: 15px;
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.3);
  color: white;
  font-size: 16px;
  text-align: center;
  font-weight: 600;
  transition: all 0.3s;
}
.overlay-content .nickname-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
}
.overlay-content .nickname-input::placeholder {
  color: rgba(255,255,255,0.5);
}

.overlay-content p {
  color: rgba(255,255,255,0.8);
  margin-bottom: 20px;
  font-size: 16px;
}

.character-option:hover {
  border-color: #667eea !important;
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.character-option.selected {
  border-color: #667eea !important;
  background: #f0f4ff;
}

button {
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 15px 40px;
  font-size: 18px;
  border-radius: 30px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(0,0,0, 0.2);
  border: 1px solid rgba(255,255,255,0.2);
}

button:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 25px rgba(118, 75, 162, 0.5);
}

button:active {
  transform: translateY(0) scale(1);
}

.score-display {
  font-size: 24px;
  color: white;
  font-weight: bold;
  margin: 15px 0;
}
.score-display span {
  color: #667eea;
  text-shadow: 0 0 8px #667eea;
}

.xp-bar-container {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  background: rgba(0, 0, 0, 0.5);
  padding: 5px;
  border-radius: 20px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
}

.xp-bar {
  width: 100%;
  height: 15px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 10px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px #667eea;
}

.xp-text {
  color: white;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  margin-top: 4px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
}

.upgrade-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(15px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.3s;
  opacity: 0;
}

.upgrade-overlay.active {
  display: flex;
  opacity: 1;
}

.upgrade-card {
  background: linear-gradient(145deg, #2c3e50, #1a2533);
  padding: 30px;
  border-radius: 20px;
  text-align: center;
  max-width: 700px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
}

.upgrade-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.upgrade-option {
  padding: 20px;
  border: 2px solid transparent;
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.3s;
  background: rgba(255,255,255,0.05);
  position: relative;
  overflow: hidden;
}

.upgrade-option::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 15px;
  border: 2px solid transparent;
  padding: 2px;
  background-clip: content-box, border-box;
  background-image: linear-gradient(rgba(255,255,255,0.05), rgba(255,255,255,0.05)), var(--rarity-gradient, linear-gradient(45deg, #444, #888));
  transition: all 0.3s;
}

.upgrade-option:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 30px rgba(0,0,0, 0.4);
}
.upgrade-option:hover::before {
  filter: brightness(1.3);
}

.upgrade-option.rarity-common { --rarity-gradient: linear-gradient(45deg, #9e9e9e, #cfcfcf); }
.upgrade-option.rarity-rare { --rarity-gradient: linear-gradient(45deg, #1e90ff, #87cefa); }
.upgrade-option.rarity-epic { --rarity-gradient: linear-gradient(45deg, #9b59b6, #d8a8e9); }
.upgrade-option.rarity-legendary { --rarity-gradient: linear-gradient(45deg, #ffa502, #ffd700); }


.upgrade-option h4, .upgrade-option p, .upgrade-option div {
  position: relative;
  z-index: 1;
}

.upgrade-option h4 {
  color: white;
  margin-bottom: 10px;
  font-weight: 600;
}

.upgrade-option p.description {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  margin: 5px 0;
  min-height: 30px;
}

.upgrade-option .rarity {
  font-size: 11px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  margin-bottom: 10px;
  color: white;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}
.rarity.common { background: linear-gradient(45deg, #9e9e9e, #bdbdbd); }
.rarity.rare { background: linear-gradient(45deg, #1e90ff, #5cacee); }
.rarity.epic { background: linear-gradient(45deg, #9b59b6, #c377e0); }
.rarity.legendary { background: linear-gradient(45deg, #ffa502, #ffc107); }

.upgrade-option .level-indicator {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin-top: 10px;
}

.level-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
}

.level-dot.active {
  background: #667eea;
  box-shadow: 0 0 5px #667eea;
}

.upgrade-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 20px 0;
  padding: 15px;
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
}

.pause-upgrade-card {
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 15px;
  text-align: center;
  border: 1px solid transparent;
  border-image-slice: 1;
}

.pause-upgrade-card.rarity-common { border-image-source: linear-gradient(45deg, #9e9e9e, #cfcfcf); }
.pause-upgrade-card.rarity-rare { border-image-source: linear-gradient(45deg, #1e90ff, #87cefa); }
.pause-upgrade-card.rarity-epic { border-image-source: linear-gradient(45deg, #9b59b6, #d8a8e9); }
.pause-upgrade-card.rarity-legendary { border-image-source: linear-gradient(45deg, #ffa502, #ffd700); }

.pause-upgrade-card .icon {
  font-size: 30px;
  margin-bottom: 5px;
}
.pause-upgrade-card h5 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 5px;
}
.pause-upgrade-card .level {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
}

.stat-item {
  text-align: center;
}

.stat-item strong {
  display: block;
  color: #667eea;
  font-size: 12px;
  text-transform: uppercase;
}

.main-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.scoreboard-container {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
  width: 300px;
  height: 695px; /* Stejná výška jako game-container */
  display: flex;
  flex-direction: column;
}

.scoreboard-container h2 {
  text-align: center;
  color: white;
  text-shadow: 0 0 10px #667eea;
  margin-bottom: 15px;
  font-size: 24px;
}

#scoreboard {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  flex-grow: 1;
}

#scoreboard li {
  display: flex;
  justify-content: space-between;
  padding: 10px 15px;
  border-radius: 10px;
  margin-bottom: 8px;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  transition: all 0.3s;
}

#scoreboard li:first-child {
  background: linear-gradient(45deg, rgba(255, 215, 0, 0.3), rgba(255, 165, 0, 0.3));
  border-color: #ffd700;
}
#scoreboard li:nth-child(2) {
  background: linear-gradient(45deg, rgba(192, 192, 192, 0.2), rgba(211, 211, 211, 0.2));
  border-color: #c0c0c0;
}
#scoreboard li:nth-child(3) {
  background: linear-gradient(45deg, rgba(205, 127, 50, 0.2), rgba(165, 42, 42, 0.2));
  border-color: #cd7f32;
}

#scoreboard .rank {
  font-weight: bold;
  color: #667eea;
  min-width: 30px;
}
#scoreboard .name {
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 10px; /* Add some space for the icon */
}
#scoreboard .score {
  font-weight: bold;
}

.hocke-intro {
  position: absolute;
  bottom: 100px;
  left: -250px; /* Start off-screen */
  width: 200px;
  display: none; /* Hidden by default */
  flex-direction: column;
  align-items: center;
  transition: left 2s ease-in-out, opacity 0.5s ease-in-out; /* Slower transition */
  z-index: 500;
  opacity: 0;
}

.hocke-intro.visible {
  /* This class is no longer used for the animation, but kept for compatibility with tutorial */
  left: 30px;
  opacity: 1;
}

.hocke-intro img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.hocke-intro .cigo {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 45px;
  height: 45px;
  opacity: 0;
  transition: opacity 0.3s ease-in;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.hocke-intro.leaving .cigo {
  opacity: 1;
}

.speech-bubble {
  position: relative;
  background: white;
  color: #333;
  border-radius: 15px;
  padding: 15px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  margin-top: -10px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.25);
  border: 2px solid #444;
}

.speech-bubble::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 15px solid #444;
}
 .speech-bubble::after {
  content: '';
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 13px solid white;
}


@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@media (max-width: 1200px) {
  .main-layout {
    flex-direction: column;
    align-items: center;
  }
  .scoreboard-container {
    width: 100%;
    max-width: 840px; /* šířka game-container */
    height: auto;
    max-height: 400px;
  }
}

@media (max-width: 600px) {
  #gameCanvas {
    width: 100%;
    height: auto;
  }
}

#muteBtn {
  position: absolute;
  top: 25px;
  right: 25px;
  width: 40px;
  height: 40px;
  background: rgba(0,0,0,0.3);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  z-index: 100;
  border: 1px solid rgba(255,255,255,0.1);
  transition: all 0.2s;
}
#muteBtn:hover {
  background: rgba(0,0,0,0.5);
  transform: scale(1.1);
}

.boss-hud {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  background: rgba(0,0,0,0.7);
  padding: 10px;
  border-radius: 15px;
  box-shadow: 0 5px 20px rgba(255,0,0,0.4);
  border: 2px solid #ff4757;
  text-align: center;
  z-index: 100;
  display: none; /* Hidden by default */
}
.boss-hud.active {
  display: block;
}
.boss-hud h3 {
  color: #ff4757;
  text-shadow: 0 0 10px #ff4757;
  margin-bottom: 5px;
}
.boss-progress-bar {
  width: 100%;
  height: 20px;
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
  overflow: hidden;
}
.boss-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff4757, #c0392b);
  width: 100%;
  transition: width 0.5s ease-out;
}

.quiz-option {
  background: rgba(0,0,0,0.2);
  color: white;
  padding: 15px;
  border-radius: 15px;
  font-weight: 600;
  font-size: 16px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 10px;
}
.quiz-option:hover {
  background: rgba(255,255,255,0.1);
  border-color: #667eea;
}
.quiz-option.correct {
  background: #2ed573;
  border-color: #2ecc71;
}
.quiz-option.incorrect {
  background: #e74c3c;
  border-color: #c0392b;
}
