@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
  --bg-color: #020617;
  --accent-color: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.6);
  --secondary-color: #8b5cf6;
  --text-main: #f8fafc;
  --glass-bg: rgba(15, 23, 42, 0.8);
  --glass-border: rgba(255, 255, 255, 0.1);
  --xp-color: #10b981;
  --hp-color: #ef4444;
  --modal-z: 999999;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: #020617;
  color: var(--text-main);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  user-select: none;
}



#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: transparent !important;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2;
}



canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5000;
  padding: 1.5rem;
  display: none;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.xp-container {
  flex-grow: 1;
  height: 10px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 99px;
  border: 1px solid var(--glass-border);
  overflow: hidden;
  backdrop-filter: blur(5px);
}

#xp-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--xp-color), #34d399);
  box-shadow: 0 0 15px var(--xp-color);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-chip {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 8px 18px;
  border-radius: 99px;
  border: 1px solid var(--glass-border);
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  pointer-events: auto !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stat-chip:hover {
  background: rgba(99, 102, 241, 0.2);
  transform: translateY(-2px);
}

.stat-chip#mobile-pause:hover {
  background: #f87171 !important;
}

.hp-container {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 99px;
  border: 1px solid var(--glass-border);
  overflow: hidden;
  backdrop-filter: blur(5px);
}

#hp-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--hp-color), #f87171);
  box-shadow: 0 0 15px var(--hp-color);
  transition: width 0.3s ease;
}

/* Hit & Freeze Overlays */
#hit-overlay, #freeze-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 4000;
  pointer-events: none;
  opacity: 0;
}
#hit-overlay {
  background-color: rgba(239, 68, 68, 0.15); 
  transition: opacity 0.1s ease-out; 
}
#freeze-overlay {
  background-color: rgba(56, 189, 248, 0.1); 
  transition: opacity 0.3s ease-out; 
}
#freeze-overlay.active {
  opacity: 1;
}

.boss-warning {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  color: #ef4444;
  font-size: 2.5rem;
  font-weight: 800;
  text-shadow: 0 0 30px rgba(239, 68, 68, 1);
  display: none;
  z-index: 5000;
  letter-spacing: 4px;
  text-align: center;
  width: 100%;
}
.boss-warning.active {
  display: block !important;
  animation: warningPulse 1s ease-in-out infinite;
}
@keyframes warningPulse {
  0% { transform: translate(-50%, 0) scale(1); }
  50% { transform: translate(-50%, 0) scale(1.1); text-shadow: 0 0 50px rgba(239, 68, 68, 1); }
  100% { transform: translate(-50%, 0) scale(1); }
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 23, 0.4);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: flex;

  justify-content: center;
  align-items: center;
  z-index: var(--modal-z);
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
  padding: 1rem;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

#menu-anim-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10;
  pointer-events: none;
}



.modal-content {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.8) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 2rem;
  border-radius: 40px;
  border: 1px solid rgba(255, 255, 255, 0.15);

  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.9), 
              0 0 40px rgba(99, 102, 241, 0.2);
  max-width: 650px;
  width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  text-align: center;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.5) transparent;
  transform: scale(0.9) translateY(20px);
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  z-index: 2;
}

.modal.active .modal-content {
  transform: scale(1) translateY(0);
}

/* Premium X Close Button */
.btn-close-x {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  color: white;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  backdrop-filter: blur(5px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.btn-close-x:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
  transform: rotate(90deg) scale(1.1);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.btn-close-x:active {
  transform: rotate(90deg) scale(0.9);
}

/* Modal Body for scrolling */
.modal-body {
  width: 100%;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 10px;
  margin-top: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
}

@keyframes logoPulse {
  0% { transform: scale(1); text-shadow: 0 0 20px rgba(255,255,255,0.2); }
  50% { transform: scale(1.05); text-shadow: 0 0 40px var(--accent-glow); }
  100% { transform: scale(1); text-shadow: 0 0 20px rgba(255,255,255,0.2); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes floating {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}


.logo {
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: -4px;
  color: white;
  margin-bottom: 0.5rem;
  line-height: 1;
  animation: logoPulse 4s ease-in-out infinite;
  background: linear-gradient(to bottom, #fff 0%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(255,255,255,0.1));
}

.logo span {
  color: var(--accent-color);
  text-shadow: 0 0 40px var(--accent-glow);
  background: linear-gradient(to bottom, #6366f1 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: #94a3b8;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 8px;
  text-transform: uppercase;
  margin-bottom: 3rem;
  opacity: 0.7;
  position: relative;
  display: inline-block;
}

.subtitle::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 2px;
  background: var(--accent-color);
  border-radius: 99px;
  box-shadow: 0 0 10px var(--accent-glow);
}


.btn-restart {
  background: var(--accent-color);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.2rem 2rem; 
  font-size: 1.1rem;
  font-weight: 800;
  border-radius: 20px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 2px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 30px -10px var(--accent-glow);
  pointer-events: auto !important;
  position: relative;
  overflow: hidden;
  flex: 1 1 auto;
  white-space: nowrap;
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn-restart:hover {
  background: var(--secondary-color);
  box-shadow: 0 8px 25px -5px rgba(139, 92, 246, 0.4);
  filter: brightness(1.1);
}


.btn-restart:active {
  transform: translateY(0) scale(0.98);
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  margin-top: 1rem;
  z-index: 10001;
  position: relative;
  pointer-events: auto;
  width: 100%;
}

.menu-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.menu-group-title {
  font-size: 0.75rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 3px;
  text-transform: uppercase;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 8px;
  margin-bottom: 5px;
}

.menu-actions-row {
  display: flex;
  gap: 15px;
  width: 100%;
}

.menu-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  width: 100%;
}

.menu-actions-grid.secondary {
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.btn-main {
  flex: 1;
  padding: 1.5rem !important;
  font-size: 1.4rem !important;
  gap: 15px !important;
}

.btn-mp {
  background: linear-gradient(to right, #6366f1, #a855f7) !important;
}

.btn-sub {
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  padding: 0.8rem 0.5rem !important;
  gap: 8px !important;
  flex-direction: column !important;
}

.btn-sub span {
  font-size: 1.1rem !important;
  margin-bottom: 2px;
}

.btn-mini {
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  padding: 0.8rem 0.5rem !important;
  gap: 6px !important;
  flex-direction: column !important;
}

.btn-mini span {
  font-size: 1rem !important;
  margin-bottom: 2px;
}

.btn-quit {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #fca5a5 !important;
}

.btn-restart span {
  font-size: 1.5em;
}

.tutorial-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 20px;
  padding: 1.5rem;
  transition: transform 0.2s ease;
}

.tutorial-card:hover {
  transform: translateY(-5px);
  background: rgba(255,255,255,0.05);
}

.tutorial-card h3 {
  color: #38bdf8;
  font-size: 1rem;
  margin-bottom: 1rem;
  letter-spacing: 1px;
}

.tutorial-card p {
  color: #94a3b8;
  font-size: 0.85rem;
  line-height: 1.6;
  margin-bottom: 0.8rem;
}

.tutorial-card strong {
  color: white;
}

.join-group {
    display: flex;
    gap: 10px;
    width: 100%;
}

#input-join-id, .login-input {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: white;
    padding: 1.1rem 1.5rem;
    border-radius: 16px;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);

    text-align: center;
    letter-spacing: 1px;
}

.login-input:focus {
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.15), inset 0 2px 10px rgba(0,0,0,0.2);
    transform: translateY(-1px);
}


.btn-join {
    padding: 15px 25px;
    font-size: 1rem;
    background: #6366f1;
    margin: 0;
}

#host-code-display {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 12px;
    color: #f8fafc;
    margin-bottom: 15px;
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 1.5rem;
  width: 100%;
}

.upgrade-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
  backdrop-filter: blur(12px);

  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.5rem;
  border-radius: 28px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.upgrade-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.upgrade-card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.upgrade-card:hover::after {
  opacity: 1;
}

.upgrade-card:hover {
  background: var(--accent-color);
  border-color: var(--accent-color);
  transform: translateY(-8px);
  box-shadow: 0 20px 40px -15px var(--accent-glow);
}

.upgrade-card.selected {
    border-color: var(--xp-color);
    box-shadow: 0 0 30px var(--xp-color);
    background: rgba(16, 185, 129, 0.2);
    animation: autoSelectGlow 0.5s ease-in-out infinite alternate;
}

@keyframes autoSelectGlow {
    from { box-shadow: 0 0 20px rgba(16, 185, 129, 0.4); }
    to { box-shadow: 0 0 40px rgba(16, 185, 129, 0.8); }
}

@keyframes bounce {
    from { transform: scale(1) translateY(0); }
    to { transform: scale(1.1) translateY(-20px); }
}

.rarity-common { color: #94a3b8; }
.rarity-uncommon { color: #38bdf8; }
.rarity-rare { color: #fbbf24; }
.rarity-epic { color: #a855f7; }
.rarity-legendary { color: #ef4444; }

.upgrade-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 20px 0;
    width: 100%;
    background: rgba(0,0,0,0.3);
    padding: 20px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    background: rgba(255,255,255,0.05);
    padding: 10px 15px;
    border-radius: 10px;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.stat-item .val {
    color: var(--accent-color);
    font-weight: bold;
}

.lb-row {
    display: flex; 
    justify-content: space-between; 
    padding: 12px 20px;
    background: rgba(0,0,0,0.4); 
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px; 
    font-weight: 600;
}
.lb-row.gold { border-color: #fbbf24; color: #fbbf24; background: rgba(245, 158, 11, 0.1);}
.lb-row.silver { border-color: #cbd5e1; color: #f8fafc; background: rgba(203, 213, 225, 0.1);}
.lb-row.bronze { border-color: #b45309; color: #d97706; background: rgba(180, 83, 9, 0.1);}

.loader {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    animation: spin 1s linear infinite;
    margin: 15px auto;
}

@keyframes spin { 
    0% { transform: rotate(0deg); } 
    100% { transform: rotate(360deg); } 
}

.scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.05) 50%),
              linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
  background-size: 100% 4px, 3px 100%;
  pointer-events: none;
  z-index: 50;
  opacity: 0.5;
}

.controls-hint {
  display: flex;
  gap: 25px;
  margin-top: 3.5rem;
  opacity: 0.4;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 2px;
}

::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.4);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.8);
}

@media screen and (max-width: 850px) {
  .modal-content {
    min-width: unset !important;
    width: 95vw !important;
    padding: 1.5rem 1rem !important;
    border-radius: 24px !important;
  }

  .logo {
    font-size: 1.8rem !important;
    letter-spacing: -2px;
  }

  .subtitle {
    font-size: 0.6rem !important;
    letter-spacing: 2px !important;
    margin-bottom: 1rem !important;
  }

  .modal-content h2, #levelup-modal h2, #waiting-modal h2 {
    font-size: 1.2rem !important;
    margin-bottom: 0.6rem !important;
  }

  .menu-actions {
    flex-direction: column;
    width: 100%;
    gap: 10px !important;
    margin-top: 0.5rem !important;
  }

  .btn-restart {
    width: 100% !important;
    padding: 0.8rem 0.5rem !important;
    font-size: 0.9rem !important;
    white-space: normal !important;
    line-height: 1.2 !important;
    text-align: center;
    display: flex;
    flex-direction: row; /* Zpět na horizontální pokud je to možné */
    align-items: center;
    justify-content: center;
    border-radius: 12px !important;
  }

  .btn-main { font-size: 1.1rem !important; padding: 1.2rem 0.5rem !important; }
  .btn-sub { font-size: 0.75rem !important; padding: 0.7rem 0.2rem !important; font-weight: 500 !important; }
  .btn-mini { font-size: 0.7rem !important; padding: 0.6rem 0.2rem !important; font-weight: 500 !important; }
  .btn-mini span { font-size: 1.2rem !important; margin-bottom: 2px !important; }
  .menu-group-title { font-size: 0.75rem !important; margin-top: 10px; }
  .tutorial-card h3 { font-size: 0.9rem !important; }
  .tutorial-card p { font-size: 0.75rem !important; }
  .menu-actions-grid.secondary { gap: 8px !important; }
  .menu-actions-row { flex-direction: column !important; gap: 8px !important; }

  .join-group {
    flex-direction: column;
  }

  #input-join-id, .login-input {
    width: 100%;
    margin-bottom: 0 !important;
  }

  .btn-join {
    width: 100%;
  }

  #server-list-container {
    max-height: 120px !important;
  }

  #host-code-display {
    font-size: 2.2rem !important;
    letter-spacing: 6px !important;
  }

  .upgrade-grid {
    grid-template-columns: 1fr;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 5px;
    gap: 15px;
  }
  
  .stats-grid {
      grid-template-columns: 1fr;
      padding: 15px;
      gap: 10px;
  }

  .upgrade-card {
    min-height: 140px;
    padding: 1.2rem;
  }

  .upgrade-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
  }

  .top-bar {
    gap: 6px !important;
    justify-content: space-between !important;
    padding: 0 !important;
  }

  .stat-chip {
    padding: 6px 12px !important;
    font-size: 0.75rem !important;
    gap: 4px !important;
  }

  #mobile-pause {
    padding: 8px !important;
    font-size: 1rem !important;
  }

  .controls-hint {
    flex-direction: column;
    gap: 8px;
    margin-top: 1.5rem;
    font-size: 0.75rem;
  }

  #btn-daily-gift {
    position: relative !important;
    top: 0 !important;
    right: 0 !important;
    margin: 15px auto 45px auto !important;
    width: 65px !important;
    height: 65px !important;
    font-size: 2rem !important;
    display: flex !important;
    justify-content: center;
    align-items: center;
  }

  #daily-timer {
    font-size: 0.8rem !important;
    bottom: -35px !important;
    background: rgba(20, 20, 30, 0.95);
    padding: 3px 12px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(251, 191, 36, 0.5);
    color: #fbbf24;
    font-weight: 900;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
    min-width: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}

@media screen and (max-height: 600px) {
    .modal-content {
        padding: 1rem !important;
        border-radius: 20px !important;
    }

    .logo {
        font-size: 1.6rem !important;
        margin-bottom: 0 !important;
    }

    .subtitle {
        font-size: 0.6rem !important;
        margin-bottom: 0.3rem !important;
    }

    .modal-content h2, #levelup-modal h2, #waiting-modal h2 {
        font-size: 1.1rem !important;
        margin-bottom: 0.3rem !important;
    }

    .menu-actions {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 10px !important;
        margin-top: 0.5rem !important;
    }

    .btn-restart {
        padding: 0.7rem 1.2rem !important;
        font-size: 0.85rem !important;
        flex: 1 1 auto; 
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
        gap: 5px !important;
        padding: 5px !important;
        margin: 5px 0 !important;
    }

    .stat-item {
        padding: 6px 12px !important;
        font-size: 0.9rem !important;
    }

    .upgrade-grid {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
        gap: 8px !important;
        margin-top: 0.5rem !important;
    }

    .upgrade-card {
        min-height: 80px !important;
        padding: 0.5rem !important;
    }

    .upgrade-icon {
        font-size: 1.2rem !important;
        margin-bottom: 0.2rem !important;
    }

    .upgrade-card h3 {
        font-size: 0.9rem !important;
    }

    .upgrade-card p {
        font-size: 0.7rem !important;
    }

    #server-list-container {
        max-height: 70px !important;
    }

    .join-group {
        flex-direction: row !important;
    }

    #input-join-id, .login-input {
        padding: 8px !important;
        font-size: 0.9rem !important;
        margin-bottom: 0 !important;
    }

    #host-code-display {
        font-size: 1.5rem !important;
        letter-spacing: 4px !important;
        margin-bottom: 10px !important;
    }

    .btn-join {
        padding: 8px 15px !important;
    }

    .controls-hint {
        margin-top: 0.5rem !important;
        flex-direction: row !important;
        justify-content: center;
    }
}

#mobile-pause:active {
  transform: scale(0.9) !important;
  filter: brightness(0.8) !important;
}

:fullscreen, :-webkit-full-screen {
  width: 100vw;
  height: 100vh;
}

/* --- GLOBAL CHAT --- */
#global-chat {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 320px;
    height: 220px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    z-index: 999999 !important;
    pointer-events: auto;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: none; /* Skryto v menu */
}

#afk-label {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.2);
    letter-spacing: 20px;
    pointer-events: none;
    z-index: 5000;
    display: none;
    text-shadow: 0 0 40px rgba(255,255,255,0.1);
}


#global-chat:not(:focus-within) {
    opacity: 0.6;
}

/* Mobilní layout pro chat - pod minimapu */
@media screen and (max-width: 850px) {
    #global-chat {
        left: auto !important;
        right: 10px !important;
        top: 80px !important; /* Vyšší, blíž k tlačítku */
        bottom: auto !important;
        width: 220px !important;
        height: 180px !important;
        font-size: 0.8rem !important;
        z-index: 999999 !important;
        display: none !important; /* Schováno, dokud se neklikne na btn-chat-mobile */
        background: rgba(15, 23, 42, 0.95) !important;
        border: 1px solid var(--accent-color) !important;
    }
    #global-chat.mobile-active {
        display: flex !important;
    }
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {
    :root {
        --modal-padding: 1rem;
    }

    h1 { font-size: 2.2rem !important; margin-bottom: 0.5rem !important; }
    h2 { font-size: 1.2rem !important; }

    .modal-content {
        width: 92vw !important;
        max-height: 90vh !important;
        padding: 1rem !important;
        border-radius: 24px !important;
    }

    .upgrade-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    /* Adjust crate cards specifically to fit multipliers */
    .menu-actions-grid .upgrade-card {
        min-height: 160px !important;
        padding-bottom: 70px !important;
    }

    .upgrade-card div {
        font-size: 1.8rem !important;
    }

    .upgrade-card h3 {
        font-size: 0.75rem !important;
        margin: 4px 0 !important;
    }

    .upgrade-card p {
        font-size: 0.6rem !important;
        line-height: 1.1 !important;
        margin-bottom: 4px !important;
    }

    .btn-buy {
        padding: 8px !important;
        font-size: 0.65rem !important;
        border-radius: 8px !important;
    }

    /* Fix confirmation buttons */
    #custom-confirm-modal .btn-restart {
        min-width: 80px;
        height: auto !important;
        padding: 12px !important;
        border-radius: 12px !important;
        font-size: 0.9rem !important;
        flex: 1;
    }

    .currency-display {
        font-size: 0.9rem !important;
        padding: 5px 12px !important;
    }

    .crate-anim-title {
        font-size: 1rem !important;
    }
}

/* --- LANDSCAPE MOBILE FIXES --- */
@media (max-width: 900px) and (orientation: landscape) {
    .modal-content {
        padding: 0.8rem !important;
        max-height: 95vh !important;
    }

    h2 { font-size: 1rem !important; margin-bottom: 0.5rem !important; }

    #crate-carousel {
        height: 100px !important;
    }

    .crate-item {
        min-width: 90px !important;
        height: 90px !important;
    }

    .crate-item div {
        font-size: 2rem !important;
    }

    #crate-result-info {
        margin-top: 0.5rem !important;
    }

    #crate-result-info h3 {
        font-size: 1.5rem !important;
    }

    #crate-result-info .btn-restart {
        margin-top: 0.5rem !important;
        padding: 8px !important;
    }
}

@media (max-width: 480px) {
    .upgrade-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .upgrade-card {
        padding: 1rem !important;
        min-height: 120px !important;
    }

    .upgrade-card h3 {
        font-size: 0.9rem !important;
    }

    .upgrade-card p {
        font-size: 0.7rem !important;
    }

    .menu-actions-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .btn-restart {
        font-size: 1rem !important;
        padding: 12px !important;
    }

    #leaderboard-list {
        max-height: 50vh !important;
    }
}

@media (max-width: 768px) {
    #btn-chat-mobile {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 45px !important;
        height: 45px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        z-index: 1000000 !important;
    }
}

#chat-messages {
    flex-grow: 1;
    padding: 10px;
    overflow-y: auto;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}

#chat-messages::-webkit-scrollbar {
    width: 4px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 2px;
}

.chat-msg {
    word-break: break-word;
    line-height: 1.4;
}

.chat-user {
    font-weight: 800;
    color: var(--accent-color);
    margin-right: 6px;
}

.chat-text {
    color: var(--text-main);
}

#chat-input-container {
    padding: 8px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid var(--glass-border);
}

#chat-input {
    width: 100%;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 6px 10px;
    color: white;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
}

#chat-input:focus {
    border-color: var(--accent-color);
    background: rgba(255,255,255,0.1);
}

#gameover-stats p {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 2px;
}

#gameover-stats span {
    font-weight: 800;
    color: var(--accent-color);
}