body {
  margin: 0;
  overflow: hidden;
  background: #111;
  font-family: Arial, sans-serif;
  color: white;
}

/* canvas */
#game {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  pointer-events: none;
}

#abilityBar {
  position: fixed;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 16px));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  z-index: 10001;
  box-sizing: border-box;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
}

#abilityBar.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.abilityBtn {
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(0,0,0,0.7);
  color: white;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.2);
}

/* 🔥 верхняя панель */
#topBar {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 1;
  transform: translateY(0);

  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 50px;
  background: linear-gradient(180deg, rgba(0,0,0,0.8), rgba(0,0,0,0.4));
  display: none;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
  z-index: 100;
}

#topBar.hidden {
  opacity: 0;
  transform: translateY(-100%);
}

/* кнопки */
#startBtn, #restartBtn, #menuBtn {
  padding: 8px 12px;
  font-size: 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin: 0 5px;
  height: 36px;
  box-sizing: border-box;
  line-height: 1;

  background: rgba(255,255,255,0.1);
  color: white;
  transition: all 0.2s ease;
  transform: scale(1);
}

#startBtn:hover, #restartBtn:hover, #menuBtn:hover {
  transform: scale(1.05);
  filter: brightness(1.2);
  background: rgba(255,255,255,0.2);
}

#startBtn:active, #restartBtn:active, #menuBtn:active {
  transform: scale(0.95);
  transition: all 0.1s ease;
}

#restartBtn {
  margin-right: 5px;
}

#menuBtn {
  margin-left: 5px;
}

/* title */
#title {
  font-size: 14px;
  font-weight: bold;
}

/* панель */
#uiPanel {
  display: none;
  border: 1px solid rgba(0,255,255,0.2);
  box-shadow:
    0 0 10px rgba(0,255,255,0.2),
    inset 0 0 10px rgba(0,255,255,0.1);
  position: fixed;
  right: 15px;
  top: 60px;
  z-index: 10;

  width: 200px;
  max-height: 30vh;
  overflow-y: auto;

  padding: 10px;
  border-radius: 10px;

  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
}

#activeEffectsHud {
  position: fixed;
  top: 60px;
  left: 15px;
  z-index: 11;
  display: none;
  width: min(280px, calc(100vw - 235px));
  right: 225px;
  max-height: 34vh;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background: rgba(0,0,0,0.52);
  backdrop-filter: blur(10px);
  box-shadow:
    0 0 10px rgba(0,255,255,0.18),
    inset 0 0 10px rgba(255,255,255,0.06);
}

#activeEffectsHud.hasEffects {
  display: block;
}

.effectHudTitle {
  font-size: 10px;
  line-height: 1;
  margin-bottom: 7px;
  color: rgba(255,255,255,0.62);
  text-transform: uppercase;
}

.effectHudItem {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  margin-bottom: 6px;
  padding: 5px 7px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
}

.effectHudItem:last-child {
  margin-bottom: 0;
}

.effectHudItem.boss {
  border-color: rgba(255,60,90,0.52);
  background: rgba(255,0,60,0.16);
}

.effectHudItem img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.effectHudMain {
  min-width: 0;
  width: max-content;
}

.effectHudName {
  font-size: 9px;
  line-height: 1.1;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.effectHudType {
  margin-top: 2px;
  font-size: 8px;
  line-height: 1.1;
  color: rgba(255,255,255,0.68);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.effectHudTimer {
  min-width: 20px;
  padding: 2px 3px;
  border-radius: 8px;
  background: rgba(0,0,0,0.42);
  color: #00f0ff;
  font-size: 8px;
  line-height: 1;
  text-align: center;
}

.menuVersion {
  margin-top: 20px;
  font-size: 12px;
  opacity: 0.6;
}

/* игрок */
.player {
  display: flex;
  align-items: center;
  margin-bottom: 3px;
  font-size: 10px;
}

.player img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  margin-right: 6px;
  object-fit: cover;
}

.player.leader {
  font-weight: bold;
  color: #00f0ff;
  text-shadow:
    0 0 5px #00f0ff,
    0 0 10px #00f0ff;
}

/* Effect items styled like players */
.player.effect-item {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: 2px 6px;
}

.player.effect-item.boss-effect {
  background: rgba(255,0,60,0.16);
  border-color: rgba(255,60,90,0.52);
  color: #ff3c5a;
  font-weight: bold;
}

/* подпись */
#signature {
  position: fixed;
  bottom: 10px;
  right: 15px;
  z-index: 10;
  font-size: 12px;
  color: rgba(255,255,255,0.3);
}

/* 📱 мобилка */
@media (max-width: 600px) {

  #topBar {
    height: 45px;
  }

  #startBtn, #restartBtn {
    font-size: 12px;
    padding: 6px 8px;
  }

  #title {
    font-size: 12px;
  }

  #uiPanel{
    position: fixed;
    top: 55px;
    right: 5px;
    left: auto;
  
    width: 118px;
    max-height: 34vh;
  
    padding: 6px;
    font-size: 11px;
    overflow-y: auto;
  }

  #activeEffectsHud{
    position: fixed;
  
    top: calc(55px + 34vh + 8px);
    right: 5px;
    left: auto;
  
    width: 118px;
    max-width: 118px;
    max-height: 26vh;
  
    display: none;
  
    overflow-y: auto;
    overflow-x: hidden;
  
    padding: 4px;
    white-space: normal;
    backdrop-filter: blur(14px);
    opacity: .92;
  }

  #activeEffectsHud.hasEffects {
    display: block;
  }

  #activeEffectsHud .effectHudTitle {
    display: none;
  }

  .effectHudItem{
    display:grid;
    grid-template-columns: 18px minmax(0,1fr) auto;
  
    width:100%;
    min-height:22px;
  
    margin-bottom:3px;
    padding:3px 4px;
    gap:4px;
  }

  .effectHudItem img{
    width:18px;
    height:18px;
  }

  .effectHudName{
    font-size:9px;
  }

  .effectHudType{
    font-size:8px;
  }

  .effectHudTimer{
    font-size:8px;
    min-width:18px;
    padding:1px 3px;
  }

  .player {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    font-size: 10px;
    line-height: 1.2;
  }

  .player img {
    width: 14px;
    height: 14px;
  }

  #signature {
    left: 50%;
    transform: translateX(-50%);
    right: auto;
  }
}

#winnerOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#winnerOverlay.show {
  opacity: 1;
}

#winnerContent {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 2px solid rgba(0,240,255,0.3);
  border-radius: 15px;
  padding: 40px;
  text-align: center;
  transform: scale(0.8);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 30px rgba(0,240,255,0.2);
}

#winnerOverlay.show #winnerContent {
  transform: scale(1);
}

#winnerTitle {
  font-size: 36px;
  font-weight: bold;
  color: #00f0ff;
  margin-bottom: 20px;
  text-shadow: 0 0 20px rgba(0,240,255,0.5);
  animation: winnerGlow 2s ease-in-out infinite;
}

@keyframes winnerGlow {
  0%, 100% {
    text-shadow: 0 0 20px rgba(0,240,255,0.5);
  }
  50% {
    text-shadow: 0 0 30px rgba(0,240,255,0.8), 0 0 50px rgba(0,240,255,0.4);
  }
}

#winnerImg {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin: 20px 0;
  border: 3px solid rgba(0,240,255,0.5);
  box-shadow: 0 0 20px rgba(0,240,255,0.3);
  animation: winnerSpin 1s ease-in-out;
}

@keyframes winnerSpin {
  from {
    transform: rotate(0deg) scale(0);
  }
  to {
    transform: rotate(360deg) scale(1);
  }
}

#winnerText {
  font-size: 20px;
  font-weight: bold;
}

#winnerRestart {
  background: linear-gradient(90deg, #00f0ff, #ff00c8);
  border: none;
  border-radius: 10px;
  padding: 12px 30px;
  font-size: 16px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 20px;
}

#winnerRestart:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 20px rgba(0,240,255,0.5);
}

#winnerText {
  font-size: 20px;
  font-weight: bold;
}

#winnerRestart {
  margin-top: 15px;
  padding: 14px 40px;
  font-size: 18px;
  border: none;
  border-radius: 10px;

  background: linear-gradient(90deg, #00f0ff, #ff00c8);
  color: white;
  cursor: pointer;

  box-shadow:
    0 0 15px rgba(0,255,255,0.5);

  transition: 0.2s;
}

#winnerRestart:hover {
  transform: scale(1.05);
}

#winnerTitle {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 10px;
  letter-spacing: 1px;
  color: gold;
}

#winnerImg {
  max-width: 250px;
  border-radius: 50%;
  margin-bottom: 20px;

  border: 4px solid gold;
  box-shadow:
    0 0 10px gold,
    0 0 25px gold,
    0 0 50px rgba(255,215,0,0.6);
}

#winnerContent {
  text-align: center;
  color: white;

  transform: scale(0.7);
  opacity: 0;
  animation: winnerPop 0.5s ease forwards;
}

@keyframes winnerPop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  60% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

#effectText {
  z-index: 9999;
  position: fixed;
  bottom: 82px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);

  background: rgba(0,0,0,0.85);
  color: white;
  padding: 10px 20px;
  border-radius: 10px;

  font-size: 16px;
  font-weight: bold;
  pointer-events: none;
  box-shadow: 
    0 0 10px rgba(0,0,0,0.8),
    0 0 20px rgba(0,0,0,0.6);
  text-shadow:
    0 0 5px black,
    0 0 10px black,
    0 0 15px black;
  border: 1px solid rgba(255,255,255,0.2);
  opacity: 0;
  transition: all 0.3s ease;
}

#effectText.show {
  animation: effectPop .25s ease, glowText .8s infinite alternate;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  animation: effectPop 0.3s ease;
}

@keyframes glowText{
  from{ box-shadow:0 0 10px rgba(0,255,255,.2);}
  to{ box-shadow:0 0 22px rgba(255,0,200,.45);}
}

@keyframes effectPop {
  0% { transform: translateX(-50%) scale(0.8); }
  100% { transform: translateX(-50%) scale(1); }
}

#mainMenu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: all;

  z-index: 99991;

  display: flex;
  justify-content: center;
  align-items: center;

  background: radial-gradient(circle at center, rgba(10,10,20,0.2), rgba(0,0,0,0.7));
  backdrop-filter: blur(2px);
}

.menuContent {
  text-align: center;
}

.menuTitle {
  font-size: 36px;
  color: #00f0ff;
  text-shadow:
    0 0 10px #00f0ff,
    0 0 30px #00f0ff;
  margin-bottom: 10px;
  animation: titlePulse 3s ease-in-out infinite;
  transition: all 0.3s ease;
}

@keyframes titlePulse {
  0%, 100% {
    transform: scale(1);
    text-shadow:
      0 0 10px #00f0ff,
      0 0 30px #00f0ff;
  }
  50% {
    transform: scale(1.02);
    text-shadow:
      0 0 15px #00f0ff,
      0 0 40px #00f0ff,
      0 0 60px rgba(0,240,255,0.5);
  }
}

.menuSubtitle {
  opacity: 0.6;
  margin-bottom: 25px;
}

#menuStart, #menuInteractive {
  margin-top: 15px;
  padding: 14px 40px;
  font-size: 18px;
  border: none;
  border-radius: 10px;

  background: linear-gradient(90deg, #00f0ff, #ff00c8);
  color: white;
  cursor: pointer;

  box-shadow:
    0 0 15px rgba(0,255,255,0.5);

  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(0) scale(1);
  position: relative;
  overflow: hidden;
}

#menuStart:hover, #menuInteractive:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow:
    0 5px 25px rgba(0,255,255,0.7),
    0 0 20px rgba(255,0,200,0.4);
}

#menuStart:active, #menuInteractive:active {
  transform: translateY(0) scale(0.98);
  transition: all 0.1s ease;
}

.abilityBtn{
  backdrop-filter: blur(8px);
  letter-spacing: 0;
  min-width: 0;
  width: 100%;
  padding:10px 6px;
  border:none;
  border-radius:8px;
  cursor:pointer;
  color:white;
  font-weight:bold;
  font-size:13px;
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: anywhere;

  background: linear-gradient(135deg,#111,#222);
  border:1px solid rgba(0,255,255,0.35);

  box-shadow:
    0 0 8px rgba(0,255,255,.25),
    inset 0 0 8px rgba(255,255,255,.05);

  transition: .18s ease;
}

.abilityBtn:hover{
  transform: translateY(-2px) scale(1.05);
  box-shadow:
    0 0 14px rgba(0,255,255,.45),
    0 0 28px rgba(255,0,200,.25);
}

.abilityBtn:active{
  transform: scale(.94);
}

.abilityBtn.active{
  background: linear-gradient(135deg,#00cfff,#ff00c8);
  box-shadow:
    0 0 14px #00f0ff,
    0 0 30px #ff00c8;
}

.abilityBtn.cooldown{
  opacity:.45;
  pointer-events:none;
  filter: grayscale(.4);
}

.abilityBtn.ready{
  animation:pulseBtn .7s infinite alternate, wiggle 1.4s infinite;
}

@keyframes wiggle{
  0%,100%{ transform:rotate(0deg);}
  25%{ transform:rotate(-1deg);}
  75%{ transform:rotate(1deg);}
}

@keyframes pulseBtn{
  from{ box-shadow:0 0 8px rgba(0,255,255,.25);}
  to{ box-shadow:0 0 18px rgba(0,255,255,.8);}
}

.abilityBtn{
  position: relative;
  overflow: hidden;
}

.abilityBtn .label{
  position: relative;
  z-index: 3;
}

.cdOverlay{
  position:absolute;
  left:0;
  bottom:0;
  width:100%;
  height:0%;
  background:rgba(0,0,0,.72);
  z-index:2;
  pointer-events:none;
}

.cdText{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:22px;
  font-weight:bold;
  color:white;
  text-shadow:0 0 10px black;
  z-index:4;
  pointer-events:none;
}

#title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: bold;
  color: white;
  text-shadow: 0 0 5px rgba(0,255,255,0.3);
  right: 80px; /* Reserve space for FPS indicator */
  width: auto;
  max-width: calc(100% - 160px);
  text-align: center;
}

#fpsDisplay {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: bold;
  font-family: monospace;
  text-shadow: 0 0 2px rgba(0,0,0,0.5);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.7;
}

/* Smooth transitions for game elements */
.player {
  transition: all 0.3s ease;
}

.player:hover {
  transform: translateX(2px);
  filter: brightness(1.1);
}

.effect-item {
  transition: all 0.3s ease;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Smooth transitions for UI panels */
#uiPanel, #activeEffectsHud {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Button animations */
#startBtn, #restartBtn, #menuBtn {
  transition: all 0.2s ease;
  transform: scale(1);
}

#startBtn:hover, #restartBtn:hover, #menuBtn:hover {
  transform: scale(1.05);
  filter: brightness(1.2);
}

#startBtn:active, #restartBtn:active, #menuBtn:active {
  transform: scale(0.95);
}
