:root {
  --outer: #1f1c17;
  --stage: #2a2620;
  --panel: #383324;
  --panel-dark: #2d2922;
  --tile: #2d2924;
  --tile-edge: #5d5446;
  --edge-dark: #16130f;
  --edge-light: #6b6250;
  --hdr: #433c34;
  --title: #ebd8a6;
  --text: #ece5d2;
  --muted: #b9b09a;
  --tab: #38332d;
  --tab-txt: #c7c4c2;
  --tab-on: #fcf36e;
  --select: #fefb59;
  --gold-hi: #cdb06b;
  --gold-lo: #9a7d44;
  --gold-txt: #2b2216;
  --parch-hi: #cbb994;
  --parch-lo: #b6a27d;
  --ink: #2a241b;
  --serif: 'Cardo', 'Palatino Linotype', Georgia, serif;
  --ui: 'Share Tech', 'Trebuchet MS', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--outer); color: var(--text); }
body { font-family: var(--serif); min-height: 100vh; display: grid; place-items: center; overflow-x: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--select); outline-offset: 2px; }

/* bevelled game frame used by panels and buttons */
.bevel {
  border: 2px solid var(--edge-dark);
  box-shadow: inset 1px 1px 0 var(--edge-light), inset -1px -1px 0 #0d0b08;
}

/* ---------- desktop: fixed 1536x1024 composition, scaled by app.js ---------- */
.viewport { position: relative; overflow: hidden; }
.stage {
  position: relative;
  width: 1536px;
  height: 1024px;
  transform-origin: 0 0;
  background: var(--stage);
}

.world { position: absolute; left: 0; top: 0; width: 1096px; height: 808px; overflow: hidden; border: 2px solid var(--edge-dark); }
.world-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.world-3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.world.three .spot, .world.three .world-img { display: none; }
.minimap-3d { position: absolute; left: 50%; top: 50%; width: 250px; height: 250px; transform: translate(-50%, -49%); border-radius: 50%; background: #6d7a45; }
.view-toggle { left: 146px; width: 140px; }
.spot { position: absolute; background: transparent; border: 0; padding: 0; }
.spot:hover, .spot:focus-visible { background: rgba(254, 251, 89, 0.07); outline: 2px dashed rgba(254, 251, 89, 0.55); outline-offset: -2px; }
.hover-label {
  position: absolute; left: 10px; top: 8px; pointer-events: none;
  font: 20px var(--ui); color: #fff; text-shadow: 1px 1px 0 #000;
}
.hover-label::first-letter { color: #fff; }

.chat {
  position: absolute; left: 8px; top: 814px; width: 1086px; height: 150px;
  display: flex; background: linear-gradient(180deg, var(--parch-hi), var(--parch-lo));
  border: 3px solid #4d4434; box-shadow: inset 0 0 0 2px #8b7b5c, inset 0 -24px 0 -22px #7a6c52;
}
.chat-log { flex: 1; overflow-y: auto; padding: 22px 18px 10px; scrollbar-width: none; }
.chat-log::-webkit-scrollbar { display: none; }
.chat-log p { margin: 0; font: 22px/28px var(--ui); color: var(--ink); }
.chat-log p.sys { color: #1b3f7a; }
.chat-log p.warn { color: #7a1b12; }
.chat-scroll { width: 30px; display: flex; flex-direction: column; margin: 4px 4px 4px 0; background: #b09c78; border-left: 2px solid #6d6049; }
.chat-scroll .track { flex: 1; }
.arrow { height: 30px; background: #d8c8a4; border: 2px solid #3b3326; font-size: 13px; color: #1d1a14; padding: 0; line-height: 1; }

.music {
  position: absolute; left: 10px; top: 968px; width: 128px; height: 44px;
  background: #4b4240; font: 20px var(--ui); color: #ece5d2;
}
.music, .tab, .slot, .gold, .plain, .strip, .map-box, .shop-hdr, .balance, .chat-scroll .arrow, .sheet { border: 2px solid var(--edge-dark); box-shadow: inset 1px 1px 0 var(--edge-light), inset -1px -1px 0 #0d0b08; }

.panel {
  position: absolute; left: 1098px; top: 0; width: 438px; height: 1024px;
  display: flex; flex-direction: column; gap: 8px; padding: 0 10px 6px;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 240, 200, 0.04), transparent 40%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.03) 0 2px, transparent 2px 5px),
    var(--panel);
  border-left: 3px solid var(--edge-dark);
  box-shadow: inset 2px 0 0 #5a5140;
}
.title { margin: 8px 0 0; height: 48px; text-align: center; font: 400 38px/48px var(--serif); color: var(--title); text-shadow: 2px 2px 0 #000; letter-spacing: 0.5px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; height: 50px; }
.tab { background: var(--tab); color: var(--tab-txt); font-size: 22px; line-height: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.tab small { font: 15px var(--ui); color: var(--muted); margin-top: 2px; }
.tab[data-tab="launchpad"] { font-size: 19px; }
.tab[aria-selected="true"] { background: #4a4436; color: var(--tab-on); }

.map-box { position: relative; height: 288px; background: var(--panel-dark); display: grid; place-items: center; }
.minimap { width: 286px; height: 286px; margin-top: 2px; }
.compass { position: absolute; right: 10px; top: 8px; width: 60px; height: 60px; }

.view { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0; }
.shop-hdr { height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; background: var(--hdr); }
.shop-hdr h2 { margin: 0; font: 400 24px var(--serif); color: #e6dcc4; }
.shop-hdr .hint { font: 16px var(--ui); color: var(--muted); }
.link { background: none; border: 0; box-shadow: none; font: 17px var(--ui); color: var(--tab-on); text-decoration: underline; padding: 0; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 136px; gap: 10px; padding: 2px 2px; overflow-y: auto; height: 286px; scrollbar-width: thin; }
.slot { position: relative; background: var(--tile); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 6px 0 0; }
.slot img { width: 104px; height: 94px; object-fit: contain; }
.slot .price { font: 20px var(--serif); color: #f3ecd8; text-shadow: 1px 1px 0 #000; margin-top: 4px; }
.slot .listed-tag { color: var(--tab-on); font-size: 17px; }
.slot[aria-selected="true"] { border-color: var(--select); box-shadow: 0 0 0 1px var(--select), inset 0 0 0 1px #8a8420; }
.slot:hover { background: #36312a; }
.empty { grid-column: 1 / -1; margin: 12px; font: 18px var(--ui); color: var(--muted); }

.strip { height: 182px; display: flex; gap: 14px; padding: 10px; background: #302d25; }
.strip-icon { width: 104px; height: 104px; flex: none; display: grid; place-items: center; background: var(--tile); border: 2px solid var(--edge-dark); box-shadow: inset 1px 1px 0 var(--edge-light); }
.strip-icon img { width: 96px; height: 88px; object-fit: contain; }
.strip-info { flex: 1; min-width: 0; }
.strip-info h3 { margin: 4px 0 2px; font: 400 25px var(--serif); color: #f3ecd8; }
.listed { margin: 0 0 8px; font: 22px var(--serif); color: #e2dac5; }
.listed strong { font-weight: 400; margin-left: 4px; }
.gold {
  width: 100%; height: 48px; font: 25px var(--serif); color: var(--gold-txt);
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-lo));
  border-color: #3b2f1a !important; box-shadow: inset 1px 1px 0 #e8d196, inset -1px -2px 0 #6f5a30 !important;
}
.gold:hover { filter: brightness(1.07); }
.note { margin: 6px 0 0; font: 17px var(--ui); color: #d8d0bc; text-align: center; }
.list-form { display: flex; flex-direction: column; gap: 8px; }
.list-form .listed { display: flex; align-items: center; gap: 6px; margin: 0; }
.list-form input { width: 130px; height: 34px; background: #1f1c17; border: 2px solid var(--edge-dark); color: #f3ecd8; font: 20px var(--serif); padding: 0 8px; }

.planned { flex: 1; padding: 18px 16px; background: var(--panel-dark); border: 2px dashed #6b6250; font: 20px/1.45 var(--ui); color: var(--muted); }
.planned p { margin: 0 0 12px; }

.balance { height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 14px; background: var(--panel-dark); font: 22px var(--serif); color: #ece5d2; }
.balance strong { font-weight: 400; }
.balance img { width: 30px; height: auto; }
.balance .sep { width: 2px; height: 34px; background: #5a5140; margin: 0 auto; }
.sol { width: 28px; height: 22px; }
.foot { text-align: center; font: 16px var(--ui); color: #a49a84; }
.wallet { background: none; border: 0; box-shadow: none; padding: 2px 4px; font: 20px var(--serif); color: #ece5d2; cursor: pointer; white-space: nowrap; }
.wallet:hover { color: var(--tab-on); }
.faucet { position: absolute; left: 12px; bottom: 10px; font-size: 17px; }
.balance { position: relative; white-space: nowrap; }
.balance > span:first-child { white-space: nowrap; }

.chat-log a.tx { color: #1b3f7a; font: inherit; }
button:disabled { opacity: 0.55; cursor: progress; }

.mint-card { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 10px; background: var(--panel-dark); border: 2px solid var(--edge-dark); min-height: 0; }
.mint-banner { width: 100%; height: 190px; object-fit: cover; border: 2px solid var(--edge-dark); }
.mint-bar { height: 12px; background: #1f1c17; border: 2px solid var(--edge-dark); }
.mint-bar span { display: block; height: 100%; background: linear-gradient(180deg, var(--gold-hi), var(--gold-lo)); }
.mint-row { display: flex; justify-content: space-between; font: 20px var(--serif); color: #e2dac5; }
.mint-row strong { font-weight: 400; color: #f3ecd8; }

.wallet-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 12px; }
.wallet-choice { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 14px; background: var(--tab); font: 21px var(--serif); text-align: left; }
.wallet-choice img { width: 28px; height: 28px; }

/* ---------- purchase review sheet ---------- */
.modal { position: absolute; inset: 0; background: rgba(10, 8, 5, 0.55); display: grid; place-items: center; z-index: 5; }
.modal[hidden] { display: none; }
.sheet { width: 560px; padding: 20px 24px 22px; background: var(--panel); }
.sheet h2 { margin: 0 0 14px; text-align: center; font: 400 30px var(--serif); color: var(--title); text-shadow: 2px 2px 0 #000; }
.sheet-item { display: flex; gap: 14px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid #5a5140; }
.sheet-item img { width: 80px; height: 74px; object-fit: contain; background: var(--tile); border: 2px solid var(--edge-dark); }
.sheet-item h3 { margin: 0; font: 400 24px var(--serif); }
.muted { margin: 2px 0 0; font: 17px var(--ui); color: var(--muted); }
.lines { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 14px 0 6px; font: 21px var(--serif); }
.lines dt { color: #d2c9b2; }
.lines dd { margin: 0; text-align: right; color: #f3ecd8; }
.lines dd small { display: block; font: 15px var(--ui); color: var(--muted); }
.sheet-actions { display: flex; gap: 12px; margin-top: 16px; }
.sheet-actions .plain { flex: 0 0 130px; height: 48px; background: var(--tab); font-size: 22px; }

/* ---------- narrow screens: stack the scene, panel and chat ---------- */
@media (max-width: 820px) {
  body { display: block; }
  .viewport { overflow: visible; }
  .stage { width: auto; height: auto; transform: none !important; display: flex; flex-direction: column; }
  .world, .chat, .music, .panel { position: relative; left: auto; top: auto; }
  .world { width: 100%; height: auto; aspect-ratio: 1096 / 808; order: 1; }
  .panel { width: 100%; height: auto; order: 2; border-left: 0; padding: 0 16px 12px; }
  .chat { width: auto; height: 116px; margin: 8px 16px 0; order: 3; }
  .music { order: 4; margin: 8px 16px 16px; }
  .title { font-size: 32px; }
  .map-box { display: none; }
  .grid { height: auto; overflow: visible; grid-auto-rows: 128px; gap: 8px; }
  .strip { height: auto; }
  .sheet { width: calc(100vw - 32px); }
  .modal { position: fixed; }
  .slot img { width: 84px; height: 76px; }
  .slot .price { font-size: 18px; }
  .balance { font-size: 18px; gap: 8px; padding: 0 10px; }
  .balance span:first-child { white-space: nowrap; }
  .tab { font-size: 18px; }
  .tab[data-tab="launchpad"] { font-size: 16px; }
}
