/* Layout: one screen. A paper strip across the top, the board lying on a
   cutting mat with rulers, a tool tray on the mat, a paper sheet of info on
   the right. Yellow is kept for the one action that matters: placing pixels.
   To restyle the site, change the colours in the three blocks below. */
:root {
  --paper: #f6f8f5;
  --paper-2: #e7ede7;
  --ink: #12211b;
  --ink-2: #47594f;
  --edge: #12211b;
  --btn-edge: #12211b;
  --line-soft: #b9c5bd;
  --mat: #2f6f5b;
  --mat-line: rgba(255, 255, 255, 0.09);
  --mat-line-strong: rgba(255, 255, 255, 0.2);
  --mat-ink: #eaf4ee;
  --ruler: #24594a;
  --mat-shadow: rgba(8, 28, 21, 0.38);
  --accent: #ffd635;
  --on-accent: #12211b;
  --danger: #b3002f;
  --danger-fill: #b3002f;
  --on-danger: #ffffff;
  --ok: #00754f;
  --focus: #2450a4;
  --hard-shadow: #12211b;
  --swatch-edge: rgba(18, 33, 27, 0.4);
  --backdrop: rgba(18, 33, 27, 0.55);
  --logo-edge: transparent;
  --font-ui: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", "Noto Sans", system-ui, sans-serif;
  --font-code: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17241f;
    --paper-2: #22342c;
    --ink: #e8f1ec;
    --ink-2: #a3b5ab;
    --edge: #050d0a;
    --btn-edge: #7c9188;
    --line-soft: #3d5047;
    --mat: #0e1f19;
    --mat-line: rgba(255, 255, 255, 0.05);
    --mat-line-strong: rgba(255, 255, 255, 0.11);
    --mat-ink: #c9d8cf;
    --ruler: #0a1712;
    --mat-shadow: rgba(0, 0, 0, 0.55);
    --accent: #ffd635;
    --on-accent: #12211b;
    --danger: #ff6b85;
    --danger-fill: #8e0a2c;
    --on-danger: #ffffff;
    --ok: #58d6a0;
    --focus: #94b3ff;
    --hard-shadow: #000000;
    --swatch-edge: rgba(255, 255, 255, 0.32);
    --backdrop: rgba(0, 0, 0, 0.62);
    --logo-edge: #e8f1ec;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #17241f;
  --paper-2: #22342c;
  --ink: #e8f1ec;
  --ink-2: #a3b5ab;
  --edge: #050d0a;
  --btn-edge: #7c9188;
  --line-soft: #3d5047;
  --mat: #0e1f19;
  --mat-line: rgba(255, 255, 255, 0.05);
  --mat-line-strong: rgba(255, 255, 255, 0.11);
  --mat-ink: #c9d8cf;
  --ruler: #0a1712;
  --mat-shadow: rgba(0, 0, 0, 0.55);
  --accent: #ffd635;
  --on-accent: #12211b;
  --danger: #ff6b85;
  --danger-fill: #8e0a2c;
  --on-danger: #ffffff;
  --ok: #58d6a0;
  --focus: #94b3ff;
  --hard-shadow: #000000;
  --swatch-edge: rgba(255, 255, 255, 0.32);
  --backdrop: rgba(0, 0, 0, 0.62);
  --logo-edge: #e8f1ec;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  height: 100%;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.45 var(--font-ui);
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
code { font-family: var(--font-code); font-size: 12px; }
h2 { margin: 0 0 8px; font-size: 15px; line-height: 1.3; text-wrap: balance; }
p { margin: 0 0 8px; }
.quiet { color: var(--ink-2); font-size: 13px; }

/* ---------- frame ---------- */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  grid-template-areas: "bar bar" "cabar cabar" "notice notice" "stage panel";
}

.bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 8px 16px;
  background: var(--paper);
  border-bottom: 2px solid var(--edge);
}
/* The site's name. It is drawn at this height when there is room, and shrinks
   to fit when the name is long or the screen is narrow. */
.brand { display: flex; align-items: center; flex: 0 1 auto; min-width: 0; height: 28px; margin: 0; overflow: hidden; font-size: 18px; line-height: 1; white-space: nowrap; }
.brand svg { display: block; flex: 0 1 auto; min-width: 0; max-width: 100%; height: 100%; width: auto; }
/* The logo (public/logo.png). In the dark theme it gets a thin light edge,
   like a sticker, so a dark outline does not sink into the dark strip. */
.logo {
  flex: none;
  height: 36px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  filter: drop-shadow(1px 0 0 var(--logo-edge)) drop-shadow(-1px 0 0 var(--logo-edge)) drop-shadow(0 1px 0 var(--logo-edge)) drop-shadow(0 -1px 0 var(--logo-edge));
}
.ticker {
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
/* The "CA:" strip under the name: the token's contract address, one click to copy. */
.cabar {
  grid-area: cabar;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 34px;
  padding: 4px 16px;
  background: var(--paper-2);
  border-bottom: 2px solid var(--edge);
  font-size: 13px;
}
.cabar-label { font-weight: 700; letter-spacing: 0.04em; }
.cabar-soon { color: var(--ink-2); }
.cabar-copy {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 3px 8px;
  border: 1.5px dashed var(--line-soft);
  border-radius: 3px;
  background: var(--paper);
  cursor: pointer;
}
.cabar-copy:hover { border-color: var(--ink); }
.cabar-copy code { font-size: 13px; }
.ca-full { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ca-short { display: none; }
.ca-copy { font-size: 12px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.links { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.links a { color: var(--ink); font-weight: 600; text-underline-offset: 3px; white-space: nowrap; }
.wallet { position: relative; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  display: grid;
  min-width: 170px;
  padding: 4px;
  background: var(--paper);
  border: 2px solid var(--btn-edge);
  border-radius: 4px;
  box-shadow: 4px 4px 0 var(--hard-shadow);
}
.menu button { padding: 8px 10px; border: 0; border-radius: 3px; background: transparent; text-align: left; cursor: pointer; }
.menu button:hover { background: var(--paper-2); }

.btn {
  padding: 8px 14px;
  border: 2px solid var(--btn-edge);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--hard-shadow);
  transition: transform 0.06s, box-shadow 0.06s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--hard-shadow); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--hard-shadow); }
.btn-accent { background: var(--accent); color: var(--on-accent); border-color: var(--edge); }
.btn-danger { background: var(--danger-fill); color: var(--on-danger); border-color: var(--edge); }
.btn-quiet, .btn-quiet:hover, .btn-quiet:active { border-width: 1.5px; font-weight: 600; box-shadow: none; transform: none; }
.btn-quiet:hover { background: var(--paper-2); }
.btn:disabled, .btn:disabled:hover { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
a.btn { display: inline-block; text-decoration: none; }

.notice {
  grid-area: notice;
  padding: 7px 16px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  font-size: 13px;
}
.notice-warn { background: var(--danger-fill); color: var(--on-danger); }

/* ---------- the mat ---------- */
.stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--mat); }
#board { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
#board:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.status {
  position: absolute;
  left: 28px;
  top: 28px;
  display: flex;
  gap: 12px;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--ruler);
  color: var(--mat-ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.status span:empty { display: none; }
.zoomer { position: absolute; right: 12px; top: 28px; display: flex; gap: 4px; }
.zoomer button {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1.5px solid var(--btn-edge);
  border-radius: 3px;
  background: var(--paper);
  font-weight: 700;
  cursor: pointer;
}
.zoomer button:hover { background: var(--paper-2); }

.tray {
  position: absolute;
  left: 30px;
  top: 66px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 138px;
  max-height: calc(100% - 80px);
  overflow-y: auto;
  padding: 8px;
  background: var(--paper);
  border: 2px solid var(--edge);
  border-radius: 6px;
  box-shadow: 5px 5px 0 var(--mat-shadow);
}
.tools { display: grid; grid-template-columns: 1fr; gap: 4px; }
.tools button {
  padding: 6px 9px;
  border: 1.5px solid var(--line-soft);
  border-radius: 3px;
  background: var(--paper-2);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.tools button[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.swatches { display: grid; grid-template-columns: repeat(4, 25px); gap: 5px; justify-content: center; padding: 2px 0 4px; }
.swatch { width: 25px; height: 25px; padding: 0; border: 1.5px solid var(--swatch-edge); border-radius: 2px; cursor: pointer; }
.swatch[aria-checked="true"] { outline: 2.5px solid var(--ink); outline-offset: 1.5px; border-color: var(--paper); }
.commit { display: flex; flex-direction: column; gap: 10px; }
.draft { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.4; }
.commit-row { display: flex; gap: 8px; }
.commit-row #place { flex: 1; }
.sheet-toggle, .sheet-close { display: none; }

.inspect {
  position: absolute;
  z-index: 5;
  width: 250px;
  padding: 10px 12px;
  background: var(--paper);
  border: 2px solid var(--edge);
  border-radius: 4px;
  box-shadow: 4px 4px 0 var(--mat-shadow);
}
.inspect p { margin: 0 0 6px; }
.inspect .row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dot { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border: 1.5px solid var(--swatch-edge); border-radius: 2px; vertical-align: -1px; }

/* ---------- the info sheet ---------- */
.panel { grid-area: panel; min-height: 0; overflow-y: auto; background: var(--paper); border-left: 2px solid var(--edge); }
.box { padding: 16px; border-bottom: 1.5px dashed var(--line-soft); }
.box:last-child { border-bottom: 0; }
.box:empty { display: none; }
#token-box { display: none; }
.bank { display: flex; align-items: flex-end; gap: 10px; margin: 2px 0 10px; }
.bank svg { height: 49px; width: auto; display: block; }
.bank-label { padding-bottom: 2px; font-weight: 600; line-height: 1.2; }
.meter { height: 12px; margin-bottom: 4px; border: 1.5px solid var(--btn-edge); border-radius: 2px; background: var(--paper-2); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--accent); border-right: 1.5px solid var(--btn-edge); }
.meter-fill.empty { border-right: 0; }
.facts { margin: 10px 0 0; padding: 0; list-style: none; }
.facts li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.facts li span:first-child { color: var(--ink-2); }
.facts li span:last-child { font-weight: 600; text-align: right; }
.warn { color: var(--danger); font-weight: 600; }
.stack { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.leaders { margin: 0; padding: 0; list-style: none; counter-reset: rank; }
.leaders li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 6px; align-items: baseline; padding: 3px 0; counter-increment: rank; font-variant-numeric: tabular-nums; }
.leaders li::before { content: counter(rank); color: var(--ink-2); font-size: 12px; }
.leaders li.mine { font-weight: 700; }
.leaders .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaders .empty { display: block; color: var(--ink-2); }
.leaders .empty::before { content: none; }

.rules { margin: 0; }
.rules dt { font-weight: 700; }
.rules dd { margin: 0 0 10px; color: var(--ink-2); }
.rules dd:last-child { margin-bottom: 0; }

.banlist { margin: 8px 0 0; padding: 0; list-style: none; }
.banlist li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; }
.link { padding: 0; border: 0; background: none; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- dialog and toasts ---------- */
.dialog {
  width: min(380px, calc(100% - 32px));
  padding: 18px;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--edge);
  border-radius: 6px;
  box-shadow: 6px 6px 0 var(--hard-shadow);
}
.dialog::backdrop { background: var(--backdrop); }
.dialog h2 { font-size: 18px; margin-bottom: 12px; }
.options { display: grid; gap: 8px; margin-bottom: 12px; }
.option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--btn-edge);
  border-radius: 4px;
  background: var(--paper);
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
}
.option:hover { background: var(--paper-2); }
.option img { width: 26px; height: 26px; border-radius: 5px; }
.option small { display: block; color: var(--ink-2); font-weight: 400; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast { max-width: min(340px, calc(100vw - 32px)); padding: 9px 12px; border-radius: 4px; background: var(--ink); color: var(--paper); font-weight: 600; }
.toast-warn { background: var(--danger-fill); color: var(--on-danger); }
.noscript { padding: 16px; }

/* ---------- small screens: the sheet slides up from the bottom ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "cabar" "notice" "stage"; }
  .bar { gap: 8px; }
  .bar .links { display: none; }
  .bar .wallet { margin-left: auto; }
  .brand { height: 21px; }
  .logo { height: 30px; }
  #token-box:not([hidden]) { display: block; }
  #token-box .links { flex-wrap: wrap; margin: 10px 0 0; }
  .panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    max-height: 80%;
    border-left: 0;
    border-top: 2px solid var(--edge);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(105%);
    transition: transform 0.2s;
    visibility: hidden;
  }
  .panel.open { transform: none; visibility: visible; }
  .sheet-toggle { display: inline-block; }
  .sheet-close { display: block; margin: 10px 16px 0 auto; }
  .tray { left: 8px; right: 8px; top: auto; bottom: 8px; flex-direction: row; flex-wrap: wrap; gap: 8px; width: auto; max-height: none; overflow: visible; }
  .tools { grid-template-columns: repeat(4, 1fr); width: 100%; }
  .tools button { padding: 6px 4px; text-align: center; }
  .swatches { display: flex; justify-content: flex-start; gap: 5px; width: 100%; padding: 4px 3px 6px; overflow-x: auto; }
  .swatch { flex: 0 0 30px; width: 30px; height: 30px; }
  .commit { flex-direction: row; align-items: center; width: 100%; }
  .draft { flex: 1; min-width: 0; font-size: 12px; }
  .commit-row #place { flex: none; }
  .status { left: 26px; top: 26px; }
  .zoomer { top: 26px; right: 8px; }
  .toasts { left: 16px; right: 16px; bottom: auto; top: 100px; align-items: stretch; }
  .toast { max-width: none; }
}
@media (max-width: 620px) {
  /* no room for the whole address: show its two ends, the Copy button still copies all of it */
  .ca-full { display: none; }
  .ca-short { display: inline; }
}
@media (max-width: 480px) {
  .bar { padding: 8px 12px; }
  .cabar { padding: 4px 12px; }
  .bar .ticker { display: none; }
  .brand { height: 20px; }
  .logo { height: 28px; }
  .bar .btn { padding: 7px 10px; }
}
@media (max-width: 350px) {
  /* the narrowest phones: keep logo, name and wallet button on one line */
  .bar { gap: 6px; }
  .brand { height: 18px; }
  .logo { height: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .panel { transition: none; }
}
