/* ===================================================
   BloppyPlace - Main Stylesheet
   Dark theme with CSS variables
   =================================================== */

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --bg-card: #1e2a45;
  --bg-input: #0d1b35;

  --text-primary: #e8eaf6;
  --text-secondary: #9fa8d5;
  --text-muted: #6b8e9f;

  --accent-primary: #51b9c8;
  --accent-secondary: #3a9aaa;
  --accent-hover: #3faabb;

  --success: #00e676;
  --warning: #ffd740;
  --danger: #ff5252;
  --info: #40c4ff;

  --border: #2a3a6a;
  --border-light: #3a4a7a;

  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);

  --navbar-height: 56px;
  --sidebar-width: 200px;
  --bottom-bar-height: 40px;
  --transition: 0.2s ease;

  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent-primary); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 14px;
  color: inherit;
}

input, select, textarea {
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  outline: none;
  transition: border-color var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent-primary);
}

/* ===================================================
   Layout
   =================================================== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* ===================================================
   Navbar
   =================================================== */
#navbar {
  height: var(--navbar-height);
  min-height: var(--navbar-height);
  background: rgba(22, 33, 62, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
  box-shadow: var(--shadow);
}

#navbar .logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-primary);
  letter-spacing: -0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

#navbar .logo span {
  color: var(--text-primary);
}

.dropdown-canvas-section {
  padding: 10px 12px 8px;
}

.dropdown-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 7px;
}

.dropdown-canvas-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color 0.1s;
}

.dropdown-canvas-select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

#navbar .spacer {
  flex: 1;
}

/* ── User dropdown menu ── */
.user-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font);
  transition: background var(--transition), border-color var(--transition);
  color: var(--text-primary);
}

.user-menu-trigger:hover,
.user-menu-trigger:focus-visible {
  background: var(--bg-card);
  border-color: var(--border);
  outline: none;
}

.user-menu-chevron {
  font-size: 9px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  line-height: 1;
}

.user-dropdown.open ~ .user-menu-trigger .user-menu-chevron,
.user-menu-trigger[aria-expanded="true"] .user-menu-chevron {
  transform: rotate(180deg);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  object-fit: cover;
  flex-shrink: 0;
}

.user-name {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.pixel-balance {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-weight: 600;
  color: var(--warning);
  font-size: 13px;
  white-space: nowrap;
}

.pixel-balance-icon {
  font-size: 14px;
}

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 200;
  padding: 5px 0;
  animation: modalSlideUp 0.15s ease;
  overflow: hidden;
}

.user-dropdown.open {
  display: flex;
  flex-direction: column;
}

.dropdown-item {
  display: block;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.dropdown-item:hover {
  background: rgba(81, 185, 200, 0.08);
  color: var(--accent-primary);
}

.dropdown-item-danger {
  color: var(--text-muted);
}

.dropdown-item-danger:hover {
  background: rgba(239, 83, 80, 0.08);
  color: #ef5350;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Transfer modal ── */
.modal-transfer {
  max-width: 400px;
}

.transfer-balance-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.transfer-balance-row strong {
  color: var(--warning);
  font-size: 15px;
}

.transfer-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.transfer-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.transfer-input {
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color var(--transition);
  width: 100%;
  box-sizing: border-box;
}

.transfer-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.transfer-error {
  padding: 8px 12px;
  background: rgba(239, 83, 80, 0.12);
  border: 1px solid rgba(239, 83, 80, 0.4);
  border-radius: 8px;
  color: #ef5350;
  font-size: 13px;
}

.transfer-error.hidden { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  transition: all var(--transition);
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

/* Twitch brand colour — intentionally kept purple */
.btn-twitch {
  background: #9146ff;
  color: #fff;
}

.btn-twitch:hover {
  background: #7b2fff;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #e53935;
}

/* ===================================================
   Promotion Banner
   =================================================== */
#promo-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  background: linear-gradient(90deg, #b8860b, #d4a843, #b8860b);
  background-size: 200% 100%;
  animation: promo-shimmer 3s ease-in-out infinite;
  color: #1a1200;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  position: relative;
  z-index: 90;
  border-bottom: 2px solid #a07010;
}

@keyframes promo-shimmer {
  0%   { background-position: 0% 0%; }
  50%  { background-position: 100% 0%; }
  100% { background-position: 0% 0%; }
}

#promo-banner-close {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  color: #1a1200;
  cursor: pointer;
  font-size: 12px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: background var(--transition);
}

#promo-banner-close:hover {
  background: rgba(0, 0, 0, 0.28);
}

/* ===================================================
   Main area
   =================================================== */
#main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ===================================================
   Left Sidebar – compact redesign
   =================================================== */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition), min-width var(--transition);
  z-index: 10;
  padding: 10px;
  gap: 0;
}

#sidebar.collapsed {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
}

/* Sidebar sections with dividers */
.sb-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
}

.sb-section:first-child { padding-top: 4px; }

.sb-section + .sb-section {
  border-top: 1px solid var(--border);
}

.sb-section-header {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-primary);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

.sb-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* Place Pixel button */
.place-pixel-btn {
  width: 100%;
  justify-content: center;
  font-size: 13px;
  padding: 9px 12px;
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.place-pixel-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.place-pixel-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cursor-pos-label {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  font-family: var(--font-mono);
}


.sb-no-credits-msg {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted);
  background: rgba(229, 62, 62, 0.08);
  border: 1px solid rgba(229, 62, 62, 0.2);
  border-radius: 6px;
  padding: 6px 8px;
}

.sb-no-credits-msg a {
  color: #9146ff;
  text-decoration: none;
}

.sb-no-credits-msg a:hover {
  text-decoration: underline;
}

/* Grayed-out place-pixel button when credits exhausted */
.btn-primary.btn-no-credits {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Selected color display */
.sb-color-display {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.selected-color-box {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.sb-color-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sb-color-hex {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.sb-color-sub {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Merged interactive color swatch + picker */
.sb-color-merged {
  display: flex;
  align-items: stretch;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--transition);
}

.sb-color-merged:hover {
  border-color: var(--accent-primary);
}

.sb-color-merged-swatch {
  width: 52px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.sb-color-merged-swatch input[type="color"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
  margin: 0;
  background: none;
}

.sb-color-merged-info {
  flex: 1;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
}

/* Custom color picker row */
.sb-picker-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.sb-picker-btn {
  width: 38px;
  height: 32px;
  border-radius: 6px;
  border: 2px solid var(--border-light);
  flex-shrink: 0;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition);
}

.sb-picker-btn:hover {
  border-color: var(--accent-primary);
}

#custom-color-picker {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
  margin: 0;
  background: none;
}

.sb-hex-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  height: 32px;
  padding: 0 8px;
}

/* Color grid – 3 columns for both palette and saved slots */
.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.color-swatch:hover {
  transform: scale(1.12);
  z-index: 1;
  position: relative;
}

.color-swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent-primary), inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  transform: scale(1.08);
}

/* Custom saved color slots */
.custom-slot {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  position: relative;
}

.custom-slot.filled {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.custom-slot.filled:hover {
  transform: scale(1.12);
  z-index: 1;
}

.custom-slot-clear {
  display: none;
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e53e3e;
  border: none;
  color: #fff;
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  z-index: 2;
  transition: background var(--transition), transform var(--transition);
}

.custom-slot.filled:hover .custom-slot-clear {
  display: block;
}

.custom-slot-clear:hover {
  background: #c53030;
  transform: scale(1.15);
}

.custom-slot.filled.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent-primary), inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  transform: scale(1.08);
}

.custom-slot.empty {
  background: var(--bg-card);
  border: 2px dashed var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 17px;
  font-weight: 300;
  line-height: 1;
}

.custom-slot.empty::after {
  content: '+';
}

.custom-slot.empty:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  transform: scale(1.06);
}

/* Eyedropper standalone button */
.sb-eyedropper-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.sb-eyedropper-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.sb-eyedropper-btn.active {
  background: rgba(81, 185, 200, 0.12);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(81, 185, 200, 0.2);
}

#pixelCanvas.eyedropper-mode {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M20.71 5.63l-2.34-2.34a1 1 0 0 0-1.41 0l-3.12 3.12-1.41-1.42-1.42 1.42 1.41 1.41-6.6 6.6A2 2 0 0 0 5 16v3h3a2 2 0 0 0 1.41-.59l6.6-6.6 1.41 1.41 1.42-1.41-1.42-1.42 3.12-3.12a1 1 0 0 0 0-1.41z' fill='white' stroke='white' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M20.71 5.63l-2.34-2.34a1 1 0 0 0-1.41 0l-3.12 3.12-1.41-1.42-1.42 1.42 1.41 1.41-6.6 6.6A2 2 0 0 0 5 16v3h3a2 2 0 0 0 1.41-.59l6.6-6.6 1.41 1.41 1.42-1.41-1.42-1.42 3.12-3.12a1 1 0 0 0 0-1.41z' fill='%2351b9c8' stroke='%23222' stroke-width='0.5'/%3E%3C/svg%3E") 5 19, crosshair;
}

/* Overlay controls */
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.overlay-import-btn {
  width: 100%;
  justify-content: center;
}

.overlay-opacity-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.overlay-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.overlay-slider {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent-primary);
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  height: 4px;
}

.overlay-opacity-val {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 28px;
  text-align: right;
}

.overlay-arrow-grid {
  display: grid;
  grid-template-columns: repeat(3, 28px);
  gap: 3px;
  justify-content: center;
}

.overlay-arrow-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--transition), border-color var(--transition);
}

.overlay-arrow-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
}

.overlay-center-btn {
  font-size: 14px;
  background: var(--bg-tertiary);
}

.overlay-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
}

.toggle-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

/* ===================================================
   Canvas container
   =================================================== */
#canvas-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  z-index: 0;
  pointer-events: none;
  background: #111827;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

#pixelCanvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transform-origin: 0 0;
  pointer-events: auto;
  cursor: crosshair;
}

#overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#cursor-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  pointer-events: none;
}

/* Sidebar toggle button */
#sidebar-toggle {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 20;
  pointer-events: auto;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

#sidebar-toggle:hover {
  background: var(--bg-card);
  border-color: var(--border-light);
}

/* Canvas disabled overlay */
#canvas-disabled-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  gap: 12px;
  pointer-events: none;
}

#canvas-disabled-overlay.hidden {
  display: none;
}

.canvas-disabled-msg {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 32px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.canvas-disabled-msg h3 {
  font-size: 18px;
  color: var(--warning);
  margin-bottom: 6px;
}

.canvas-disabled-msg p {
  color: var(--text-secondary);
  font-size: 13px;
}

/* ===================================================
   Bottom status bar
   =================================================== */
#bottom-bar {
  height: var(--bottom-bar-height);
  min-height: var(--bottom-bar-height);
  background: rgba(22, 33, 62, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  z-index: 10;
  font-family: var(--font-mono);
}

.bar-stat {
  display: flex;
  align-items: center;
  gap: 5px;
}

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

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

.pixel-color-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1px solid var(--border-light);
  border-radius: 2px;
  flex-shrink: 0;
}

.bar-sep {
  width: 1px;
  height: 16px;
  background: var(--border-light);
  flex-shrink: 0;
}

#bottom-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

#cooldown-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  height: 26px;
  background: rgba(64, 196, 255, 0.12);
  border: 1px solid rgba(64, 196, 255, 0.35);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--info);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  flex-shrink: 0;
  font-family: var(--font);
  white-space: nowrap;
}

.info-btn:hover {
  background: rgba(64, 196, 255, 0.22);
  border-color: var(--info);
}

.info-btn-icon {
  font-size: 14px;
  line-height: 1;
}

.cooldown-bar-outer {
  width: 80px;
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.cooldown-bar-inner {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 4px;
  transition: width 0.1s linear;
}

#cooldown-text {
  min-width: 40px;
  text-align: right;
  color: var(--warning);
  font-weight: 600;
}

/* ===================================================
   Toast notifications
   =================================================== */
#toast-container {
  position: fixed;
  top: calc(var(--navbar-height) + 12px);
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
  pointer-events: none;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: auto;
  animation: toastSlideIn 0.3s ease;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 320px;
}

.toast.hiding {
  opacity: 0;
  transform: translateX(100%);
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1.3;
}

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 2px;
}

.toast-msg {
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-word;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.bits    { border-left: 3px solid var(--accent-primary); }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===================================================
   Modals
   =================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-backdrop.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp 0.2s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--danger);
  color: #fff;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-body p {
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-footer {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.login-modal-icon {
  text-align: center;
  font-size: 48px;
  margin-bottom: 8px;
}

.modal-info {
  max-width: 480px;
}

/* ── Leaderboard modal ── */
.modal-leaderboard {
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-leaderboard .modal-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leaderboard-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 24px 0;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 32px 36px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s;
}

.leaderboard-row:hover {
  border-color: var(--border-light);
}

.leaderboard-row.rank-1 { border-color: #ffd700; }
.leaderboard-row.rank-2 { border-color: #c0c0c0; }
.leaderboard-row.rank-3 { border-color: #cd7f32; }

.lb-rank {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

.leaderboard-row.rank-1 .lb-rank { color: #ffd700; }
.leaderboard-row.rank-2 .lb-rank { color: #c0c0c0; }
.leaderboard-row.rank-3 .lb-rank { color: #cd7f32; }

.lb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.lb-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.lb-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-stats {
  text-align: right;
  flex-shrink: 0;
}

.lb-pixels {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-primary);
}

.lb-credits {
  font-size: 11px;
  color: var(--text-muted);
}

.leaderboard-my-rank {
  margin-top: 8px;
  padding: 10px 12px;
  background: rgba(81, 185, 200, 0.08);
  border: 1px solid rgba(81, 185, 200, 0.35);
  border-radius: 8px;
}

.leaderboard-my-rank.hidden { display: none; }

.lb-my-rank-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.info-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.info-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

.info-stat-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
}

.info-label {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.info-value {
  color: var(--text-primary);
  font-weight: 600;
  font-family: var(--font-mono);
  text-align: right;
}

.info-rules-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-rule {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.info-rule::before {
  content: '▸';
  color: var(--accent-primary);
  flex-shrink: 0;
  font-size: 11px;
  margin-top: 2px;
}

.info-section p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.info-shortcuts-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 14px;
  align-items: center;
}

.info-shortcuts-grid kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 3px 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(0,0,0,0.4);
}

.info-shortcuts-grid span {
  font-size: 13px;
  color: var(--text-secondary);
}

.info-section-license {
  border-color: rgba(81, 185, 200, 0.25);
  background: rgba(81, 185, 200, 0.05);
}

.info-license-text {
  font-size: 12px !important;
  color: var(--text-muted) !important;
  font-style: italic;
}

/* ── Reward cards (info modal) ─────────────────────────── */
.info-section-rewards {
  border-color: rgba(81, 185, 200, 0.3);
}

.reward-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.reward-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 16px 10px 14px;
  background: var(--bg-primary);
  border: 1.5px solid var(--accent-primary);
  border-radius: 10px;
  text-align: center;
}

.reward-card-icon {
  font-size: 26px;
  line-height: 1;
  margin-bottom: 2px;
}

.reward-card-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.reward-card-amount {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-primary);
  line-height: 1.15;
  margin: 2px 0;
}

.reward-card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.reward-card-link {
  font-size: 11px;
  color: var(--accent-primary);
  text-decoration: none;
  margin-top: 4px;
  opacity: 0.85;
}

.reward-card-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.reward-promo-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  background: rgba(81, 185, 200, 0.1);
  border: 1px solid rgba(81, 185, 200, 0.35);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-primary);
  text-align: center;
  line-height: 1.4;
}

@media (max-width: 460px) {
  .reward-cards {
    grid-template-columns: 1fr;
  }
}

/* ===================================================
   Scrollbar
   =================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===================================================
   Stream status button
   =================================================== */
.stream-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 26px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  font-family: var(--font);
  white-space: nowrap;
}

.stream-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
}

.stream-btn.live {
  color: #ff4040;
  border-color: rgba(255, 64, 64, 0.4);
  background: rgba(255, 64, 64, 0.08);
}

.stream-btn.live:hover {
  background: rgba(255, 64, 64, 0.14);
  border-color: rgba(255, 64, 64, 0.65);
}

.stream-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition);
}

.stream-btn.live .stream-dot {
  background: #ff4040;
  animation: streamPulse 1.8s ease-in-out infinite;
}

@keyframes streamPulse {
  0%   { box-shadow: 0 0 0 0   rgba(255, 64, 64, 0.7); }
  60%  { box-shadow: 0 0 0 5px rgba(255, 64, 64, 0); }
  100% { box-shadow: 0 0 0 0   rgba(255, 64, 64, 0); }
}

/* ===================================================
   Stream embed panel
   =================================================== */
#stream-embed-panel {
  position: fixed;
  right: 12px;
  bottom: calc(var(--bottom-bar-height) + 10px);
  width: 420px;
  height: 270px;
  min-width: 260px;
  min-height: 180px;
  max-width: min(80vw, 760px);
  max-height: 60vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 300;
  resize: both;
  animation: modalSlideUp 0.18s ease;
}

#stream-embed-panel.hidden { display: none; }

#stream-embed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
  gap: 8px;
}

#stream-embed-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#stream-embed-close {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
  cursor: pointer;
}

#stream-embed-close:hover {
  background: var(--danger);
  color: #fff;
}

#stream-embed-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
}

#stream-iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}

#stream-offline-msg {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg-card);
  text-align: center;
  padding: 20px;
}

.stream-offline-icon { font-size: 36px; line-height: 1; }

#stream-offline-msg p {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.stream-offline-sub {
  font-size: 12px !important;
  font-weight: 400 !important;
  color: var(--text-muted) !important;
}

.stream-offline-sub a { color: var(--accent-primary); }

#stream-embed-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: se-resize;
  pointer-events: none;
  background:
    linear-gradient(
      135deg,
      transparent 30%,
      var(--border-light) 30%, var(--border-light) 40%,
      transparent 40%,
      transparent 55%,
      var(--border-light) 55%, var(--border-light) 65%,
      transparent 65%
    );
}

/* ===================================================
   Chat embed panel
   =================================================== */
#chat-embed-panel {
  position: fixed;
  right: 12px;
  bottom: calc(var(--bottom-bar-height) + 10px);
  width: 350px;
  height: 500px;
  min-width: 350px;
  min-height: 500px;
  max-width: min(90vw, 600px);
  max-height: 80vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10000;
  pointer-events: auto;
  padding-bottom: 14px;
  animation: modalSlideUp 0.18s ease;
}

#chat-embed-panel.hidden { display: none; }

#chat-embed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
  gap: 8px;
}

#chat-embed-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

#chat-embed-close {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
  cursor: pointer;
}

#chat-embed-close:hover {
  background: var(--danger);
  color: #fff;
}

#chat-embed-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#chat-iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
  pointer-events: auto;
}

#chat-embed-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: se-resize;
  pointer-events: auto;
  background:
    linear-gradient(
      135deg,
      transparent 30%,
      var(--border-light) 30%, var(--border-light) 40%,
      transparent 40%,
      transparent 55%,
      var(--border-light) 55%, var(--border-light) 65%,
      transparent 65%
    );
}

/* ===================================================
   Mobile zoom indicator
   =================================================== */
#mobile-zoom-indicator {
  display: none; /* shown only on mobile via media query */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  padding: 10px 20px;
  border-radius: 10px;
  pointer-events: none;
  z-index: 30;
  opacity: 0;
  transition: opacity 0.25s ease;
}
#mobile-zoom-indicator.visible { opacity: 1; }

/* ===================================================
   Mobile +/- zoom buttons
   =================================================== */
#mobile-zoom-controls {
  display: none; /* shown only on mobile via media query */
  position: absolute;
  bottom: 16px;
  left: 16px;
  flex-direction: column;
  gap: 8px;
  z-index: 25;
  pointer-events: auto;
}
#mobile-zoom-controls button {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  touch-action: manipulation;
  transition: background var(--transition);
}
#mobile-zoom-controls button:active {
  background: var(--bg-card);
}

/* Mobile-only elements hidden on desktop */
#mobile-tools-row         { display: none; }
.mobile-tool-btn          { display: none; }
.mobile-drawer-handle     { display: none; }
#mobile-controls          { display: none; }
#mobile-color-popup       { display: none; }
#mobile-overlay-popup     { display: none; }

/* ===================================================
   Mobile D-pad
   =================================================== */
#mobile-dpad {
  display: none; /* enabled via media query on mobile */
  position: fixed;
  bottom: 60px;
  right: 16px;
  z-index: 1000;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
  /* Outer wrap: subtle shadow so the D-pad reads against any canvas colour */
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.6));
}

.dpad-row {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.dpad-btn {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 46, 0.85);
  border: 1.5px solid rgba(81, 185, 200, 0.35);
  border-radius: 12px;
  color: #51b9c8;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07), 0 2px 6px rgba(0,0,0,0.4);
  transition: background 0.08s, transform 0.08s, border-color 0.08s;
}

.dpad-btn.dpad-pressed {
  background: rgba(81, 185, 200, 0.2);
  border-color: rgba(81, 185, 200, 0.7);
  transform: scale(0.91);
}

#dpad-place {
  border-radius: 50%;
  background: #51b9c8;
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  box-shadow: 0 0 0 3px rgba(81, 185, 200, 0.2), 0 3px 10px rgba(81, 185, 200, 0.4);
}
#dpad-place.dpad-pressed {
  background: #3faabb;
  transform: scale(0.9);
  box-shadow: 0 0 0 2px rgba(81, 185, 200, 0.15), 0 2px 6px rgba(81, 185, 200, 0.3);
}

/* Empty placeholder cell in the 3×3 grid (bottom-left and bottom-right) */
.dpad-empty {
  display: block;
  width: 52px;
  height: 52px;
}

/* ===================================================
   Responsive (mobile — drawer panel)
   =================================================== */
@media (max-width: 768px) {
  :root { --sidebar-width: 100%; }

  /* ── Navbar ────────────────────────────────────────────────────── */
  #navbar { padding: 0 10px; gap: 8px; }
  #navbar .logo { font-size: 16px; }
  .user-name     { display: none; }
  .pixel-balance { display: none; }

  /* ── Hide the sidebar / bottom drawer completely ────────────────── */
  #sidebar { display: none !important; }

  /* ── Canvas + status ───────────────────────────────────────────── */
  #canvas-container { margin-bottom: 0; }
  #bottom-bar { font-size: 11px; gap: 10px; padding: 0 10px; }
  .toast-container { right: 8px; max-width: calc(100vw - 16px); }

  /* ── Mobile utilities ──────────────────────────────────────────── */
  #mobile-zoom-indicator { display: block; }
  #mobile-zoom-controls  { display: flex; }

  /* ═══════════════════════════════════════════════════════════════════
     Mobile controls: D-pad (3×3 grid) + Overlay button
     Fixed bottom-right, above the status bar.
     ═══════════════════════════════════════════════════════════════════ */
  #mobile-controls {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    position: fixed;
    right: 12px;
    bottom: calc(var(--bottom-bar-height) + 12px);
    z-index: 1000;
    width: 164px;   /* 3 × 52px + 2 × 4px gap */
    filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.65));
    pointer-events: auto;
  }

  /* D-pad: flat 3×3 CSS grid — no more row wrappers */
  #mobile-dpad {
    display: grid !important;
    position: static !important;  /* positioned by #mobile-controls */
    bottom: auto !important;
    right: auto !important;
    filter: none;
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 52px);
    gap: 4px;
    width: 164px;
    height: 164px;
  }

  /* All D-pad buttons inherit the existing .dpad-btn styles. Extra overrides: */
  .dpad-btn {
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
  }

  /* Color swatch button (top-left) */
  #dpad-color-btn { padding: 5px; }
  #dpad-color-swatch {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 7px;
    background: #ff0000;
    pointer-events: none;
    border: 1.5px solid rgba(255, 255, 255, 0.18);
  }

  /* Pipette button (top-right) */
  #dpad-pipette-btn { color: var(--text-secondary, #94a3b8); }
  #dpad-pipette-btn.active {
    background: rgba(81, 185, 200, 0.2);
    border-color: rgba(81, 185, 200, 0.7);
    color: #51b9c8;
  }

  /* Overlay button below D-pad */
  #mobile-overlay-dpad-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 42px;
    width: 100%;
    background: rgba(26, 26, 46, 0.88);
    border: 1.5px solid rgba(81, 185, 200, 0.35);
    border-radius: 12px;
    color: #51b9c8;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.07), 0 2px 6px rgba(0,0,0,0.4);
    transition: background 0.08s, border-color 0.08s;
  }
  #mobile-overlay-dpad-btn.active {
    background: rgba(81, 185, 200, 0.2);
    border-color: rgba(81, 185, 200, 0.7);
  }
  #mobile-overlay-dpad-btn:active {
    background: rgba(81, 185, 200, 0.2);
    transform: scale(0.96);
  }

  /* ═══════════════════════════════════════════════════════════════════
     Mobile color picker popup
     Anchored above the controls container.
     ═══════════════════════════════════════════════════════════════════ */
  #mobile-color-popup {
    display: flex;          /* overrides desktop display:none */
    flex-direction: column;
    gap: 10px;
    position: fixed;
    right: 12px;
    /* controls: bottom-bar+12 + dpad 164 + gap 6 + overlay-btn 42 + gap 8 */
    bottom: calc(var(--bottom-bar-height) + 232px);
    width: 220px;
    background: rgba(14, 14, 26, 0.97);
    border: 1.5px solid rgba(81, 185, 200, 0.3);
    border-radius: 16px;
    padding: 12px;
    z-index: 1100;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65);
  }
  #mobile-color-popup.hidden { display: none !important; }

  .mcp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .mcp-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  .mcp-close {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary, #94a3b8);
    font-size: 12px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .mcp-close:active { background: rgba(239,68,68,0.25); color: #ef4444; }

  /* 12 preset colors — 6 per row */
  .mcp-palette {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
  }
  /* 4 saved slots */
  .mcp-saved {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    border-top: 1px solid rgba(255,255,255,0.07);
    padding-top: 8px;
  }
  .mcp-color-cell {
    aspect-ratio: 1;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
    transition: transform 0.08s, border-color 0.08s;
    padding: 0;
  }
  .mcp-color-cell:active { transform: scale(0.86); }
  .mcp-color-cell.selected { border-color: rgba(255,255,255,0.85); }
  .mcp-slot-empty {
    background: rgba(255,255,255,0.06);
    border: 1.5px dashed rgba(255,255,255,0.15) !important;
    cursor: default;
  }

  .mcp-hex-row {
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid rgba(255,255,255,0.07);
    padding-top: 8px;
  }
  .mcp-hex-preview {
    width: 32px; height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
    border: 1.5px solid rgba(255,255,255,0.15);
  }
  .mcp-hex-input {
    flex: 1;
    height: 32px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: var(--text-primary, #e2e8f0);
    font-family: monospace;
    font-size: 13px;
    padding: 0 8px;
    outline: none;
    text-transform: uppercase;
  }
  .mcp-hex-input:focus { border-color: rgba(81,185,200,0.5); }

  /* ═══════════════════════════════════════════════════════════════════
     Mobile overlay popup
     Same anchor as the color popup — only one visible at a time.
     ═══════════════════════════════════════════════════════════════════ */
  #mobile-overlay-popup {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: fixed;
    right: 12px;
    bottom: calc(var(--bottom-bar-height) + 232px);
    width: 220px;
    background: rgba(14, 14, 26, 0.97);
    border: 1.5px solid rgba(81, 185, 200, 0.3);
    border-radius: 16px;
    padding: 12px;
    z-index: 1100;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65);
  }
  #mobile-overlay-popup.hidden { display: none !important; }

  .mop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .mop-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
  .mop-close {
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary, #94a3b8);
    font-size: 12px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .mop-close:active { background: rgba(239,68,68,0.25); color: #ef4444; }

  .mop-opacity-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary, #94a3b8);
  }
  .mop-opacity-row input[type="range"] { flex: 1; }

  .mop-visible-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
  }

  /* Overlay arrow grid inside mobile popup */
  #mobile-overlay-popup .overlay-arrow-grid {
    grid-template-columns: repeat(3, 36px);
    gap: 4px;
  }
  #mobile-overlay-popup .overlay-arrow-btn {
    width: 36px;
    height: 36px;
  }
}

/* ===================================================
   Online users popup
   =================================================== */
.online-popup {
  position: fixed;
  bottom: calc(var(--bottom-bar-height) + 8px);
  right: 12px;
  width: 220px;
  max-height: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 400;
  overflow: hidden;
  animation: modalSlideUp 0.15s ease;
}

.online-popup.hidden { display: none; }

.online-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 7px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.online-popup-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.online-popup-close {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.online-popup-close:hover {
  background: var(--danger);
  color: #fff;
}

.online-popup-list {
  overflow-y: auto;
  list-style: none;
  padding: 4px 0;
  flex: 1;
  margin: 0;
}

.online-user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
}

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

.online-user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border-light);
}

.online-user-avatar-placeholder {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.online-user-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-user-name.anonymous {
  color: var(--text-muted);
  font-style: italic;
}

/* ── Anonymous mode ──────────────────────────────────────────────────── */

/* Place Pixel button tinted purple when anon mode is active */
.place-pixel-btn.btn-anon-mode {
  background: #7c3aed;
  border-color: #7c3aed;
}
.place-pixel-btn.btn-anon-mode:hover:not(:disabled) {
  background: #6d28d9;
  border-color: #6d28d9;
}

/* Pill badge shown next to "Mode Anonyme" in dropdown */
.anon-mode-badge {
  display: inline-block;
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.anon-mode-badge.active {
  background: #7c3aed;
  color: #fff;
}

/* Highlight the dropdown item when anon mode is active */
#anon-mode-btn.anon-active {
  color: #c4b5fd;
}

