/* ─── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Author display: flex/block beats the UA-stylesheet [hidden]{display:none},
   so we re-enforce it here with !important. */
[hidden] { display: none !important; }

html, body {
  width: 100%; height: 100%;
  background: #0d0d14;
  color: #e0e0f0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
}

/* ─── Join screen ────────────────────────────────────────────────────────────── */
#joinScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  gap: 20px;
}

#joinScreen h1 {
  font-size: 2.2rem;
  text-align: center;
  text-shadow: 0 0 20px #7b5ea7;
}

.subtitle {
  color: #aaa;
  font-size: 1rem;
}

#classGrid {
  display: grid;
  grid-template-columns: repeat(4, 180px);
  gap: 14px;
}

@media (max-width: 800px) {
  #classGrid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  #classGrid { grid-template-columns: repeat(2, 1fr); }
}

.classCard {
  background: #1a1a2e;
  border: 2px solid #333;
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  user-select: none;
}

.classCard:hover {
  border-color: #7b5ea7;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px #7b5ea766;
}

.classCard.selected {
  border-color: #a78bfa;
  background: #2a1a4e;
  box-shadow: 0 0 20px #a78bfa55;
}

.classEmoji { font-size: 2.4rem; margin-bottom: 6px; }
.className  { font-weight: 700; font-size: 1.1rem; margin-bottom: 4px; }
.classDesc  { font-size: 0.78rem; color: #aaa; line-height: 1.4; }

#joinForm {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

#nameInput {
  padding: 10px 14px;
  border-radius: 8px;
  border: 2px solid #333;
  background: #111;
  color: #fff;
  font-size: 1rem;
  outline: none;
  width: 220px;
  transition: border-color 0.15s;
}
#nameInput:focus { border-color: #7b5ea7; }

#joinBtn {
  padding: 10px 24px;
  border-radius: 8px;
  border: none;
  background: #7b5ea7;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
#joinBtn:hover:not(:disabled) { background: #9d7ecf; transform: translateY(-1px); }
#joinBtn:disabled { opacity: 0.45; cursor: not-allowed; }

.error { color: #f87171; font-size: 0.9rem; min-height: 1.2em; }

/* ─── Game screen ────────────────────────────────────────────────────────────── */
#gameScreen {
  position: relative;
  width: 100vw; height: 100vh;
}

#gameCanvas {
  display: block;
  width: 100%; height: 100%;
  background: #0d0d14;
}

/* ─── HUD ──────────────────────────────────────────────────────────────────── */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 16px;
  pointer-events: none;
}

#hudWave {
  background: #00000088;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  border: 1px solid #ffffff22;
}

#hudRight {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.playerHud {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #00000088;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid #ffffff22;
  font-size: 0.85rem;
}

.playerHud .hpBar {
  width: 100px;
  height: 8px;
  background: #333;
  border-radius: 4px;
  overflow: hidden;
}

.playerHud .hpFill {
  height: 100%;
  background: #4ade80;
  border-radius: 4px;
  transition: width 0.1s;
}

.playerHud .xpBar {
  width: 60px;
  height: 5px;
  background: #333;
  border-radius: 4px;
  overflow: hidden;
}

.playerHud .xpFill {
  height: 100%;
  background: #a78bfa;
  border-radius: 4px;
}

/* ─── Wave banner ───────────────────────────────────────────────────────────── */
#waveBanner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  font-weight: 900;
  text-shadow: 0 0 30px #f59e0b, 0 2px 6px #000;
  color: #fde68a;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
  white-space: nowrap;
}
#waveBanner.show { opacity: 1; }

/* ─── Level-up overlay ──────────────────────────────────────────────────────── */
#levelUpOverlay {
  position: absolute;
  inset: 0;
  background: #000000bb;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#levelUpBox {
  background: #1a1a2e;
  border: 2px solid #7b5ea7;
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 700px;
  width: 95%;
  text-align: center;
  box-shadow: 0 0 60px #7b5ea788;
}

#levelUpBox h2 {
  font-size: 1.6rem;
  margin-bottom: 24px;
  color: #e0e0f0;
}

#itemCards {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.itemCard {
  background: #12122a;
  border: 2px solid #444;
  border-radius: 12px;
  padding: 20px 16px;
  width: 190px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  text-align: center;
}
.itemCard:hover {
  border-color: #a78bfa;
  transform: translateY(-3px);
  box-shadow: 0 6px 20px #a78bfa44;
}
.itemCard .itemIcon  { font-size: 2.5rem; margin-bottom: 8px; }
.itemCard .itemName  { font-weight: 700; font-size: 1rem; margin-bottom: 6px; }
.itemCard .itemDesc  { font-size: 0.8rem; color: #aaa; line-height: 1.4; }
