.pixel-battle-page {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100dvh;
  gap: 18px;
  padding: 18px;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100dvh - 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);
  min-width: 0;
}

.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-card,
.palette-popover-card {
  --palette-swatch-size: 32px;
}

.selected-color-card {
  gap: 12px;
}

.selected-color-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.selected-color-actions,
.palette-title-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.selected-color-actions {
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.palette-title {
  min-width: 0;
}

.palette-count {
  flex: 0 0 auto;
  white-space: nowrap;
}

.palette-tool-button {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.palette-tool-button img {
  width: 15px;
  height: 15px;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.palette-tool-button:hover,
.palette-tool-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(110, 231, 249, 0.36);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.palette-tool-button.is-active {
  border-color: rgba(110, 231, 249, 0.5);
  color: var(--accent);
  background: rgba(34, 211, 238, 0.14);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

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

.selected-color-body {
  align-items: center;
}

.open-palette-button {
  min-height: 32px;
  padding: 7px 12px;
  border: 1px solid rgba(110, 231, 249, 0.24);
  border-radius: 999px;
  background: rgba(110, 231, 249, 0.08);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.open-palette-button:hover,
.open-palette-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(110, 231, 249, 0.42);
  background: rgba(34, 211, 238, 0.14);
  color: var(--text-primary);
  outline: none;
}

.palette-popover {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 23, 0.52);
  backdrop-filter: blur(10px);
}

.palette-popover.hidden {
  display: none;
}

.palette-popover-card {
  width: min(420px, 100%);
  max-height: min(70vh, 520px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(19, 24, 34, 0.98), rgba(10, 14, 22, 0.98));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.palette-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.palette-popover-scroll {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 148, 186, 0.35) transparent;
}

.palette-popover-scroll::-webkit-scrollbar {
  width: 8px;
}

.palette-popover-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.palette-popover-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(125, 148, 186, 0.32);
}

.palette-popover-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(125, 148, 186, 0.48);
}

.palette-close-button {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.palette-close-button:hover,
.palette-close-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(110, 231, 249, 0.36);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.leaderboard-modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 23, 0.58);
  backdrop-filter: blur(10px);
}

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

.leaderboard-card {
  width: min(520px, calc(100vw - 32px));
  max-height: min(75vh, 640px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(19, 24, 34, 0.98), rgba(10, 14, 22, 0.98));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.leaderboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.leaderboard-title {
  margin: 0 0 6px;
  color: var(--text-primary);
  font-size: 1.35rem;
  line-height: 1.15;
}

.leaderboard-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.4;
}

.leaderboard-close-button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.leaderboard-close-button:hover,
.leaderboard-close-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(110, 231, 249, 0.36);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.leaderboard-body {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 148, 186, 0.35) transparent;
}

.leaderboard-body::-webkit-scrollbar {
  width: 8px;
}

.leaderboard-body::-webkit-scrollbar-track {
  background: transparent;
}

.leaderboard-body::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(125, 148, 186, 0.32);
}

.leaderboard-state {
  padding: 14px 2px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.5;
}

.leaderboard-state.is-error {
  color: #fca5a5;
}

.leaderboard-list {
  display: grid;
  gap: 10px;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-item.is-top-1,
.leaderboard-item.is-top-2,
.leaderboard-item.is-top-3 {
  background: linear-gradient(180deg, rgba(26, 35, 53, 0.96), rgba(14, 20, 32, 0.96));
  border-color: rgba(110, 231, 249, 0.16);
}

.leaderboard-rank {
  min-width: 40px;
  color: var(--accent);
  font-weight: 800;
  font-size: 0.96rem;
}

.leaderboard-user {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.leaderboard-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  flex: 0 0 auto;
}

.leaderboard-user-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.leaderboard-username {
  color: var(--text-primary);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.leaderboard-role {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(110, 231, 249, 0.08);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}

.leaderboard-no-roles {
  color: var(--text-secondary);
  font-size: 0.76rem;
}

.leaderboard-score {
  color: var(--text-primary);
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

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

.auth-avatar-shell {
  position: relative;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 999px;
  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-ring {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  transform: rotate(-90deg);
  overflow: visible;
  pointer-events: none;
}

.auth-avatar-ring-track,
.auth-avatar-ring-progress {
  fill: none;
  stroke-width: 8;
}

.auth-avatar-ring-track {
  stroke: rgba(255, 255, 255, 0.08);
}

.auth-avatar-ring-progress {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 0.2s ease;
}

.auth-avatar-shell img {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.auth-user-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}

.auth-name-row,
.auth-xp-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.auth-user-copy strong {
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.auth-level-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
}

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

.auth-xp-meta {
  font-size: 0.78rem;
}

.auth-xp-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.auth-xp-bar-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-strong) 100%);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.2s ease;
}

.auth-bonus-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
}

.auth-bonus-list {
  display: grid;
  gap: 4px;
}

.auth-bonus-item {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.auth-bonus-copy::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.08);
}

.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(auto-fill, minmax(var(--palette-swatch-size), 1fr));
  grid-auto-rows: var(--palette-swatch-size);
  gap: 8px;
  min-height: var(--palette-swatch-size);
  align-content: start;
  justify-items: center;
}

.palette-color {
  width: var(--palette-swatch-size);
  height: var(--palette-swatch-size);
  min-width: var(--palette-swatch-size);
  min-height: var(--palette-swatch-size);
  display: block;
  justify-self: center;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  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;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tool-button {
  min-height: 44px;
  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 {
  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;
  position: relative;
}

.board-frame {
  position: relative;
  height: calc(100dvh - 36px);
  min-height: 0;
  width: 100%;
  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);
}

.board-corner-actions {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.board-help-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.76);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.board-help-button:hover,
.board-help-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(110, 231, 249, 0.42);
  background: rgba(17, 24, 39, 0.92);
  outline: none;
}

.leaderboard-trigger-button img {
  width: 16px;
  height: 16px;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.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;
  max-width: calc(100% - 120px);
  white-space: nowrap;
}

.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;
}

.canvas-action-bar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 4;
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(100%, 340px);
  padding: 0 16px;
  transform: translateX(-50%);
  pointer-events: none;
}

.canvas-action-buttons {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: center;
  pointer-events: auto;
}

.canvas-selected-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(11, 17, 27, 0.74);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  pointer-events: auto;
}

.canvas-selected-badge.is-active {
  border-color: rgba(110, 231, 249, 0.32);
  background: rgba(16, 32, 40, 0.9);
  color: var(--accent);
}

.canvas-draw-button {
  width: min(100%, 280px);
  min-height: 48px;
  border-radius: 18px;
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
}

.canvas-clear-button {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.84);
  color: var(--text-primary);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.canvas-clear-button:hover,
.canvas-clear-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(58, 18, 24, 0.92);
  outline: none;
}

.canvas-clear-button:disabled {
  opacity: 0;
  pointer-events: none;
}

#pixelCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

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

#pixelCanvas.is-eyedropper-active {
  cursor: copy;
}

.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;
}

.help-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(10px);
}

.help-modal-backdrop.is-open {
  display: flex;
}

.help-modal {
  width: min(720px, 100%);
  max-height: min(82vh, 920px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(19, 24, 34, 0.98), rgba(10, 14, 22, 0.98));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
}

.help-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 0;
}

.help-modal-title {
  margin: 8px 0 0;
  color: var(--text-primary);
  font-size: 1.45rem;
  line-height: 1.15;
}

.help-modal-close {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.help-modal-close:hover,
.help-modal-close:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(110, 231, 249, 0.32);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.help-modal-content {
  overflow-y: auto;
  padding: 20px 22px 22px;
  display: grid;
  gap: 18px;
}

.help-modal-section {
  display: grid;
  gap: 10px;
}

.help-modal-section h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1rem;
}

.help-modal-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  display: grid;
  gap: 8px;
  line-height: 1.5;
}

button,
a,
.palette-color,
.palette-tool-button,
.tool-button,
.board-help-button {
  touch-action: manipulation;
}

@media (max-width: 1024px) {
  .selected-color-card,
  .palette-popover-card {
    --palette-swatch-size: 30px;
  }

  .pixel-battle-page {
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 16px;
    padding: 16px;
  }

  .control-panel {
    padding: 18px 16px;
    border-radius: 22px;
  }

  .palette-tool-button {
    width: 26px;
    height: 26px;
  }
}

@media (min-width: 769px) {
  .panel-card-camera {
    display: none;
  }
}

@media (max-width: 768px) {
  .selected-color-card,
  .palette-popover-card {
    --palette-swatch-size: 30px;
  }

  .pixel-battle-page {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    gap: 12px;
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    overflow: visible;
  }

  .control-panel {
    order: 2;
    max-height: none;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    overflow: visible;
  }

  .board-section {
    order: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: visible;
  }

  .board-frame {
    height: auto;
    width: min(100%, 420px);
    max-width: 100%;
    align-self: center;
    aspect-ratio: 1 / 1;
    min-height: min(62vw, 420px);
    max-height: min(58vh, 420px);
    border-radius: 22px;
  }

  .brand-block {
    order: 7;
    padding: 4px 2px 0;
  }

  .panel-card-camera {
    order: 1;
  }

  .panel-card-selected-color {
    order: 2;
  }

  .panel-card-account {
    order: 3;
  }

  .panel-card-selected-pixel {
    order: 4;
  }

  .panel-card-stats {
    order: 5;
  }

  .panel-card {
    width: 100%;
    padding: 14px;
    border-radius: 18px;
  }

  .panel-header-row,
  .stat-row,
  .pixel-info-row,
  .auth-name-row,
  .auth-xp-meta {
    flex-wrap: wrap;
  }

  .selected-color-row > div:last-child {
    min-width: 0;
  }

  .selected-color-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .auth-user-row {
    align-items: flex-start;
  }

  .auth-avatar-shell {
    width: 52px;
    height: 52px;
  }

  .auth-user-copy span,
  .auth-xp-meta {
    font-size: 0.84rem;
  }

  .auth-bonus-list {
    gap: 6px;
  }

  .auth-bonus-item {
    line-height: 1.4;
  }

  .tool-button,
  .palette-tool-button {
    min-height: 40px;
  }

  .palette-popover-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .palette-title-row {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .palette-popover {
    padding: 12px;
  }

  .palette-popover-card {
    width: min(100%, 420px);
    max-height: min(72dvh, 520px);
    padding: 14px;
    border-radius: 18px;
  }

  .palette-popover-scroll {
    max-height: min(56dvh, 420px);
  }

  .leaderboard-card {
    width: min(100%, 520px);
    max-height: min(78dvh, 640px);
    padding: 16px;
    border-radius: 20px;
  }

  .leaderboard-header {
    gap: 12px;
  }

  .leaderboard-item {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
  }

  .leaderboard-score {
    grid-column: 2;
    text-align: left;
    white-space: normal;
  }

  .palette-grid {
    grid-template-columns: repeat(auto-fill, minmax(var(--palette-swatch-size), 1fr));
    gap: 6px;
  }

  .panel-card-camera {
    margin-top: 2px;
    padding: 12px 14px;
    gap: 0;
  }

  .panel-card-camera .panel-label,
  .panel-card-camera .draw-hint,
  .panel-card-camera #resetCameraButton {
    display: none;
  }

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

  .tool-button-wide {
    grid-column: 1 / -1;
  }

  .charge-island {
    top: 10px;
    left: 100px;
    right: 10px;
    transform: none;
    width: auto;
    max-width: none;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 10px;
    border-radius: 16px;
    flex-direction: column;
    pointer-events: none;
    white-space: normal;
  }

  .charge-text,
  .charge-timer {
    min-width: 0;
  }

  .charge-text {
    font-size: 0.9rem;
    line-height: 1.2;
  }

  .charge-timer {
    font-size: 0.74rem;
    line-height: 1.2;
  }

  .board-overlay {
    top: auto;
    bottom: 72px;
    right: 12px;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: calc(100% - 24px);
  }

  .board-pill {
    padding: 6px 9px;
    font-size: 0.72rem;
  }

  .board-corner-actions {
    top: 12px;
    left: 12px;
    gap: 8px;
  }

  .board-help-button {
    width: 36px;
    height: 36px;
  }

  .canvas-action-bar {
    bottom: 12px;
    width: min(calc(100% - 24px), 320px);
    gap: 8px;
    padding: 0;
  }

  .canvas-action-buttons {
    gap: 8px;
    align-items: stretch;
  }

  .canvas-draw-button {
    width: calc(100% - 48px);
    max-width: 320px;
    min-height: 46px;
    padding-inline: 16px;
  }

  .canvas-clear-button {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }

  .help-modal-backdrop {
    padding: 12px;
  }

  .help-modal {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    border-radius: 20px;
  }

  .help-modal-header {
    padding: 18px 18px 0;
  }

  .help-modal-content {
    padding: 16px 18px 18px;
  }

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

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

@media (max-width: 480px) {
  .selected-color-card,
  .palette-popover-card {
    --palette-swatch-size: 28px;
  }

  .pixel-battle-page {
    padding: 12px;
    gap: 12px;
  }

  .brand-block h1 {
    font-size: 1.6rem;
  }

  .panel-card {
    padding: 12px;
    gap: 12px;
  }

  .panel-label {
    font-size: 0.75rem;
  }

  .auth-avatar-shell {
    width: 48px;
    height: 48px;
  }

  .auth-level-badge {
    padding: 3px 7px;
  }

  .palette-color {
    min-width: var(--palette-swatch-size);
  }

  .palette-popover {
    padding: 10px;
  }

  .palette-popover-card {
    width: 100%;
    max-height: min(78dvh, 520px);
    padding: 12px;
  }

  .palette-popover-scroll {
    max-height: min(62dvh, 430px);
  }

  .leaderboard-modal {
    padding: 10px;
  }

  .leaderboard-card {
    width: 100%;
    max-height: min(82dvh, 640px);
    padding: 14px;
    border-radius: 18px;
  }

  .leaderboard-avatar {
    width: 34px;
    height: 34px;
  }

  .panel-card-camera {
    padding: 10px 12px;
  }

  .charge-island {
    left: 92px;
    right: 8px;
    padding: 7px 9px;
  }

  .charge-text {
    font-size: 0.84rem;
  }

  .charge-timer {
    font-size: 0.7rem;
  }

  .board-corner-actions {
    gap: 6px;
  }

  .board-help-button {
    width: 34px;
    height: 34px;
  }

  .canvas-action-bar {
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: calc(100% - 16px);
  }

  .canvas-selected-badge {
    min-height: 26px;
    padding: 5px 10px;
    font-size: 0.74rem;
  }

  .canvas-draw-button {
    min-height: 44px;
    border-radius: 16px;
  }

  .canvas-clear-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    font-size: 1.2rem;
  }

  .board-overlay {
    bottom: calc(64px + env(safe-area-inset-bottom));
    right: 10px;
    max-width: calc(100% - 20px);
  }

  .board-pill:last-child {
    display: none;
  }

  .help-modal-title {
    font-size: 1.2rem;
  }

  .help-modal-content {
    gap: 16px;
  }
}
