/* 1dollarto1million.com
   Layout: the wall is the page. A slim banknote-style header with the live total,
   the wall filling the main column, and a side panel that becomes the checkout slip. */
:root {
  --paper: #e9ece3;
  --sheet: #f6f7f2;
  --ink: #173326;
  --ink-soft: #4f6658;
  --rule: #c9d2c4;
  --accent: #b8322a;
  --empty: #f1efe7;
  --grid: rgba(23, 51, 38, 0.07);
  --ok: #1e7a4f;
  --f-display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --f-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "Space Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0c1511; --sheet: #121e18; --ink: #dbe7d7; --ink-soft: #95ad9d; --rule: #2a3f31;
    --accent: #ef6a5c; --empty: #1a2a21; --grid: rgba(219, 231, 215, 0.06); --ok: #6fd3a0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font-family: var(--f-body); font-size: 15px; line-height: 1.5;
  padding-inline: 16px; padding-block: 0 32px;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.label { font-family: var(--f-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }

/* ---------- header ---------- */
.top {
  max-width: 1400px; margin: 0 auto; padding-block: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; }
.brand b {
  font-family: var(--f-display); font-weight: 900; font-size: 30px; line-height: 1;
  text-transform: uppercase; letter-spacing: .01em;
}
.brand b em { font-style: normal; color: var(--accent); }
.tally { display: flex; gap: 22px; align-items: baseline; flex-wrap: wrap; }
.tally div { display: grid; gap: 2px; }
.tally small { font-family: var(--f-mono); font-size: 13px; color: var(--ink-soft); font-weight: 400; }
.tally strong { font-family: var(--f-display); font-weight: 800; font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-soft); }
.live-dot.on::before { background: var(--accent); animation: pulse 1.8s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- main layout ---------- */
.main {
  max-width: 1400px; margin: 16px auto 0;
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start;
}
@media (max-width: 960px) { .main { grid-template-columns: 1fr; } }

/* ---------- wall ---------- */
.stage { min-width: 0; display: grid; gap: 10px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.seg button { background: var(--sheet); border: 0; padding: 7px 12px; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.coords { font-family: var(--f-mono); font-size: 12px; color: var(--ink-soft); min-width: 9ch; text-align: right; }

.viewport {
  position: relative; overflow: hidden; touch-action: none; user-select: none;
  aspect-ratio: 1 / 1; width: min(100%, calc(100vh - 170px)); min-width: min(100%, 320px); margin-inline: auto;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 4px;
  cursor: crosshair;
}
.viewport.move { cursor: grab; }
.viewport.grabbing { cursor: grabbing; }
@media (max-width: 960px) { .viewport { width: 100%; } }
.layer {
  position: absolute; left: 0; top: 0; width: 1000px; height: 1000px; transform-origin: 0 0;
  background-color: var(--empty);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 100px 100px;
  box-shadow: 0 0 0 1px var(--rule);
}
.layer canvas { position: absolute; inset: 0; width: 1000px; height: 1000px; image-rendering: pixelated; }
.sel {
  position: absolute; outline: 2px solid var(--accent); outline-offset: 1px; pointer-events: none;
}
.flash { position: absolute; pointer-events: none; outline: 2px solid var(--accent); animation: flash 1.6s ease-out forwards; }
@keyframes flash { from { outline-offset: 6px; opacity: 1; } to { outline-offset: 0; opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; opacity: 0; } .live-dot.on::before { animation: none; } }
.tip {
  position: absolute; z-index: 3; pointer-events: none; max-width: 280px;
  background: var(--ink); color: var(--paper); padding: 8px 10px; border-radius: 4px; font-size: 13px; line-height: 1.35;
}
.tip .mono { opacity: .85; font-size: 12px; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-soft); }

/* ---------- side panel ---------- */
.side { display: grid; gap: 16px; min-width: 0; }
@media (min-width: 961px) { .side { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; } }
.card { background: var(--sheet); border: 1px solid var(--rule); border-radius: 4px; padding: 16px; display: grid; gap: 12px; min-width: 0; }
.card h2 { margin: 0; font-family: var(--f-display); font-weight: 800; font-size: 28px; line-height: 1; text-transform: uppercase; }
.card p { margin: 0; }
.how { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.how li { display: grid; grid-template-columns: 54px 1fr; gap: 8px; align-items: baseline; }
.how b { font-family: var(--f-display); font-weight: 800; font-size: 22px; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 2px solid var(--ink); border-radius: 4px; padding: 11px 16px; cursor: pointer;
  font-weight: 700; text-decoration: none; background: transparent; color: var(--ink);
}
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.paypal { background: #ffc439; border-color: #ffc439; color: #111; }
.btn.kr { background: #0064ff; border-color: #0064ff; color: #fff; }
.linkbtn { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; color: var(--ink-soft); font-size: 13px; }

/* checkout slip */
.slip label { display: grid; gap: 5px; font-weight: 600; font-size: 14px; }
.slip input[type="text"], .slip select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper);
}
.row2 { display: grid; grid-template-columns: 130px 1fr; gap: 8px; }
.tabs { display: flex; border-bottom: 1px solid var(--rule); gap: 4px; }
.tabs button { background: none; border: 0; padding: 6px 10px; cursor: pointer; border-bottom: 2px solid transparent; font-weight: 600; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--accent); }
.palette { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.palette button { aspect-ratio: 1; border-radius: 3px; border: 2px solid transparent; padding: 0; cursor: pointer; }
.palette button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--sheet); }
.custom { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.custom input { width: 44px; height: 30px; padding: 0; border: 1px solid var(--rule); background: none; }
.drop {
  border: 2px dashed var(--rule); border-radius: 4px; padding: 16px; text-align: center; cursor: pointer;
  display: grid; gap: 6px; justify-items: center;
}
.drop.over { border-color: var(--accent); }
.drop canvas { max-width: 100%; image-rendering: pixelated; border: 1px solid var(--rule); }
.quote { display: grid; gap: 4px; font-family: var(--f-mono); font-size: 13px; border-top: 1px dashed var(--rule); padding-top: 10px; }
.quote div { display: flex; justify-content: space-between; gap: 8px; }
.quote .total { font-size: 20px; font-weight: 700; border-top: 1px solid var(--rule); padding-top: 6px; margin-top: 2px; }
.agree { display: flex !important; gap: 8px; align-items: flex-start; font-weight: 400 !important; font-size: 13px !important; }
.agree input { margin-top: 3px; }
.err { color: var(--accent); font-size: 14px; margin: 0; }
.ok { color: var(--ok); }
.pay { display: grid; gap: 8px; }

/* feed */
.feed { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.feed li { border-bottom: 1px solid var(--rule); padding-block: 8px; display: grid; gap: 2px; cursor: pointer; }
.feed li:last-child { border-bottom: 0; }
.feed .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .what { font-family: var(--f-mono); font-size: 12px; color: var(--ink-soft); }
.feed .take { color: var(--accent); }

/* dialog */
dialog { border: 1px solid var(--rule); border-radius: 6px; background: var(--sheet); color: var(--ink); padding: 22px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin: 0 0 8px; font-family: var(--f-display); font-weight: 800; font-size: 34px; text-transform: uppercase; line-height: 1; }
dialog .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* footer + text pages */
.foot {
  max-width: 1400px; margin: 28px auto 0; padding-top: 14px; border-top: 1px solid var(--rule);
  display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; font-size: 13px; color: var(--ink-soft);
}
.foot nav { display: flex; gap: 14px; flex-wrap: wrap; }
.doc { max-width: 720px; margin: 24px auto; display: grid; gap: 14px; }
.doc h1 { font-family: var(--f-display); font-weight: 900; font-size: clamp(40px, 8vw, 64px); text-transform: uppercase; margin: 0; line-height: .95; }
.doc h2 { font-size: 18px; margin: 14px 0 0; }
.doc p, .doc li { color: var(--ink); max-width: 68ch; }
.doc table { border-collapse: collapse; width: 100%; }
.doc td, .doc th { border-bottom: 1px solid var(--rule); padding: 8px 6px; text-align: left; vertical-align: top; }
.tablewrap { overflow-x: auto; }

/* archive + admin */
.archive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.archive-grid a { display: grid; gap: 6px; text-decoration: none; }
.archive-grid img { width: 100%; aspect-ratio: 1; image-rendering: pixelated; border: 1px solid var(--rule); background: var(--empty); }
.doc.admin { max-width: 1200px; }
.doc.admin label { display: grid; gap: 6px; font-weight: 600; }
.doc.admin input { padding: 9px 10px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); }
#orders td { font-size: 13px; }
.adm-img { width: 120px; image-rendering: pixelated; border: 1px solid var(--rule); }

/* stream overlay */
body.overlay { background: transparent; padding: 0; }
.ov { display: grid; grid-template-columns: 720px 380px; gap: 16px; padding: 16px; color: #fff; font-family: var(--f-body); }
.ov canvas { width: 720px; height: 720px; image-rendering: pixelated; background: #f1efe7; border-radius: 6px; }
.ov .panel { background: rgba(12, 21, 17, .82); border-radius: 6px; padding: 16px; display: grid; gap: 10px; align-content: start; }
.ov .big { font-family: var(--f-display); font-weight: 900; font-size: 54px; line-height: 1; }
.ov li { list-style: none; border-bottom: 1px solid rgba(255,255,255,.15); padding-block: 6px; }
.ov ul { margin: 0; padding: 0; }

@media (max-width: 600px) {
  .brand b { font-size: 24px; }
  .tally { gap: 14px; }
  .tally strong { font-size: 22px; }
}
.toolbar, #help { width: min(100%, calc(100vh - 170px)); min-width: min(100%, 320px); margin-inline: auto; }
@media (max-width: 960px) { .toolbar, #help { width: 100%; } }
