:root { --walnut:#2b1d12; --rust:#8a4b2a; --amber:#e0a243; --moss:#7fa35a; --cream:#f6e3c0; --danger:#e0523a; --ok:#8fc46a; --teal:#5fb3a8; --ink:#2a1608; --font: system-ui, sans-serif; }
html { font-size: calc(min(100vw, 56.25vh) / 24.75); }
* { box-sizing: border-box; scrollbar-width: none; -webkit-tap-highlight-color: transparent; }
*::-webkit-scrollbar { display: none; }
body { font-family: var(--font); color: var(--cream); }
button { font-family: inherit; color: inherit; }
img { -webkit-user-drag: none; }

#hud { position: fixed; top: 0; bottom: 0; left: 50%; width: min(100vw, 56.25vh); transform: translateX(-50%); pointer-events: none; z-index: 20; font-family: var(--font); font-weight: 800; font-size: 1rem; }
#hud.hidden { display: none; }
#hud > * { pointer-events: auto; }
#hud .txt, #hud, .btn, .chip, .tag { text-shadow: -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink), 1px 1px 0 var(--ink), 0 2px 4px rgba(0,0,0,.6); }

/* panels */
.panel { border-style: solid; border-width: .9rem; border-image: url(assets/ui-panel.webp) 22% fill / .9rem stretch; background: none; }
.card { display: flex; gap: .6rem; align-items: center; border-style: solid; border-width: .8rem; border-image: url(assets/ui-panel.webp) 22% fill / .8rem stretch; padding: .1rem .2rem; margin: .1rem 0 .5rem; }
.card .ico { width: 3rem; height: 3rem; object-fit: contain; flex: none; }
.card .ctitle { font-size: 1rem; line-height: 1.2; }
.card .cdesc { font-size: max(12.5px, .8rem); font-weight: 600; opacity: .9; line-height: 1.25; }
.card .cbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .25rem; }
.card .btns { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }

/* top rows */
.toprow { position: absolute; left: .5rem; right: 4rem; top: .5rem; display: flex; gap: .5rem; align-items: stretch; }
.clock { padding: 0; min-width: 9.6rem; border-width: .7rem; border-image-width: .7rem; border-image: url(assets/ui-panel.webp) 22% fill / .7rem stretch; display: flex; flex-direction: column; justify-content: center; line-height: 1.1; padding: 0 .1rem; }
.clock .l1 { font-size: .8rem; white-space: nowrap; }
.clock .l2 { font-size: 1.5rem; letter-spacing: .04em; }
.goldchip { align-self: center; display: flex; align-items: center; gap: .3rem; padding: .3rem .7rem .3rem .4rem; background: rgba(30,18,8,.72); border: .12rem solid var(--rust); border-radius: 1rem; font-size: 1.1rem; min-height: 2.2rem; }
.goldchip img { width: 1.6rem; height: 1.6rem; object-fit: contain; }
.powerbadge { align-self: center; background: var(--danger); border-radius: .8rem; padding: .2rem .5rem; font-size: .8rem; animation: blink 1s infinite; display: none; }
.powerbadge.on { display: block; }
@keyframes blink { 50% { opacity: .55; } }

.speedrow { position: absolute; left: .5rem; right: .5rem; display: flex; gap: .4rem; }
.speedrow .btn.small { flex: 1; padding: 0; min-width: 0; min-height: max(46px, 2.8rem); font-size: .8rem; white-space: nowrap; border-width: .4rem; border-image-width: .4rem; }
.speedrow .btn.active { filter: brightness(1.35) saturate(1.3) drop-shadow(0 0 .35rem var(--amber)); }
.tankrow { position: absolute; left: .5rem; right: .5rem; display: flex; gap: .5rem; align-items: center; }
.tankrow .name { flex: 1; text-align: center; font-size: 1rem; min-height: 2.75rem; display: flex; align-items: center; justify-content: center; padding: 0 .4rem; background: rgba(30,18,8,.72); border: .12rem solid var(--rust); border-radius: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catrow { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; overscroll-behavior: contain; scrollbar-width: none; margin-bottom: 8px; padding-bottom: 2px; }
.catrow::-webkit-scrollbar { display: none; }
.catrow .btn { flex: none; white-space: nowrap; }
.tankrow .arrow { width: max(46px, 2.75rem); min-width: 46px; padding: 0; flex: none; font-size: 1.1rem; }
.warnbadge { min-width: max(46px, 2.75rem); height: max(46px, 2.75rem); border-radius: 1.4rem; display: none; align-items: center; justify-content: center; font-size: .95rem; padding: 0 .6rem; cursor: pointer; border: .15rem solid var(--ink); background: var(--amber); color: var(--cream); }
.warnbadge.on { display: flex; }
.warnbadge[data-lv="1"] { background: #b88a2a; }
.warnbadge[data-lv="2"] { background: #d0702a; }
.warnbadge[data-lv="3"] { background: var(--danger); animation: blink 1s infinite; }

/* toasts */
.toasts { position: absolute; left: .5rem; right: .5rem; display: flex; flex-direction: column; gap: .35rem; align-items: center; pointer-events: none !important; }
.toast { pointer-events: none; padding: .1rem .3rem; font-size: .9rem; text-align: center; animation: pop .26s cubic-bezier(.3,1.7,.5,1) both; border-width: .6rem; border-image: url(assets/ui-panel.webp) 22% fill / .6rem stretch; max-width: 100%; }
.toast.good { filter: drop-shadow(0 0 .3rem var(--ok)); color: #d7f2b8; }
.toast.bad { filter: drop-shadow(0 0 .3rem var(--danger)); color: #ffc4b6; }
.toast.out { animation: fadeout .3s forwards; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeout { to { opacity: 0; transform: translateY(-.5rem); } }

/* dialog bubble */
.bubble { position: absolute; left: .5rem; right: .5rem; bottom: calc(max(46px, 2.8rem) + 5.2rem + env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: .4rem; animation: slideup .28s cubic-bezier(.3,1.5,.5,1) both; }
.bubble.out { animation: slidedown .22s forwards; }
.bubble .portrait { width: 4.4rem; height: 4.4rem; flex: none; border-radius: .8rem; border: .15rem solid var(--rust); object-fit: cover; background: var(--walnut); }
.bubble .bt { flex: 1; font-size: .95rem; line-height: 1.3; font-weight: 700; padding: .1rem .2rem; border-width: .8rem; border-image: url(assets/ui-panel.webp) 22% fill / .8rem stretch; }
.bubble.radio .bt { border-image: none; background: rgba(60,38,8,.92); border: .15rem solid var(--amber); border-radius: .8rem; padding: .5rem .7rem; color: #ffe2a0; }
.bubble .badge { font-size: 2rem; flex: none; }
@keyframes slideup { from { transform: translateY(3rem); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slidedown { to { transform: translateY(3rem); opacity: 0; } }

/* vitals + tabs */
.vitals { position: absolute; left: .5rem; right: .5rem; bottom: calc(4.6rem + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(7, 1fr); gap: .25rem; cursor: pointer; transition: transform .2s, opacity .2s; }
.vitals.hide { transform: translateY(5rem); opacity: 0; pointer-events: none; }
.vchip { background: rgba(30,18,8,.78); border: .1rem solid var(--rust); border-radius: .6rem; padding: .25rem 0; min-height: max(46px, 2.8rem); display: flex; flex-direction: column; justify-content: center; text-align: center; line-height: 1.1; min-width: 0; }
.vchip small { display: block; font-size: max(12px, .75rem); font-weight: 700; color: #d9c29a; }
.vchip b { font-size: .88rem; }
.vchip[data-s="bad"] { border-color: var(--danger); background: rgba(120,30,16,.8); }
.vchip[data-s="bad"] b { color: #ffb4a4; }
.vchip[data-s="ok"] b { color: #d4f0b0; }
.tabbar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: .2rem; padding: .3rem .4rem calc(.3rem + env(safe-area-inset-bottom)); border-top: .2rem solid var(--rust); background: linear-gradient(#3a2616, #22160c); z-index: 3; }
.tab { flex: 1; min-width: 0; height: 3.6rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .05rem; background: rgba(0,0,0,.25); border: .1rem solid transparent; border-radius: .7rem; font-size: max(12px, .78rem); padding: 0; cursor: pointer; transition: transform .12s; }
.tab .ti { font-size: 1.5rem; height: 1.8rem; line-height: 1.8rem; }
.tab img { width: 1.8rem; height: 1.8rem; object-fit: contain; }
.tab.active { background: rgba(224,162,67,.28); border-color: var(--amber); transform: translateY(-.15rem); }
.tab:active { transform: scale(.94); }

/* sheet */
.sheet { position: absolute; left: 0; right: 0; bottom: calc(4.2rem + env(safe-area-inset-bottom)); height: 54%; display: flex; flex-direction: column; transform: translateY(110%); visibility: hidden; transition: transform .24s cubic-bezier(.3,1.35,.5,1), visibility 0s .24s; z-index: 2; border-width: 1rem .9rem .6rem; border-image: url(assets/ui-panel.webp) 22% fill / 1rem .9rem .6rem stretch; }
.sheet.open { transform: none; visibility: visible; transition: transform .24s cubic-bezier(.3,1.35,.5,1), visibility 0s; }
.sheet .shead { display: flex; align-items: center; gap: .5rem; min-height: 2.75rem; flex: none; }
.sheet .stitle { flex: 1; font-size: 1.15rem; }
.sheet .scontent { flex: 1; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding: .2rem .1rem .6rem; }
.xbtn { width: max(46px, 2.75rem); min-width: 46px; height: max(46px, 2.75rem); padding: 0; flex: none; font-size: 1.1rem; }

/* modal + banner */
.modalwrap { position: absolute; inset: 0; background: rgba(8,5,2,.6); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 1rem; animation: fadein .2s both; }
.modal { width: 100%; max-width: 22rem; max-height: 85%; display: flex; flex-direction: column; animation: pop .26s cubic-bezier(.3,1.6,.5,1) both; border-width: 1rem; border-image: url(assets/ui-panel.webp) 22% fill / 1rem stretch; }
.modal .mhead { display: flex; align-items: center; min-height: 2.75rem; gap: .5rem; flex: none; }
.modal .mtitle { flex: 1; font-size: 1.15rem; }
.modal .mbody { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; flex: 1; padding: .3rem 0; font-size: .95rem; line-height: 1.35; }
.modal .mbtns { display: flex; gap: .6rem; justify-content: center; margin-top: .6rem; }
.modal .mbtns .btn { flex: 1; }
@keyframes fadein { from { opacity: 0; } }
.banner { position: absolute; left: 0; right: 0; top: 36%; text-align: center; font-size: 2rem; padding: 0 1rem; pointer-events: none !important; color: #ffe29a; z-index: 12; text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink), 0 5px 0 var(--ink), 0 0 18px rgba(224,162,67,.8) !important; animation: slam 1.7s both; }
@keyframes slam { 0% { transform: scale(3); opacity: 0; } 14% { transform: scale(.92); opacity: 1; } 22% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1.05) translateY(-1rem); } }

/* buttons */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 2.75rem; padding: 0 .9rem; font-size: .95rem; font-weight: 800; cursor: pointer; border-style: solid; border-width: .6rem; border-image: url(assets/ui-button.webp) 30% fill / .6rem stretch; background: none; outline: none; transition: filter .12s, transform .12s; -webkit-appearance: none; appearance: none; }
.btn .bico { width: 1.4rem; height: 1.4rem; object-fit: contain; }
.btn.primary { filter: brightness(1.18) saturate(1.25); }
.btn.small { min-height: max(46px, 2.75rem); padding: 0 .55rem; font-size: .85rem; }
.btn.pressed { animation: squash .18s; }
@keyframes squash { 0% { transform: scale(.92); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
.btn.disabled { filter: grayscale(.85) brightness(.7); cursor: default; }
.btn:active { transform: scale(.94); }
.focus { filter: drop-shadow(0 0 .45rem var(--amber)) drop-shadow(0 0 .15rem #ffd27a) brightness(1.2); transform: scale(1.04); }
.btn.focus.primary { filter: brightness(1.3) saturate(1.25) drop-shadow(0 0 .45rem var(--amber)); }
body:not(.kbd) .focus { filter: none; transform: none; }
body:not(.kbd) .btn.primary.focus { filter: brightness(1.18) saturate(1.25); }
body:not(.kbd) .speedrow .btn.active.focus { filter: brightness(1.35) saturate(1.3) drop-shadow(0 0 .35rem var(--amber)); }
.tab.focus, .vitals.focus, .warnbadge.focus { outline: .15rem solid var(--amber); }
body:not(.kbd) .tab.focus, body:not(.kbd) .vitals.focus, body:not(.kbd) .warnbadge.focus { outline: none; }

/* bars, chips, tags, price */
.bar { position: relative; height: .9rem; border-radius: .5rem; background: #140c06; border: .1rem solid #000; box-shadow: inset 0 .15rem .25rem rgba(0,0,0,.7); overflow: hidden; flex: 1; }
.bar .band { position: absolute; top: 0; bottom: 0; background: rgba(127,163,90,.55); }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#f3b858, #c27f24); border-radius: .5rem; transition: width .3s; }
.bar[data-state=bad] .fill { background: linear-gradient(#f06a50, #b03420); }
.bar[data-state=ok] .fill { background: linear-gradient(#a8d884, #5f8a3c); }
.chip { display: inline-flex; align-items: center; gap: .25rem; padding: .15rem .6rem; background: rgba(30,18,8,.72); border: .1rem solid var(--rust); border-radius: 1rem; font-size: .85rem; font-weight: 800; min-height: 1.6rem; }
.chip .cico { width: 1.2rem; height: 1.2rem; object-fit: contain; }
.chip.good { border-color: var(--ok); } .chip.bad { border-color: var(--danger); }
.price { display: inline-flex; align-items: center; gap: .2rem; font-weight: 800; }
.price .cico, .cico { width: 1.1rem; height: 1.1rem; object-fit: contain; }
.tag { display: inline-block; padding: .05rem .5rem; border-radius: .6rem; background: rgba(0,0,0,.4); border: .1rem solid var(--teal); font-size: max(12px, .78rem); font-weight: 800; }
.tag.bad { border-color: var(--danger); color: #ffb4a4; }
.tag.good { border-color: var(--ok); color: #d4f0b0; }
.muted { opacity: .7; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: .4rem; }
.section { margin: .2rem 0 .7rem; }
.section-title { font-size: .95rem; color: var(--amber); border-bottom: .12rem solid var(--rust); padding-bottom: .15rem; margin-bottom: .4rem; }
