:root {
  --bg-main: #0c1123;
  --bg-soft: rgba(16, 24, 48, 0.72);
  --card-border: rgba(148, 163, 184, 0.28);
  --text-main: #f5f7ff;
  --text-muted: #9fb0d4;
  --accent: #4ee6a0;
  --danger: #ff5d73;
  --shadow: 0 28px 72px rgba(2, 8, 22, 0.48);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 12% 10%, rgba(64, 102, 255, 0.32) 0%, rgba(64, 102, 255, 0) 40%),
    radial-gradient(circle at 85% 16%, rgba(58, 219, 177, 0.22) 0%, rgba(58, 219, 177, 0) 45%),
    linear-gradient(150deg, #090d1d 0%, #0f1730 44%, #111c3f 100%);
}

.layout {
  width: min(1260px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 2.4vw, 30px);
  display: grid;
  grid-template-columns: minmax(300px, 370px) 1fr;
  gap: clamp(16px, 2vw, 28px);
}

.panel,
.board-panel {
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.panel {
  padding: clamp(18px, 2vw, 28px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

h1 {
  margin: 0;
  font-family: "Manrope", "Space Grotesk", sans-serif;
  font-size: clamp(1.7rem, 2.2vw, 2.3rem);
  line-height: 1.1;
}

.lead {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.45;
}

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

.stat-card {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(5, 10, 23, 0.56);
  border: 1px solid rgba(128, 146, 184, 0.26);
}

.stat-label {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.2rem;
  font-family: "Manrope", "Space Grotesk", sans-serif;
}

.toolbar {
  display: grid;
  gap: 12px;
}

.color-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 0.93rem;
}

.color-picker input[type="color"] {
  width: 64px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.brush-picker {
  display: grid;
  gap: 8px;
  font-size: 0.93rem;
}

.brush-picker span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brush-picker input[type="range"] {
  width: 100%;
  accent-color: #5c8bff;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.color-chip {
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: var(--chip);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.color-chip:hover {
  transform: translateY(-2px);
}

.color-chip.is-active {
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.18);
}

.status {
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.status-connecting {
  color: #ffd976;
  background: rgba(255, 219, 120, 0.14);
  border-color: rgba(255, 219, 120, 0.4);
}

.status-online {
  color: #5af0b0;
  background: rgba(90, 240, 176, 0.14);
  border-color: rgba(90, 240, 176, 0.4);
}

.status-retrying {
  color: #ff92a2;
  background: rgba(255, 118, 145, 0.12);
  border-color: rgba(255, 118, 145, 0.42);
}

.board-panel {
  padding: clamp(16px, 2vw, 26px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: min(92vh, 980px);
}

.board-header h2 {
  margin: 0;
  font-family: "Manrope", "Space Grotesk", sans-serif;
  font-size: clamp(1.2rem, 1.7vw, 1.5rem);
}

.board-header p {
  margin: 8px 0 0;
  color: var(--text-muted);
}

.canvas-wrap {
  width: 100%;
  max-width: 100%;
  max-height: 72vh;
  margin: 0 auto;
  border-radius: 18px;
  overflow: auto;
  border: 1px solid rgba(133, 156, 210, 0.35);
  background:
    linear-gradient(90deg, rgba(42, 60, 108, 0.25) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(rgba(42, 60, 108, 0.25) 1px, transparent 1px) 0 0 / 20px 20px,
    linear-gradient(160deg, #fdfdfd 0%, #eff4ff 100%);
}

#pixelCanvas {
  display: block;
  image-rendering: pixelated;
  touch-action: none;
  cursor: crosshair;
  width: auto;
  height: auto;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .board-panel {
    min-height: unset;
  }
}

@media (max-width: 560px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-value {
    font-size: 1rem;
  }

  .color-chip {
    width: 32px;
    height: 32px;
  }
}
