:root {
  --ink: #2b2118; --paper: #fff8ec; --paper2: #f6ead6; --line: #e3d2b5; --brand: #c8553d; --brand2: #2f6f5e; --gold: #e0a526;
  --shadow: 0 10px 30px rgba(40, 25, 10, .28);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Avenir Next", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9cc6e4; color: var(--ink); user-select: none; -webkit-user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#game:active { cursor: grabbing; }
.hidden { display: none !important; }
kbd { display: inline-block; min-width: 1.7em; padding: .12em .45em; margin: 0 .12em; border-radius: 7px; background: #fff; border: 1px solid #cdbb9c; border-bottom-width: 3px; font: 700 .82em ui-monospace, Menlo, monospace; text-align: center; color: var(--ink); }
button { font: inherit; cursor: pointer; border: 0; border-radius: 14px; padding: .65em 1.1em; font-weight: 800; background: var(--paper2); color: var(--ink); border: 2px solid var(--line); transition: transform .08s, background .15s; }
button:hover:not(:disabled) { transform: translateY(-1px); background: #fff; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--brand); border-color: #a23f2b; color: #fff; }
button.primary:hover:not(:disabled) { background: #d9644b; }
button.green { background: var(--brand2); border-color: #23564a; color: #fff; }
button.green:hover:not(:disabled) { background: #3a8571; }
button.big { font-size: 1.25rem; padding: .8em 2em; border-radius: 18px; }
button.ghost { background: transparent; border-color: transparent; font-weight: 700; color: #7a6650; padding: .3em .6em; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#topleft { position: absolute; left: 18px; top: 16px; display: flex; flex-direction: column; gap: 10px; width: 330px; }
.chip { display: inline-flex; align-items: center; gap: 12px; align-self: flex-start; background: rgba(255, 248, 236, .93); border: 2px solid var(--line); border-radius: 999px; padding: 7px 16px; box-shadow: 0 4px 14px rgba(40, 25, 10, .18); font-weight: 700; font-size: 15px; }
#clockTime { color: #7a6650; font-variant-numeric: tabular-nums; }
#objective { background: rgba(43, 33, 24, .78); color: #fff; border-radius: 16px; padding: 10px 14px; backdrop-filter: blur(6px); box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
.lbl { font-size: 11px; letter-spacing: .14em; font-weight: 800; opacity: .7; }
#objText { font-weight: 700; font-size: 15px; line-height: 1.3; margin-top: 2px; }
#alerts { display: flex; flex-direction: column; gap: 6px; }
.alert { background: rgba(255, 248, 236, .95); border: 2px solid #e8452e; border-left-width: 8px; border-radius: 12px; padding: 7px 11px; font-size: 13.5px; line-height: 1.3; box-shadow: 0 4px 12px rgba(40, 25, 10, .18); }
.alert b { display: block; font-size: 14px; }
.alert span { color: #7a6650; }
#topright { position: absolute; right: 18px; top: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#miniWrap { position: relative; width: 230px; height: 230px; border-radius: 50%; overflow: hidden; border: 5px solid var(--paper); box-shadow: var(--shadow); background: #b9d8a0; }
#minimap { width: 100%; height: 100%; display: block; }
#district { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
#keys { display: flex; gap: 10px; font-size: 12.5px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); }
#bottom { position: absolute; left: 0; right: 0; bottom: 26px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
#prompt { position: relative; display: flex; align-items: center; gap: 10px; background: rgba(255, 248, 236, .96); border: 2px solid var(--line); border-radius: 16px; padding: 10px 18px; font-weight: 800; font-size: 17px; box-shadow: var(--shadow); overflow: hidden; }
#promptHold { position: absolute; left: 0; bottom: 0; height: 5px; width: 100%; }
#promptHold i { display: block; height: 100%; width: 0; background: var(--brand); }
#modeHint { font-size: 13px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
#stamina { width: 260px; text-align: center; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
.bar { height: 12px; border-radius: 99px; background: rgba(43, 33, 24, .35); overflow: hidden; border: 2px solid rgba(255, 255, 255, .7); }
.bar i { display: block; height: 100%; border-radius: 99px; background: #6cc070; transition: width .2s; }
#toasts { position: absolute; right: 18px; top: 300px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: min(420px, 60vw); }
.toast { background: rgba(43, 33, 24, .88); color: #fff; padding: 9px 18px; border-radius: 999px; font-weight: 700; font-size: 15px; animation: tin .25s ease-out, tout .4s ease-in 3.4s forwards; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); border-radius: 18px; text-align: right; }
.toast.warn { background: #c8372a; }
.toast.good { background: #2f7d5e; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }
@keyframes tout { to { opacity: 0; transform: translateY(-8px); } }
#banner { position: absolute; left: 0; right: 0; top: 34%; text-align: center; color: #fff; text-shadow: 0 3px 16px rgba(0, 0, 0, .55); animation: bin .5s cubic-bezier(.2, 1.4, .4, 1); }
#bannerSmall { font-size: 15px; letter-spacing: .3em; font-weight: 800; }
#bannerBig { font: 800 58px/1.05 Georgia, "Times New Roman", serif; margin: 6px 0; }
#bannerSub { font-size: 19px; font-weight: 700; }
@keyframes bin { from { opacity: 0; transform: scale(.85); } }

/* ---------- panels ---------- */
.panel { position: fixed; right: 22px; bottom: 22px; width: 380px; background: var(--paper); border: 3px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 16px; animation: pin .2s ease-out; }
@keyframes pin { from { opacity: 0; transform: translateY(14px); } }
.hp-head { display: flex; gap: 12px; align-items: center; }
.portrait { width: 92px; height: 92px; border-radius: 18px; background: linear-gradient(#cfe6f3, #e9f2d9); border: 2px solid var(--line); object-fit: cover; flex: none; }
.portrait.unknown { filter: brightness(0) opacity(.35); }
.hp-head h2 { margin: 0; font: 800 26px/1.1 Georgia, serif; }
.sub { color: #7a6650; font-size: 13.5px; font-weight: 600; }
.rar { display: inline-block; padding: 2px 9px; border-radius: 99px; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.hearts { color: var(--brand); letter-spacing: 2px; font-size: 16px; }
.hearts i { color: #dccbb0; font-style: normal; }
.about { font-size: 14px; line-height: 1.4; margin: 12px 0; color: #54463a; }
.need { display: grid; grid-template-columns: 78px 1fr 34px; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; margin: 6px 0; }
.need .bar { height: 11px; border-color: var(--line); background: #efe2cb; }
.need.low { color: #c8372a; }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.acts button { padding: .6em .4em; font-size: 14.5px; }
.acts .wide { grid-column: 1 / -1; }
.note { font-size: 12.5px; color: #7a6650; margin-top: 8px; line-height: 1.35; }
.close { position: absolute; right: 10px; top: 8px; }

.overlay { position: fixed; inset: 0; background: rgba(30, 22, 14, .55); backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; z-index: 5; }
.sheet { background: var(--paper); border: 3px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); padding: 22px 24px; max-width: min(1100px, 94vw); max-height: 92vh; display: flex; flex-direction: column; position: relative; }
.sheet h2 { margin: 0 0 2px; font: 800 30px Georgia, serif; }
.sheet-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 12px; padding-right: 70px; }
.jr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(230px, 320px); gap: 18px; min-height: 0; flex: 1; width: min(1010px, 88vw); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; overflow-y: auto; padding: 4px; align-content: start; max-height: 68vh; }
.card { background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 7px; text-align: center; cursor: pointer; position: relative; font-weight: 800; font-size: 13.5px; transition: transform .08s; }
.card:hover { transform: translateY(-2px); }
.card.sel { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(200, 85, 61, .25); }
.card img { width: 100%; aspect-ratio: 1; border-radius: 11px; background: linear-gradient(#cfe6f3, #e9f2d9); display: block; margin-bottom: 4px; }
.card.unk img { filter: grayscale(.75) brightness(.72) contrast(.9); }
.card.unk { color: #8a7a66; background: #f4ecdd; }
.card .tag { position: absolute; left: 10px; top: 10px; font-size: 10px; padding: 2px 7px; border-radius: 99px; background: var(--brand2); color: #fff; }
.card .bang { position: absolute; right: 9px; top: 9px; width: 20px; height: 20px; border-radius: 50%; background: #e8452e; color: #fff; font-size: 13px; line-height: 20px; }
.card .dot { height: 5px; border-radius: 9px; margin-top: 4px; }
.detail { background: var(--paper2); border-radius: 18px; padding: 14px; overflow-y: auto; }
.mapwrap { display: grid; grid-template-columns: auto minmax(200px, 290px); gap: 18px; min-height: 0; }
#bigmap { width: min(76vh, 58vw); height: min(76vh, 58vw); border-radius: 18px; border: 3px solid var(--line); display: block; }
.stlist { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.st { background: #fff; border: 2px solid var(--line); border-left: 10px solid #999; border-radius: 12px; padding: 8px 10px; font-size: 13px; line-height: 1.35; }
.st b { font-size: 14.5px; display: block; }
.st.unk { opacity: .6; border-left-color: #bbb; }
.st .warn { color: #c8372a; font-weight: 800; }
.legend { font-size: 12.5px; color: #7a6650; line-height: 1.7; margin-top: 4px; }
.help { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 26px; font-size: 15px; margin: 8px 0 16px; }
.help div { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px dashed var(--line); padding: 5px 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; display: flex; align-items: center; justify-content: flex-start; padding-left: 7vw; z-index: 10; background: linear-gradient(90deg, rgba(30, 20, 12, .62), rgba(30, 20, 12, .12) 60%, transparent); }
#titleCard { color: #fff; max-width: 560px; text-shadow: 0 2px 14px rgba(0, 0, 0, .5); }
.kicker { letter-spacing: .32em; font-size: 13px; font-weight: 800; opacity: .9; }
#title h1 { font: 800 clamp(54px, 8vw, 104px)/.95 Georgia, "Times New Roman", serif; margin: 12px 0 18px; }
#loadText { font-size: 18px; font-weight: 700; min-height: 1.4em; }
#titleBtns { display: flex; gap: 12px; margin: 18px 0 26px; }
#title .controls { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; font-weight: 700; opacity: .95; }

.binds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 22px; margin: 6px 0 10px; }
.bindrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14.5px; font-weight: 700; }
.bindrow button { min-width: 132px; padding: .45em .7em; font-size: 14px; }

.sw { display: inline-block; width: 13px; height: 13px; border-radius: 3px; vertical-align: -2px; }
.legend b { color: var(--ink); }

.pic { position: relative; flex: none; }
.lock { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 30px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .5)); }
.hp-head .lock { font-size: 34px; }
.portrait.locked { filter: grayscale(.75) brightness(.72); }
.card .lockedtag { font-size: 9px; letter-spacing: .05em; }
.unlock { background: #fff; border: 2px dashed var(--line); border-radius: 14px; padding: 10px 12px; font-size: 14px; line-height: 1.4; margin-top: 12px; color: #54463a; }
.unlock > b:first-child { display: block; margin-bottom: 4px; color: var(--ink); }

#objective, #alerts .alert, #inv, #payday { pointer-events: auto; cursor: pointer; }
#objective:hover { background: rgba(43, 33, 24, .92); }
#alerts .alert:hover { background: #fff; }
.spk { font-size: 11px; opacity: .75; margin-left: 4px; }
#payday { font-size: 13.5px; padding: 6px 14px; }
#payday.short { border-color: #e8452e; color: #c8372a; }
#coinChip.pop { animation: coinpop .5s ease-out; display: inline-block; }
@keyframes coinpop { 30% { transform: scale(1.5); color: #c88a10; } }
.handpic { display: flex; align-items: center; justify-content: center; font-size: 54px; }
#titleBtns { flex-direction: column; gap: 10px; max-width: 520px; }
.slot { display: flex; align-items: center; gap: 12px; background: rgba(255, 248, 236, .95); border: 2px solid var(--line); border-radius: 18px; padding: 10px 12px 10px 18px; color: var(--ink); text-shadow: none; box-shadow: var(--shadow); }
.slot > div { flex: 1; display: flex; flex-direction: column; line-height: 1.3; }
.slot b { font-size: 18px; }
.slot span { font-size: 13px; color: #7a6650; font-weight: 600; }
.slot.empty { background: rgba(255, 248, 236, .78); }
.slot button.big { font-size: 1rem; padding: .6em 1.2em; }

.codebox { background: rgba(43, 33, 24, .72); border-radius: 14px; padding: 10px 14px; font-size: 14px; line-height: 1.5; text-shadow: none; }
.codebox b { font-family: ui-monospace, Menlo, monospace; background: rgba(255, 255, 255, .16); padding: 2px 7px; border-radius: 7px; user-select: text; -webkit-user-select: text; }
.codebox span { opacity: .8; font-size: 12.5px; }
.codebox .ghost { color: #ffe9b0; text-decoration: underline; }

.chipbtn { pointer-events: auto; align-self: flex-start; border-radius: 999px; padding: 6px 14px; font-size: 13.5px; background: #f2c230; border-color: #c89a10; color: #3a2a08; box-shadow: 0 4px 14px rgba(40, 25, 10, .18); }
.chipbtn:hover:not(:disabled) { background: #ffd95a; }
.earnlist { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.earn { display: flex; gap: 14px; background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 12px 14px; font-size: 14px; line-height: 1.45; color: #54463a; }
.earn .ico { font-size: 34px; line-height: 1; }
.earn b:first-child { display: block; font-size: 16px; color: var(--ink); margin-bottom: 2px; }
.earn .row { margin-top: 8px; }
.earn .row button { font-size: 13px; padding: .45em .8em; }
