:root {
  color-scheme: dark;
  --bg: #080b12;
  --panel: #111725;
  --panel-soft: #171f30;
  --ink: #f4f7ff;
  --muted: #9aa7bd;
  --line: #2b354a;
  --accent: #79f2c0;
  --accent-dark: #071c15;
  --danger: #ff8a8a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at 15% 0%, #182035 0, var(--bg) 38rem);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}
button, input { font: inherit; }
button {
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: var(--panel-soft);
  color: var(--ink);
  padding: .65rem .85rem;
  cursor: pointer;
}
button:hover, button.active { border-color: var(--accent); color: var(--accent); }
button:focus-visible, input:focus-visible, .board-viewport:focus-visible {
  outline: 3px solid rgba(121, 242, 192, .45);
  outline-offset: 2px;
}
button:disabled { cursor: not-allowed; opacity: .45; }
.primary {
  width: 100%;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-dark);
  font-weight: 750;
}
.site-header, footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  max-width: 94rem;
  margin: auto;
  padding: 1.25rem 2rem;
}
.brand { color: var(--ink); font-size: 1.2rem; font-weight: 850; text-decoration: none; }
.site-header p, footer { color: var(--muted); }
.site-header a, footer a, .policy-page a { color: var(--accent); }
footer { align-items: flex-start; }
footer nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem 1rem; }
.policy-page {
  width: min(48rem, calc(100% - 2rem));
  margin: 2rem auto 5rem;
  padding: clamp(1.25rem, 4vw, 3rem);
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
}
.policy-page h2 { margin-top: 2rem; }
.policy-page p { color: var(--muted); line-height: 1.7; }
.policy-warning {
  margin: 1.5rem 0;
  padding: 1rem;
  border: 1px solid #9b7626;
  border-radius: .65rem;
  background: #2a220f;
  color: #ffe29b;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 24rem);
  gap: 1.25rem;
  max-width: 94rem;
  margin: auto;
  padding: 1rem 2rem 2rem;
}
.board-panel, .purchase-panel {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(17, 23, 37, .92);
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, .28);
}
.board-panel { min-width: 0; padding: 1rem; }
.purchase-panel { align-self: start; padding: 1.25rem; position: sticky; top: 1rem; }
.board-heading-row { display: flex; justify-content: space-between; gap: 1rem; align-items: end; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.6rem, 3vw, 2.8rem); }
.eyebrow { color: var(--accent); letter-spacing: .14em; text-transform: uppercase; font-size: .72rem; font-weight: 800; margin-bottom: .35rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; justify-content: end; }
#zoom-value { min-width: 3.5rem; text-align: center; color: var(--muted); }
.board-help, .status-line { color: var(--muted); margin: .8rem 0; }
.board-viewport {
  width: 100%;
  height: min(72vh, 64rem);
  overflow: auto;
  scrollbar-gutter: stable both-edges;
  border: 1px solid var(--line);
  border-radius: .6rem;
  background: #fff;
  overscroll-behavior: contain;
}
#pixel-board {
  display: block;
  width: 1000px;
  height: 1000px;
  image-rendering: pixelated;
  touch-action: none;
  cursor: crosshair;
}
.selection-summary { margin: 1rem 0; }
.selection-summary div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .65rem 0;
  border-bottom: 1px solid var(--line);
}
dt { color: var(--muted); }
dd { margin: 0; font-weight: 700; text-align: right; }
label { display: grid; gap: .4rem; color: var(--muted); margin: .9rem 0; }
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: .55rem;
  background: var(--bg);
  color: var(--ink);
  padding: .75rem;
}
.form-message { min-height: 1.4rem; margin: .8rem 0; color: var(--muted); overflow-wrap: anywhere; }
.form-message.error { color: var(--danger); }
.wallet-guide {
  margin: .8rem 0 1rem;
  padding: .85rem;
  border: 1px solid #9b7626;
  border-radius: .65rem;
  background: #2a220f;
  color: #ffe29b;
  line-height: 1.45;
}
.wallet-guide a {
  display: block;
  margin-top: .55rem;
  color: var(--accent);
  font-weight: 750;
}
.phantom-qr {
  display: block;
  width: min(15rem, 100%);
  margin: .8rem auto;
  padding: .5rem;
  border-radius: .5rem;
  background: #fff;
}
.buy-action {
  margin-top: .8rem;
}
.buy-action .primary {
  max-width: 28rem;
}
.hidden { display: none; }
#advertisement-form, #preview-section { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }
#ad-preview { display: block; max-width: 100%; max-height: 18rem; margin: .8rem auto; border: 1px solid var(--line); image-rendering: pixelated; }

@media (max-width: 850px) {
  .site-header { align-items: flex-start; flex-direction: column; }
  .layout { grid-template-columns: 1fr; padding: .5rem 1rem 2rem; }
  .purchase-panel { position: static; }
  .board-heading-row { align-items: flex-start; flex-direction: column; }
  .toolbar { justify-content: start; }
  .board-viewport { height: 58vh; }
  .buy-action:not(.hidden) {
    position: fixed;
    z-index: 30;
    left: 1rem;
    right: 1rem;
    bottom: max(1rem, env(safe-area-inset-bottom));
    padding: .7rem;
    border: 1px solid var(--line);
    border-radius: .85rem;
    background: var(--panel);
    box-shadow: 0 .8rem 2.5rem rgba(0,0,0,.45);
  }
  .buy-action .primary { max-width: none; }
  .buy-action .form-message { margin-bottom: 0; }
  .purchase-panel {
    position: static;
  }
}
