:root {
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Primary HSL Theme Colors */
  --bg-dark: 224 71% 4%;
  --card-bg: 222 47% 11%;
  --glass-bg: 224 71% 4% / 45%;
  --border-color: 217.2 32.6% 17.5%;
  --border-glass: 255 255 255 / 8%;
  
  --primary: 221.2 83.2% 53.3%;
  --primary-hover: 226.2 80% 60%;
  --text-light: 210 40% 98%;
  --text-muted: 215.4 16.3% 56.9%;
  
  /* Status Colors */
  --success: 142.1 76.2% 36.3%;
  --danger: 0 84.2% 60.2%;
  
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: hsl(var(--bg-dark));
  color: hsl(var(--text-light));
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
}

#game-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* Glassmorphism base style */
.glass {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Overlays Container (Login & Loading) */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  background: radial-gradient(circle at center, rgba(8, 12, 24, 0.82) 0%, rgba(4, 7, 14, 0.92) 100%);
}

/* Login overlay specifically: lighter so 3D world shows through */
#login-overlay {
  background: radial-gradient(ellipse at 50% 40%, rgba(14, 20, 42, 0.72) 0%, rgba(4, 8, 18, 0.88) 100%);
  backdrop-filter: blur(2px) saturate(120%);
  -webkit-backdrop-filter: blur(2px) saturate(120%);
}

.overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Spinner */
.spinner-container {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: hsl(var(--primary));
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Login/Avatar Customizer Card */
.login-card {
  width: 90%;
  max-width: 480px;
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  text-align: left;
  transform: translateY(20px);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.overlay.active .login-card {
  transform: translateY(0);
}

/* Music hint below Enter button */
.login-music-hint {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.78rem;
  color: rgba(148, 163, 184, 0.7);
  letter-spacing: 0.03em;
  animation: pulse-hint 3s ease-in-out infinite;
  pointer-events: none;
  user-select: none;
}

.login-music-icon {
  display: inline-block;
  animation: bob-icon 2s ease-in-out infinite;
}

@keyframes bob-icon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes pulse-hint {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.95; }
}

.login-header {
  margin-bottom: 2rem;
  text-align: center;
}

.login-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.login-header p {
  color: hsl(var(--text-muted));
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.6rem;
  color: hsl(var(--text-muted));
}

.form-group input[type="text"] {
  width: 100%;
  padding: 0.9rem 1.2rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-family);
  font-size: 1rem;
  transition: var(--transition);
}

.form-group input[type="text"]:focus {
  outline: none;
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 2px hsl(var(--primary) / 25%);
  background: rgba(15, 23, 42, 0.8);
}



/* Color Picker customization */
.color-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
}

.color-picker-wrapper input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  background: none;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

.color-value {
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* HUD elements container */
#hud-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none; /* Let clicks pass through to Three.js canvas */
}

#hud-container > * {
  pointer-events: auto; /* Re-enable pointer events for UI panels */
}

/* HUD Panels */
.hud-card {
  position: absolute;
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-md);
}


.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: hsl(var(--danger));
  box-shadow: 0 0 8px hsl(var(--danger));
  transition: var(--transition);
}

.status-dot.connected {
  background-color: hsl(var(--success));
  box-shadow: 0 0 8px hsl(var(--success));
}

.player-name-tag {
  font-weight: 700;
  font-size: 0.95rem;
}

.stats-location {
  font-size: 0.75rem;
  color: hsl(var(--text-muted));
  font-weight: 500;
}

.event-board {
  position: absolute;
  top: 1.5rem;
  right: calc(1.5rem + 72px + 0.75rem); /* icon bar width + gap */
  width: 360px;
  max-height: 400px;
  display: none;
  flex-direction: column;
  gap: 0.9rem;
  z-index: 15;
}

.event-board.panel-open {
  display: flex;
}

.event-board-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.event-board-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.event-board-header p,
#event-board-count {
  font-size: 0.75rem;
  color: hsl(var(--text-muted));
}

.event-board-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow-y: auto;
  min-height: 0;
}

.event-board-item {
  padding: 0.75rem 0.8rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.event-board-item:hover,
.event-board-item:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(59, 130, 246, 0.09);
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.28);
}

.event-board-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.event-board-item-top strong {
  font-size: 0.85rem;
}

.event-board-item-meta,
.event-board-item-detail {
  font-size: 0.75rem;
  color: hsl(var(--text-muted));
}

.soundtrack-card {
  position: absolute;
  top: 1.5rem;
  right: calc(1.5rem + 72px + 0.75rem);
  width: min(360px, calc(100vw - 3rem));
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 15;
  max-height: calc(100vh - 3rem);
}

.soundtrack-card.panel-open {
  display: flex;
}

/* Right-side vertical icon toolbar */
.hud-icon-bar {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 20;
  pointer-events: auto;
}

.hud-icon-square {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.65);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font-family);
  padding: 0;
}

.hud-icon-square:hover {
  background: rgba(96, 165, 250, 0.18);
  border-color: rgba(96, 165, 250, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.hud-icon-square.active {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(129, 140, 248, 0.55);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.25), 0 8px 24px rgba(0, 0, 0, 0.35);
}

.hud-icon-glyph {
  font-size: 1.5rem;
  line-height: 1;
  display: block;
}

.hud-icon-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.65);
  display: block;
}

.soundtrack-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.soundtrack-info {
  flex: 1;
  min-width: 0;
}

.soundtrack-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: hsl(var(--text-muted));
  margin-bottom: 0.15rem;
}

.soundtrack-card strong {
  display: block;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.soundtrack-card p {
  margin: 0;
  font-size: 0.72rem;
  color: hsl(var(--text-muted));
}

.soundtrack-transport {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.soundtrack-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  transition: color 0.15s ease, background 0.15s ease;
  padding: 0;
}

.soundtrack-icon-btn:hover,
.soundtrack-icon-btn:focus-visible {
  color: #fff;
  background: rgba(96, 165, 250, 0.15);
  outline: none;
}

.soundtrack-play-btn {
  color: #60a5fa;
  font-size: 0.9rem;
  width: 32px;
  height: 32px;
}

.soundtrack-play-btn:hover,
.soundtrack-play-btn:focus-visible {
  color: #93c5fd;
  background: rgba(96, 165, 250, 0.18);
}

.soundtrack-tracklist {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 14rem;
  overflow-y: auto;
  margin-top: 0.1rem;
  padding-right: 2px;
}

.soundtrack-tracklist::-webkit-scrollbar {
  width: 4px;
}

.soundtrack-tracklist::-webkit-scrollbar-track {
  background: transparent;
}

.soundtrack-tracklist::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
}

.soundtrack-tracklist::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.soundtrack-track-btn {
  appearance: none;
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 3px;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  font-size: 0.73rem;
  font-family: var(--font-family);
  padding: 0.18rem 0.4rem;
  text-align: left;
  transition: color 0.12s, background 0.12s;
}

.soundtrack-track-btn:hover,
.soundtrack-track-btn:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.soundtrack-track-btn.active {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.1);
}

.soundtrack-card.paused .soundtrack-info,
.soundtrack-card.paused #soundtrack-status {
  opacity: 0.55;
}

/* .editor-toggle removed — editor is now an .hud-icon-square in .hud-icon-bar */

.editor-auth-panel,
.world-editor-panel {
  position: absolute;
  right: calc(1.5rem + 64px + 0.75rem);
  z-index: 19;
  border-radius: var(--radius-md);
}

.editor-auth-panel {
  top: 1.5rem;
  width: 330px;
  padding: 1rem;
  display: none;
  flex-direction: column;
  gap: 0.6rem;
}

.editor-auth-panel.active {
  display: flex;
}

.editor-auth-header {
  margin-bottom: 0.15rem;
}

.editor-auth-header p {
  font-size: 0.78rem;
}

.editor-auth-panel label,
.editor-section-label,
.editor-field-grid label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: hsl(var(--text-muted));
  font-weight: 700;
}

.editor-auth-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
}

.editor-auth-actions {
  display: flex;
  justify-content: flex-end;
}

.editor-auth-row input,
.editor-field-grid input {
  min-width: 0;
  padding: 0.52rem 0.65rem;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-family);
}

.editor-auth-row input:focus,
.editor-field-grid input:focus {
  outline: none;
  border-color: hsl(var(--primary));
}

#editor-auth-status {
  min-height: 1rem;
  color: hsl(var(--text-muted));
  font-size: 0.75rem;
}

.world-editor-panel {
  top: 1.5rem;
  width: 360px;
  max-height: calc(100vh - 3rem);
  padding: 1rem;
  display: none;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

.world-editor-panel.active {
  display: flex;
}

.editor-panel-header {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
}

.editor-panel-header h3 {
  font-size: 0.95rem;
  font-weight: 800;
}

.editor-panel-header p,
.editor-room-label,
#editor-selection-label {
  margin-top: 0.25rem;
  color: hsl(var(--text-muted));
  font-size: 0.76rem;
  line-height: 1.35;
}

.editor-icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.editor-section {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.editor-asset-palette {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.editor-asset-btn,
.editor-mode-btn {
  min-height: 40px;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.045);
  color: #fff;
  font-family: var(--font-family);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.editor-asset-btn.active,
.editor-mode-btn.active {
  border-color: rgba(56, 189, 248, 0.65);
  background: rgba(14, 165, 233, 0.18);
}

.editor-mode-row,
.editor-action-row,
.editor-save-row {
  display: grid;
  gap: 0.5rem;
}

.editor-mode-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.editor-mode-btn {
  text-align: center;
}

.editor-inspector {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 0.2rem;
}

.editor-inspector-empty .editor-field-grid,
.editor-inspector-empty .editor-room-label,
.editor-inspector-empty .editor-action-row {
  display: none;
}

.editor-field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.editor-field-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.editor-action-row,
.editor-save-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.btn-secondary.danger {
  color: #fecdd3;
  border-color: rgba(244, 63, 94, 0.3);
}

/* Chat HUD Overlay */
.chat-wrapper {
  position: absolute;
  bottom: 1.5rem;
  left: 1.5rem;
  width: 360px;
  max-height: 300px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.75rem 1rem 0.55rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 12, 20, 0.45);
}

.chat-toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.chat-toolbar-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: hsl(var(--text-muted));
  font-weight: 700;
}

.chat-chip {
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.72);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.chat-chip:hover {
  border-color: rgba(129, 140, 248, 0.5);
  color: #fff;
}

.chat-chip.active {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(129, 140, 248, 0.55);
  color: #eef2ff;
}

.chat-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-log {
  flex: 1;
  padding: 0.8rem 1rem;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 200px;
}

/* Chat messages formatting */
.chat-msg {
  word-wrap: break-word;
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.chat-author {
  font-weight: 700;
  margin-right: 0.4rem;
}

.chat-scope-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.6rem;
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chat-scope-badge.global {
  background: rgba(14, 165, 233, 0.16);
  color: #7dd3fc;
}

.chat-scope-badge.room {
  background: rgba(99, 102, 241, 0.16);
  color: #c7d2fe;
}

.system-msg {
  color: #a5b4fc;
  font-style: italic;
  font-size: 0.8rem;
}

.chat-input-row {
  display: flex;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(10, 12, 20, 0.4);
}

.chat-input-row input {
  flex: 1;
  padding: 0.8rem 1rem;
  background: transparent;
  border: none;
  color: #fff;
  font-family: var(--font-family);
  font-size: 0.85rem;
}

.chat-input-row input:focus {
  outline: none;
}

.btn-send {
  padding: 0 1.2rem;
  background: transparent;
  border: none;
  color: hsl(var(--primary));
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-send:hover {
  color: hsl(var(--primary-hover));
}

/* Room slide-out panel (Right side) */
#room-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 400px;
  height: 100%;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  border-top: none;
  border-right: none;
  border-bottom: none;
  border-radius: 0;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: -8px 0 32px 0 rgba(0, 0, 0, 0.4);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  transform: translateX(100%);
  opacity: 0;
}

#room-panel.room-panel-visible {
  transform: translateX(0);
  opacity: 1;
}

.close-panel-btn {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: transparent;
  border: none;
  color: hsl(var(--text-muted));
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition);
  z-index: 10;
}

.close-panel-btn:hover {
  color: #fff;
}

.room-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.room-capacity {
  font-size: 0.8rem;
  color: hsl(var(--text-muted));
  font-weight: 600;
}

.room-status-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.event-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.event-status-badge.idle {
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.14);
  border-color: rgba(148, 163, 184, 0.22);
}

.event-status-badge.ready,
.event-status-badge.upcoming {
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(59, 130, 246, 0.28);
}

.event-status-badge.live {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.28);
}

.event-status-badge.ended {
  color: #fecdd3;
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.28);
}

.room-status-text {
  font-size: 0.8rem;
  color: hsl(var(--text-muted));
  line-height: 1.45;
}

/* YouTube Video container aspect ratio */
.video-section {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.video-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  height: 0;
  background: #000;
}

.video-container iframe,
.video-container #youtube-player {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
}

.room-players-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 100px;
}

.room-players-section h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: hsl(var(--text-muted));
}

#room-players-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.room-player-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.room-player-badge {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.video-control-section {
  position: relative;
}

/* Video configuration overlay modal inside side panel */
#video-input-modal {
  position: absolute;
  inset: 0;
  left: 0;
  width: 100%;
  border-radius: var(--radius-md);
  z-index: 20;
  display: none;
}

#video-input-modal.active {
  display: flex;
}

#video-input-modal h4 {
  font-size: 0.9rem;
  font-weight: 700;
}

.modal-help {
  font-size: 0.75rem;
  color: hsl(var(--text-muted));
  line-height: 1.3;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.modal-header h3,
.modal-header h4 {
  margin: 0;
}

.modal-header p {
  margin: 0.2rem 0 0;
}

.modal-close-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: var(--transition);
}

.modal-close-btn:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(96, 165, 250, 0.6);
}

.modal-close-btn:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.85);
  outline-offset: 2px;
}

.modal-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.modal-field label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: hsl(var(--text-muted));
}

.modal-field input {
  padding: 0.5rem 0.8rem;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-family);
  font-size: 0.8rem;
  width: 100%;
}

.modal-field input:focus {
  outline: none;
  border-color: hsl(var(--primary));
}

.panel-modal-shell {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 7;
}

.panel-modal-shell.active {
  display: flex;
}

.panel-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(5px);
  border-radius: inherit;
}

.panel-modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 440px);
  padding: 1rem;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
}

/* Controls Panel (collapsed by default, toggled via ⌨ icon) */
.controls-card {
  position: absolute;
  top: 1.5rem;
  right: calc(1.5rem + 72px + 0.75rem);
  width: min(260px, calc(100vw - 3rem));
  display: none;
  flex-direction: column;
  gap: 0.55rem;
  z-index: 15;
  padding: 1rem 1.2rem;
  font-size: 0.75rem;
  color: hsl(var(--text-muted));
}

.controls-card.panel-open {
  display: flex;
}

.controls-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.controls-card-header h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.debug-card {
  position: absolute;
  top: 1.5rem;
  right: calc(1.5rem + 72px + 0.75rem);
  width: min(380px, calc(100vw - 3rem));
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 15;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding: 1.2rem;
}

.debug-card.panel-open {
  display: flex;
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.debug-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
}

.debug-header p {
  font-size: 0.7rem;
  color: hsl(var(--text-muted));
  margin: 0;
}

.debug-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 0.2rem 0;
}

.debug-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.debug-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: hsl(var(--text-muted));
  margin-bottom: 0.2rem;
}

.debug-metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  gap: 0.5rem;
}

.debug-metric-label {
  color: hsl(var(--text-muted));
  font-weight: 600;
}

.debug-metric-value {
  color: #fff;
  font-family: monospace;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.debug-grid-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.debug-grid-label {
  font-size: 0.65rem;
  color: hsl(var(--text-muted));
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.debug-grid-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  margin-top: 0.1rem;
}

.debug-errors-list {
  max-height: 90px;
  overflow-y: auto;
  font-family: monospace;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Controls panel sits alongside other HUD cards — no room-panel slide needed */

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.legend-item kbd {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-family: monospace;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 0 rgba(0,0,0,0.3);
}

/* Buttons style */
.btn-primary {
  width: 100%;
  padding: 0.9rem;
  background: hsl(var(--primary));
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-family);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 14px hsl(var(--primary) / 30%);
}

.btn-primary:hover {
  background: hsl(var(--primary-hover));
  box-shadow: 0 6px 20px hsl(var(--primary) / 40%);
  transform: translateY(-1px);
}

.btn-secondary {
  width: 100%;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-sm {
  padding: 0.5rem 0.8rem;
  font-size: 0.8rem;
  width: auto;
}

.btn-text {
  background: transparent;
  border: none;
  color: hsl(var(--text-muted));
  font-size: 0.75rem;
  cursor: pointer;
  align-self: center;
  transition: var(--transition);
}

.btn-text:hover {
  color: #fff;
}

/* Utility visibility classes */
.video-modal-hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.room-panel-hidden {
  transform: translateX(100%);
  opacity: 0;
}

/* Custom Scrollbar for chat and player list */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .event-board,
  .soundtrack-card,
  .debug-card {
    right: 1rem;
    left: 1rem;
    width: auto;
    max-width: none;
    top: auto;
    bottom: calc(1rem + 64px + 0.5rem); /* above icon bar if stacked */
  }

  .hud-icon-bar {
    top: auto;
    bottom: 1rem;
    right: 1rem;
    flex-direction: row; /* horizontal row on mobile */
  }

  .editor-auth-panel,
  .world-editor-panel {
    left: 1rem;
    right: 1rem;
    width: auto;
    top: auto;
    bottom: calc(1rem + 64px + 0.5rem);
  }

  .world-editor-panel {
    max-height: 55vh;
  }

  .modal-field-grid {
    grid-template-columns: 1fr;
  }

  #room-panel {
    width: 100%;
    max-width: 100%;
  }

  .chat-wrapper {
    width: calc(100% - 3rem);
    max-height: 180px;
  }

  /* Old debug panel styling removed */

  .controls-card {
    right: 1rem;
    width: min(260px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }
}

/* Theater Modal Styles */
.theater-card {
  width: 92%;
  height: 88%;
  max-width: 1400px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  padding: 24px;
  position: relative;
  z-index: 100;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
}

.close-theater-btn {
  position: absolute;
  top: 20px;
  right: 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.2rem;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.close-theater-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.theater-header {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.theater-header h2 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  color: #f8fafc;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.theater-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.modal-shortcut-hint {
  margin: 0;
  color: hsl(var(--text-muted));
  font-size: 0.78rem;
}

.theater-body {
  flex: 1;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#theater-player-container {
  width: 100%;
  height: 100%;
}

#theater-player-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Reconnect / paused overlay ─────────────────────────────────────────── */
#reconnect-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.reconnect-label {
  color: #e2e8f0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  animation: reconnect-pulse 1.6s ease-in-out infinite;
}

@keyframes reconnect-pulse {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}

.theater-placeholder-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #94a3b8;
  font-size: 1.1rem;
  text-align: center;
}

/* ── AI & Developer Tools (2D Dev Map & Placement Auditor) ──────────────── */
.dev-map-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(95vw, 960px);
  height: min(90vh, 680px);
  z-index: 1050;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.dev-map-header {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dev-map-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.dev-map-header p {
  font-size: 0.78rem;
  color: hsl(var(--text-muted));
  margin-top: 0.15rem;
}

.dev-map-body {
  flex: 1;
  display: flex;
  min-height: 0; /* Important for scrollable children in flexboxes */
}

.dev-map-canvas-container {
  flex: 1;
  position: relative;
  background: #020617;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#dev-map-canvas {
  cursor: grab;
  display: block;
}

#dev-map-canvas:active {
  cursor: grabbing;
}

.dev-map-tooltip {
  position: absolute;
  display: none;
  background: rgba(8, 12, 24, 0.94);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: #fff;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  max-width: 240px;
  line-height: 1.45;
}

.dev-map-auditor {
  width: 340px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 15, 30, 0.4);
  display: flex;
  flex-direction: column;
  padding: 1.2rem;
  min-width: 0;
}

.auditor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.auditor-header h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: #f1f5f9;
}

.badge {
  padding: 0.18rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-ok {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warn {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.dev-auditor-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
  padding-right: 0.25rem;
}

.dev-auditor-list::-webkit-scrollbar {
  width: 5px;
}

.dev-auditor-list::-webkit-scrollbar-track {
  background: transparent;
}

.dev-auditor-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
}

.auditor-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  color: hsl(var(--text-muted));
  font-size: 0.8rem;
  padding: 2rem;
  border: 1.5px dashed rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
}

.auditor-item {
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.76rem;
  line-height: 1.35;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: var(--transition);
}

.auditor-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.auditor-item.severity-critical {
  border-left: 3.5px solid #ef4444;
  background: rgba(239, 68, 68, 0.03);
}

.auditor-item.severity-high {
  border-left: 3.5px solid #f97316;
  background: rgba(249, 115, 22, 0.03);
}

.auditor-item.severity-medium {
  border-left: 3.5px solid #eab308;
  background: rgba(234, 179, 8, 0.03);
}

.auditor-info {
  flex: 1;
  min-width: 0;
  color: #cbd5e1;
}

.auditor-warp-btn {
  flex-shrink: 0;
  padding: 3px 6px;
  font-size: 0.68rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}


/* ── 1920s Elevator Control Panel (slide-in from right) ──────────────── */
.elevator-panel {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%) translateX(100%);
  width: 100px;
  background: linear-gradient(180deg, #2a1a0a 0%, #1a0f05 100%);
  border: 3px solid #b8860b;
  border-right: none;
  border-radius: 4px 0 0 4px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: -4px 0 20px rgba(0,0,0,0.6);
  z-index: 40;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.elevator-panel.elevator-visible {
  transform: translateY(-50%) translateX(0);
}
.elevator-panel-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.elevator-header { text-align: center; line-height: 1; margin-bottom: 4px; }
.elevator-brand { display: block; font-family: 'Georgia', serif; font-size: 0.7rem; font-weight: 700; letter-spacing: 3px; color: #b8860b; }
.elevator-sub { display: block; font-size: 0.45rem; letter-spacing: 2px; color: #8a7a5a; }
.elevator-indicator { background: #0a0a0a; border: 2px solid #b8860b; border-radius: 3px; padding: 4px 12px; text-align: center; width: 100%; box-sizing: border-box; }
.elevator-floor-num { font-family: 'Georgia', serif; font-size: 1.4rem; font-weight: 700; color: #fbbf24; line-height: 1; text-shadow: 0 0 6px rgba(251,191,36,0.4); }
.elevator-floor-label { font-size: 0.4rem; letter-spacing: 2px; color: #8a7a5a; text-transform: uppercase; }
.elevator-arrow-panel { display: flex; flex-direction: row; gap: 6px; width: 100%; }
.elevator-arrow-btn { flex: 1; background: linear-gradient(180deg, #3a2510 0%, #2a1a0a 100%); border: 2px solid #b8860b; border-radius: 3px; padding: 6px 0; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.elevator-arrow-btn:hover { background: linear-gradient(180deg, #4a3520 0%, #3a2510 100%); border-color: #d4a030; }
.elevator-arrow-btn:active { background: #1a0f05; }
.elevator-arrow-btn.elevator-active { background: linear-gradient(180deg, #1a3a10 0%, #0f2a08 100%); border-color: #22c55e; box-shadow: 0 0 12px rgba(34,197,94,0.3); }
.elevator-arrow { font-size: 1.2rem; color: #b8860b; display: block; line-height: 1; }
.elevator-arrow.up { color: #22c55e; }
.elevator-arrow.down { color: #ef4444; }
.elevator-brass-plate { border: 1px solid #8a7a5a; border-radius: 2px; padding: 3px 6px; text-align: center; width: 100%; box-sizing: border-box; background: rgba(0,0,0,0.3); }
.elevator-plate-text { display: block; font-size: 0.38rem; letter-spacing: 2px; color: #8a7a5a; line-height: 1.2; text-transform: uppercase; }
