/* Redstring app — noir detective office. Warm lamp on dark wood, typewriter
   accents, film grain. The 3D canvas is the star; chrome stays out of its way. */

:root {
  --bg: #17120d;
  --panel: #221a12;
  --panel-2: #2b2115;
  --ink: #e8ddc8;
  --ink-dim: #a8987e;
  --ink-faint: #6e6250;
  --red: #c22a2a;
  --red-deep: #8c2020;
  --gold: #d8a03c;
  --seam: rgba(232, 221, 200, 0.12);
  --type: "Special Elite", "Courier New", monospace;
  --ui: "Alegreya Sans", -apple-system, sans-serif;
  --hand: "Caveat", cursive;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--ui); font-size: 14px;
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Loading ── */
#loading {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  font-family: var(--type); color: var(--ink-dim); letter-spacing: .1em;
  transition: opacity .5s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
.load-mark { color: var(--red); font-size: 28px; animation: pulse 1.2s ease infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 14px; flex-shrink: 0;
  background: linear-gradient(#241b11, #1d1610);
  border-bottom: 1px solid var(--seam);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.brand-pin {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e05545, var(--red-deep));
  box-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.brand-name { font-family: var(--type); font-size: 19px; letter-spacing: .02em; }
.board-name {
  background: transparent; border: 1px dashed transparent; border-radius: 6px;
  color: var(--gold); font-family: var(--hand); font-size: 20px;
  padding: 3px 8px; width: 210px; outline: none;
}
.board-name:hover, .board-name:focus { border-color: var(--seam); background: rgba(0,0,0,.18); }

.tools { display: flex; align-items: center; gap: 5px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tools::-webkit-scrollbar { display: none; }
.tool {
  font-family: var(--type); font-size: 12.5px; white-space: nowrap;
  color: var(--ink-dim); background: var(--panel); border: 1px solid var(--seam);
  border-radius: 7px; padding: 7px 10px; cursor: pointer;
}
.tool:hover:not(:disabled) { color: var(--ink); border-color: var(--ink-faint); background: var(--panel-2); }
.tool:disabled { opacity: .35; cursor: default; }
.tool.connect.active { color: #fff; background: var(--red-deep); border-color: var(--red); }
select.tool { appearance: none; }
.tool-sep { width: 1px; height: 22px; background: var(--seam); margin: 0 4px; flex-shrink: 0; }

.btn-pro {
  font-family: var(--type); font-size: 13px; color: #1b1104;
  background: linear-gradient(#e7b654, #c8922e); border: 0; border-radius: 8px;
  padding: 8px 14px; cursor: pointer; white-space: nowrap;
}
.btn-pro:hover { filter: brightness(1.08); }
.pro-badge {
  font-family: var(--type); font-size: 11px; letter-spacing: .18em; color: var(--gold);
  border: 1px solid var(--gold); border-radius: 6px; padding: 4px 8px;
}

/* ── Stage ── */
.stage-wrap { position: relative; flex: 1; }
#stage {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none;   /* we own all gestures — without this, mobile drags scroll the page */
}
.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 46% 42%, transparent 52%, rgba(8,5,2,.55) 100%);
}
.grain { position: absolute; inset: 0; pointer-events: none; opacity: .05; }
.grain::after {
  content: ""; position: absolute; inset: -100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.7'/%3E%3C/svg%3E");
  animation: grain-shift 0.9s steps(4) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); } 25% { transform: translate(-2%, 3%); }
  50% { transform: translate(3%, -2%); } 75% { transform: translate(-3%, -3%); } 100% { transform: translate(0, 0); }
}
.hint {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  font-family: var(--type); font-size: 13px; color: var(--gold);
  text-shadow: 0 1px 6px rgba(0,0,0,.8); pointer-events: none;
}

/* ── Modals ── */
.modal {
  border: 1px solid var(--seam); border-radius: 12px; padding: 0;
  background: var(--panel); color: var(--ink);
  width: min(520px, calc(100vw - 32px));
  box-shadow: 0 40px 120px rgba(0,0,0,.7);
}
.modal::backdrop { background: rgba(6,4,2,.62); backdrop-filter: blur(2px); }
.modal-body { padding: 26px 24px; position: relative; }
.modal-close {
  position: absolute; top: 12px; right: 12px; background: none; border: 0;
  color: var(--ink-faint); font-size: 15px; cursor: pointer;
}
.modal-close:hover { color: var(--ink); }
.modal-title { font-family: var(--type); font-weight: 400; font-size: 21px; margin: 0 0 16px; color: var(--gold); }
.help-list { margin: 0; padding-left: 18px; line-height: 1.9; color: var(--ink-dim); font-size: 14.5px; }
.help-list b { color: var(--ink); }
.help-list kbd {
  font-family: var(--type); font-size: 11px; background: var(--panel-2);
  border: 1px solid var(--seam); border-radius: 4px; padding: 1px 5px;
}
.help-foot { margin: 16px 0 0; font-size: 13px; color: var(--ink-faint); font-style: italic; }

.edit-text {
  width: 100%; background: #efe8d4; color: #26221a; border: 0; border-radius: 8px;
  font-family: var(--hand); font-size: 21px; padding: 12px; resize: vertical; outline: none;
}
.edit-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

.btn {
  font-family: var(--ui); font-weight: 600; font-size: 13.5px; cursor: pointer;
  border-radius: 8px; padding: 9px 15px; border: 1px solid var(--seam);
  background: var(--panel-2); color: var(--ink);
}
.btn:hover { border-color: var(--ink-faint); }
.btn.primary { background: var(--red-deep); border-color: var(--red); color: #fff; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }

/* Pro modal internals */
.pro-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.pro-mark { color: var(--red); font-size: 30px; }
.pro-title { font-family: var(--type); font-weight: 400; font-size: 24px; margin: 0; color: var(--ink); }
.pro-sub { font-size: 12.5px; color: var(--ink-faint); }
.pro-perks { list-style: none; margin: 0 0 14px; padding: 0; font-size: 14px; line-height: 2; color: var(--ink-dim); }
.pro-perks li::before { content: "◉ "; color: var(--red); }
.pro-divider {
  display: flex; align-items: center; gap: 12px; margin: 14px 0 10px;
  font-family: var(--type); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-faint);
}
.pro-divider::before, .pro-divider::after { content: ""; flex: 1; height: 1px; background: var(--seam); }
.pay-step { font-size: 13px; color: var(--ink-dim); margin: 0 0 8px; }
.pay-step strong { color: var(--gold); }
.pay-addr { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.pay-addr code {
  flex: 1; font-family: var(--type); font-size: 10.5px; word-break: break-all;
  background: var(--panel-2); border: 1px solid var(--seam); border-radius: 8px; padding: 8px 10px; user-select: all;
}
.wallet-link { margin-bottom: 10px; font-size: 13px; }
.wallet-link a { color: var(--gold); }
.pay-row { display: flex; gap: 8px; margin-bottom: 8px; }
.text-input {
  flex: 1; background: var(--panel-2); color: var(--ink); border: 1px solid var(--seam);
  border-radius: 8px; padding: 9px 10px; font-family: var(--ui); font-size: 13px; outline: none;
}
.text-input:focus { border-color: var(--gold); }
.pay-msg { min-height: 16px; margin: 8px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.pay-msg.ok { color: #7cc98a; } .pay-msg.err { color: #e07a6a; }
.card-links { display: flex; gap: 8px; }
.pay-foot { margin: 12px 0 0; font-size: 12px; color: var(--ink-faint); font-style: italic; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 12px);
  font-family: var(--type); font-size: 13.5px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--seam);
  border-radius: 9px; padding: 10px 18px; z-index: 80;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  box-shadow: 0 14px 40px rgba(0,0,0,.6);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.accent { border-color: var(--gold); color: var(--gold); }

@media (max-width: 900px) {
  .board-name { width: 130px; }
  .tool { padding: 7px 8px; font-size: 11.5px; }
}
