:root {
  --bg: #090a0f;
  --page-bg-1: #090a0f;
  --page-bg-2: #11131c;
  --page-bg-3: #07080d;
  --panel: #131620;
  --panel-2: #191d2a;
  --line: #2a3042;
  --text: #f6f7fb;
  --muted: #a7afc3;
  --accent: #02f5b8;
  --accent-2: #7c3cff;
  --danger: #ff3d5a;
  --cols: 100;
  --rows: 100;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f7fb;
  --page-bg-1: #f7fafc;
  --page-bg-2: #eef4f8;
  --page-bg-3: #f9fbff;
  --panel: #ffffff;
  --panel-2: #eef3f8;
  --line: #c7d2e0;
  --text: #101828;
  --muted: #5f6f86;
  --accent: #008f78;
  --accent-2: #6544db;
  --danger: #c01f45;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--page-bg-1) 0%, var(--page-bg-2) 48%, var(--page-bg-3) 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 76px;
  padding: 12px clamp(14px, 3vw, 32px);
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto auto minmax(190px, 0.7fr);
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(9, 10, 15, 0.84);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: clamp(1rem, 1.4vw, 1.25rem);
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 8px;
  background: #0d1018;
  border: 1px solid var(--line);
  box-shadow: 0 0 26px rgba(2, 245, 184, 0.22);
}

.brand-mark span:nth-child(1) { background: #02f5b8; }
.brand-mark span:nth-child(2) { background: #7c3cff; }
.brand-mark span:nth-child(3) { background: #ff3d81; }
.brand-mark span:nth-child(4) { background: #f6ff00; }
.brand-mark span {
  border-radius: 3px;
}

.platform-strip,
.top-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.platform-chip {
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
}

.platform-twitch { color: #c7a8ff; }
.platform-kick { color: #90ff4d; }
.platform-youtube { color: #ff7184; }

.top-stats {
  justify-content: flex-end;
  color: var(--muted);
}

.view-controls {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.preference-toggle {
  min-height: 38px;
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.preference-button {
  min-width: 40px;
  min-height: 30px;
  padding: 0 9px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  font-size: 0.78rem;
}

.preference-button.is-active {
  background: var(--text);
  color: var(--bg);
}

.top-stats span {
  min-width: 92px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.top-stats strong {
  color: var(--text);
}

.workspace {
  width: min(1780px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 2.2vw, 32px);
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 390px;
  gap: clamp(16px, 2vw, 26px);
  flex: 1;
}

.leaderboard-panel {
  border-radius: 8px;
  padding: 14px;
  align-self: start;
  position: sticky;
  top: 92px;
  max-height: calc(100dvh - 108px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(19, 22, 32, 0.82);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

.leaderboard-header {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.leaderboard-header span {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.leaderboard-header strong {
  font-size: 1rem;
}

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

.leaderboard-empty,
.leaderboard-item {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-empty {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.leaderboard-empty strong {
  font-size: 0.9rem;
}

.leaderboard-empty small {
  color: var(--muted);
  line-height: 1.35;
}

.leaderboard-item {
  width: 100%;
  min-height: 62px;
  display: grid;
  grid-template-columns: 28px 44px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 8px;
  text-align: left;
}

.leaderboard-item:hover {
  border-color: rgba(2, 245, 184, 0.55);
  background: rgba(2, 245, 184, 0.11);
}

.leaderboard-rank {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 950;
  font-size: 0.82rem;
}

.leaderboard-thumb {
  width: 44px;
  height: 40px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--thumb-a), var(--thumb-b));
  border: 1px solid rgba(255, 255, 255, 0.12);
}

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

.leaderboard-copy strong,
.leaderboard-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-copy small {
  color: var(--muted);
  font-size: 0.78rem;
}

.leaderboard-copy i {
  height: 4px;
  min-width: 4px;
  max-width: 100%;
  display: block;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.board-stage {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage-toolbar,
.control-panel,
.canvas-frame {
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(19, 22, 32, 0.82);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

.stage-toolbar {
  min-height: 60px;
  padding: 10px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
}

.tool-group {
  display: inline-flex;
  gap: 8px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.icon-button:hover,
.icon-button.is-active {
  border-color: rgba(2, 245, 184, 0.55);
  background: rgba(2, 245, 184, 0.13);
}

.icon-button svg,
.primary-action svg,
.secondary-action svg,
.file-drop svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.zoom-control {
  flex: 1;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.zoom-control input {
  width: 100%;
  accent-color: var(--accent);
}

.selection-meter {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 190px;
  justify-content: flex-end;
  color: var(--muted);
}

.selection-meter strong {
  min-width: 88px;
  text-align: right;
  color: var(--accent);
  font-size: 1.05rem;
}

.canvas-frame {
  border-radius: 8px;
  padding: clamp(10px, 1.5vw, 18px);
  height: clamp(430px, calc(100dvh - 220px), 760px);
  overflow: auto;
  min-height: 0;
  overscroll-behavior: contain;
}

.pixel-board {
  --cell-scale: 1;
  --pixel-unit: 1px;
  width: calc(1000px * var(--cell-scale));
  aspect-ratio: 1 / 1;
  display: block;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  gap: 0;
  padding: 0;
  margin: 0 auto;
  background: #070911;
  background-size: auto;
  border: 0;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  overflow: hidden;
  image-rendering: pixelated;
  user-select: none;
  touch-action: none;
}

.pixel-board.show-pixel-grid {
  background-color: #070911;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: var(--pixel-unit) var(--pixel-unit);
}

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: 2px;
  background: #111522;
  border: 0;
  padding: 0;
  overflow: hidden;
  color: #fff;
}

.cell::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--cell-a, transparent), var(--cell-b, transparent));
  opacity: 0;
}

.cell::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.94);
  font-size: clamp(5px, 0.62vw, 10px);
  font-weight: 900;
  line-height: 1;
  overflow: hidden;
  text-transform: uppercase;
}

.cell:hover {
  outline: 1px solid rgba(255, 255, 255, 0.42);
  z-index: 2;
}

.cell.is-owned {
  background-color: #202536;
}

.cell.is-owned::before {
  opacity: 1;
}

.cell.is-selected {
  background: rgba(2, 245, 184, 0.28);
  outline: 1px solid var(--accent);
  box-shadow: inset 0 0 0 1px rgba(246, 255, 0, 0.4);
  z-index: 3;
}

.pixel-board.has-invalid-selection .cell.is-selected {
  background: rgba(255, 61, 90, 0.22);
  outline-color: var(--danger);
}

.cell.has-image {
  background-repeat: no-repeat;
}

.cell.pattern-scan::before {
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.22) 0 1px, transparent 1px 4px),
    linear-gradient(135deg, var(--cell-a), var(--cell-b));
}

.cell.pattern-burst::before {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.9), transparent 20%),
    linear-gradient(135deg, var(--cell-a), var(--cell-b));
}

.cell.pattern-grid::before {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.24) 1px, transparent 1px),
    linear-gradient(135deg, var(--cell-a), var(--cell-b));
  background-size: 6px 6px, 6px 6px, auto;
}

.cell.is-glowing {
  animation: livePulse 2.8s ease-in-out infinite;
}

.spot.is-glowing {
  animation: livePulse 2.8s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35) saturate(1.25); }
}

.pixel-board {
  position: relative;
  display: block;
  gap: 0;
  padding: 0;
}

.spot,
.selection-rect {
  position: absolute;
  min-width: 1px;
  min-height: 1px;
}

.spot {
  display: block;
  padding: 0;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    linear-gradient(135deg, var(--cell-a, #7c3cff), var(--cell-b, #02f5b8));
  color: #fff;
  text-decoration: none;
  overflow: hidden;
  z-index: 2;
}

.spot::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.62;
}

.spot::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2px;
  color: rgba(255, 255, 255, 0.94);
  font-size: clamp(7px, 0.7vw, 14px);
  font-weight: 950;
  line-height: 1;
  overflow: hidden;
  text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.spot.has-image:not(.has-image-error)::after {
  content: "";
}

.spot img {
  display: none;
}

.spot:hover,
.spot.is-focused {
  outline: 2px solid rgba(2, 245, 184, 0.9);
  z-index: 4;
}

.spot.is-channel-focused {
  outline: 2px solid rgba(246, 255, 0, 0.95);
  box-shadow:
    0 0 0 1px rgba(2, 245, 184, 0.7),
    0 0 18px rgba(246, 255, 0, 0.42);
  z-index: 4;
}

.spot.pattern-scan::before {
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.24) 0 2px, transparent 2px 8px);
}

.spot.pattern-burst::before {
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.86), transparent 22%);
}

.spot.pattern-grid::before {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.26) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px);
  background-size: 10px 10px;
}

.selection-rect {
  display: grid;
  place-items: center;
  border: 1px solid var(--accent);
  background: rgba(2, 245, 184, 0.18);
  box-shadow:
    inset 0 0 0 1px rgba(246, 255, 0, 0.35),
    0 0 0 1px rgba(2, 245, 184, 0.28);
  color: #f6f7fb;
  font-size: clamp(8px, 0.9vw, 15px);
  font-weight: 900;
  line-height: 1;
  overflow: hidden;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  z-index: 5;
}

.selection-rect.is-invalid {
  border-color: var(--danger);
  background: rgba(255, 61, 90, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.control-panel {
  border-radius: 8px;
  padding: 14px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 92px;
  max-height: calc(100dvh - 108px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.panel-tabs,
.segmented,
.style-grid {
  display: grid;
  gap: 6px;
}

.panel-tabs {
  grid-template-columns: repeat(2, 1fr);
  padding: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.tab,
.segment,
.style-option {
  min-height: 36px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  font-weight: 750;
}

.tab.is-active,
.segment.is-active,
.style-option.is-active {
  background: #f6f7fb;
  color: #080a10;
}

.preview-tile {
  width: 100%;
  min-height: 130px;
  max-height: 280px;
  aspect-ratio: var(--preview-aspect, 1 / 1);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(135deg, var(--preview-a, #7c3cff), var(--preview-b, #02f5b8));
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  isolation: isolate;
}

.preview-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    var(--template-overlay, none),
    var(--preview-pattern, none);
  background-size:
    var(--template-grid-size, auto),
    auto;
  opacity: 0.72;
}

.preview-tile::after {
  content: "";
  position: absolute;
  inset: -30%;
  background: linear-gradient(100deg, transparent 34%, rgba(255, 255, 255, 0.36) 50%, transparent 66%);
  transform: translateX(-70%);
  animation: sheen 4s ease-in-out infinite;
  display: var(--preview-glow, block);
}

@keyframes sheen {
  0%, 45% { transform: translateX(-70%); }
  70%, 100% { transform: translateX(70%); }
}

.preview-tile span,
.preview-tile strong {
  position: relative;
  z-index: 1;
}

.preview-tile span:empty,
.preview-tile strong:empty {
  display: none;
}

.preview-tile span {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  font-weight: 900;
  font-size: 0.75rem;
}

.preview-tile strong {
  max-width: 90%;
  overflow-wrap: anywhere;
  text-align: center;
  font-size: clamp(1.7rem, 5vw, 3.1rem);
  line-height: 0.95;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

.purchase-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(2, 245, 184, 0.08);
  border: 1px solid rgba(2, 245, 184, 0.2);
}

.auth-panel.is-connected {
  background: rgba(2, 245, 184, 0.12);
  border-color: rgba(2, 245, 184, 0.38);
}

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

.auth-copy strong {
  color: var(--text);
  font-size: 0.92rem;
}

.auth-copy small {
  color: var(--muted);
  line-height: 1.35;
}

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

.auth-button {
  min-height: 40px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  color: #050609;
  text-decoration: none;
  font-weight: 950;
}

.auth-twitch { background: #c7a8ff; }
.auth-youtube { background: #ff7184; }
.auth-kick { background: #90ff4d; }

.auth-button.is-disabled {
  opacity: 0.42;
  pointer-events: none;
  filter: saturate(0.35);
}

label,
fieldset {
  margin: 0;
  border: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

legend {
  color: var(--muted);
  margin-bottom: 7px;
  font-size: 0.88rem;
}

input[type="text"],
input[type="url"] {
  width: 100%;
  min-height: 42px;
  margin-top: 7px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input[readonly] {
  color: rgba(246, 247, 251, 0.72);
  background: rgba(2, 245, 184, 0.07);
}

input[type="text"]:focus,
input[type="url"]:focus {
  border-color: rgba(2, 245, 184, 0.65);
  box-shadow: 0 0 0 3px rgba(2, 245, 184, 0.14);
}

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

.swatches {
  display: flex;
  gap: 8px;
}

.swatch {
  width: 42px;
  height: 34px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, var(--a), var(--b));
}

.swatch.is-active {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

.style-grid {
  grid-template-columns: repeat(4, 1fr);
}

.style-option {
  background: rgba(255, 255, 255, 0.06);
}

.file-drop {
  position: relative;
  min-height: 58px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.file-drop input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.file-drop span {
  flex: 1;
}

.file-drop strong,
.file-drop small {
  display: block;
}

.file-drop strong {
  color: var(--text);
}

.asset-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.asset-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.84rem;
}

.asset-row strong {
  color: var(--text);
  text-align: right;
}

.asset-status {
  min-height: 34px;
  margin: 0;
  padding: 8px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.16);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
}

.asset-status.is-good {
  color: #9dffcf;
  background: rgba(2, 245, 184, 0.1);
}

.asset-status.is-warn {
  color: #ffe18a;
  background: rgba(246, 255, 0, 0.09);
}

.asset-status.is-bad {
  color: #ff9aae;
  background: rgba(255, 61, 90, 0.1);
}

.template-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.secondary-action {
  min-height: 38px;
  border-radius: 8px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-weight: 850;
}

.secondary-action:hover:not(:disabled) {
  border-color: rgba(2, 245, 184, 0.55);
  background: rgba(2, 245, 184, 0.13);
}

.toggle-row.compact {
  min-height: 38px;
  white-space: nowrap;
}

.toggle-row {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.fit-segmented {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.buy-summary {
  min-height: 58px;
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(2, 245, 184, 0.08);
  border: 1px solid rgba(2, 245, 184, 0.18);
}

.buy-summary span {
  color: var(--muted);
  font-size: 0.88rem;
}

.buy-summary strong {
  color: var(--accent);
  font-size: 1.25rem;
  white-space: nowrap;
}

.terms-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.terms-check input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.terms-check a,
.auth-legal a,
.site-footer a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.terms-check a:hover,
.auth-legal a:hover,
.site-footer a:hover {
  text-decoration: underline;
}

.auth-legal {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

.primary-action {
  min-height: 48px;
  border-radius: 8px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--accent), #f6ff00);
  color: #050609;
  font-weight: 950;
  box-shadow: 0 16px 34px rgba(2, 245, 184, 0.18);
}

.payment-actions {
  display: grid;
  gap: 10px;
}

.paypal-panel {
  display: grid;
  gap: 7px;
}

.paypal-panel span {
  color: var(--muted);
  font-size: 0.78rem;
}

.paypal-buttons:empty {
  display: none;
}

.payment-status {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.payment-status.is-good {
  color: #9dffcf;
}

.payment-status.is-bad {
  color: #ff9aae;
}

.payment-status.is-warn {
  color: #ffe18a;
}

.owned-strip {
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  padding-top: 12px;
}

.owned-header {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.owned-list {
  display: grid;
  gap: 8px;
}

.owned-item {
  min-height: 54px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.owned-thumb {
  width: 44px;
  height: 38px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--thumb-a), var(--thumb-b));
}

.owned-copy {
  min-width: 0;
}

.owned-copy strong,
.owned-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.owned-copy small {
  color: var(--muted);
}

.owned-item a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 800;
}

.legal-band {
  width: 100%;
  margin-top: clamp(8px, 1.5vw, 18px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 9, 17, 0.52);
}

.legal-content {
  width: min(1780px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 2.2vw, 30px) clamp(14px, 2.2vw, 32px);
}

.legal-content h2 {
  margin: 0 0 14px;
  font-size: 1rem;
  letter-spacing: 0;
}

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

.legal-grid article {
  min-width: 0;
}

.legal-grid h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 0.88rem;
}

.legal-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.site-footer {
  width: min(1780px, 100%);
  margin: 0 auto;
  padding: 0 clamp(14px, 2.2vw, 32px) clamp(18px, 2.4vw, 34px);
  color: rgba(167, 175, 195, 0.78);
  font-size: 0.82rem;
  line-height: 1.5;
}

.site-footer p {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.policy-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--page-bg-1) 0%, var(--page-bg-2) 48%, var(--page-bg-3) 100%);
}

.policy-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 48px) clamp(16px, 4vw, 28px);
}

.policy-nav {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: clamp(28px, 5vw, 56px);
}

.policy-nav a {
  color: inherit;
  text-decoration: none;
}

.policy-card {
  border-radius: 8px;
  padding: clamp(20px, 4vw, 38px);
  background: rgba(19, 22, 32, 0.78);
  border: 1px solid var(--line);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.22);
}

.policy-card h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.policy-card h2 {
  margin: 32px 0 10px;
  font-size: 1.08rem;
}

.policy-card p,
.policy-card li {
  color: var(--muted);
  line-height: 1.65;
}

.policy-card ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.policy-card strong {
  color: var(--text);
}

.policy-meta {
  margin: 0 0 24px;
  color: var(--muted);
}

.policy-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 30px;
}

.policy-action {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #03120f;
  font-weight: 850;
  text-decoration: none;
}

.policy-action.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
}

:root[data-theme="light"] .policy-card {
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 20px 70px rgba(16, 24, 40, 0.12);
}

:root[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.9);
  border-bottom-color: rgba(16, 24, 40, 0.1);
}

:root[data-theme="light"] .brand-mark {
  background: #ffffff;
  border-color: var(--line);
  box-shadow: 0 12px 32px rgba(0, 143, 120, 0.16);
}

:root[data-theme="light"] .stage-toolbar,
:root[data-theme="light"] .control-panel,
:root[data-theme="light"] .canvas-frame,
:root[data-theme="light"] .leaderboard-panel {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(16, 24, 40, 0.1);
  box-shadow: 0 22px 60px rgba(16, 24, 40, 0.12);
}

:root[data-theme="light"] .platform-chip,
:root[data-theme="light"] .top-stats span,
:root[data-theme="light"] .preference-toggle,
:root[data-theme="light"] .icon-button,
:root[data-theme="light"] .asset-panel,
:root[data-theme="light"] .owned-item,
:root[data-theme="light"] .leaderboard-empty,
:root[data-theme="light"] .leaderboard-item,
:root[data-theme="light"] .secondary-action {
  background: rgba(16, 24, 40, 0.045);
  border-color: rgba(16, 24, 40, 0.1);
}

:root[data-theme="light"] input[type="text"],
:root[data-theme="light"] input[type="url"] {
  background: #ffffff;
  border-color: rgba(16, 24, 40, 0.16);
}

:root[data-theme="light"] input[readonly] {
  color: rgba(16, 24, 40, 0.72);
  background: rgba(0, 143, 120, 0.08);
}

:root[data-theme="light"] .file-drop {
  background: rgba(16, 24, 40, 0.04);
  border-color: rgba(16, 24, 40, 0.18);
}

:root[data-theme="light"] .buy-summary,
:root[data-theme="light"] .auth-panel {
  background: rgba(0, 143, 120, 0.08);
  border-color: rgba(0, 143, 120, 0.2);
}

:root[data-theme="light"] .pixel-board,
:root[data-theme="light"] .pixel-board.show-pixel-grid {
  background-color: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(16, 24, 40, 0.14);
}

:root[data-theme="light"] .pixel-board.show-pixel-grid {
  background-image:
    linear-gradient(90deg, rgba(16, 24, 40, 0.14) 1px, transparent 1px),
    linear-gradient(0deg, rgba(16, 24, 40, 0.14) 1px, transparent 1px);
}

:root[data-theme="light"] .selection-rect {
  color: #ffffff;
}

:root[data-theme="light"] .legal-band {
  background: rgba(255, 255, 255, 0.58);
  border-color: rgba(16, 24, 40, 0.1);
}

:root[data-theme="light"] .site-footer p {
  border-top-color: rgba(16, 24, 40, 0.1);
}

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

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

  .leaderboard-panel,
  .control-panel {
    position: static;
    max-height: none;
    overflow-y: visible;
  }

  .leaderboard-panel {
    order: -1;
  }

  .control-panel {
    display: grid;
    grid-template-columns: minmax(220px, 0.7fr) minmax(280px, 1fr);
    align-items: start;
  }

  .panel-tabs,
  .preview-tile,
  .owned-strip {
    grid-column: 1;
  }

  .purchase-form {
    grid-column: 2;
    grid-row: 1 / span 4;
  }
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .platform-strip,
  .view-controls,
  .top-stats {
    justify-content: flex-start;
  }

  .stage-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .selection-meter,
  .zoom-control {
    max-width: none;
    width: 100%;
  }

  .control-panel {
    display: flex;
  }

  .segmented {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 10px;
  }

  .platform-strip {
    display: none;
  }

  .top-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .view-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .pixel-board {
    width: calc(1000px * var(--cell-scale));
  }

  .style-grid,
  .segmented,
  .auth-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .template-actions {
    grid-template-columns: 1fr;
  }

  .legal-grid {
    grid-template-columns: 1fr;
  }
}
