@import url("https://fonts.googleapis.com/css2?family=Sometype+Mono:wght@400;500;600;700&display=swap");

* {
  -webkit-tap-highlight-color: transparent;
  outline: 0;
  -webkit-user-select: none;
  user-select: none;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-tertiary: #1a1a1a;
  --text-primary: #ffffff;
  --text-secondary: #888888;
  --text-muted: #444444;
  --accent: #ffffff;
  --border: #333333;
  --border-light: #555555;
}

body {
  margin: 0;
  font-family: "Sometype Mono", monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

/* Canvas */
#canvas {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  cursor: default;
  touch-action: none;
}

#canvas.grabbing {
  cursor: grabbing !important;
}

#minimapCanvas {
  position: absolute;
  display: none; /* Hidden for now */
}

.hidden {
  display: none !important;
}

/* Fullscreen Auth Container */
#fullscreenDiv {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.auth-header {
  text-align: center;
  margin-bottom: 40px;
}

.auth-header h1 {
  font-family: "Sometype Mono", monospace;
  font-size: 48px;
  font-weight: 700;
  letter-spacing: 8px;
  margin: 0;
  padding: 0;
  color: var(--text-primary);
  border-bottom: 2px solid var(--text-primary);
  padding-bottom: 10px;
}

.subtitle {
  font-family: "Sometype Mono", monospace;
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--text-secondary);
  margin-top: 15px;
  text-transform: uppercase;
}

/* reCAPTCHA container */
.g-recaptcha {
  margin-top: 20px;
}

/* Setup Panel */
#playerSetupDiv {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.setup-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 30px;
  min-width: 320px;
  max-width: 400px;
}

.setup-header {
  margin-bottom: 25px;
}

.setup-header h2 {
  font-family: "Sometype Mono", monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 4px;
  margin: 0;
  padding: 0;
}

.header-line {
  height: 2px;
  background: var(--text-primary);
  margin-top: 10px;
}

/* Form Groups */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-family: "Sometype Mono", monospace;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
}

#playerName {
  width: 100%;
  padding: 10px;
  font-family: "Sometype Mono", monospace;
  font-size: 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#playerName:focus {
  border-color: var(--text-primary);
  background: var(--bg-secondary);
}

#playerName::placeholder {
  color: var(--text-muted);
}

/* Color Grid */
.piece-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.piece-option {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  border: 2px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 4px;
}

.piece-option:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-primary);
}

.piece-option.selected {
  border-color: var(--text-primary);
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.color-swatch {
  aspect-ratio: 1;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.1s;
}

.color-swatch:hover {
  border-color: var(--text-primary);
  transform: scale(1.05);
}

.color-swatch.selected {
  border: 2px solid var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--bg-primary);
}

/* Preview Panel */
.preview-panel {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 15px;
  margin: 20px 0;
  text-align: center;
}

.preview-label {
  font-family: "Sometype Mono", monospace;
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

#previewCanvas {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto 10px;
}

#previewName {
  font-family: "Sometype Mono", monospace;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--text-primary);
  text-transform: uppercase;
}

/* Deploy Button */
.deploy-btn {
  width: 100%;
  padding: 15px;
  font-family: "Sometype Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  background: var(--text-primary);
  color: var(--bg-primary);
  border: none;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.1s;
}

.deploy-btn:hover {
  background: var(--text-secondary);
}

.deploy-btn:active {
  background: var(--text-muted);
}

/* Chat Container */
.chatContainer {
  position: fixed;
  bottom: 0;
  left: 0;
  pointer-events: none;
}

.chat {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 300px;
  padding: 8px;
  font-family: "Sometype Mono", monospace;
  font-size: 11px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: none;
  border-bottom: none;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  pointer-events: auto;
  opacity: 0.4;
  transition: opacity 0.2s;
  outline: none;
}

.chat::placeholder {
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 1px;
}

.chat:focus {
  opacity: 1;
  border-color: var(--text-primary);
  background: rgba(15, 15, 15, 0.95);
}

.chat-div {
  position: fixed;
  left: 0;
  bottom: 35px;
  width: 300px;
  max-height: 150px;
  display: flex;
  flex-direction: column-reverse;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  pointer-events: auto;
}

.chat-message {
  font-family: "Sometype Mono", monospace;
  font-size: 11px;
  color: var(--text-primary);
  padding: 4px 8px;
  margin: 1px 0;
  background: rgba(0, 0, 0, 0.7);
  border-left: 2px solid var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

.chat-message.server-msg {
  border-left-color: #ffcc66;
  background: rgba(40, 30, 0, 0.7);
}

.chat-name {
  font-weight: 700;
}

.chat-rank {
  color: var(--text-muted);
  font-size: 9px;
}

.chat-text {
  color: var(--text-primary);
}

.system-message {
  font-family: "Sometype Mono", monospace;
  font-size: 10px;
  color: var(--text-secondary);
  padding: 4px 8px;
  margin: 1px 0;
  background: rgba(0, 0, 0, 0.5);
  border-left: 2px solid var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
}

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

/* Leaderboard */
.leaderboard-div {
  position: fixed;
  right: 0;
  top: 0;
  width: 240px;
  height: 100vh;
  background: linear-gradient(
    to left,
    rgba(10, 10, 10, 0.95),
    rgba(10, 10, 10, 0.7)
  );
  padding: 15px;
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: auto;
}

.leaderboard-header {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.online-count {
  font-family: "Sometype Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-primary);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.online-indicator {
  width: 8px;
  height: 8px;
  background: #00ff00;
  border-radius: 50%;
  box-shadow: 0 0 8px #00ff00;
  animation: pulse 2s ease-in-out infinite;
}

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

.leaderboard-div::-webkit-scrollbar {
  width: 4px;
}

.leaderboard-div::-webkit-scrollbar-thumb {
  background: var(--border-light);
}

.lb-group {
  background: transparent;
  margin-bottom: 15px;
}

.lb-name {
  font-family: "Sometype Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.lb-players {
  margin: 0;
  padding: 0;
}

.lb-players div {
  font-family: "Sometype Mono", monospace;
  font-size: 11px;
  padding: 4px 0;
  cursor: pointer;
  transition: all 0.1s;
  border-left: 2px solid transparent;
  padding-left: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lb-players div:hover {
  background: rgba(255, 255, 255, 0.05);
  border-left-color: var(--text-primary);
}

.player-color-indicator {
  width: 12px;
  height: 12px;
  min-width: 12px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.player-name {
  letter-spacing: 0.5px;
  color: var(--text-primary) !important;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hide utilities */
.hideLB {
  right: -240px !important;
  opacity: 0;
}

.hideChat {
  left: -300px !important;
  opacity: 0;
}

/* Rainbow text for server messages */
.rainbow {
  animation: colorCycle 3s linear infinite;
}

@keyframes colorCycle {
  0%,
  100% {
    color: #ff0000;
  }
  33% {
    color: #00ff00;
  }
  66% {
    color: #0000ff;
  }
}

/* Chat Bubbles */
.chat-bubble {
  position: absolute;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  font-family: "Sometype Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.5px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
  transform: translate(-50%, -100%);
  margin-top: -8px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bubble-name {
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  font-size: 9px;
}

.chat-bubble::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--border);
}

.chat-bubble.fading {
  animation: bubbleFade 0.3s ease-out forwards;
}

@keyframes bubbleFade {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translate(-50%, -110%);
  }
}

/* Statistics Panel */
.stats-panel {
  position: fixed;
  left: 10px;
  top: 10px;
  background: rgba(10, 10, 10, 0.95);
  border: 1px solid var(--border);
  padding: 12px;
  min-width: 200px;
  font-family: "Sometype Mono", monospace;
  pointer-events: auto;
  z-index: 100;
}

@media (max-width: 768px) {
  .stats-panel {
    left: 5px;
    top: 5px;
    padding: 8px;
    min-width: 150px;
    font-size: 9px;
  }
}

.stats-header {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

.stats-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.5px;
}

.stat-label {
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-value {
  color: var(--text-primary);
  font-weight: 500;
}

.toggle-row {
  padding: 4px 0 0;
}

.toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: "Sometype Mono", monospace;
  font-size: 9px;
  letter-spacing: 1.5px;
  padding: 2px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toggle-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.toggle-btn.on {
  background: rgba(186, 255, 201, 0.15);
  border-color: rgba(186, 255, 201, 0.4);
  color: #baffc9;
}

.recenter-btn {
  width: 100%;
  margin-top: 10px;
  padding: 6px 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: "Sometype Mono", monospace;
  font-size: 9px;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.recenter-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

/* Kill Feed */
.kill-feed {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 150;
  pointer-events: none;
}

.kill-entry {
  font-family: "Sometype Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid var(--border);
  padding: 4px 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  animation: killSlideIn 0.25s ease-out;
}

.kill-entry.kill-self {
  border-color: #ffcc66;
  color: #ffcc66;
}

.kill-attacker {
  font-weight: 700;
  color: var(--text-primary);
}

.kill-self .kill-attacker {
  color: #ffcc66;
}

.kill-victim {
  font-weight: 700;
  color: #ff8888;
}

.kill-piece {
  color: var(--text-muted);
  font-style: italic;
}

.kill-fade {
  animation: killFadeOut 0.4s ease-out forwards;
}

@keyframes killSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes killFadeOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-5px); }
}

.piece-tooltip {
  position: fixed;
  background: rgba(10, 10, 10, 0.95);
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-family: "Sometype Mono", monospace;
  font-size: 10px;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 200;
  letter-spacing: 0.5px;
  line-height: 1.6;
  min-width: 120px;
}

.piece-tooltip .tooltip-title {
  font-weight: 700;
  font-size: 11px;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.piece-tooltip .tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.piece-tooltip .tooltip-label {
  color: var(--text-muted);
}

.piece-tooltip .tooltip-color {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  font-family: "Sometype Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  background: rgba(10, 10, 10, 0.95);
  color: var(--text-primary);
  pointer-events: auto;
  animation: toastIn 0.25s ease-out;
  max-width: 400px;
  text-align: center;
}

.toast.toast-error {
  border-color: #e53e3e;
  color: #fc8181;
}

.toast.toast-warning {
  border-color: #d69e2e;
  color: #f6e05e;
}

.toast.toast-info {
  border-color: var(--border-light);
}

.toast.toast-out {
  animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(10px); }
}

/* Collapse Buttons */
.collapse-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: "Sometype Mono", monospace;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.collapse-btn:hover {
  color: var(--text-primary);
}

/* Panel expand tabs - tiny buttons that appear when panels are hidden */
.panel-tab {
  position: fixed;
  z-index: 101;
  background: rgba(10, 10, 10, 0.9);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: "Sometype Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 6px 10px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.15s ease;
}

.panel-tab:hover {
  background: rgba(30, 30, 30, 0.95);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.panel-tab-left {
  left: 10px;
  top: 10px;
}

.panel-tab-right {
  right: 10px;
  top: 10px;
}

@media (max-width: 768px) {
  .panel-tab-left { left: 5px; top: 5px; }
  .panel-tab-right { right: 5px; top: 5px; }
}

/* Adjust headers for collapse button */
.stats-header,
.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Tool Menu (if used) */
#toolMenu {
  font-size: 11px;
  margin: 0;
  padding: 8px;
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.8);
  font-family: "Sometype Mono", monospace;
}

.menu-button-div {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-direction: column;
  color: var(--text-primary);
  font-size: 9px;
  cursor: pointer;
  margin: 5px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.menu-button {
  color: var(--text-primary);
  border: 1px solid var(--border);
  font-size: 14px;
  padding: 5px 10px;
  background: transparent;
  cursor: pointer;
}

.menu-button:hover {
  border-color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .leaderboard-div {
    width: 200px;
    font-size: 10px;
    padding: 10px;
  }

  .chat-div,
  .chat {
    width: 250px;
    font-size: 10px;
  }

  .online-count {
    font-size: 9px;
  }

  .lb-name {
    font-size: 9px;
  }

  .player-color-indicator {
    width: 10px;
    height: 10px;
    min-width: 10px;
  }

  .hideLB {
    right: -200px !important;
  }

  .hideChat {
    left: -250px !important;
  }
}

/* Prevent text selection during touch interactions */
body.touching * {
  -webkit-user-select: none;
  user-select: none;
}

/* Center GUI (if used) */
.centergui {
  height: auto;
  justify-content: center;
  width: 100%;
}

.all-gui {
  width: 100%;
  position: relative;
}

/* Selected placable (if used) */
.selectedPlacable {
  border: 2px solid var(--text-primary);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}
