/* css/play.css: the game HUD laid over the full-screen paper island. */
html, body { height: 100%; overflow: hidden; background: #3e8aa3; overscroll-behavior: none; }
body.game { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#world { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; cursor: grab; }
#world.dragging { cursor: grabbing; }
#tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag { position: absolute; transform: translate(-50%, -100%); font: 600 11px/1 var(--fb); color: var(--ink); background: rgba(247, 240, 222, .92); padding: 4px 7px; border-radius: 6px; box-shadow: 0 1px 0 var(--line-2); white-space: nowrap; }
.tag.me { background: var(--terra); color: #fff8ec; }
.tag.npc { background: rgba(239, 228, 200, .85); color: var(--ink-2); font-weight: 500; }
.tag.npc b { font-family: var(--fl); font-size: 9px; letter-spacing: .12em; margin-left: 4px; color: var(--ink-3); font-weight: 400; }
.tag b.cz { font-family: var(--fl); font-size: 9px; letter-spacing: .12em; margin-left: 5px; padding: 1px 4px; border-radius: 4px; background: #c9a227; color: #2b2116; font-weight: 600; }
.tag.me b.cz { background: #f3d77a; }
.ware .cz-note { font-style: normal; font-size: 10px; letter-spacing: .06em; color: #8a6d12; margin-left: 2px; }
.bubble { position: absolute; transform: translate(-50%, -100%); max-width: 220px; font: 500 13px/1.3 var(--fb); background: var(--paper); color: var(--ink); padding: 7px 10px; border-radius: 10px; box-shadow: var(--lift); white-space: normal; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; border: 6px solid transparent; border-top-color: var(--paper); border-bottom: 0; transform: translateX(-50%); }
.marker { position: absolute; width: 18px; height: 10px; transform: translate(-50%, -50%); border: 2px solid var(--terra); border-radius: 50%; animation: ping 0.7s ease-out forwards; }
@keyframes ping { from { opacity: 1; transform: translate(-50%, -50%) scale(.6); } to { opacity: 0; transform: translate(-50%, -50%) scale(1.8); } }

/* loader: a sheet folding up */
.loader { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--paper) var(--grain); transition: opacity .6s ease; }
.loader.done { opacity: 0; pointer-events: none; }
.loader .fold { width: 120px; height: 84px; position: relative; perspective: 400px; margin: 0 auto 22px; }
.loader .fold i { position: absolute; left: 0; right: 0; bottom: 0; height: 42px; background: var(--terra); border-radius: 3px; transform-origin: bottom; animation: fold 1.6s ease-in-out infinite; box-shadow: var(--cut); }
.loader .fold i:nth-child(2) { background: var(--aegean); animation-delay: .25s; left: 18px; right: 18px; height: 64px; }
.loader .fold i:nth-child(3) { background: #e8dcc0; animation-delay: .5s; left: 44px; right: 44px; height: 80px; }
@keyframes fold { 0%, 100% { transform: rotateX(80deg); } 40%, 70% { transform: rotateX(0deg); } }
.loader p { font-family: var(--fd); font-size: 22px; margin: 0; text-align: center; }
.loader small { display: block; margin-top: 8px; font: 13px var(--fb); color: var(--ink-2); text-align: center; }

/* top bar */
.hud-top { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.hud-top .spacer { flex: 1; pointer-events: none; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-family: var(--fd); font-size: 19px; padding: 6px 12px 6px 8px; border-radius: 12px; background: var(--paper) var(--grain); box-shadow: var(--lift); }
.brand svg { width: 26px; height: 26px; }
.chip svg { width: 18px; height: 18px; }
.chip.live { color: #2f6b3a; } .chip.prelim { color: var(--terra-d); }
.iconbtn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--paper) var(--grain); box-shadow: 0 1px 0 var(--line-2); cursor: pointer; padding: 0; }
.iconbtn svg { width: 20px; height: 20px; }
button.chip { cursor: pointer; }

/* works panel */
.works { position: fixed; left: max(12px, env(safe-area-inset-left)); top: 66px; z-index: 9; width: 250px; padding: 12px 14px; }
.works h3, .panel-h { margin: 0 0 8px; font: 400 16px var(--fd); display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.works h3 button { border: 0; background: none; cursor: pointer; padding: 2px; }
.work { margin: 8px 0 10px; }
.work .t { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.work .s { font-size: 12px; color: var(--ink-2); margin: 2px 0 5px; }
.work .needs { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.work .needs span { display: inline-flex; align-items: center; gap: 3px; }
.work .needs svg { width: 14px; height: 14px; }
.works.collapsed .list { display: none; }
.works.collapsed { width: auto; }
.works.collapsed h3 { margin: 0; }

/* pack */
.pack { position: fixed; left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); z-index: 9; padding: 10px 12px; }
.pack .slots { display: grid; grid-template-columns: repeat(6, 38px); gap: 6px; margin-top: 6px; }
.slot { width: 38px; height: 38px; border-radius: 9px; background: var(--paper-2); box-shadow: inset 0 1px 2px rgba(60, 34, 18, .25); display: grid; place-items: center; position: relative; }
.slot svg { width: 26px; height: 26px; }
.slot.pop { animation: pop .4s ease; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
.pack .head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* action card */
.action { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 12; width: min(400px, calc(100vw - 24px)); padding: 14px 16px 16px; }
.action h4 { margin: 0; font: 400 19px var(--fd); }
.action .sub { font-size: 13px; color: var(--ink-2); margin: 3px 0 12px; }
.action .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.action .hint { font-size: 12.5px; color: var(--terra-d); margin-top: 10px; min-height: 1em; }
.action .x { position: absolute; top: 8px; right: 8px; border: 0; background: none; cursor: pointer; padding: 6px; }
.action .goods { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 10px; align-items: center; font-size: 14px; margin-bottom: 12px; }
.action .goods svg { width: 18px; height: 18px; vertical-align: -4px; margin-right: 4px; }
.progress { height: 6px; margin-top: 10px; }
.wares { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; max-height: 210px; overflow: auto; margin-bottom: 10px; }
.ware { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 7px 9px; border-radius: 8px; background: var(--paper-2); font-size: 13px; }
.ware button { border: 0; border-radius: 6px; background: var(--terra); color: #fff8ec; font-weight: 600; font-size: 12px; padding: 5px 8px; cursor: pointer; }
.ware button[disabled] { background: var(--ink-3); cursor: default; }

/* chat */
.chat { position: fixed; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); z-index: 9; width: 300px; display: flex; flex-direction: column; gap: 6px; }
.chat .log { max-height: 180px; overflow-y: auto; padding: 8px 10px; font-size: 13px; line-height: 1.35; display: flex; flex-direction: column; gap: 3px; }
.chat .log:empty { display: none; }
.chat .log b { font-weight: 700; }
.chat .log .sys { color: var(--ink-2); font-style: italic; }
.chat form { display: flex; gap: 6px; }
.chat input { flex: 1; min-width: 0; font: 14px var(--fb); color: var(--ink); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--paper) var(--grain); box-shadow: inset 0 1px 2px rgba(60, 34, 18, .15); }
.chat.collapsed .log, .chat.collapsed form { display: none; }
#chatToggle { display: none; }

.toasts { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 45; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { font-weight: 600; font-size: 14px; padding: 9px 14px; border-radius: 10px; background: var(--paper) var(--grain); box-shadow: var(--lift); animation: tin .25s ease; display: inline-flex; gap: 6px; align-items: center; }
.toast svg { width: 18px; height: 18px; }
.toast.bad { color: var(--terra-d); }
.toast.big { font: 400 20px var(--fd); padding: 12px 18px; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

.recenter { position: fixed; right: max(12px, env(safe-area-inset-right)); bottom: 260px; z-index: 9; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(40, 25, 12, .35); padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { position: relative; width: min(520px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 20px 22px; }
.modal-card h2 { font: 400 24px var(--fd); margin: 0 0 6px; }
.modal-card .x { position: absolute; top: 10px; right: 10px; border: 0; background: none; cursor: pointer; padding: 6px; }
.modal-card p { line-height: 1.5; }
.look-grid { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: start; }
.look-grid canvas { width: 120px; height: 240px; background: var(--paper-2); border-radius: 10px; }
.opt { margin-bottom: 10px; }
.opt .label { display: block; margin-bottom: 5px; }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.sw { width: 26px; height: 26px; border-radius: 7px; border: 2px solid transparent; cursor: pointer; box-shadow: 0 1px 0 var(--line-2); padding: 0; position: relative; }
.sw.on { border-color: var(--ink); }
.sw.locked { opacity: .35; }
.pill { font-size: 12px; padding: 5px 9px; border-radius: 7px; background: var(--paper-2); border: 1px solid var(--line); cursor: pointer; }
.pill.on { background: var(--ink); color: var(--paper); }
.pill.locked { opacity: .4; }
.field { width: 100%; font: 15px var(--fb); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: #fffaf0; color: var(--ink); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; margin: 12px 0; }
.kv span:nth-child(odd) { color: var(--ink-2); }
.board { width: 100%; border-collapse: collapse; font-size: 14px; }
.board td { padding: 6px 4px; border-bottom: 1px dashed var(--line); }
.board td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* race */
.race { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 25; width: min(420px, calc(100vw - 24px)); padding: 16px; text-align: center; }
.race[hidden] { display: none; }
.race .big { font: 400 34px var(--fd); font-variant-numeric: tabular-nums; }
.race .pads { display: flex; gap: 12px; justify-content: center; margin-top: 12px; }
.race .pads button { width: 110px; height: 70px; font: 400 18px var(--fd); }

/* phones and small windows */
@media (max-width: 860px), (max-height: 520px) {
  .brand span { display: none; }
  .hud-top { gap: 6px; }
  .hud-top .chip { padding: 5px 8px; font-size: 12px; }
  #online span, #clock span.lbl { display: none; }
  .works { top: 58px; width: 210px; padding: 10px 12px; }
  .pack { padding: 8px 9px; }
  .pack .slots { grid-template-columns: repeat(6, 32px); gap: 4px; }
  .slot { width: 32px; height: 32px; }
  .slot svg { width: 22px; height: 22px; }
  .chat { width: auto; max-width: 300px; }
  #chatToggle { display: grid; align-self: flex-end; }
  .chat .log { max-height: 120px; }
  .recenter { bottom: auto; top: 58px; right: max(12px, env(safe-area-inset-right)); }
  .action { bottom: auto; top: 58px; width: min(360px, calc(100vw - 24px)); padding: 12px 14px; }
}
@media (max-height: 520px) {
  .works { max-height: calc(100dvh - 150px); overflow: auto; }
  .action { left: auto; right: 60px; transform: none; top: 56px; max-height: calc(100dvh - 70px); overflow: auto; }
  .chat .log { max-height: 90px; }
  .pack .head .label { display: none; }
}
@media (max-width: 560px) {
  .works:not(.collapsed) { width: calc(100vw - 24px); }
  #dr span.lbl, #pointsBtn span.lbl, #questBtn span.lbl { display: none; }
  .pack .slots { grid-template-columns: repeat(6, 30px); }
  .slot { width: 30px; height: 30px; }
  .action { top: auto; bottom: 126px; left: 50%; transform: translateX(-50%); max-height: calc(100dvh - 196px); }
  .chat { bottom: max(12px, env(safe-area-inset-bottom)); }
  .chat:not(.collapsed) { left: 12px; right: 12px; max-width: none; bottom: 100px; z-index: 13; }
  .modal-card { padding: 18px 16px; }
  .look-grid { grid-template-columns: 90px 1fr; }
  .look-grid canvas { width: 90px; height: 180px; }
}
@media (max-width: 560px) {
  #online, #mode, #soundBtn { display: none; }
  #walletBtn span { display: none; }
  #walletBtn { padding: 8px 9px; }
  .hud-top { gap: 5px; }
  .brand { padding: 5px 7px; }
  .iconbtn { width: 34px; height: 34px; }
  .toast.big { font-size: 16px; padding: 10px 14px; }
}

/* the door: connect a wallet, make a character (above the HUD and modals, under the loader and toasts) */
.gate { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(40, 25, 12, .38); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.gate[hidden] { display: none; }
.gate-card { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; padding: 22px 24px 20px; }
.gate-card h2 { margin: 4px 0 10px; }
.gate-card .label { color: var(--ink-2); }
.wallet-list { display: grid; gap: 8px; margin: 16px 0 14px; }
.wallet-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; }
.wallet-btn img, .wallet-btn svg { width: 22px; height: 22px; border-radius: 6px; flex: none; }
.gate-note { margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; background: rgba(181, 69, 47, .1); color: #8a2f1d; font-size: 14px; }
.gate-note[hidden] { display: none; }
@media (max-width: 560px) { .gate-card { padding: 18px 16px 16px; } }

/* conversations and missions (js/game/talk.js) */
.action { max-height: min(70vh, 560px); overflow: auto; }
.action .say { font: 400 15px/1.45 var(--fd); margin: 2px 0 12px; color: var(--ink); }
.npc-chip { font: 400 9px var(--fl); letter-spacing: .12em; vertical-align: 3px; margin-left: 4px; padding: 2px 5px; border-radius: 4px; background: rgba(58, 38, 24, .08); color: var(--ink-3); }
.quest { border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 11px; margin: 0 0 8px; background: rgba(255, 252, 244, .6); }
.quest.ready { border-color: #c9a227; background: rgba(214, 166, 58, .12); }
.quest .qt { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.quest .qt span { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.quest .qg { font-size: 12.5px; color: var(--ink-2); margin: 5px 0 6px; }
.qbar { height: 5px; border-radius: 3px; background: rgba(58, 38, 24, .1); overflow: hidden; margin-top: 6px; }
.qbar i { display: block; height: 100%; background: var(--terra); border-radius: 3px; }
.quest.ready .qbar i { background: #c9a227; }
.linkbtn { border: 0; background: none; padding: 4px 2px; font: 500 12px var(--fb); color: var(--ink-3); text-decoration: underline; cursor: pointer; }
.offers { display: grid; gap: 6px; margin: 0 0 10px; }
.quest-offer { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 11px; background: #fffaf0; font: 500 14px var(--fb); color: var(--ink); cursor: pointer; }
.quest-offer:hover { border-color: var(--terra); }
.quest-offer span { flex: 1; }
.quest-offer em { font: 400 9px var(--fl); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-style: normal; }
.qm { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; font: 700 11px/1 var(--fb); font-style: normal; background: #c45b3c; color: #fff8ec; flex: none; }
.qm.ready { background: #c9a227; color: #2b2116; }
.tag .qm { width: 14px; height: 14px; font-size: 10px; margin-right: 4px; vertical-align: -2px; }
.talk-foot { margin-top: 8px; }
#questBtn { position: relative; }
#questBtn .qdot { position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: #c9a227; box-shadow: 0 0 0 2px var(--paper); }
.who { display: flex; flex-wrap: wrap; gap: 6px; }
.who .pill b { margin-left: 4px; color: var(--terra-d); }
