* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  overflow: hidden;
  background: #000;
  font-family: "Arial", sans-serif;
}
canvas {
  display: block;
}

/* ===== TITLE SCREEN ===== */
#title-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #ff006e, #8338ec, #3a86ff);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
}
#title-screen h1 {
  font-size: 80px;
  color: #ffbe0b;
  text-shadow:
    4px 4px 0 #fb5607,
    8px 8px 0 #ff006e;
  animation: bounce 0.6s ease-in-out infinite alternate;
}
#title-screen p {
  font-size: 24px;
  color: white;
  margin-top: 20px;
  opacity: 0.8;
}
.title-controls-hint {
  margin-top: 40px;
  font-size: 16px;
  opacity: 0.6;
}
@keyframes bounce {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-20px);
  }
}

/* ===== LOBBY SCREEN ===== */
#lobby-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: linear-gradient(135deg, #ff006e, #8338ec, #3a86ff);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding: clamp(28px, 7vh, 72px) 16px 56px;
  z-index: 200;
}
#lobby-screen h1 {
  font-size: clamp(42px, 8vw, 60px);
  color: #ffbe0b;
  text-shadow:
    3px 3px 0 #fb5607,
    6px 6px 0 #ff006e;
  margin-bottom: 8px;
  text-align: center;
}
.lobby-author {
  font-size: 24px;
  color: rgba(255, 255, 255, 0.85);
  margin: 0 0 24px;
  text-shadow: 0 0 16px rgba(255, 255, 255, 0.35);
}
#lobby-screen input {
  font-size: 24px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  text-align: center;
  margin: 8px;
  width: 260px;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
}
#lobby-screen input::placeholder {
  color: #999;
}
#lobby-screen button {
  font-size: 22px;
  padding: 12px 30px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin: 8px;
  font-weight: bold;
  width: 260px;
  transition: transform 0.1s;
}
#lobby-screen button:hover {
  transform: scale(1.05);
}
.btn-create {
  background: #06d6a0;
  color: #000;
}
.btn-join {
  background: #ffbe0b;
  color: #000;
}
#lobby-status {
  color: white;
  font-size: 18px;
  margin-top: 15px;
  min-height: 24px;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}
.lobby-divider {
  color: white;
  font-size: 18px;
  margin: 10px 0;
}
.room-code-input {
  text-transform: uppercase;
  letter-spacing: 6px;
}
.btn-solo {
  background: #8338ec;
  color: white;
}
#start-game-btn {
  display: none;
  margin-top: 20px;
  background: #fb5607;
  color: white;
}
.player-list {
  color: white;
  font-size: 16px;
  margin-top: 10px;
}
#room-code-display {
  font-size: 48px;
  color: #ffbe0b;
  font-weight: bold;
  letter-spacing: 12px;
  text-shadow: 3px 3px 0 #fb5607;
  margin: 15px 0;
  display: none;
}
/* ===== ABOUT SECTION (SEO) ===== */
.about-section {
  margin-top: max(120px, calc(100vh - 560px));
  padding: 20px 30px;
  max-width: 480px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  text-align: center;
  color: rgba(255, 255, 255, 0.75);
  font-size: 14px;
  line-height: 1.6;
}

@media (max-height: 720px) {
  #lobby-screen {
    padding-top: 24px;
  }
  .lobby-author {
    margin-bottom: 14px;
  }
  #lobby-screen input,
  #lobby-screen button {
    margin: 5px;
  }
  .lobby-divider {
    margin: 5px 0;
  }
}
.about-section h3 {
  font-size: 16px;
  color: #ffbe0b;
  margin-bottom: 6px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
.about-section p {
  margin-bottom: 12px;
}
.about-section p:last-child {
  margin-bottom: 0;
}

/* ===== HUD ===== */
#hud {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 10;
  color: white;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}
#hud .score {
  font-size: 32px;
  color: #ffbe0b;
}
#hud .total {
  font-size: 16px;
  color: #ccc;
  margin-top: 4px;
}

/* ===== INVENTORY BAR ===== */
#inventory {
  --inventory-border: rgba(255, 255, 255, 0.4);
  --inventory-active: #ffbe0b;
  --inventory-panel: rgba(0, 0, 0, 0.58);
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: min(520px, calc(100vw - 24px));
}
.inv-slot {
  width: 68px;
  height: 72px;
  border: 3px solid var(--inventory-border);
  border-radius: 8px;
  background: var(--inventory-panel);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  padding: 8px 5px 6px;
  font: inherit;
  overflow: hidden;
  transition:
    border-color 0.15s,
    background 0.15s,
    transform 0.15s;
}
.inv-slot.active {
  border-color: var(--inventory-active);
  background: rgba(255, 190, 11, 0.25);
}
.inv-slot:hover {
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 10px rgba(255, 190, 11, 0.3);
  transform: translateY(-1px);
}
.inv-slot .key-hint {
  position: absolute;
  top: 2px;
  left: 5px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: bold;
}
.inv-slot .item-icon {
  width: 30px;
  height: 30px;
  font-size: 24px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.inv-slot .item-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.inv-slot .item-name {
  width: 100%;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 4px;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: 0;
  white-space: nowrap;
}
.inv-slot .item-status {
  width: 100%;
  min-height: 11px;
  margin-top: 1px;
  color: #ffdf7d;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 520px) {
  #inventory {
    bottom: 12px;
    gap: 6px;
    width: min(356px, calc(100vw - 16px));
  }

  .inv-slot {
    width: 58px;
    height: 66px;
    padding: 8px 4px 5px;
  }

  .inv-slot .item-icon {
    width: 27px;
    height: 27px;
    font-size: 21px;
  }

  .inv-slot .item-name,
  .inv-slot .item-status {
    font-size: 8px;
  }
}

/* ===== DAMAGE NUMBERS ===== */
.damage-number {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  font-size: 28px;
  font-weight: 900;
  color: #ff4444;
  text-shadow:
    2px 2px 0 #000,
    -1px -1px 0 #000;
  animation: damageFloat 0.8s ease-out forwards;
}
@keyframes damageFloat {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translateY(-60px) scale(0.6);
  }
}

/* ===== HEALTH BAR ===== */
#health-bar-container {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 16px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid #fff;
  border-radius: 8px;
  overflow: hidden;
  z-index: 20;
}
#health-bar-fill {
  width: 100%;
  height: 100%;
  background: #44ff44;
  transition:
    width 0.3s ease-out,
    background 0.3s ease;
  border-radius: 6px;
}
#health-text {
  position: fixed;
  bottom: 118px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
  text-shadow: 1px 1px 2px black;
  z-index: 20;
  pointer-events: none;
}
#damage-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 0, 0, 0);
  pointer-events: none;
  z-index: 25;
  transition: background 0.1s;
}
#death-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(139, 0, 0, 0.85);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 30;
  color: #ff4444;
  font-size: 72px;
  font-weight: 900;
  text-shadow: 4px 4px 0 #000;
}
#death-overlay .respawn-timer {
  font-size: 24px;
  color: white;
  margin-top: 20px;
}

/* ===== CROSSHAIR ===== */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  pointer-events: none;
  display: none;
}
#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.8);
}
#crosshair::before {
  width: 20px;
  height: 2px;
  top: -1px;
  left: -10px;
}
#crosshair::after {
  width: 2px;
  height: 20px;
  top: -10px;
  left: -1px;
}
#game-fade-in {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: black;
  z-index: 50;
  pointer-events: none;
  animation: fadeOut 1s ease-out 0.2s forwards;
}
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

#title-screen.hidden,
#hud.hidden,
#health-bar-container.hidden,
#health-text.hidden,
#game-fade-in.hidden {
  display: none;
}
