body {
  margin: 0;
  overflow: hidden;
  background: #1a1a2e;
  color: #eee;
  font-family: sans-serif;
}
#game {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
}
#ui {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 320px;
}
#mapName {
  align-self: flex-start;
  padding: 5px 9px;
  border: 1px solid rgba(233, 196, 106, 0.4);
  border-radius: 999px;
  background: rgba(15, 15, 35, 0.82);
  color: #e9c46a;
  font-size: 12px;
  font-weight: bold;
  backdrop-filter: blur(4px);
}
#funcInput {
  padding: 8px;
  font-size: 14px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #111;
  color: #eee;
}
#fireBtn {
  padding: 8px;
  background: #2a9d8f;
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
}
#fireBtn:disabled {
  background: #555;
  cursor: not-allowed;
}
#cdBar {
  height: 6px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
}
#cdFill {
  width: 100%;
  height: 100%;
  background: #e9c46a;
  transition: width 0.1s linear;
}
#hpBar {
  position: relative;
  width: 200px;
  height: 22px;
  background: #2a2a3a;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}
#hpFill {
  width: 100%;
  height: 100%;
  background: #2a9d8f;
  transition: width 0.2s, background 0.2s;
}
#hpText {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
#winner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  font-weight: bold;
  color: #e9c46a;
  text-shadow: 0 4px 12px rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 20;
}
#winner.hidden { display: none; }
#status {
  font-size: 12px;
  color: #aaa;
}
#hitConfirm {
  position: absolute;
  top: 46px;
  left: 214px;
  color: #ffe36e;
  font-size: 18px;
  font-weight: bold;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(255, 82, 30, 0.9);
  transform: translateY(4px) scale(0.9);
}
#hitConfirm.active {
  animation: hit-confirm 600ms ease-out forwards;
}

#killFeed {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  max-width: min(440px, 60vw);
  pointer-events: none;
}
#killFeed.hidden {
  display: none;
}
.kill-feed-entry {
  padding: 8px 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 153, 76, 0.35);
  border-radius: 7px;
  background: rgba(13, 17, 32, 0.86);
  color: #ffd9ad;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.28);
  animation: kill-feed-life 4.2s ease forwards;
}
.kill-feed-entry.killed {
  border-color: rgba(255, 72, 88, 0.55);
  color: #ffafb7;
}

#damageFlash {
  position: fixed;
  inset: 0;
  z-index: 18;
  background: rgba(255, 28, 45, 0.22);
  opacity: 0;
  pointer-events: none;
}
#damageFlash.active {
  animation: damage-flash 150ms ease-out;
}

@keyframes damage-flash {
  0% { opacity: 0.8; }
  100% { opacity: 0; }
}

@keyframes hit-confirm {
  0% { opacity: 0; transform: translateY(5px) scale(0.8); }
  22% { opacity: 1; transform: translateY(0) scale(1.08); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px) scale(1); }
}

@keyframes kill-feed-life {
  0% { opacity: 0; transform: translateX(10px); }
  8%, 76% { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(6px); }
}

/* ===== Lobby ===== */
#lobby {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 680px;
  max-width: 90vw;
  max-height: 88vh;
  box-sizing: border-box;
  padding: 32px;
  overflow-y: auto;
  background: #16213e;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#lobby.hidden {
  display: none;
}

#lobby h1 {
  margin: 0;
  font-size: 28px;
  text-align: center;
  color: #e9c46a;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  color: #aaa;
  font-weight: bold;
}

.label-note {
  margin-left: 5px;
  color: #69738b;
  font-size: 11px;
  font-weight: normal;
}

.form-group input {
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #0f0f23;
  color: #eee;
  outline: none;
}

.form-group input:focus {
  border-color: #2a9d8f;
}

#avatarGrid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
}

#avatarGrid button {
  padding: 8px;
  font-size: 24px;
  background: #0f0f23;
  border: 2px solid #333;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
}

#avatarGrid button:hover {
  border-color: #2a9d8f;
  transform: scale(1.1);
}

#avatarGrid button.selected {
  border-color: #e9c46a;
  background: #1a1a2e;
}

#mapCards {
  display: flex;
  gap: 9px;
  padding: 2px 2px 7px;
  overflow-x: auto;
}

.map-card {
  flex: 0 0 138px;
  min-width: 0;
  padding: 10px;
  border: 2px solid #30364a;
  border-radius: 9px;
  background: #0f0f23;
  color: #eee;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s, background 0.18s, transform 0.12s;
}

.map-card:hover {
  border-color: #2a9d8f;
  transform: translateY(-2px);
}

.map-card.selected {
  border-color: #e9c46a;
  background: #22223d;
  box-shadow: 0 0 0 1px rgba(233, 196, 106, 0.2);
}

.map-card-title,
.map-card-description {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-card-title {
  margin-bottom: 6px;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
}

.map-card-description {
  color: #858da5;
  font-size: 11px;
}

#mapPickerStatus {
  min-height: 14px;
  color: #858da5;
  font-size: 11px;
}

.lobby-actions {
  display: flex;
  gap: 12px;
}

.lobby-actions button {
  flex: 1;
  padding: 12px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}

.lobby-actions button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.lobby-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#createBtn {
  background: #2a9d8f;
  color: #fff;
}

#joinBtn {
  background: #e9c46a;
  color: #1a1a2e;
}

#lobbyStatus {
  font-size: 13px;
  color: #aaa;
  text-align: center;
  min-height: 20px;
}

/* ===== Game UI ===== */
#ui.hidden,
#game.hidden {
  display: none;
}

@media (max-width: 560px) {
  #lobby {
    width: 360px;
    padding: 22px;
  }

  #avatarGrid {
    grid-template-columns: repeat(5, 1fr);
  }

  #killFeed {
    top: 10px;
    right: 10px;
    max-width: 54vw;
  }
}
