.pixel-battle-page {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
  gap: 18px;
  padding: 18px;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 36px);
  padding: 22px 18px;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(31, 36, 48, 0.96), rgba(20, 24, 33, 0.96));
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(16px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 148, 186, 0.4) transparent;
}

.control-panel::-webkit-scrollbar {
  width: 10px;
}

.control-panel::-webkit-scrollbar-track {
  background: transparent;
}

.control-panel::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(125, 148, 186, 0.35);
  background-clip: padding-box;
}

.control-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(125, 148, 186, 0.5);
  background-clip: padding-box;
}

.brand-block h1 {
  margin: 8px 0 10px;
  font-size: 1.9rem;
  line-height: 1.1;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
}

.subtitle,
.draw-hint,
.selected-color-hint {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.5;
  font-size: 0.95rem;
}

.panel-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(12, 16, 23, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.panel-header-row,
.stat-row,
.pixel-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.panel-badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(110, 231, 249, 0.08);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}

.selected-color-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-user-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-avatar-shell {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(45, 55, 72, 0.96), rgba(22, 28, 39, 0.96));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.auth-avatar-shell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.auth-user-copy {
  display: grid;
  gap: 6px;
}

.auth-user-copy strong {
  color: var(--text-primary);
}

.auth-user-copy span {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.4;
}

.selected-color-preview {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.selected-color-name {
  margin-bottom: 6px;
  font-size: 1.05rem;
  font-weight: 700;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
}

.palette-color {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.palette-color:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.2);
}

.palette-color.is-active {
  border-color: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 0 3px rgba(110, 231, 249, 0.2);
  transform: translateY(-1px);
}

.camera-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.draft-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.tool-button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text-primary);
  background: linear-gradient(180deg, rgba(50, 58, 78, 0.9), rgba(29, 35, 49, 0.9));
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

.tool-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.14);
  filter: brightness(1.04);
}

.tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  filter: none;
}

.tool-button-accent {
  color: #04131a;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 12px 24px rgba(34, 211, 238, 0.18);
}

.tool-button-danger {
  color: #ffe7e7;
  background: linear-gradient(180deg, rgba(115, 31, 45, 0.95), rgba(82, 24, 36, 0.95));
}

.tool-button-wide {
  grid-column: span 2;
}

.stats-card,
.pixel-info-grid,
.help-list {
  display: grid;
  gap: 8px;
}

.pixel-info-row,
.help-row {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.pixel-info-row strong,
.help-row strong {
  color: var(--text-primary);
  font-size: 0.88rem;
  text-align: right;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.connection-status::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.04);
}

.connection-status.is-online {
  color: #34d399;
}

.connection-status.is-reconnecting {
  color: #fbbf24;
}

.connection-status.is-offline {
  color: #f87171;
}

.board-section {
  min-width: 0;
}

.board-frame {
  position: relative;
  height: calc(100vh - 36px);
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at 20% 20%, rgba(110, 231, 249, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
    #090d14;
  box-shadow: var(--panel-shadow);
}

.charge-island {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(12, 16, 24, 0.9);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%);
  pointer-events: none;
}

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

.charge-timer {
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.board-overlay {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.board-pill {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.78);
  color: var(--text-secondary);
  font-size: 0.78rem;
}

#pixelCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#pixelCanvas.is-panning {
  cursor: grabbing;
}

.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  pointer-events: none;
}

.floating-toast {
  min-width: 260px;
  padding: 14px 14px 12px;
  border: 1px solid rgba(248, 113, 113, 0.22);
  border-radius: 18px;
  background: rgba(56, 18, 23, 0.96);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.floating-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.floating-toast-title {
  margin-bottom: 10px;
  color: #ffe7e7;
  font-weight: 700;
}

.floating-toast-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.floating-toast-progress {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #fb7185 0%, #ef4444 100%);
  transform-origin: left center;
}

@media (max-width: 1100px) {
  .pixel-battle-page {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .palette-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .pixel-battle-page {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .control-panel {
    order: 2;
    max-height: none;
  }

  .board-section {
    order: 1;
  }

  .board-frame {
    height: 68vh;
    min-height: 420px;
  }

  .palette-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .pixel-battle-page {
    padding: 12px;
    gap: 12px;
  }

  .control-panel {
    padding: 16px;
  }

  .camera-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-button-wide {
    grid-column: span 2;
  }

  .palette-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .charge-island {
    gap: 8px;
    width: min(calc(100% - 32px), 320px);
    justify-content: space-between;
  }

  .toast-stack {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .floating-toast {
    min-width: 0;
  }
}
