* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #0d0d1a;
  color: #eee;
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Buttons */
.btn {
  padding: 12px 32px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.btn-primary {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
  box-shadow: 0 2px 12px rgba(231, 76, 60, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(231, 76, 60, 0.35);
}

.btn-secondary {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
  box-shadow: 0 2px 12px rgba(52, 152, 219, 0.2);
}

.btn-secondary:hover {
  box-shadow: 0 6px 24px rgba(52, 152, 219, 0.3);
}

.btn-small {
  padding: 6px 16px;
  font-size: 13px;
  background: rgba(60, 60, 80, 0.6);
  color: #aab;
  border: 1px solid rgba(255,255,255,0.08);
}

.btn-small:hover {
  background: rgba(80, 80, 100, 0.7);
}

/* Menu Screen */
#menu-screen {
  background: radial-gradient(ellipse at 50% 30%, #1a1028 0%, #0d0d1a 70%);
  overflow: hidden;
}

#menu-screen .menu-bg-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

#menu-model-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

#menu-model-container canvas {
  width: 100%;
  height: 100%;
}

.menu-container {
  position: relative;
  z-index: 1;
}

.menu-container {
  text-align: center;
  max-width: 480px;
  width: 100%;
  padding: 40px 32px;
  background: rgba(16, 16, 32, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 20px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.04);
}

.game-title {
  font-size: 72px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 36px;
  background: linear-gradient(135deg, #e74c3c, #f39c12);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 2px 8px rgba(231, 76, 60, 0.3));
}

.game-title span {
  font-size: 36px;
  letter-spacing: 8px;
  background: linear-gradient(135deg, #f39c12, #e67e22);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.name-input {
  margin-bottom: 24px;
}

.name-input input {
  width: 100%;
  padding: 14px 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(22, 33, 62, 0.8);
  color: #eee;
  font-size: 18px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.name-input input:focus {
  border-color: #e74c3c;
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.15);
}

.menu-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 28px;
}

.room-list {
  background: rgba(22, 33, 62, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 18px;
  text-align: left;
}

.room-list h3 {
  margin-bottom: 12px;
  color: #667;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(26, 26, 46, 0.6);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.room-item:hover {
  background: rgba(42, 42, 78, 0.7);
  border-color: rgba(231, 76, 60, 0.2);
  transform: translateX(2px);
}

.room-item .room-info {
  flex: 1;
}

.room-item .room-players {
  color: #778;
  font-size: 13px;
}

.no-rooms {
  color: #556;
  text-align: center;
  padding: 20px;
  font-style: italic;
}

/* Lobby */
#lobby-screen {
  background: radial-gradient(ellipse at 50% 20%, #141428 0%, #0d0d1a 70%);
}

.lobby-container {
  width: 100%;
  max-width: 860px;
  padding: 32px;
  max-height: 100vh;
  overflow-y: auto;
}

.lobby-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.lobby-header h2 {
  flex: 1;
  font-size: 22px;
  font-weight: 700;
}

.room-code {
  background: rgba(50, 50, 70, 0.6);
  padding: 6px 14px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 16px;
  color: #f39c12;
  cursor: pointer;
  border: 1px solid rgba(243, 156, 18, 0.2);
  transition: background 0.2s;
}

.room-code:hover {
  background: rgba(50, 50, 70, 0.9);
}

.lobby-rename {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.lobby-rename input {
  flex: 1;
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(22, 33, 62, 0.6);
  color: #eee;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.lobby-rename input:focus {
  border-color: #e74c3c;
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.lobby-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.player-list, .spell-select, .room-settings {
  background: rgba(16, 20, 40, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 18px;
}

.lobby-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-list h3, .spell-select h3, .room-settings h3 {
  margin-bottom: 14px;
  color: #667;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.room-settings #settings-host-only {
  font-size: 11px;
  color: #556;
}

.setting-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 0;
  font-size: 14px;
  color: #bbc;
}

.setting-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #e74c3c;
  cursor: pointer;
}

.setting-toggle input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lobby-player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: rgba(255,255,255,0.02);
  transition: background 0.15s;
}

.lobby-player:hover {
  background: rgba(255,255,255,0.04);
}

.lobby-player .color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}

.lobby-player .name {
  flex: 1;
  font-size: 15px;
}

.lobby-player .ready-status {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lobby-player .ready-status.ready {
  color: #2ecc71;
}

.lobby-player .ready-status.not-ready {
  color: #c0392b;
  opacity: 0.7;
}

.spell-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.spell-option {
  padding: 10px 12px;
  background: rgba(26, 26, 46, 0.5);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.spell-option:hover {
  background: rgba(42, 42, 78, 0.5);
  border-color: rgba(255,255,255,0.08);
}

.spell-option.selected {
  border-color: rgba(231, 76, 60, 0.5);
  background: rgba(231, 76, 60, 0.08);
  box-shadow: inset 0 0 12px rgba(231, 76, 60, 0.05);
}

.spell-option .spell-name {
  font-weight: 600;
  margin-bottom: 2px;
  font-size: 14px;
}

.spell-option .spell-desc {
  font-size: 11px;
  color: #778;
}

.lobby-footer {
  text-align: center;
}

.lobby-footer .btn {
  min-width: 180px;
  padding: 14px 40px;
  font-size: 18px;
}

.btn-ready.is-ready {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
}

/* Game Screen */
#game-screen {
  background: #111;
}

#game-screen.active {
  display: block;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#hud > * {
  pointer-events: auto;
}

#hud-top {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
  gap: 32px;
}

#round-counter {
  background: rgba(0,0,0,0.6);
  padding: 8px 24px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
}

#kill-feed {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.kill-message {
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 600;
  animation: fadeInOut 3s forwards;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateY(-10px); }
  10% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

#hud-right {
  position: absolute;
  top: 16px;
  right: 16px;
}

#scoreboard {
  background: rgba(0,0,0,0.6);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 200px;
}

.score-row {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  font-size: 13px;
  align-items: center;
}

.score-row .color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.score-row .name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-row .kills, .score-row .points {
  width: 30px;
  text-align: right;
}

.score-row.dead {
  opacity: 0.4;
}

#hud-bottom {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#hp-bar-container {
  width: 200px;
  height: 20px;
  background: rgba(0,0,0,0.6);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

#hp-bar {
  height: 100%;
  background: linear-gradient(90deg, #e74c3c, #2ecc71);
  transition: width 0.2s;
  width: 100%;
}

#hp-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

#spell-bar {
  display: flex;
  gap: 8px;
}

.spell-slot {
  width: 56px;
  height: 56px;
  background: rgba(0,0,0,0.6);
  border: 2px solid #444;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  pointer-events: auto;
}

.spell-slot .spell-key {
  font-size: 13px;
  font-weight: 800;
  color: #f39c12;
  position: absolute;
  top: 2px;
  left: 4px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  letter-spacing: -0.5px;
}

.spell-slot .spell-icon {
  font-size: 20px;
}

.spell-slot .cooldown-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(0,0,0,0.7);
  transition: height 0.1s linear;
}

.spell-slot .cooldown-text {
  position: absolute;
  bottom: 2px;
  width: 100%;
  text-align: center;
  font-size: 11px;
  color: #f39c12;
  font-weight: 700;
}

/* Overlays */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: auto;
}

.overlay.hidden {
  display: none;
}

.overlay h1 {
  font-size: 48px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #f39c12, #e74c3c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overlay h2 {
  font-size: 28px;
  margin-bottom: 16px;
}

#final-scores {
  margin: 20px 0 28px;
  background: rgba(10, 10, 20, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  min-width: 420px;
  backdrop-filter: blur(8px);
}

.final-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.final-table thead {
  background: rgba(255, 255, 255, 0.04);
}

.final-table th {
  padding: 10px 16px;
  text-align: center;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #667;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.final-table th.name-col {
  text-align: left;
}

.final-table td {
  padding: 12px 16px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: #bbc;
}

.final-table td.name-col {
  text-align: left;
  font-weight: 600;
  color: #eee;
  display: flex;
  align-items: center;
  gap: 10px;
}

.final-table td.pts-col {
  font-weight: 800;
  font-size: 17px;
  color: #f39c12;
}

.final-table tr:last-child td {
  border-bottom: none;
}

.final-table .winner-row td {
  background: rgba(243, 156, 18, 0.08);
}

.final-table .winner-row td.name-col {
  color: #f39c12;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  background: rgba(255,255,255,0.06);
  color: #888;
}

.rank-badge.rank-1 {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: #fff;
  box-shadow: 0 0 10px rgba(243, 156, 18, 0.4);
}

.rank-badge.rank-2 {
  background: linear-gradient(135deg, #95a5a6, #7f8c8d);
  color: #fff;
}

.rank-badge.rank-3 {
  background: linear-gradient(135deg, #cd7f32, #a0622e);
  color: #fff;
}

/* Spell icon badges (text-based, no emojis) */
.spell-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  vertical-align: middle;
  margin-right: 6px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.spell-icon-hud {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.spell-icon-img {
  width: 28px;
  height: 28px;
  vertical-align: middle;
  margin-right: 6px;
  border-radius: 4px;
}

.spell-icon-hud-img {
  width: 32px;
  height: 32px;
  border-radius: 5px;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

/* Scoreboard header */
#scoreboard .score-header {
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 4px;
  padding-bottom: 4px;
}

/* Mute button */

#hud-left {
  position: absolute;
  top: 16px;
  left: 16px;
  pointer-events: auto;
}

#global-audio {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 9999;
  pointer-events: auto;
}

.audio-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0,0,0,0.6);
  border-radius: 8px;
  padding: 8px 12px;
}

.audio-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.audio-label {
  font-size: 11px;
  font-weight: 700;
  color: #aaa;
  letter-spacing: 0.5px;
  min-width: 46px;
}

.audio-slider {
  width: 70px;
  height: 4px;
  accent-color: #f39c12;
  cursor: pointer;
  pointer-events: auto;
}

/* Speed slider */
.setting-toggle input[type="range"] {
  flex: 1;
  accent-color: #e74c3c;
  cursor: pointer;
}

.setting-toggle input[type="range"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 3D game overlays */
.game-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 50;
}

.game-overlay.hidden {
  display: none;
}

#countdown-overlay {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 120px;
  font-weight: 900;
  color: white;
  text-shadow: 0 3px 6px rgba(0,0,0,0.8);
}

#countdown-overlay.animate {
  animation: countdownPulse 0.667s ease-out;
}

@keyframes countdownPulse {
  0% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
}

#shrink-warning {
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 28px;
  font-weight: 700;
  color: #e74c3c;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
  animation: shrinkPulse 0.4s ease-in-out infinite alternate;
}

@keyframes shrinkPulse {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}

#lava-vignette {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: box-shadow 0.2s;
}
