:root { --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --ink: #1b1626; --panel: #2a2140; --panel2: #3b2f5c; --edge: #f3e6c8; --gold: #ffd23a; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #14213d; position: fixed; inset: 0; overscroll-behavior: none; touch-action: manipulation; }
body { font: 700 13px/1.2 ui-monospace, Menlo, Consolas, monospace; color: #fff; letter-spacing: .5px; }
#cv { position: fixed; inset: 0; width: 100vw; height: 100%; display: block; image-rendering: pixelated; touch-action: none; }
.hide { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
.ic { display: inline-block; width: 18px; height: 18px; background-size: 100% 100%; image-rendering: pixelated; flex: none; }
/* pixel panel look */
.pill, .card, #rollBtn, .sq, .btn, .slot, .shopItem, .mapCard, #speedBtn, #fStats, .stat { border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px rgba(255,255,255,.18), 0 3px 0 var(--ink); border-radius: 6px; }
#hud { position: fixed; left: 0; right: 0; top: 0; padding: calc(var(--sat) + 6px) 8px 0; display: flex; flex-direction: column; gap: 6px; pointer-events: none; z-index: 5; }
#hud .row { display: flex; gap: 6px; align-items: center; }
.pill { background: var(--panel); padding: 3px 7px; display: flex; align-items: center; gap: 5px; height: 30px; }
.pill b { font-size: 14px; text-shadow: 0 2px 0 var(--ink); }
.pill.hp { flex: 1; }
.pill .bar { flex: 1; height: 18px; background: #12101c; border: 2px solid var(--ink); position: relative; border-radius: 3px; overflow: hidden; }
.pill .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: linear-gradient(#7cf26a 0 45%, #3fb83a 45%); transition: width .35s; }
.pill .bar i.low { background: linear-gradient(#ff7a6a 0 45%, #d23a3a 45%); }
.pill .bar b { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 14px; }
.pill.gold { min-width: 86px; justify-content: flex-start; color: var(--gold); }
.pill.gold.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.15); } }
.pill.small { min-width: 58px; }
.pill.info { flex: 1; justify-content: center; font-size: 11px; color: #f3e6c8; }
#bottom { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 10px calc(var(--sab) + 10px); display: flex; gap: 10px; align-items: flex-end; z-index: 5; }
#rollBtn { flex: 1; height: 74px; background: linear-gradient(#ffe36a 0 50%, #ffc21a 50%); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 28px; letter-spacing: 3px; box-shadow: inset 0 0 0 3px rgba(255,255,255,.45), 0 5px 0 var(--ink); transition: transform .08s; }
#rollBtn small { font-size: 11px; letter-spacing: 1px; opacity: .75; }
#rollBtn:active, .sq:active, .btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px rgba(255,255,255,.3), 0 0 0 var(--ink); }
#rollBtn.busy { filter: grayscale(.7) brightness(.8); }
#rollBtn.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.03); } }
.sq { width: 64px; height: 64px; background: var(--panel2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.sq .ic { width: 28px; height: 28px; }
.sq em { font-style: normal; font-size: 10px; }
.sq.dot::after { content: ''; position: absolute; width: 12px; height: 12px; background: #ff4a4a; border: 2px solid var(--ink); border-radius: 50%; margin: -44px 0 0 44px; }
#toast { position: fixed; left: 50%; top: calc(var(--sat) + 86px); transform: translateX(-50%); z-index: 30; pointer-events: none; display: flex; flex-direction: column; gap: 4px; align-items: center; }
#toast div { background: var(--panel); border: 3px solid var(--ink); border-radius: 6px; padding: 6px 12px; animation: toast 2.2s forwards; white-space: nowrap; font-size: 12px; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
/* fight overlay */
#fightUi { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 8px calc(var(--sab) + 8px); z-index: 6; display: flex; gap: 6px; align-items: stretch; }
#fSlots { display: grid; grid-template-columns: repeat(3, 34px); gap: 4px; }
#fSlots .slot { width: 34px; height: 34px; }
#fStats { flex: 1; background: rgba(30,22,50,.92); padding: 6px 8px; font-size: 11px; display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; align-content: center; }
#fStats .h { grid-column: 1 / -1; color: var(--gold); font-size: 12px; margin-bottom: 2px; }
#fStats span:nth-child(odd):not(.h) { color: #c9bfe0; }
#speedBtn { width: 52px; background: var(--panel2); font-size: 16px; }
/* modal */
#modal { position: fixed; inset: 0; z-index: 20; background: rgba(10,8,20,.62); display: flex; align-items: center; justify-content: center; padding: calc(var(--sat) + 10px) 10px calc(var(--sab) + 10px); animation: fade .18s; }
@keyframes fade { from { opacity: 0; } }
.card { background: var(--panel); width: 100%; max-width: 420px; max-height: 100%; padding: 14px; display: flex; flex-direction: column; gap: 10px; animation: pop .22s cubic-bezier(.3,1.6,.6,1); overflow: hidden; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.card h2 { margin: 0; font-size: 20px; text-align: center; color: var(--gold); text-shadow: 0 3px 0 var(--ink); letter-spacing: 2px; }
.card p { margin: 0; text-align: center; color: #e6dcf5; font-size: 13px; line-height: 1.45; }
.card .art { display: flex; justify-content: center; }
.card .art img { width: 96px; height: 96px; image-rendering: pixelated; }
.btns { display: flex; gap: 8px; }
.btn { flex: 1; min-height: 50px; padding: 6px 8px; background: var(--panel2); font-size: 14px; letter-spacing: 1px; }
.btn.go { background: linear-gradient(#ffe36a 0 50%, #ffc21a 50%); color: var(--ink); }
.btn.green { background: linear-gradient(#8ee06a 0 50%, #4fb83a 50%); color: var(--ink); }
.btn.red { background: linear-gradient(#ff8a7a 0 50%, #d8443c 50%); }
.btn:disabled { filter: grayscale(1) brightness(.6); }
.btn small { display: block; font-size: 10px; opacity: .8; }
.cost { color: var(--gold); }
.item { display: flex; gap: 10px; align-items: center; background: #1e1830; border-radius: 6px; padding: 8px; border: 2px solid var(--ink); }
.item img { width: 48px; height: 48px; image-rendering: pixelated; flex: none; }
.item .nm { font-size: 14px; }
.item .st { font-size: 11px; color: #d8d0ea; margin-top: 3px; line-height: 1.4; }
.up { color: #7cf26a; } .down { color: #ff6a6a; }
.r-common { color: #e1e6ea; } .r-rare { color: #6ab4ff; } .r-epic { color: #d08cff; } .r-boss { color: #ffc43a; }
/* gear screen */
.doll { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.slot { width: 52px; height: 52px; background: #1e1830; position: relative; display: flex; align-items: center; justify-content: center; }
.slot img { width: 40px; height: 40px; image-rendering: pixelated; }
.slot.e-rare { background: #1c2a4a; } .slot.e-epic { background: #34204a; } .slot.e-boss { background: #4a3818; }
.slot.empty::after { content: attr(data-l); font-size: 8px; color: #6e6488; }
.slot.sel { outline: 3px solid var(--gold); }
.portrait { width: 110px; height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.portrait img { width: 96px; height: 96px; image-rendering: pixelated; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.stat { background: #1e1830; padding: 4px; text-align: center; font-size: 10px; color: #c9bfe0; border-width: 2px; box-shadow: none; }
.stat b { display: block; font-size: 13px; color: #fff; }
.bag { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; overflow-y: auto; min-height: 60px; max-height: 30vh; padding: 2px; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.bag > .small { grid-column: 1 / -1; padding: 8px; }
.bag .slot { width: auto; aspect-ratio: 1; height: auto; }
.tabs { display: flex; gap: 6px; }
/* shop */
.shop { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; touch-action: pan-y; }
.shopItem { display: flex; gap: 8px; align-items: center; background: #1e1830; padding: 6px; border-width: 2px; }
.shopItem img { width: 44px; height: 44px; image-rendering: pixelated; flex: none; }
.shopItem .info { flex: 1; min-width: 0; }
.shopItem .btn { flex: none; width: 82px; min-height: 44px; }
.shopItem.sold { opacity: .4; }
/* title */
.maps { display: flex; flex-direction: column; gap: 8px; }
.mapCard { display: flex; align-items: center; gap: 10px; padding: 8px; background: #1e1830; text-align: left; width: 100%; }
.mapCard img { width: 64px; height: 64px; image-rendering: pixelated; flex: none; }
.mapCard .t { font-size: 15px; } .mapCard .s { font-size: 11px; color: #c9bfe0; margin-top: 3px; }
.mapCard.locked { filter: grayscale(1) brightness(.55); }
.mapCard.cur { outline: 3px solid var(--gold); }
.logo { display: flex; justify-content: center; }
.logo canvas { width: 100%; max-width: 360px; image-rendering: pixelated; }
.small { font-size: 11px; color: #a99fc2; text-align: center; }
