/* RiddleWorld dashboard. Black and cream, Space Mono for data, Syne for headings. Mobile first. */

@font-face { font-family: 'Space Mono'; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/space-mono-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Space Mono'; font-weight: 700; font-style: normal; font-display: swap; src: url(fonts/space-mono-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Syne'; font-weight: 700; font-style: normal; font-display: swap; src: url(fonts/syne-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Syne'; font-weight: 800; font-style: normal; font-display: swap; src: url(fonts/syne-latin-800-normal.woff2) format('woff2'); }

:root {
  --bg: #0b0a08;
  --bg-2: #110f0c;
  --panel: #16130f;
  --panel-2: #1d1914;
  --line: #2c271f;
  --line-2: #433b2e;
  --cream: #efe5cf;
  --cream-2: #d4c8ab;
  --muted: #968b74;
  --faint: #6b6353;
  --gold: #c9a24c;
  --red: #c0513f;
  --green: #8aa35a;
  --blue: #6f97a8;
  --on-cream: #0b0a08;

  --mono: 'Space Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display: 'Syne', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;

  --r: 3px;
  --gap: 12px;
  --pad: 16px;
  --tabbar-h: 62px;
  --topbar-h: 56px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--cream);
  font: 13px/1.55 var(--mono);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
body.no-nav { padding-bottom: 0; }
img { max-width: 100%; display: block; }
a { color: var(--cream); text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--cream); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 800; letter-spacing: .01em; margin: 0; line-height: 1.15; text-wrap: balance; }
h1 { font-size: 26px; overflow-wrap: anywhere; }
h2 { font-size: 19px; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 100; background: var(--cream); color: var(--on-cream); padding: 6px 10px; }
.noscript { padding: 24px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h); padding: 0 var(--pad);
  background: rgba(11, 10, 8, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; overflow: hidden; }
.brand-mark { width: 26px; height: 26px; color: var(--cream); flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text b { font-family: var(--display); font-weight: 800; font-size: 14px; letter-spacing: .06em; text-transform: uppercase; line-height: 1; }
.brand-text small { font-size: 9.5px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; margin-top: 3px; white-space: nowrap; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.scan-chip, .wallet-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--bg-2);
  font-size: 11px; color: var(--cream-2); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.scan-chip span { display: none; }
.scan-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.scan-chip.ok .dot { background: var(--green); box-shadow: 0 0 0 3px rgba(138,163,90,.18); }
.scan-chip.warn .dot { background: var(--gold); }
.scan-chip.err .dot { background: var(--red); }
.wallet-chip:hover, .scan-chip:hover { border-color: var(--cream-2); }

.nav { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(11, 10, 8, .97); border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  text-decoration: none; color: var(--muted); font-size: 10px; letter-spacing: .04em; min-width: 0;
}
.tabbar a svg { width: 20px; height: 20px; }
.tabbar a.active { color: var(--cream); }
.tabbar a.active svg { color: var(--gold); }
body.no-nav .tabbar, body.no-nav .nav, body.no-nav .wallet-chip { display: none !important; }

/* ---------- layout ---------- */
main { display: block; padding: 18px var(--pad) 32px; max-width: 1240px; margin: 0 auto; outline: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; margin-bottom: 16px; }
.page-head .grow { flex: 1 1 200px; min-width: 0; }
.page-head .kicker { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section { margin-top: 26px; }
.section > .section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.section > .section-head h2::before { content: '\25C6'; font-size: 9px; color: var(--gold); margin-right: 8px; vertical-align: 3px; }
.section-head .meta { color: var(--muted); font-size: 11px; }
.grid { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 11px; }
.mono-num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.two-col { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
hr.rule { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* ---------- cards ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; min-width: 0; position: relative;
}
.card.framed { box-shadow: inset 0 0 0 3px var(--panel), inset 0 0 0 4px var(--line); padding: 18px; }
.card.link { cursor: pointer; transition: border-color .15s; }
.card.link:hover { border-color: var(--line-2); }
.card h3 { margin-bottom: 2px; }

.stat-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; min-width: 0; }
.stat .k { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stat .v { font-family: var(--display); font-weight: 800; font-size: 22px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v small { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--muted); }

/* plot card */
.plot-card { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 12px; }
.plot-card .thumb { width: 96px; height: 96px; }
.plot-card .body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.plot-card .bars { grid-column: 1 / -1; }
.plot-card .foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.plot-card .title { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.plot-card .title h3 { font-size: 15px; overflow-wrap: anywhere; }
.thumb { position: relative; border-radius: var(--r); overflow: hidden; background: var(--bg-2); border: 1px solid var(--line); flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.lvl {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; flex: none;
  min-width: 42px; height: 42px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--bg-2);
}
.lvl b { font-family: var(--display); font-size: 18px; line-height: 1; }
.lvl small { font-size: 8.5px; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }

.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 7px;
  border: 1px solid var(--line-2); border-radius: 2px; font-size: 10.5px; color: var(--cream-2);
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.tag .sw { width: 9px; height: 9px; border-radius: 1px; flex: none; }
.tag.gold { border-color: rgba(201,162,76,.55); color: var(--gold); }
.tag.red { border-color: rgba(192,81,63,.6); color: #e08a7b; }
.tag.green { border-color: rgba(138,163,90,.55); color: #b3c98a; }
.tag.solid { background: var(--cream); color: var(--on-cream); border-color: var(--cream); }

/* bars */
.bars { display: grid; grid-template-columns: 1fr; gap: 7px 18px; }
.bar { min-width: 0; }
.bar .lbl { display: flex; justify-content: space-between; gap: 8px; font-size: 10.5px; color: var(--muted); letter-spacing: .04em; }
.bar .lbl b { color: var(--cream); font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar .track { height: 5px; background: #26221b; border-radius: 1px; margin-top: 3px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--cream-2); border-radius: 1px; transition: width .4s ease; }
.bar.gold .fill { background: var(--gold); }
.bar.green .fill { background: var(--green); }
.bar.red .fill { background: var(--red); }
.bar.blue .fill { background: var(--blue); }

/* resources */
.res-list { display: flex; flex-wrap: wrap; gap: 5px; }
.res {
  display: inline-flex; align-items: baseline; gap: 5px; padding: 3px 7px; border-radius: 2px;
  background: var(--bg-2); border: 1px solid var(--line); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.res i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; align-self: center; }
.res .k { color: var(--muted); font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; }
.res .rate { color: var(--green); font-size: 10px; }
.res .rate.neg { color: var(--red); }
.res.short { border-color: rgba(192,81,63,.6); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 14px; border-radius: var(--r); cursor: pointer;
  background: var(--cream); color: var(--on-cream); border: 1px solid var(--cream);
  font-weight: 700; font-size: 12px; letter-spacing: .02em; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: #fff8e8; }
.btn.ghost { background: transparent; color: var(--cream); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--cream-2); background: var(--panel-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--on-cream); }
.btn.danger { background: transparent; color: #e08a7b; border-color: rgba(192,81,63,.55); }
.btn.danger:hover { background: rgba(192,81,63,.12); }
.btn.sm { min-height: 28px; padding: 0 10px; font-size: 11px; }
.btn.lg { min-height: 46px; padding: 0 20px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.busy { opacity: .45; cursor: not-allowed; }
.btn.busy { cursor: progress; }
.btn svg { width: 16px; height: 16px; flex: none; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.field .hint { font-size: 11px; color: var(--faint); }
.input, select.input, textarea.input {
  width: 100%; min-height: 38px; padding: 7px 10px; border-radius: var(--r);
  background: var(--bg); border: 1px solid var(--line-2); color: var(--cream); min-width: 0;
}
select.input { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input:focus { border-color: var(--cream-2); outline: none; }
input[type=color].input { padding: 3px; height: 38px; }
input[type=range] { width: 100%; accent-color: var(--gold); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12px; }
.check input { accent-color: var(--gold); width: 16px; height: 16px; flex: none; }
.check > span { min-width: 0; } /* long plot names ellipsize instead of widening the row */
.form { display: grid; gap: 12px; grid-template-columns: 1fr; }
.form .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; grid-column: 1 / -1; }

.seg { display: flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.seg::-webkit-scrollbar { display: none; }
.seg button, .seg a {
  flex: 1 0 auto; background: none; border: 0; border-right: 1px solid var(--line); padding: 8px 12px; cursor: pointer;
  font-size: 11.5px; color: var(--muted); text-decoration: none; text-align: center; white-space: nowrap;
}
.seg > :last-child { border-right: 0; }
.seg .on { background: var(--cream); color: var(--on-cream); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); background: none; border-radius: 999px; padding: 4px 10px; font-size: 11px; cursor: pointer; color: var(--cream-2); }
.chip.on { background: var(--cream); color: var(--on-cream); border-color: var(--cream); }

/* ---------- lists / tables ---------- */
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.list .item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); min-width: 0; flex-wrap: wrap; }
.list .item:last-child { border-bottom: 0; }
.list .item .grow { flex: 1 1 160px; min-width: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-weight: 400; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.table tr.me td { background: rgba(201,162,76,.08); }
.table .r { text-align: right; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); overflow: hidden; }

.empty { border: 1px dashed var(--line-2); border-radius: var(--r); padding: 26px 18px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--cream); margin-bottom: 6px; }
.empty .btn { margin-top: 12px; }
.error-box { border: 1px solid rgba(192,81,63,.5); background: rgba(192,81,63,.07); border-radius: var(--r); padding: 14px; color: #e8a597; }
.notice { border: 1px solid var(--line-2); border-left: 3px solid var(--gold); background: var(--panel); padding: 10px 12px; border-radius: var(--r); color: var(--cream-2); font-size: 12px; }

/* skeleton */
.skel { background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: sk 1.3s linear infinite; border-radius: var(--r); }
@keyframes sk { to { background-position: -200% 0; } }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--cream); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- dividers (login styles live in login.css) ---------- */
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; margin: 20px 0 14px; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.ornament { text-align: center; color: var(--line-2); letter-spacing: .6em; font-size: 10px; margin: 18px 0 0; }

/* ---------- modal ---------- */
.modal-root:empty { display: none; }
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(5, 4, 3, .78); display: flex; align-items: flex-end; justify-content: center; }
.modal {
  width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--line-2); border-bottom: 0; border-radius: 8px 8px 0 0;
  padding: 18px var(--pad) calc(18px + env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
.modal.wide { max-width: 640px; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.modal-head .x { background: none; border: 1px solid var(--line-2); width: 32px; height: 32px; border-radius: var(--r); cursor: pointer; flex: none; color: var(--cream-2); font-size: 16px; line-height: 1; }
.sign-body { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.qr-box { background: var(--cream); padding: 12px; border-radius: var(--r); width: 232px; max-width: 100%; aspect-ratio: 1; display: grid; place-items: center; }
.qr-box svg, .qr-box img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.sign-status { display: flex; align-items: center; gap: 8px; justify-content: center; color: var(--cream-2); font-size: 12px; min-height: 20px; }
.sign-status.done { color: #b3c98a; }
.sign-status.fail { color: #e08a7b; }
.sign-steps { text-align: left; color: var(--muted); font-size: 11.5px; padding-left: 18px; margin: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: var(--pad); right: var(--pad); bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; max-width: 440px; width: 100%; background: var(--cream); color: var(--on-cream); padding: 10px 14px; border-radius: var(--r); font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.5); animation: up .18s ease-out; }
.toast.err { background: #2a1512; color: #f0b1a4; border: 1px solid rgba(192,81,63,.6); }
body.no-nav .toasts { bottom: 16px; }

/* ---------- plot detail ---------- */
.plot-hero { display: grid; gap: 14px; grid-template-columns: 1fr; }
.plot-hero .thumb { width: 100%; aspect-ratio: 1; max-width: 340px; }
.plot-hero .info { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.layout-grid { display: grid; gap: 2px; background: var(--line); border: 1px solid var(--line-2); padding: 2px; border-radius: var(--r); width: 100%; max-width: 440px; aspect-ratio: 1; position: relative; }
.layout-grid .cell { background: #1a1712; border: 0; padding: 0; cursor: pointer; min-width: 0; min-height: 0; }
.layout-grid .cell:hover { background: #262117; }
.layout-grid .cell.sel { background: rgba(201,162,76,.45); }
.layout-grid .bld {
  display: flex; align-items: center; justify-content: center; text-align: center; overflow: hidden;
  font-size: 9px; line-height: 1.1; padding: 2px; border-radius: 2px; color: var(--on-cream); cursor: pointer; border: 0; min-width: 0; min-height: 0;
  font-weight: 700; word-break: break-word;
}
.layout-grid .bld.building { background-image: repeating-linear-gradient(45deg, rgba(0,0,0,.18) 0 4px, transparent 4px 8px); }
.layout-grid .bld.hl { outline: 2px solid var(--cream); outline-offset: -2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 10.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.bld-item .ico { width: 30px; height: 30px; border-radius: 2px; flex: none; display: grid; place-items: center; font-family: var(--display); font-weight: 800; color: var(--on-cream); font-size: 12px; }
.bld-item .name { font-weight: 700; }
.bld-item .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.build-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.build-opt:last-child { border-bottom: 0; }
.build-opt.blocked { opacity: .5; }
.build-opt .grow { flex: 1 1 180px; min-width: 0; }
.build-opt .why { color: #e08a7b; font-size: 11px; }
.build-list { max-height: 520px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.unit-grid { display: grid; gap: 8px; grid-template-columns: 1fr; }
.unit { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.unit .grow { flex: 1 1 150px; min-width: 0; }
.unit.locked { opacity: .5; }
.unit .n { width: 74px; }
details.more { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
details.more > summary { padding: 10px 12px; cursor: pointer; color: var(--cream-2); font-size: 12px; list-style: none; }
details.more > summary::before { content: '+ '; color: var(--gold); }
details.more[open] > summary::before { content: '\2212  '; }
details.more > .inner { padding: 0 12px 12px; }

/* ---------- world map ---------- */
.map-wrap { position: relative; width: 100%; border: 1px solid var(--line-2); border-radius: var(--r); background: #070605; overflow: hidden; touch-action: none; aspect-ratio: 1; max-height: 78vh; }
.map-wrap canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.map-wrap canvas.dragging { cursor: grabbing; }
.map-tools { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.map-tools button { width: 34px; height: 34px; border-radius: var(--r); background: rgba(11,10,8,.85); border: 1px solid var(--line-2); color: var(--cream); cursor: pointer; font-size: 16px; line-height: 1; }
.tooltip { position: absolute; z-index: 3; pointer-events: none; background: rgba(11,10,8,.95); border: 1px solid var(--line-2); border-radius: var(--r); padding: 8px 10px; font-size: 11px; max-width: 240px; box-shadow: 0 6px 18px rgba(0,0,0,.6); }
.tooltip b { font-family: var(--display); font-size: 13px; display: block; margin-bottom: 2px; }
.map-layout { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
.map-side { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }

/* ---------- market ---------- */
.listing { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.listing .top { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; }
.listing .thumb { width: 72px; height: 72px; }
.price { font-family: var(--display); font-weight: 800; font-size: 20px; white-space: nowrap; }
.price small { font-family: var(--mono); font-weight: 400; font-size: 11px; color: var(--muted); margin-left: 3px; }
.filters { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 14px; }

/* ---------- civ ---------- */
.banner-img { width: 64px; flex: none; aspect-ratio: 100 / 130; background: var(--bg-2); border-radius: 2px; overflow: hidden; }
.banner-img img, .banner-img svg { width: 100%; height: 100%; }
.civ-card { display: flex; gap: 12px; align-items: flex-start; }
.civ-card .grow { flex: 1; min-width: 0; }
.plot-checks { display: grid; gap: 4px; grid-template-columns: minmax(0, 1fr); max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r); padding: 8px; background: var(--bg); }

/* ---------- battle ---------- */
.battle { border: 1px solid var(--line-2); border-radius: var(--r); padding: 14px; background: var(--bg-2); }
.battle .verdict { font-family: var(--display); font-weight: 800; font-size: 24px; text-transform: uppercase; letter-spacing: .04em; }
.battle .verdict.win { color: var(--gold); }
.battle .verdict.lose { color: var(--red); }
.rounds { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--cream-2); margin-top: 8px; }

/* ---------- 3D viewers (viewer3d.js / views3d.js) ---------- */
.v3d-box { position: relative; aspect-ratio: 1; background: radial-gradient(ellipse at 50% 38%, #2a241b 0%, #17140f 58%, #0f0d0a 100%); overflow: hidden; }
.v3d-box.lg { aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: var(--r); }
.v3d-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.v3d-canvas:active { cursor: grabbing; }
.v3d-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font-size: 11px; pointer-events: none; }
.v3d-box[data-state=ready] .v3d-msg, .v3d-box[data-state=fallback] .v3d-msg { display: none; }
.v3d-box[data-state=fallback]::after { content: 'Placeholder'; position: absolute; right: 8px; bottom: 6px; font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); pointer-events: none; }
.char-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.char-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.char-view { position: relative; border-bottom: 1px solid var(--line); }
.char-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.char-view .v3d-box { position: relative; z-index: 1; background: transparent; }
.role-badge { position: absolute; top: 8px; left: 8px; padding: 2px 7px; border-radius: 2px; font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--on-cream); font-weight: 700; pointer-events: none; }
.char-card .body { padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.char-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.cs { display: grid; grid-template-columns: 30px minmax(0, 1fr) 24px; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); }
.cs b { color: var(--cream); font-weight: 400; text-align: right; font-variant-numeric: tabular-nums; }
.cs .track { height: 4px; background: #26221b; border-radius: 1px; overflow: hidden; }
.cs .fill { height: 100%; background: var(--gold); }
.bonus { color: #b3c98a; font-size: 11.5px; }
.equip-list .item { padding: 6px 10px; }
@media (max-width: 539px) { .char-view .v3d-box { aspect-ratio: 4 / 3; } }
.gallery-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.gal-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.gal-card .v3d-box { border-bottom: 1px solid var(--line); }
.gal-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.gal-body .row { flex-wrap: nowrap; }
.gal-foot { gap: 6px; }
.gal-foot > span { min-width: 0; flex: 1 1 auto; }
.gal-foot .btn { flex: none; }
.gal-head { margin-bottom: 10px; gap: 8px 14px; flex-wrap: wrap; }
.load-meter { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.load-meter[hidden] { display: none; }
.pager { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager[hidden] { display: none; }
.pager button { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--line-2); background: none; color: var(--cream-2); border-radius: var(--r); font: inherit; font-size: 12px; cursor: pointer; }
.pager button.on { background: var(--cream); color: var(--on-cream); border-color: var(--cream); }
.pager button:disabled:not(.on) { opacity: .35; cursor: default; }
.pager .gap { color: var(--faint); padding: 0 2px; }
.view-toggle { flex: none; }
.view-toggle button { padding: 5px 14px; flex: 0 0 auto; }
.layout-holder { min-width: 0; }
.city3d-host { position: relative; width: 100%; aspect-ratio: 1; max-height: 78vh; border: 1px solid var(--line-2); border-radius: var(--r); background: #0f0d0b; overflow: hidden; touch-action: none; }
.v3d-stage { width: 100%; height: 100%; display: block; cursor: grab; }
.city3d-status { position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--cream-2); background: rgba(11,10,8,.8); padding: 5px 9px; border-radius: var(--r); pointer-events: none; }
.city3d-label { position: absolute; left: 10px; top: 10px; font-size: 11px; background: rgba(11,10,8,.85); border: 1px solid var(--line-2); padding: 5px 9px; border-radius: var(--r); pointer-events: none; }
.world3d-host { position: absolute; inset: 0; touch-action: none; }
.char-bonus { display: flex; flex-wrap: wrap; gap: 6px; }
.bonus-chip { font-size: 11px; color: #c6d9a0; border: 1px solid #3c4a2c; background: #171c11; padding: 3px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.char-item .ico { color: var(--on-cream); }
/* showcase (#/showcase) */
.showcase-head { margin-bottom: 14px; }
.showcase-stage { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: 76vh; border: 1px solid var(--line-2); border-radius: var(--r); background: #0e0c0a; overflow: hidden; touch-action: none; }
@media (max-width: 539px) { .showcase-stage { aspect-ratio: 4 / 5; max-height: 70vh; } }
.showcase-wrap { position: relative; }
.lvl-seg { margin-left: auto; }
.lvl-seg button { padding: 5px 12px; flex: 0 0 auto; }
.showcase-veil { position: absolute; inset: 0; background: #0e0c0a; opacity: 0; transition: opacity .18s ease; pointer-events: none; }
.showcase-veil.on { opacity: 1; }
.showcase-cap { position: absolute; left: 14px; top: 14px; max-width: min(460px, calc(100% - 28px)); background: rgba(11,10,8,.78); border: 1px solid var(--line-2); border-radius: var(--r); padding: 10px 12px; pointer-events: none; }
.showcase-cap:empty { display: none; }
.showcase-cap b { font-family: var(--display); font-size: 17px; letter-spacing: .02em; display: block; }
.showcase-cap p { margin: 4px 0 0; font-size: 12px; color: var(--cream-2); line-height: 1.45; }
@media (max-width: 539px) { .showcase-cap { position: static; max-width: none; margin-top: 8px; } .showcase-cap p { font-size: 11.5px; } }
.showcase-stage .city3d-status { left: auto; right: 10px; top: 10px; bottom: auto; }
.showcase-bar { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.showcase-dots { display: flex; gap: 6px; }
.showcase-dots button { width: 26px; height: 26px; border: 0; background: none; padding: 0; cursor: pointer; display: grid; place-items: center; }
.showcase-dots button::before { content: ''; width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--cream-2); }
.showcase-dots button.on::before { background: var(--gold); border-color: var(--gold); }
.showcase-cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.load-bar { display: inline-block; width: 64px; height: 3px; background: #2a251d; border-radius: 2px; overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .2s; }

/* ---------- breakpoints ---------- */
@media (max-width: 400px) {
  .brand-text small { display: none; }
  .topbar { gap: 8px; }
  .scan-chip { display: none; } /* scanner status stays reachable from the account sheet */
}
@media (min-width: 540px) {
  .brand-text b { font-size: 17px; }
  .stat-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bars { grid-template-columns: 1fr 1fr; }
  .form { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .unit-grid { grid-template-columns: 1fr 1fr; }
  .plot-checks { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 6px; border-bottom: 1px solid var(--line-2); padding-bottom: 20px; }
  .scan-chip span { display: inline; }
}
@media (min-width: 760px) {
  .grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .plot-hero { grid-template-columns: 300px minmax(0, 1fr); }
  .plot-card { grid-template-columns: 120px minmax(0, 1fr); }
  .plot-card .thumb { width: 120px; height: 120px; }
  h1 { font-size: 32px; }
}
@media (min-width: 1024px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .toasts { bottom: 20px; }
  .nav { display: flex; gap: 2px; margin-left: 22px; height: 100%; }
  .nav a { display: flex; align-items: center; padding: 0 12px; text-decoration: none; color: var(--muted); font-size: 12px; letter-spacing: .04em; border-bottom: 2px solid transparent; margin-bottom: -1px; }
  .nav a:hover { color: var(--cream); }
  .nav a.active { color: var(--cream); border-bottom-color: var(--gold); }
  .grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .map-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  main { padding-top: 26px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
