/* Layout: full-bleed canvas world with a game HUD pinned to the edges; panels rise as bottom sheets on phones and float centred on wide screens. */
:root {
  --bg: #12161a; --panel: #1c2328; --panel2: #27313a; --deep: #103d41; --pri: #1f6e73; --acc: #e0632b; --gold: #e4b65c;
  --sand: #d9be8a; --tx: #f5eedf; --mut: #9aa6ae; --line: #34404a; --frame: #c59a55; --bad: #d94236; --ok: #5cbf6a; --vio: #a066e0;
  --f-disp: 'Kufam', 'Cairo', system-ui, sans-serif; --f-ui: 'Cairo', system-ui, sans-serif;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--tx); font-family: var(--f-ui); overflow: hidden; -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; cursor: grab; }
button { font-family: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; }
.ic { width: 22px; height: 22px; object-fit: contain; vertical-align: middle; }
.ic.sm { width: 16px; height: 16px; } .ic.lg { width: 40px; height: 40px; }
b, .num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.top { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 8px); right: max(10px, env(safe-area-inset-right, 0px)); left: max(10px, env(safe-area-inset-left, 0px)); display: flex; align-items: center; gap: 10px; }
.top .sp { flex: 1; }
.player { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; text-align: right; }
.av { position: relative; width: 54px; height: 54px; border-radius: 50%; border: 3px solid var(--frame); overflow: visible; background: var(--panel2); box-shadow: 0 3px 10px #0008; }
.av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.av b { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); background: var(--acc); color: #1a1208; font-weight: 900; font-size: 12px; padding: 0 7px; border-radius: 9px; border: 1.5px solid #fff3; }
.pinfo { display: flex; flex-direction: column; gap: 2px; text-shadow: 0 1px 4px #000; font-weight: 700; font-size: 14px; }
.pw { display: inline-flex; align-items: center; gap: 4px; background: #0009; border-radius: 10px; padding: 1px 10px; color: var(--gold); font-weight: 900; font-size: 13px; }
.pw img { width: 15px; height: 15px; }
.gems { display: flex; align-items: center; gap: 6px; background: #000a; border: 1px solid var(--frame); border-radius: 18px; padding: 4px 6px 4px 12px; font-weight: 900; }
.gems img { width: 22px; } .gems i { font-style: normal; background: var(--ok); color: #111; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; }
.res-bar { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 72px); right: max(10px, env(safe-area-inset-right, 0px)); left: max(10px, env(safe-area-inset-left, 0px)); display: flex; justify-content: space-between; gap: 4px; background: #0b0e11d0; border: 1px solid var(--line); border-radius: 14px; padding: 5px 8px; max-width: 560px; margin-inline: auto; backdrop-filter: blur(4px); }
.res-bar .r { display: flex; align-items: center; gap: 4px; background: none; border: 0; padding: 0; }
.res-bar .r img { width: 26px; height: 26px; object-fit: contain; }
.res-bar .r span { display: flex; flex-direction: column; line-height: 1.1; font-weight: 900; font-size: 13px; text-align: right; }
.res-bar .r small { font-size: 9.5px; color: var(--ok); font-weight: 700; }
.res-bar .r small.neg { color: var(--bad); }
.res-bar .r.full b { color: var(--gold); }
.bump { animation: bump .35s ease; } @keyframes bump { 40% { transform: scale(1.12); } }
.side { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 128px); display: flex; flex-direction: column; gap: 10px; }
.side.left { left: max(10px, env(safe-area-inset-left, 0px)); } .side.right { right: max(10px, env(safe-area-inset-right, 0px)); }
.sbtn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: 0; padding: 0; width: 58px; }
.sbtn .bx { width: 50px; height: 50px; border-radius: 14px; background: #1c2328e8; border: 1.5px solid var(--frame); display: grid; place-items: center; box-shadow: 0 3px 8px #0009; }
.sbtn .bx img { width: 36px; height: 36px; object-fit: contain; }
.sbtn em { font-style: normal; font-size: 10.5px; font-weight: 700; background: #000b; border-radius: 6px; padding: 0 5px; white-space: nowrap; }
.badge { position: absolute; top: -5px; left: 2px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 900; display: grid; place-items: center; padding: 0 4px; border: 1.5px solid #fff8; }
.queues { position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 146px); right: max(10px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 6px; width: min(290px, 64vw); }
.qrow { display: flex; align-items: center; gap: 8px; background: #0b0e11d8; border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px; font-size: 12px; font-weight: 700; }
.qrow img { width: 30px; height: 30px; object-fit: contain; }
.qrow .qt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.qrow .qt span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qrow.idle { border-style: dashed; color: var(--mut); }
.qrow button { font-size: 11px; padding: 4px 9px; }
.ticker { position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); left: max(10px, env(safe-area-inset-left, 0px)); right: max(10px, env(safe-area-inset-right, 0px)); max-width: 520px; margin-inline: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #0b0e11c8; border-radius: 10px; padding: 6px 10px; font-size: 11.5px; line-height: 1.5; cursor: pointer; }
.ticker b { color: var(--gold); }
.nav { position: absolute; bottom: 0; left: 0; right: 0; height: calc(88px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); background: linear-gradient(#1c2328f2, #12161af8); border-top: 1.5px solid var(--frame); display: flex; justify-content: space-around; align-items: flex-start; padding-inline: max(6px, env(safe-area-inset-left, 0px)); }
.nav button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding-top: 10px; width: 20%; font-size: 12px; font-weight: 700; color: var(--tx); }
.nav button img { width: 38px; height: 38px; object-fit: contain; opacity: .85; }
.nav button.on { color: var(--acc); } .nav button.on img { opacity: 1; transform: scale(1.08); }
.nav button.mid { transform: translateY(-22px); }
.nav button.mid .bigc { width: 66px; height: 66px; border-radius: 50%; background: var(--pri); border: 3px solid var(--frame); display: grid; place-items: center; box-shadow: 0 4px 14px #000a; }
.nav button.mid.on .bigc { background: var(--acc); }
.nav button.mid img { width: 46px; height: 46px; }
.nav .dot { position: absolute; margin-right: 26px; }

/* sheets */
.sheet-wrap { position: fixed; inset: 0; background: #000a; display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fade .18s; }
.sheet-wrap.out { opacity: 0; transition: opacity .18s; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: min(560px, 100%); max-height: calc(100% - env(safe-area-inset-top, 0px) - 18px); display: flex; flex-direction: column; background: var(--bg); border: 1.5px solid var(--frame); border-bottom: 0; border-radius: 20px 20px 0 0; overflow: hidden; animation: rise .24s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -10px 40px #000a; }
@keyframes rise { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 760px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 20px; border-bottom: 1.5px solid var(--frame); max-height: 88vh; } .sheet-wrap.wide .sheet { width: min(980px, 96vw); } }
.sheet-wrap.small .sheet { width: min(420px, 100%); }
.sh-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: linear-gradient(#28333b, #161b20); border-bottom: 2px solid var(--frame); }
.sh-head h2 { flex: 1; margin: 0; text-align: center; font-family: var(--f-disp); font-size: 19px; color: var(--gold); text-wrap: balance; }
.sh-btn { width: 36px; height: 36px; border-radius: 10px; background: var(--panel2); border: 1.5px solid var(--frame); font-size: 17px; font-weight: 900; }
.sh-tabs { display: flex; gap: 6px; padding: 10px 12px 0; overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.tab { flex-shrink: 0; background: var(--panel2); border: 1px solid var(--line); color: var(--mut); border-radius: 12px; padding: 7px 14px; font-weight: 700; font-size: 13px; }
.tab.on { background: var(--acc); color: #1a1208; border-color: var(--frame); }
.sh-body { padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.sh-foot { display: flex; gap: 10px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1.5px solid var(--frame); background: var(--panel); }
.sh-foot .btn { flex: 1; }

/* widgets */
.btn { border: 1.5px solid var(--frame); border-radius: 13px; padding: 11px 16px; font-weight: 900; font-size: 15px; box-shadow: 0 3px 0 #0007, inset 0 2px 0 #fff3; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform .08s; white-space: nowrap; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0007; }
.btn.pri { background: var(--acc); color: #1a1208; } .btn.sec { background: var(--pri); color: var(--tx); } .btn.gold { background: var(--gold); color: #1a1208; }
.btn.ok { background: var(--ok); color: #10140f; } .btn.bad { background: var(--bad); color: #fff; } .btn.ghost { background: var(--panel2); color: var(--tx); border-color: var(--line); }
.btn.dis { background: var(--panel2); color: var(--mut); border-color: var(--line); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.card.hl { background: var(--deep); border-color: var(--frame); }
.card h3, .h3 { margin: 0; font-size: 16px; font-weight: 900; color: var(--gold); }
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; } .kv span:first-child { color: var(--mut); } .kv b { font-weight: 900; }
.mut { color: var(--mut); } .good { color: var(--ok); } .bad { color: var(--bad); } .gold-t { color: var(--gold); }
.lead { margin: 0; line-height: 1.7; font-size: 14.5px; }
.small { font-size: 12px; }
.pbar { height: 10px; border-radius: 5px; background: var(--panel2); border: 1px solid var(--line); overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--acc); border-radius: 5px; margin-right: 0; margin-left: auto; transition: width .4s; }
.cost { display: inline-flex; align-items: center; gap: 3px; font-weight: 900; font-size: 13px; margin-left: 10px; }
.cost.miss { color: var(--bad); }
.costs { display: flex; flex-wrap: wrap; gap: 4px 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel2); border-radius: 10px; padding: 2px 9px; font-size: 12px; font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.tile { background: var(--panel2); border: 1.5px solid var(--line); border-radius: 14px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; font-size: 12.5px; font-weight: 700; }
.tile.on { border-color: var(--acc); box-shadow: 0 0 0 2px #e0632b55; }
.tile.lock { opacity: .5; }
.tile img { width: 72px; height: 56px; object-fit: contain; }
.speed-row { display: flex; flex-wrap: wrap; gap: 6px; }
.speed-row .btn { padding: 6px 10px; font-size: 12.5px; }
.req { display: flex; align-items: center; gap: 10px; background: var(--panel2); border-radius: 12px; padding: 7px 10px; font-weight: 700; font-size: 13.5px; }
.req img { width: 30px; height: 30px; object-fit: contain; }
.req .grow { flex: 1; } .req .st { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 900; color: #111; background: var(--ok); }
.req.no .st { background: var(--bad); color: #fff; } .req.no .v { color: var(--bad); }
.hero-hd { position: relative; border-radius: 16px; overflow: hidden; border: 1.5px solid var(--frame); min-height: 150px; background: radial-gradient(circle at 50% 70%, #5a4826, #12161a 70%); display: flex; align-items: flex-end; justify-content: center; }
.hero-hd img.big { max-height: 190px; object-fit: contain; filter: drop-shadow(0 8px 14px #000a); }
.hero-hd .lvl { position: absolute; top: 10px; right: 10px; background: #000b; border: 1px solid var(--frame); border-radius: 12px; padding: 3px 12px; font-weight: 900; }
.slider { width: 100%; accent-color: var(--acc); }
input[type=text], select, textarea { background: var(--panel2); border: 1.5px solid var(--frame); color: var(--tx); border-radius: 12px; padding: 10px 12px; font: inherit; width: 100%; box-sizing: border-box; }
.list { display: flex; flex-direction: column; gap: 6px; }
.li { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 9px 12px; }
.li img { width: 40px; height: 40px; object-fit: contain; }
.li .grow { flex: 1; min-width: 0; } .li .t { font-weight: 900; font-size: 14px; } .li .s { font-size: 12px; color: var(--mut); }
.warn { background: #d9423622; border: 1px solid var(--bad); border-radius: 12px; padding: 8px 12px; font-size: 13px; }
.note { background: #e0632b1f; border: 1px solid var(--acc); border-radius: 12px; padding: 8px 12px; font-size: 13px; }
.okbox { background: #5cbf6a1f; border: 1px solid var(--ok); border-radius: 12px; padding: 8px 12px; font-size: 13px; }

/* feedback */
#toasts { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 120px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 90; width: min(420px, 92vw); pointer-events: none; }
.toast { background: #0b0e11f0; border: 1px solid var(--frame); border-radius: 12px; padding: 9px 14px; font-weight: 700; font-size: 13.5px; text-align: center; animation: rise .2s; transition: opacity .4s, transform .4s; }
.toast.good { border-color: var(--ok); } .toast.bad { border-color: var(--bad); } .toast.out { opacity: 0; transform: translateY(-10px); }
.floater { position: fixed; z-index: 80; pointer-events: none; font-weight: 900; font-size: 16px; color: var(--gold); text-shadow: 0 2px 4px #000; transform: translate(-50%, -50%); animation: up 1.3s ease-out forwards; }
@keyframes up { to { transform: translate(-50%, -90px); opacity: 0; } }
.flyer { position: fixed; z-index: 85; width: 36px; height: 36px; pointer-events: none; transition: transform .7s cubic-bezier(.5,0,.6,1), opacity .7s; }

/* full screens (boot, login) */
#screen:empty { display: none; }
#screen { position: fixed; inset: 0; z-index: 70; }
.boot { position: absolute; inset: 0; background: #0b0e11 center/cover no-repeat; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top, 0px) + 40px) max(20px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 30px) max(20px, env(safe-area-inset-left, 0px)); text-align: center; }
.boot::before { content: ''; position: absolute; inset: 0; background: linear-gradient(#000a, #0000 35%, #0000 60%, #000e); }
.boot > * { position: relative; }
.boot h1 { font-family: var(--f-disp); font-size: clamp(38px, 9vw, 64px); color: var(--gold); margin: 4px 0 0; text-shadow: 0 4px 18px #000; }
.boot .latin { letter-spacing: .22em; font-weight: 700; color: var(--sand); font-size: 13px; }
.boot .panel { width: min(440px, 100%); display: flex; flex-direction: column; gap: 10px; }
.boot .tip { font-size: 13px; color: var(--tx); text-shadow: 0 1px 4px #000; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media (max-width: 420px) { .res-bar .r img { width: 22px; height: 22px; } .res-bar .r span { font-size: 12px; } .sbtn { width: 52px; } .sbtn .bx { width: 46px; height: 46px; } }
