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

body {
  background: #0a0a0f;
  color: #e0e0e0;
  font-family: 'Rajdhani', 'Segoe UI', sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

#lobby {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0f;
  z-index: 100;
}

#lobby.hidden {
  display: none;
}

#lobby-box {
  text-align: center;
  padding: 40px;
  border: 2px solid #333;
  border-radius: 8px;
  background: #111118;
  min-width: 360px;
}

#lobby-box h1 {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 52px;
  letter-spacing: 4px;
  margin-bottom: 8px;
  color: #fff;
}

.accent {
  color: #e74c3c;
}

.subtitle {
  font-family: 'Share Tech Mono', monospace;
  color: #666;
  font-size: 14px;
  margin-bottom: 30px;
  text-transform: uppercase;
  letter-spacing: 3px;
}

#name-input {
  display: block;
  width: 100%;
  padding: 12px 16px;
  font-size: 18px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  background: #1a1a24;
  border: 2px solid #333;
  border-radius: 4px;
  color: #fff;
  text-align: center;
  outline: none;
  margin-bottom: 16px;
  letter-spacing: 1px;
}

#name-input:focus {
  border-color: #e74c3c;
}

.mode-buttons {
  display: flex;
  gap: 10px;
}

#play-btn, #bots-btn, #code-btn {
  flex: 1;
  padding: 14px;
  font-size: 18px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: background 0.2s;
}

#play-btn {
  background: #27ae60;
}

#play-btn:hover {
  background: #1e8449;
}

#bots-btn {
  background: #e74c3c;
}

#bots-btn:hover {
  background: #c0392b;
}

#code-btn {
  background: #8e44ad;
}

#code-btn:hover {
  background: #6c3483;
}

#play-again-btn {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 22px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 3px;
  text-transform: uppercase;
  transition: background 0.2s;
}

#play-again-btn:hover {
  background: #c0392b;
}

#online-count {
  margin-top: 16px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  color: #555;
  min-height: 20px;
}

#lobby-status {
  margin-top: 8px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  color: #888;
  min-height: 24px;
}

#game-canvas {
  display: none;
  width: 100vw;
  height: 100vh;
}

#game-canvas.active {
  display: block;
  cursor: crosshair;
}

#game-over {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  z-index: 200;
}

#game-over.hidden {
  display: none;
}

#game-over-box {
  text-align: center;
  padding: 40px;
  border: 2px solid #e74c3c;
  border-radius: 8px;
  background: #111118;
  min-width: 400px;
}

#game-over-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 40px;
  margin-bottom: 20px;
  color: #fff;
}

#game-over-stats {
  margin-bottom: 24px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 16px;
  line-height: 1.8;
  color: #ccc;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  padding: 4px 20px;
}

.stat-line.winner {
  color: #f1c40f;
  font-weight: bold;
}

#spectate-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
}

#spectate-bar.hidden {
  display: none;
}

#leave-btn {
  padding: 10px 32px;
  font-size: 16px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  background: rgba(40, 40, 40, 0.8);
  color: #aaa;
  border: 1px solid #555;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: background 0.2s, color 0.2s;
}

#leave-btn:hover {
  background: rgba(60, 60, 60, 0.9);
  color: #fff;
}

/* --- Code Editor Screen --- */

#code-editor {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #0a0a0f;
  z-index: 100;
}

#code-editor.hidden {
  display: none;
}

#code-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #111118;
  border-bottom: 2px solid #333;
}

#code-editor-header h2 {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: #8e44ad;
  letter-spacing: 2px;
}

#preset-select {
  padding: 8px 12px;
  font-size: 13px;
  font-family: 'Share Tech Mono', monospace;
  background: #1a1a24;
  color: #9b59b6;
  border: 1px solid #555;
  border-radius: 4px;
  cursor: pointer;
  outline: none;
}

#preset-select:hover {
  border-color: #8e44ad;
}

#code-back-btn {
  padding: 8px 20px;
  font-size: 14px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  background: #333;
  color: #aaa;
  border: 1px solid #555;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.2s, color 0.2s;
}

#code-back-btn:hover {
  background: #444;
  color: #fff;
}

#deploy-btn {
  padding: 10px 28px;
  font-size: 16px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  background: #8e44ad;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: background 0.2s;
}

#deploy-btn:hover {
  background: #6c3483;
}

#code-editor-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#code-editor-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  min-width: 0;
}

#code-textarea {
  flex: 1;
  width: 100%;
  resize: none;
  font-family: 'Share Tech Mono', monospace;
  font-size: 15px;
  line-height: 1.6;
  padding: 20px;
  background: #0d0d14;
  color: #e0e0e0;
  border: 2px solid #333;
  border-radius: 6px;
  outline: none;
  tab-size: 2;
  -moz-tab-size: 2;
}

#code-textarea:focus {
  border-color: #8e44ad;
}

#code-error {
  margin-top: 8px;
  padding: 10px 14px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid #e74c3c;
  border-radius: 4px;
}

#code-error.hidden {
  display: none;
}

#code-editor-right {
  width: 320px;
  padding: 20px;
  background: #111118;
  border-left: 2px solid #333;
  overflow-y: auto;
}

#code-editor-right h3 {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #8e44ad;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

.ref-section {
  margin-bottom: 18px;
}

.ref-section h4 {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 11px;
  color: #f1c40f;
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.ref-section code {
  display: inline-block;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  background: #1a1a24;
  color: #9b59b6;
  padding: 2px 6px;
  border-radius: 3px;
  margin: 2px 2px;
}

.ref-section pre {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  background: #0d0d14;
  color: #aaa;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid #333;
  margin: 6px 0;
  white-space: pre;
  overflow-x: auto;
}

.ref-note {
  font-size: 12px;
  color: #666;
}

/* Tooltip wrapper */
.ref-tip {
  position: relative;
  display: inline-block;
  cursor: help;
}

.ref-tip code {
  transition: background 0.15s, color 0.15s;
}

.ref-tip:hover code {
  background: #2a1a3a;
  color: #bb86fc;
}

.ref-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  color: #e0e0e0;
  background: #1a1a2e;
  border: 1px solid #8e44ad;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}

.ref-tip:hover::after {
  opacity: 1;
}

/* Keep tooltips on-screen for items near the right edge */
#code-editor-right .ref-tip::after {
  left: 0;
  transform: none;
  white-space: normal;
  max-width: 240px;
}

/* --- Benchmark --- */

#benchmark-btn {
  padding: 10px 28px;
  font-size: 16px;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  background: #2980b9;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: background 0.2s;
}

#benchmark-btn:hover {
  background: #1f6da0;
}

#benchmark-btn:disabled {
  background: #555;
  cursor: default;
}

#benchmark-results {
  margin-top: 10px;
  padding: 14px;
  background: #111118;
  border: 1px solid #333;
  border-radius: 6px;
}

#benchmark-results.hidden {
  display: none;
}

#benchmark-stats {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  color: #ccc;
  margin-bottom: 10px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

#benchmark-stats .bm-stat {
  color: #888;
}

#benchmark-stats .bm-stat span {
  color: #f1c40f;
  font-weight: bold;
}

#benchmark-chart {
  width: 100%;
  height: 200px;
  display: block;
}
