/* ===========================================================
   IRAN NFT Metaverse — interface
   -----------------------------------------------------------
   The visual language is the Persian illuminated manuscript:
   burnished paper, the jadval (the ruled frame of gold, lapis
   and red lines around every page), lachak corner pieces, a
   sarlowh headpiece over each title — and buttons glazed like
   the turquoise tile of the square itself.
   =========================================================== */

@font-face {
  font-family: 'Vazirmatn';
  src: url('../vendor/fonts/Vazirmatn-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Marcellus';
  src: url('../vendor/fonts/Marcellus-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
  /* without its digits (its 1 and 0 read as I and O): numbers fall back to Vazirmatn */
  unicode-range: U+0000-002F, U+003A-10FFFF;
}

:root {
  --lapis-950: #070b1f;
  --lapis-900: #0b1230;
  --lapis-800: #121c45;
  --lapis-700: #1b2a63;
  --lapis: #26408f;
  --turq: #2aa6a1;
  --turq-deep: #13706d;
  --turq-light: #7fd6cf;
  --gold: #c9a14a;
  --gold-light: #ecd08a;
  --gold-dark: #8a6a26;
  --ivory: #f6eedb;
  --paper: #eadcb9;
  --paper-2: #e0cfa5;
  --paper-dark: #cdb688;
  --madder: #9b2c2c;
  --ink: #2a1d12;
  --ink-soft: #5b4630;
  --ink-faint: #8a7356;
  --ok: #2f8f6a;
  --bad: #a83a32;
  --q0: #d9cba8;
  --q1: #2aa6a1;
  --q2: #e2b84a;

  --serif: 'Marcellus', 'Vazirmatn', 'Iowan Old Style', Georgia, serif;
  --sans: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --tile: none;            /* set from JS: a data URL of the star-and-cross tile */
  --radius: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--lapis-900);
  color: var(--ivory);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
/* :where() keeps this at zero specificity, so a layer's own
   `pointer-events: none` (the HUD, the travel veil, the cinematic fade) wins
   and the mouse reaches the 3D view beneath them. */
:where(#ui) > * { pointer-events: auto; }
#ui .passthrough { pointer-events: none; }
#ui .passthrough > * { pointer-events: auto; }

.fa {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  direction: rtl;
  unicode-bidi: isolate;
}
.serif { font-family: var(--serif); }
.muted { color: var(--ink-faint); }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- full screens */
.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.screen.show { opacity: 1; }
.screen.vignette {
  background: radial-gradient(ellipse at center, rgba(7, 11, 31, 0.15) 0%, rgba(7, 11, 31, 0.78) 75%, rgba(7, 11, 31, 0.95) 100%);
}

/* Loading: a girih star turning slowly, as if drawn by compass. */
.loading {
  background: var(--lapis-950);
  flex-direction: column;
  text-align: center;
}
.loading .star { width: 92px; height: 92px; animation: spin 9s linear infinite; filter: drop-shadow(0 0 18px rgba(201, 161, 74, 0.35)); }
.loading .title { font-family: var(--serif); letter-spacing: 0.32em; font-size: 13px; color: var(--gold-light); margin-top: 22px; }
.loading .fa { color: var(--ink-faint); margin-top: 6px; font-size: 14px; }
.loading .bar { width: 220px; height: 2px; background: rgba(201, 161, 74, 0.18); margin: 18px auto 0; overflow: hidden; border-radius: 2px; }
.loading .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-dark), var(--gold-light)); transition: width 0.3s; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- the manuscript page */
.ms {
  position: relative;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 30% 0%, rgba(255, 252, 240, 0.55), transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(160, 120, 60, 0.18), transparent 60%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  border-radius: 8px;
  /* The jadval: gold, lapis and madder rules, drawn as inset rings. */
  box-shadow:
    inset 0 0 0 8px var(--paper),
    inset 0 0 0 9.5px var(--gold),
    inset 0 0 0 11px var(--paper),
    inset 0 0 0 12px var(--lapis),
    inset 0 0 0 14px var(--paper-2),
    inset 0 0 0 14.6px var(--madder),
    0 24px 60px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.35);
}
.ms::before {
  /* paper fibre */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .12 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
.ms > * { position: relative; }

/* Lachak: quarter-medallions in the four corners. */
.lachak { position: absolute; width: 46px; height: 46px; pointer-events: none; z-index: 1; }
.lachak.tl { top: 15px; left: 15px; }
.lachak.tr { top: 15px; right: 15px; transform: scaleX(-1); }
.lachak.bl { bottom: 15px; left: 15px; transform: scaleY(-1); }
.lachak.br { bottom: 15px; right: 15px; transform: scale(-1, -1); }

/* Sarlowh: the illuminated headpiece over a title. */
.sarlowh {
  position: relative;
  margin: 0 auto 14px;
  padding: 12px 54px 11px;
  text-align: center;
  color: var(--gold-light);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 40%),
    linear-gradient(180deg, var(--lapis-700), var(--lapis-800));
  border-radius: 4px;
  box-shadow:
    inset 0 0 0 1.5px var(--gold),
    inset 0 0 0 4px var(--lapis-800),
    inset 0 0 0 5px rgba(201, 161, 74, 0.5),
    0 2px 0 rgba(0, 0, 0, 0.2);
}
.sarlowh::before, .sarlowh::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 26px;
  height: 26px;
  margin-top: -13px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-10 -10 20 20'%3E%3Cpath d='M0-9 2.2-5.3 6.4-6.4 5.3-2.2 9 0 5.3 2.2 6.4 6.4 2.2 5.3 0 9-2.2 5.3-6.4 6.4-5.3 2.2-9 0-5.3-2.2-6.4-6.4-2.2-5.3Z' fill='%23c9a14a'/%3E%3Ccircle r='2.6' fill='%232aa6a1'/%3E%3C/svg%3E") center/contain no-repeat;
}
.sarlowh::before { left: 16px; }
.sarlowh::after { right: 16px; }
.sarlowh h2, .sarlowh h1 { margin: 0; font-family: var(--serif); font-weight: 400; letter-spacing: 0.14em; font-size: 17px; text-transform: uppercase; }
.sarlowh .fa { display: block; font-size: 13px; color: var(--turq-light); margin-top: 1px; letter-spacing: 0; }

/* Tile border: a frame filled with the same star-and-cross tile as the world. */
.tileframe {
  padding: 12px;
  border-radius: 12px;
  background: var(--tile) center/96px repeat, var(--lapis-800);
  box-shadow: 0 0 0 2px var(--gold-dark), 0 0 0 4px var(--lapis-950), 0 30px 80px rgba(0, 0, 0, 0.6);
}

/* ---------------------------------------------------------------- buttons */
.btn {
  appearance: none;
  border: 0;
  border-radius: 8px;
  padding: 12px 20px;
  min-height: 46px;
  font-family: var(--serif);
  letter-spacing: 0.08em;
  font-size: 15px;
  line-height: 1.15;
  transition: transform 0.12s ease, filter 0.2s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  position: relative;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { filter: grayscale(0.7) brightness(0.85); cursor: not-allowed; }
.btn .fa { font-size: 13px; opacity: 0.85; letter-spacing: 0; }
.btn small { display: block; font-family: var(--sans); font-size: 11px; letter-spacing: 0.02em; opacity: 0.8; }

/* Glazed turquoise tile */
.btn-tile {
  color: #fffaf0;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  background:
    radial-gradient(ellipse at 50% -20%, rgba(255, 255, 255, 0.55), transparent 55%),
    linear-gradient(180deg, #46c6bd 0%, #1f9a95 48%, #15736f 100%);
  box-shadow:
    inset 0 0 0 1.5px var(--gold),
    inset 0 0 0 3px rgba(11, 63, 60, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 3px 0 #0b3f3c,
    0 10px 22px rgba(0, 0, 0, 0.35);
}
.btn-tile:hover:not(:disabled) { filter: brightness(1.08); box-shadow: inset 0 0 0 1.5px var(--gold-light), inset 0 0 0 3px rgba(11, 63, 60, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 3px 0 #0b3f3c, 0 0 26px rgba(42, 166, 161, 0.45); }

/* Lapis with gold — for the wallet, the most important action */
.btn-lapis {
  color: var(--gold-light);
  background:
    radial-gradient(ellipse at 50% -20%, rgba(255, 255, 255, 0.22), transparent 55%),
    linear-gradient(180deg, var(--lapis) 0%, var(--lapis-700) 55%, var(--lapis-800) 100%);
  box-shadow:
    inset 0 0 0 1.5px var(--gold),
    inset 0 0 0 3.5px var(--lapis-900),
    inset 0 0 0 4.5px rgba(201, 161, 74, 0.45),
    0 3px 0 var(--lapis-950),
    0 10px 22px rgba(0, 0, 0, 0.35);
}
.btn-lapis:hover:not(:disabled) { filter: brightness(1.12); }

/* Paper */
.btn-paper {
  color: var(--ink);
  background: linear-gradient(180deg, #f5ead0, #e3d1a6);
  box-shadow: inset 0 0 0 1px var(--gold-dark), inset 0 1px 0 #fffaf0, 0 2px 0 rgba(90, 60, 20, 0.35);
}
.btn-paper:hover:not(:disabled) { filter: brightness(1.04); }

.btn-ghost {
  color: var(--ink-soft);
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(91, 70, 48, 0.4);
  min-height: 38px;
  padding: 8px 14px;
  font-size: 13px;
}
.btn-ghost:hover { background: rgba(91, 70, 48, 0.08); }

.btn-sm { min-height: 34px; padding: 7px 12px; font-size: 13px; border-radius: 6px; }
.btn-icon { width: 38px; min-height: 38px; padding: 0; }
.btn-wide { width: 100%; }

/* ---------------------------------------------------------------- the gate (title screen) */
.gate-wrap { width: min(440px, 100%); }
.gate-card {
  padding: 34px 34px 26px;
  text-align: center;
}
.gate-card .shamseh { width: 84px; height: 84px; margin: 6px auto 6px; display: block; filter: drop-shadow(0 4px 8px rgba(90, 60, 20, 0.35)); }
.gate-card h1 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: 0.12em;
  font-size: 30px;
  color: var(--lapis-800);
}
.gate-card .title-fa { font-size: 22px; color: var(--madder); margin-top: 2px; font-weight: 600; }
.gate-card .motto {
  margin: 14px auto 18px;
  max-width: 320px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
}
.gate-card .motto .fa { display: block; font-size: 15px; color: var(--ink); margin-bottom: 2px; }
.gate-card .actions { display: grid; gap: 12px; margin-top: 8px; }
.gate-card .fine { margin-top: 16px; font-size: 12px; color: var(--ink-faint); line-height: 1.55; }
.gate-card .err { margin-top: 12px; color: var(--bad); font-size: 13px; min-height: 18px; }
.divider {
  height: 14px;
  margin: 14px auto;
  max-width: 260px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 260 14'%3E%3Cpath d='M0 7H108M152 7H260' stroke='%23c9a14a' stroke-width='1'/%3E%3Cpath d='M130 1 136 7 130 13 124 7Z' fill='%23c9a14a'/%3E%3Ccircle cx='116' cy='7' r='2' fill='%232aa6a1'/%3E%3Ccircle cx='144' cy='7' r='2' fill='%232aa6a1'/%3E%3C/svg%3E") center/contain no-repeat;
}
.welcome-back { display: flex; align-items: center; gap: 12px; text-align: start; padding: 10px 12px; margin: 4px 0 6px; border-radius: 8px; background: rgba(255, 252, 240, 0.45); box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.35); }
.welcome-back img { width: 48px; height: 48px; border-radius: 50%; box-shadow: 0 0 0 2px var(--gold), 0 0 0 4px var(--lapis-800); background: var(--lapis-800); }
.welcome-back b { display: block; font-size: 16px; }
.welcome-back span { font-size: 12px; color: var(--ink-faint); }

.wallets { display: grid; gap: 8px; }
.wallets .btn { justify-content: flex-start; }
.wallets img, .wallets svg { width: 22px; height: 22px; border-radius: 5px; }

/* ---------------------------------------------------------------- character creator */
.creator {
  place-items: center start;
  padding: 24px clamp(16px, 5vw, 64px);
}
.creator-card { width: min(400px, 100%); padding: 30px 28px 24px; }
.creator-card .lede { font-size: 13.5px; color: var(--ink-soft); line-height: 1.6; margin: 0 0 14px; text-align: center; }
.variant-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 14px; }
.variant-nav .count { font-family: var(--serif); letter-spacing: 0.1em; color: var(--ink-soft); }
.variant-dots { display: flex; gap: 6px; justify-content: center; margin-top: 6px; }
.variant-dots i { width: 8px; height: 8px; transform: rotate(45deg); background: var(--paper-dark); box-shadow: inset 0 0 0 1px var(--gold-dark); }
.variant-dots i.on { background: var(--turq); }
.traits { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 6px; }
.traits li { display: grid; grid-template-columns: 80px 1fr; gap: 10px; align-items: baseline; padding: 6px 10px; border-radius: 6px; background: rgba(255, 252, 240, 0.4); }
.traits b { font-family: var(--serif); font-weight: 400; color: var(--ink-faint); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; }
.traits span { font-size: 14px; }
.traits .fa { color: var(--ink-faint); font-size: 12.5px; margin-left: 8px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-inline-end: 6px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-family: var(--serif); letter-spacing: 0.1em; font-size: 12px; color: var(--ink-soft); text-transform: uppercase; }
.field .row { display: flex; gap: 8px; }
.input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border-radius: 7px;
  border: 0;
  background: #fbf5e4;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--gold-dark), inset 0 2px 4px rgba(90, 60, 20, 0.15);
  unicode-bidi: plaintext;
}
.input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--turq), inset 0 2px 4px rgba(90, 60, 20, 0.15); }
.hint { font-size: 12px; color: var(--ink-faint); }
/* the creator's two ways in: the wallet's characters, or one designed by hand */
.creator-card.designing { width: min(460px, 100%); max-height: calc(100dvh - 48px); overflow-y: auto; scrollbar-width: thin; }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 0 0 12px; border-radius: 9px; background: rgba(90, 60, 20, 0.1); box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.35); }
.mode-tabs .tab { border: 0; border-radius: 6px; padding: 8px 6px; background: transparent; color: var(--ink-soft); font: inherit; font-size: 13px; cursor: pointer; }
.mode-tabs .tab.on { background: var(--turq); color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
.mode-tabs .tab:focus-visible { outline: 2px solid var(--lapis); outline-offset: 1px; }
.mode-tabs .tab { display: flex; align-items: center; justify-content: center; gap: 7px; }
.tab-ico { width: 18px; height: 18px; display: inline-flex; flex: none; }
.tab-ico svg { width: 100%; height: 100%; }
.creator-card.designing .gender-row { display: none; }
.design-pane { position: relative; }
.d-tools { position: absolute; top: 0; inset-inline-end: 0; display: flex; gap: 6px; z-index: 1; }
.d-tool { width: 34px; height: 34px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: #fbf5e4; color: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--gold-dark); }
.d-tool span { width: 19px; height: 19px; display: inline-flex; }
.d-tool:hover { color: var(--turq-deep); }
.d-tool:focus-visible { outline: 2px solid var(--lapis); outline-offset: 2px; }
.designer { display: grid; gap: 10px; margin-bottom: 14px; }
/* the categories: a row of pictures, the chosen one lit */
.d-rail { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 42px; }
.d-cat { display: grid; justify-items: center; gap: 3px; padding: 8px 2px 6px; border: 0; border-radius: 9px; cursor: pointer; background: rgba(255, 252, 240, 0.45); color: var(--ink-soft); box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.25); }
.d-cat-ico { width: 26px; height: 26px; display: inline-flex; }
.d-cat-ico svg { width: 100%; height: 100%; }
.d-cat small { font-size: 10.5px; line-height: 1.2; }
.d-cat.on { background: var(--turq); color: #fff; box-shadow: inset 0 0 0 1px var(--turq-deep), 0 2px 6px rgba(19, 112, 109, 0.35); }
.d-cat:focus-visible { outline: 2px solid var(--lapis); outline-offset: 2px; }
.d-pane { display: grid; gap: 12px; padding: 12px; border-radius: 10px; background: rgba(255, 252, 240, 0.42); box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.22); min-height: 150px; align-content: start; }
/* choices shown as pictures of the character wearing them */
.d-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.d-tile { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 10px; cursor: pointer; overflow: hidden; background: radial-gradient(circle at 50% 35%, #fffaf0, #e8dbbb); box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.45); transition: transform 0.12s; }
.d-tile img { width: 100%; height: 100%; display: block; object-fit: cover; }
.d-tile:hover { transform: translateY(-2px); }
.d-tile.on { box-shadow: inset 0 0 0 3px var(--turq), 0 3px 8px rgba(19, 112, 109, 0.3); }
.d-tile.on::after { content: '✓'; position: absolute; top: 4px; inset-inline-end: 4px; width: 18px; height: 18px; border-radius: 50%; background: var(--turq); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.d-tile.loading { background: linear-gradient(100deg, #efe4c8 30%, #fbf5e4 50%, #efe4c8 70%) 0 0 / 200% 100%; animation: d-shimmer 1s linear infinite; }
@keyframes d-shimmer { to { background-position: -200% 0; } }
.d-tile:focus-visible { outline: 2px solid var(--lapis); outline-offset: 2px; }
.d-tile-ico { position: absolute; inset: 22%; color: var(--ink-soft); display: flex; }
.d-tile-ico svg { width: 100%; height: 100%; }
.d-chosen { text-align: center; font-size: 12.5px; color: var(--ink-soft); margin-top: -4px; }
.d-chosen .fa { margin-inline-start: 6px; color: var(--ink-faint); }
/* a row of colours, named by its icon */
.d-row { display: flex; align-items: center; gap: 10px; }
.d-ico { width: 26px; height: 26px; flex: none; display: inline-flex; color: var(--gold-dark); }
.d-ico svg { width: 100%; height: 100%; }
.d-ico.sm { width: 18px; height: 18px; }
.d-swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.d-sw { width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28), inset 0 -3px 6px rgba(0, 0, 0, 0.12); transition: transform 0.12s; }
.d-sw:hover { transform: scale(1.12); }
.d-sw.on { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--turq); }
.d-sw:focus-visible { outline: 2px solid var(--lapis); outline-offset: 3px; }
.d-slider { display: flex; align-items: center; gap: 10px; padding: 0 2px; }
.d-slider input { flex: 1; accent-color: var(--turq); height: 26px; }
.d-slider .d-ico { color: var(--ink-faint); align-self: flex-end; }
.final-note { display: flex; gap: 8px; align-items: flex-start; margin: -4px 0 10px; padding: 8px 10px; border-radius: 7px; font-size: 12.5px; line-height: 1.5; color: #7a4a14; background: rgba(201, 161, 74, 0.16); box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.35); }
.final-ico { width: 18px; height: 18px; flex: none; display: inline-flex; margin-top: 1px; }
.final-ico svg { width: 100%; height: 100%; }
.crown-box { padding: 10px 12px; border-radius: 8px; background: rgba(201, 161, 74, 0.12); box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.35); display: grid; gap: 8px; justify-items: start; }
.crown-box .hint { margin: 0; }
.crown-needs { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.crown-needs .mark { display: inline-block; width: 18px; color: var(--bad, #9b2c2c); font-weight: 700; }
.crown-needs .ok .mark { color: var(--turq-deep); }
.address-chip { display: inline-flex; align-items: center; gap: 6px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; padding: 4px 10px; border-radius: 99px; background: rgba(38, 64, 143, 0.1); color: var(--lapis-700); }

/* ---------------------------------------------------------------- HUD */
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }

.plate {
  position: absolute;
  top: calc(14px + var(--safe-t));
  left: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px 8px 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(18, 28, 69, 0.92), rgba(11, 18, 48, 0.92));
  box-shadow: inset 0 0 0 1px var(--gold-dark), inset 0 0 0 3px rgba(11, 18, 48, 0.9), inset 0 0 0 4px rgba(201, 161, 74, 0.35), 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
}
.medallion { position: relative; width: 58px; height: 58px; flex: none; }
.medallion svg { position: absolute; inset: 0; }
/* The portrait sits above the star frame, inside its inner ring. */
.medallion img { position: absolute; inset: 7px; width: 44px; height: 44px; border-radius: 50%; z-index: 1; object-fit: cover; background: radial-gradient(circle at 50% 35%, #2a3f84, #0b1230); }
.plate .who b { display: block; font-size: 15px; font-weight: 700; unicode-bidi: plaintext; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plate .who span { font-size: 11.5px; color: #a9b2d4; font-family: ui-monospace, Menlo, Consolas, monospace; }
.plate .badge { font-family: var(--sans); font-size: 10.5px; padding: 1px 7px; border-radius: 99px; background: rgba(201, 161, 74, 0.2); color: var(--gold-light); margin-inline-start: 6px; }
.coin { display: inline-flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--gold-light); font-weight: 700; font-size: 14px; }
.coin svg { width: 18px; height: 18px; }

.banner {
  position: absolute;
  top: calc(18px + var(--safe-t));
  left: 50%;
  transform: translate(-50%, -12px);
  opacity: 0;
  transition: opacity 0.6s, transform 0.6s;
  padding: 12px 64px 10px;
  text-align: center;
  pointer-events: none;
}
.banner.show { opacity: 1; transform: translate(-50%, 0); }
.banner { width: max-content; max-width: 92vw; }
.banner h2 { white-space: nowrap; }
.banner h2 { font-size: 20px; }
.banner .era { font-family: var(--sans); font-size: 12px; color: #c9cfe6; letter-spacing: 0.04em; margin-top: 2px; }

.astrolabe {
  position: absolute;
  top: calc(12px + var(--safe-t));
  right: 12px;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
}
.astrolabe canvas { width: 100%; height: 100%; display: block; }

.prompt {
  position: absolute;
  left: 50%;
  bottom: calc(118px + var(--safe-b));
  transform: translate(-50%, 8px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px 8px 8px;
  border-radius: 999px;
  background: rgba(11, 18, 48, 0.86);
  box-shadow: inset 0 0 0 1px var(--gold-dark), 0 10px 26px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
}
.prompt.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.keycap {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 7px;
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink);
  background: linear-gradient(180deg, #f8efd6, #dcc79a);
  box-shadow: inset 0 0 0 1px var(--gold-dark), 0 2px 0 #8a6a26;
}
.prompt .txt b { display: block; font-family: var(--serif); font-weight: 400; letter-spacing: 0.05em; font-size: 15px; }
.prompt .txt .fa { font-size: 12px; color: var(--turq-light); }
.prompt.locked .keycap { filter: grayscale(1); opacity: 0.6; }

.progress {
  position: absolute;
  left: 50%;
  bottom: calc(172px + var(--safe-b));
  transform: translateX(-50%);
  width: 220px;
  padding: 8px 12px 10px;
  border-radius: 10px;
  background: rgba(11, 18, 48, 0.86);
  box-shadow: inset 0 0 0 1px var(--gold-dark);
  text-align: center;
  font-size: 12.5px;
  pointer-events: none;
}
.progress .track { height: 6px; border-radius: 6px; margin-top: 6px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--turq-deep), var(--turq-light)); border-radius: 6px; }

.actionbar {
  position: absolute;
  left: 50%;
  bottom: calc(16px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(18, 28, 69, 0.9), rgba(11, 18, 48, 0.92));
  box-shadow: inset 0 0 0 1px var(--gold-dark), inset 0 0 0 4px rgba(11, 18, 48, 0.9), inset 0 0 0 5px rgba(201, 161, 74, 0.3), 0 10px 30px rgba(0, 0, 0, 0.45);
}
.act {
  position: relative;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--gold-light);
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.16), transparent 60%),
    radial-gradient(circle, var(--lapis-700), var(--lapis-800));
  box-shadow: inset 0 0 0 1.5px var(--gold), inset 0 0 0 4px var(--lapis-900), inset 0 0 0 5px rgba(201, 161, 74, 0.35);
  transition: transform 0.12s, filter 0.2s;
}
.act:hover { filter: brightness(1.2); }
.act:active { transform: scale(0.95); }
.act svg { width: 28px; height: 28px; }
.act .k {
  position: absolute;
  bottom: -4px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 20px;
  font-family: var(--serif);
  color: var(--ink);
  background: linear-gradient(180deg, #f8efd6, #dcc79a);
  box-shadow: inset 0 0 0 1px var(--gold-dark);
}
.act.dim { filter: grayscale(0.6) brightness(0.7); }
.act .pip { position: absolute; top: 2px; right: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--turq-light); box-shadow: 0 0 10px var(--turq-light); }

/* toasts */
.toasts {
  position: absolute;
  right: 14px;
  top: calc(196px + var(--safe-t));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  width: min(340px, 80vw);
  z-index: 20;   /* above open panels, so errors from a panel are seen */
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  border-radius: 10px;
  background: rgba(11, 18, 48, 0.9);
  box-shadow: inset 0 0 0 1px var(--gold-dark), 0 8px 22px rgba(0, 0, 0, 0.35);
  font-size: 13.5px;
  animation: toastIn 0.35s ease both;
}
.toast.out { animation: toastOut 0.4s ease both; }
.toast.err { box-shadow: inset 0 0 0 1px #a8443a, 0 8px 22px rgba(0, 0, 0, 0.35); }
.toast .ic { width: 34px; height: 34px; flex: none; }
.toast b { font-weight: 700; }
.toast .fa { color: var(--turq-light); font-size: 12px; margin-left: 6px; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* chat */
.chat {
  position: absolute;
  left: 14px;
  bottom: calc(16px + var(--safe-b));
  width: min(380px, 42vw);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat .log {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px 2px;
  mask-image: linear-gradient(180deg, transparent 0, #000 22px);
  scrollbar-width: none;
}
.chat .line { font-size: 13.5px; line-height: 1.45; padding: 3px 10px; border-radius: 8px; background: rgba(11, 18, 48, 0.62); unicode-bidi: plaintext; transition: opacity 1s; align-self: flex-start; max-width: 100%; overflow-wrap: anywhere; }
.chat .line b { color: var(--gold-light); font-weight: 700; }
.chat .line .sep { color: var(--gold-light); margin-right: 2px; }
.chat .line bdi { unicode-bidi: isolate; }
.chat .line.sys { color: var(--turq-light); font-style: italic; }
.chat .line.faded { opacity: 0.35; }
.chat form { display: none; }
.chat.open form { display: flex; gap: 6px; }
.chat .input { background: rgba(11, 18, 48, 0.9); color: var(--ivory); box-shadow: inset 0 0 0 1px var(--gold-dark); height: 40px; }

/* touch joystick */
#joystick {
  position: fixed;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  z-index: 11;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle, rgba(201, 161, 74, 0.12), rgba(11, 18, 48, 0.4));
  box-shadow: inset 0 0 0 1.5px rgba(201, 161, 74, 0.6);
  transition: opacity 0.15s;
}
#joystick.active { opacity: 1; }
#joystick .knob { position: absolute; left: 39px; top: 39px; width: 50px; height: 50px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #f8efd6, #c9a14a); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); }
.touch-act { display: none; }

/* ---------------------------------------------------------------- panels */
.panel-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 11, 31, 0.35);
  animation: fadeIn 0.2s ease both;
}
@keyframes fadeIn { from { opacity: 0; } }
.panel {
  width: min(var(--w, 720px), 100%);
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
  /* Side padding clears the lachak corner pieces (15 px inset + 38 px). */
  padding: 26px 54px 24px;
  animation: rise 0.25s ease both;
}
.panel .lachak { width: 38px; height: 38px; }
.panel .sarlowh { max-width: calc(100% - 40px); }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(0.985); } }
.panel.noanim { animation: none; }
.panel .close {
  position: absolute;
  top: 58px;
  right: 18px;
  z-index: 2;
  width: 34px;
  min-height: 34px;
  border-radius: 50%;
  background: rgba(255, 252, 240, 0.6);
}
.panel .close svg { width: 14px; height: 14px; }
.panel .body { overflow-y: auto; padding: 4px 6px 4px 2px; margin: 0 -4px; min-height: 0; flex: 1; scrollbar-width: thin; scrollbar-color: var(--gold-dark) transparent; }
.panel .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 14px; margin-top: 10px; border-top: 1px solid rgba(138, 106, 38, 0.3); flex-wrap: wrap; }

.tabs { display: flex; gap: 6px; margin: 0 0 12px; justify-content: center; flex-wrap: wrap; }
.tab {
  border: 0;
  padding: 8px 16px;
  border-radius: 999px;
  font-family: var(--serif);
  letter-spacing: 0.08em;
  font-size: 13px;
  color: var(--ink-soft);
  background: rgba(255, 252, 240, 0.4);
  box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.35);
}
.tab.on { color: var(--ivory); background: linear-gradient(180deg, var(--lapis), var(--lapis-700)); box-shadow: inset 0 0 0 1px var(--gold); }
.tab .fa { font-size: 12px; margin-left: 7px; opacity: 0.8; }

.banner-note { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; line-height: 1.5; background: rgba(38, 64, 143, 0.1); box-shadow: inset 0 0 0 1px rgba(38, 64, 143, 0.25); color: var(--lapis-800); }
.banner-note.warn { background: rgba(155, 44, 44, 0.08); box-shadow: inset 0 0 0 1px rgba(155, 44, 44, 0.3); color: #6f2420; }

/* item slots */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 10px; }
.slot {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 35%, #fffaf0, #e8d8b0);
  box-shadow: inset 0 0 0 1.5px var(--qc, var(--q0)), inset 0 0 0 4px #f4e9cf, inset 0 0 0 5px rgba(138, 106, 38, 0.25), 0 2px 0 rgba(90, 60, 20, 0.25);
  transition: transform 0.12s;
}
.slot:hover { transform: translateY(-2px); }
.slot.sel { box-shadow: inset 0 0 0 2.5px var(--turq), inset 0 0 0 5px #f4e9cf, 0 0 0 3px rgba(42, 166, 161, 0.35); }
.slot svg { width: 58%; height: 58%; }
.slot .n { position: absolute; bottom: 5px; right: 7px; font-weight: 800; font-size: 13px; color: var(--ink); text-shadow: 0 0 3px #fffaf0, 0 0 3px #fffaf0; }
.slot .q { position: absolute; top: 6px; left: 7px; width: 9px; height: 9px; transform: rotate(45deg); background: var(--qc); }
.slot.empty { opacity: 0.4; }
.q1 { --qc: var(--q1); }
.q2 { --qc: var(--q2); }

.detail { display: grid; grid-template-columns: 76px 1fr; gap: 14px; align-items: start; padding: 12px; border-radius: 10px; background: rgba(255, 252, 240, 0.45); box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.3); margin-top: 14px; }
.detail .ic { width: 76px; height: 76px; }
.detail h3 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 19px; letter-spacing: 0.04em; }
.detail .fa { color: var(--madder); font-size: 15px; font-weight: 600; }
.detail p { margin: 6px 0 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.55; font-style: italic; }
.kv { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; color: var(--ink-soft); }
.kv b { color: var(--ink); }

.section-title { font-family: var(--serif); letter-spacing: 0.14em; text-transform: uppercase; font-size: 12px; color: var(--ink-faint); margin: 18px 0 8px; display: flex; align-items: center; gap: 10px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(138, 106, 38, 0.45), transparent); }

.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.skill { padding: 10px 12px; border-radius: 8px; background: rgba(255, 252, 240, 0.45); box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.3); }
.skill .top { display: flex; justify-content: space-between; align-items: baseline; }
.skill b { font-family: var(--serif); font-weight: 400; font-size: 15px; }
.skill .lvl { font-size: 12px; color: var(--ink-faint); }
.skill .track { height: 6px; border-radius: 6px; background: rgba(90, 60, 20, 0.15); margin-top: 8px; overflow: hidden; }
.skill .fill { height: 100%; background: linear-gradient(90deg, var(--turq-deep), var(--turq)); }

/* recipes */
.recipes { display: grid; gap: 12px; }
.recipe { display: grid; grid-template-columns: 70px 1fr auto; gap: 14px; align-items: center; padding: 12px; border-radius: 10px; background: rgba(255, 252, 240, 0.5); box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.3); }
.recipe.locked { opacity: 0.6; }
.recipe .ic { width: 70px; height: 70px; border-radius: 10px; background: radial-gradient(circle at 50% 35%, #fffaf0, #e8d8b0); display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.3); }
.recipe .ic svg { width: 46px; height: 46px; }
.recipe h4 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 17px; }
.recipe h4 .fa { color: var(--madder); font-size: 14px; margin-left: 8px; }
.needs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.need { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 4px; border-radius: 99px; font-size: 12.5px; background: rgba(42, 166, 161, 0.12); color: #0f5552; }
.need.short { background: rgba(155, 44, 44, 0.1); color: #7a2a24; }
.need svg { width: 18px; height: 18px; }
.recipe .meta { font-size: 12px; color: var(--ink-faint); margin-top: 6px; }

/* market */
.market-list { display: grid; gap: 8px; }
.mrow { display: grid; grid-template-columns: 50px 1fr auto auto; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 10px; background: rgba(255, 252, 240, 0.5); box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.25); }
.mrow .ic { width: 50px; height: 50px; border-radius: 8px; display: grid; place-items: center; background: radial-gradient(circle at 50% 35%, #fffaf0, #e8d8b0); box-shadow: inset 0 0 0 1.5px var(--qc, var(--q0)); }
.mrow .ic svg { width: 34px; height: 34px; }
.mrow b { font-family: var(--serif); font-weight: 400; font-size: 15px; }
.mrow .sub { font-size: 12px; color: var(--ink-faint); unicode-bidi: plaintext; }
.mrow .sub.warn { color: #9b2c2c; font-weight: 600; }
.taxbox { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; }
.taxbox.kv { flex-direction: row; flex-wrap: wrap; align-items: center; }
.taxbox > .btn { align-self: flex-start; }
.taxbox .qty { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.taxbox .qty .input { flex: 0 0 160px; width: 160px; }
.price { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; color: var(--gold-dark); white-space: nowrap; }
.price svg { width: 16px; height: 16px; }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty input { width: 64px; text-align: center; height: 34px; padding: 0 4px; }
.empty-state { text-align: center; color: var(--ink-faint); padding: 34px 10px; font-style: italic; line-height: 1.6; }
.sell-form { display: grid; gap: 12px; }
.sell-form .summary { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 10px 12px; border-radius: 8px; background: rgba(42, 166, 161, 0.1); font-size: 13px; color: #0f5552; }

/* help / settings */
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; font-size: 14px; }
.keys .keycap { min-width: 30px; height: 30px; font-size: 14px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(138, 106, 38, 0.2); }
.seg { display: inline-flex; border-radius: 99px; box-shadow: inset 0 0 0 1px var(--gold-dark); overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 7px 14px; font-size: 13px; color: var(--ink-soft); }
.seg button.on { background: var(--lapis-700); color: var(--gold-light); }

/* fade between rooms */
.travel-veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, rgba(42, 166, 161, 0.25), var(--lapis-950) 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  text-align: center;
}
.travel-veil.show { opacity: 1; pointer-events: auto; }
.travel-veil .to { font-family: var(--serif); letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold-light); font-size: 14px; }
.travel-veil h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(24px, 7.5vw, 34px); margin: 10px 0 4px; letter-spacing: 0.06em; padding: 0 16px; overflow-wrap: anywhere; }
.travel-veil .fa { font-size: 22px; color: var(--turq-light); }
.travel-veil .blurb { max-width: 460px; margin: 16px auto 0; color: #c9cfe6; line-height: 1.6; font-size: 14px; }
.travel-veil .star { width: 60px; height: 60px; margin: 22px auto 0; animation: spin 6s linear infinite; }

.conn-lost { position: absolute; top: calc(14px + var(--safe-t)); left: 50%; transform: translateX(-50%); padding: 8px 16px; border-radius: 99px; background: rgba(155, 44, 44, 0.9); box-shadow: inset 0 0 0 1px #e8a39a; font-size: 13px; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .creator { place-items: end center; padding: 12px; }
  .creator-card { padding: 22px 18px 16px; max-height: 62vh; overflow-y: auto; }
  .creator-card.designing { max-height: 50vh; }
  .astrolabe { width: 112px; height: 112px; top: calc(8px + var(--safe-t)); right: 8px; }
  .plate { top: calc(8px + var(--safe-t)); left: 8px; padding: 6px 14px 6px 6px; gap: 8px; }
  .medallion { width: 46px; height: 46px; }
  .medallion img { inset: 5px; width: 36px; height: 36px; }
  .plate .who b { font-size: 13.5px; max-width: 120px; }
  .banner { top: calc(128px + var(--safe-t)); padding: 8px 40px 7px; }
  .banner h2 { font-size: 13px; letter-spacing: 0.08em; }
  .banner .fa { font-size: 12px; }
  .banner .era { font-size: 11px; }
  .banner.sarlowh::before, .banner.sarlowh::after { width: 18px; height: 18px; margin-top: -9px; }
  .banner.sarlowh::before { left: 11px; }
  .banner.sarlowh::after { right: 11px; }
  .actionbar { gap: 6px; padding: 7px 10px; bottom: calc(10px + var(--safe-b)); left: auto; right: 10px; transform: none; }
  .act { width: 46px; height: 46px; }
  .act svg { width: 22px; height: 22px; }
  .act .k { display: none; }
  .prompt { bottom: calc(80px + var(--safe-b)); }
  .progress { bottom: calc(136px + var(--safe-b)); }
  .chat { width: calc(100vw - 24px); bottom: calc(72px + var(--safe-b)); }
  .chat .log { max-height: 110px; }
  .toasts { top: calc(128px + var(--safe-t)); right: 8px; }
  .panel { padding: 22px 26px 16px; max-height: 90vh; }
  .panel .lachak { width: 24px; height: 24px; }
  .panel .close { top: 46px; right: 10px; }
  .recipe { grid-template-columns: 54px 1fr; }
  .recipe .ic { width: 54px; height: 54px; }
  .recipe > :last-child { grid-column: 1 / -1; }
  .mrow { grid-template-columns: 42px 1fr auto; }
  .mrow > :last-child { grid-column: 1 / -1; justify-self: end; }
  .touch-act { display: grid; }
}
@media (pointer: coarse) {
  .touch-act { display: grid; }
}
.touch-act.big {
  position: absolute;
  right: 18px;
  bottom: calc(92px + var(--safe-b));
  width: 74px;
  height: 74px;
  font-family: var(--serif);
  font-size: 22px;
}
.fly-pad { position: absolute; right: 18px; bottom: calc(180px + var(--safe-b)); display: none; flex-direction: column; gap: 8px; }
.fly-btn { width: 56px; height: 56px; font-size: 20px; touch-action: none; }
@media (pointer: coarse) { .fly-pad:not(.hidden) { display: flex; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* the treasury (ui/panels-token.js) */
.coin[role="button"] { cursor: pointer; border-radius: 8px; padding: 0 4px; margin-left: -4px; transition: background 0.2s; }
.coin[role="button"]:hover { background: rgba(236, 208, 138, 0.15); }
.token-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.token-head b { font-family: var(--serif); font-size: 18px; font-weight: 400; }
.token-head .badge { margin-inline-start: 8px; font-size: 11px; padding: 1px 8px; border-radius: 9px; background: rgba(155, 44, 44, 0.12); color: var(--madder); }
.token-head .ok { color: var(--ok); }
.token-buy .qty .input, .token-pledge .qty .input { width: 200px; text-align: start; }
.token-preview { margin: 12px 0; padding: 12px 14px; border-radius: 10px; background: rgba(201, 161, 74, 0.12); box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.3); }
.token-preview .big { font-family: var(--serif); font-size: 20px; }
.token-preview .big b { font-size: 26px; color: var(--gold-dark); }
.token-status { margin-top: 10px; }
.wallet-ic { width: 18px; height: 18px; border-radius: 4px; margin-inline-end: 6px; vertical-align: -4px; }
.token-rows { display: flex; flex-direction: column; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(138, 106, 38, 0.25); overflow: hidden; }
.token-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 10px 12px; font-size: 13.5px; }
.token-row + .token-row { border-top: 1px solid rgba(138, 106, 38, 0.18); }
.token-row b { font-family: var(--serif); font-weight: 400; font-size: 15px; white-space: nowrap; }
.token-row .sub { color: var(--ink-soft); font-size: 12.5px; }
@media (max-width: 560px) { .token-row { grid-template-columns: 1fr auto; } }

/* the treasury: buying a token with SOL, folded away until wanted */
.swap-box { margin-top: 14px; border: 1px solid rgba(201,161,74,.45); border-radius: 12px; padding: 10px 14px; background: rgba(255,250,240,.55); }
.swap-box summary { cursor: pointer; font-weight: 700; color: #6b3d22; }
.swap-box[open] summary { margin-bottom: 10px; }
.swap-box .qty { margin: 6px 0; }
