:root {
  --ink: #f6ead2;
  --muted: #b9a88a;
  --panel: rgba(28, 20, 14, 0.94);
  --panel2: #2b1f15;
  --line: #6b4a26;
  --orange: #ff8a1f;
  --orange2: #ffb347;
  --red: #ff4b4b;
  --gold: #ffd34d;
  --green: #7ee08a;
  --blue: #7cc4ff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #10131a; color: var(--ink); overflow: hidden; -webkit-tap-highlight-color: transparent; user-select: none; }
#stage { position: fixed; inset: 0; }
#stage canvas { display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--ink); background: #140e09; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; outline: none; }
input:focus { border-color: var(--orange); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.red { color: var(--red); }
.green { color: var(--green); }
.small { font-size: 12px; }
.center { text-align: center; justify-content: center; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.gap { gap: 10px; margin: 10px 0; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.err { color: var(--red); min-height: 1em; font-size: 13px; }
h4 { margin: 16px 0 6px; color: var(--orange2); font-size: 14px; letter-spacing: 0.5px; text-transform: uppercase; }

/* buttons */
.btn { background: linear-gradient(#ff9b33, #d4620a); border: 1px solid #ffbe74; border-radius: 9px; padding: 8px 16px; font-weight: 800; color: #2a1200; box-shadow: 0 2px 0 #7a3300, inset 0 1px 0 rgba(255, 255, 255, 0.4); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #7a3300; }
.btn:disabled { filter: grayscale(1) brightness(0.7); cursor: not-allowed; }
.btn.red { background: linear-gradient(#ff5a5a, #b31919); border-color: #ff9a9a; color: #fff; box-shadow: 0 2px 0 #5a0000; }
.btn.on { outline: 2px solid var(--gold); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 12px 22px; font-size: 16px; }
.link { background: none; border: 0; color: var(--orange2); padding: 8px; display: block; margin: 4px auto 0; text-decoration: underline; }
.pill { background: rgba(20, 14, 9, 0.75); border: 1px solid var(--line); border-radius: 20px; padding: 6px 12px; font-size: 13px; font-weight: 700; color: var(--muted); }
.pill.on { color: #2a1200; background: linear-gradient(#ffd27a, #ff9b33); border-color: #ffd27a; }
.pill.red.on { color: #fff; background: linear-gradient(#ff6b6b, #c41d1d); border-color: #ff9a9a; }

/* screens */
.screen { position: fixed; inset: 0; }
#create, #auth { display: grid; place-items: center; background: radial-gradient(circle at 50% 30%, rgba(255, 138, 31, 0.25), transparent 60%), linear-gradient(#1b120c, #0b0806); overflow: auto; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); width: min(380px, 100%); }
.card.wide { width: min(760px, 100%); }
.logo { font-family: 'Bungee', 'Be Vietnam Pro', sans-serif; text-align: center; font-size: 38px; margin: 0 0 6px; color: var(--orange); letter-spacing: 2px; text-shadow: 0 3px 0 #5a2400, 0 0 24px rgba(255, 138, 31, 0.45); }
.logo span { color: var(--red); }
.bodies { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.body { background: var(--panel2); border: 2px solid var(--line); border-radius: 12px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.body.sel { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 138, 31, 0.3); background: #3a2715; }
.body small { color: var(--muted); font-size: 11px; }
#createForm input { flex: 1; min-width: 160px; }

/* HUD */
.hud-top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; gap: 10px; padding: calc(8px + env(safe-area-inset-top)) 10px 0; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.me { display: flex; gap: 8px; background: rgba(20, 14, 9, 0.78); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px 6px 6px; min-width: 240px; }
.lvbadge { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(#ffb347, #c45200); border: 2px solid #ffd27a; color: #2a1200; font-size: 13px; text-align: center; }
.meinfo { flex: 1; display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.meinfo small { color: var(--muted); }
.bar { position: relative; height: 14px; background: #0c0805; border: 1px solid #3a2a18; border-radius: 7px; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#ff7a7a, #c41d1d); transition: width 0.2s; }
.bar.exp { height: 10px; }
.bar.exp i { background: linear-gradient(#ffe28a, #e0a000); }
.bar.big { height: 22px; border-radius: 11px; }
.bar.big i { background: linear-gradient(#ff6b6b, #8b0000); }
.bar span { position: relative; display: block; text-align: center; font-size: 10px; line-height: 13px; font-weight: 800; text-shadow: 0 1px 2px #000; }
.bar.exp span { font-size: 9px; line-height: 9px; }
.bar.big span { font-size: 13px; line-height: 21px; }
.where { flex: 1; text-align: center; padding-top: 2px; text-shadow: 0 2px 4px #000, 0 0 2px #000; }
.mapname { font-weight: 800; font-size: 17px; color: var(--orange2); }
.where .muted { font-size: 12px; color: #e8dcc2; }
.res { background: rgba(20, 14, 9, 0.78); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; font-size: 13px; text-align: right; min-width: 120px; }
.quick { position: fixed; top: calc(76px + env(safe-area-inset-top)); left: 10px; display: flex; gap: 6px; }
#loot { position: fixed; left: 10px; bottom: calc(78px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 3px; pointer-events: none; }
.lootline { background: rgba(10, 8, 6, 0.6); padding: 3px 10px; border-radius: 6px; font-size: 13px; color: #e8dcc2; transition: opacity 0.5s; border-left: 3px solid var(--blue); }
.lootline.special { color: #ffb3b3; border-left-color: var(--red); font-weight: 700; }
.lootline.out { opacity: 0; }
.nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(6px + env(safe-area-inset-bottom)); display: flex; gap: 4px; background: rgba(20, 14, 9, 0.88); border: 1px solid var(--line); border-radius: 16px; padding: 5px; box-shadow: var(--shadow); max-width: calc(100vw - 12px); overflow-x: auto; }
.navbtn { background: none; border: 0; border-radius: 11px; padding: 5px 9px; display: flex; flex-direction: column; align-items: center; font-size: 11px; font-weight: 600; color: var(--muted); min-width: 62px; white-space: nowrap; }
.navbtn i { font-style: normal; font-size: 21px; line-height: 26px; }
.navbtn.active, .navbtn:hover { background: #3a2715; color: var(--ink); }
.navbtn.xly { color: #ff9a9a; }
.eyeicon { width: 24px; height: 24px; margin: 1px 0; border-radius: 50%; background: radial-gradient(circle, #000 0 18%, #d40000 20% 62%, #000 64% 70%, #d40000 72%); display: block; box-shadow: 0 0 8px rgba(255, 0, 0, 0.6); }
.gpu { position: fixed; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); font-size: 10px; color: rgba(255, 255, 255, 0.35); pointer-events: none; }

/* panel */
#panel { position: fixed; right: 10px; top: calc(70px + env(safe-area-inset-top)); bottom: calc(78px + env(safe-area-inset-bottom)); width: min(430px, calc(100vw - 20px)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; z-index: 5; }
#panel header { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
#panel h3 { margin: 0; flex: 1; color: var(--orange2); }
.x { background: none; border: 0; font-size: 18px; padding: 4px 8px; color: var(--muted); }
#panelBody { padding: 10px 14px 16px; overflow-y: auto; flex: 1; user-select: text; }
.maplist { display: flex; flex-direction: column; gap: 5px; }
.maprow { display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid #3a2a18; border-radius: 9px; padding: 8px 10px; text-align: left; }
.maprow.cur { border-color: var(--orange); background: #3a2715; }
.maprow.lock { opacity: 0.45; }
.ml { font-size: 12px; color: var(--orange2); width: 64px; flex: none; font-weight: 700; }
.mn { flex: 1; }
.tag { font-size: 10px; padding: 2px 6px; border-radius: 5px; font-weight: 800; }
.tag.red { background: #5a0b0b; color: #ffb3b3; }
.tag.gold { background: #4a3a05; color: var(--gold); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.cell { position: relative; background: var(--panel2); border: 1px solid #3a2a18; border-radius: 9px; padding: 6px 4px 4px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; min-height: 74px; }
.cell.eq { border-color: #2f6aa8; }
.cell.eqno { opacity: 0.6; }
.cn { font-size: 10px; text-align: center; line-height: 1.2; color: #e8dcc2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cq { position: absolute; right: 4px; top: 3px; font-size: 11px; font-weight: 800; color: var(--gold); text-shadow: 0 1px 2px #000; }
.ic { display: inline-block; overflow: hidden; flex: none; border-radius: 6px; background: rgba(0, 0, 0, 0.25); }
.ic i { image-rendering: auto; }
.ic-none { display: inline-grid; place-items: center; color: var(--muted); }
.iteminfo { display: flex; gap: 10px; margin-top: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #1f160e; }
.iteminfo small { color: var(--muted); }
.charhead { display: flex; gap: 12px; align-items: center; }
.portrait { display: inline-block; background: radial-gradient(circle, #3a2715, #140e09); border-radius: 12px; border: 1px solid var(--line); }
.big { font-size: 18px; font-weight: 800; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; margin: 10px 0; }
.stats div { display: flex; justify-content: space-between; border-bottom: 1px dashed #3a2a18; padding: 3px 0; font-size: 14px; }
.stats span { color: var(--muted); }
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.slot { display: flex; gap: 8px; align-items: center; background: var(--panel2); border: 1px solid #3a2a18; border-radius: 9px; padding: 5px; font-size: 12px; cursor: pointer; }
.slot small { display: block; color: var(--muted); font-size: 10px; }
.slot.has { border-color: #2f6aa8; }
.shop { display: flex; flex-direction: column; gap: 6px; }
.shoprow { display: flex; align-items: center; gap: 8px; background: var(--panel2); border-radius: 9px; padding: 6px 8px; }
.shoprow > span:nth-child(2) { flex: 1; }
.shoprow small { display: block; color: var(--muted); font-size: 11px; }
.rank { display: flex; flex-direction: column; gap: 4px; }
.rankrow { display: grid; grid-template-columns: 30px 1fr 56px 60px 64px; gap: 6px; align-items: center; background: var(--panel2); border-radius: 8px; padding: 7px 8px; font-size: 13px; }
.rankrow.me { outline: 1px solid var(--orange); }
.rankrow small { display: block; color: var(--muted); font-size: 10px; }
.setlist { display: flex; flex-direction: column; gap: 12px; }
.setlist label { display: flex; flex-direction: column; gap: 6px; }
.chk { flex-direction: row !important; align-items: center; gap: 8px !important; font-size: 14px; }
.chk input { width: 18px; height: 18px; accent-color: var(--orange); }
input[type='range'] { accent-color: var(--orange); padding: 0; }

/* sharingan eye */
.eye { width: 120px; height: 120px; margin: 4px auto 8px; border-radius: 50%; background: radial-gradient(circle, #000 0 15%, #c00000 17% 64%, #120000 66% 70%, #8a0000 72%); position: relative; box-shadow: 0 0 30px rgba(255, 0, 0, 0.5), inset 0 0 18px #000; animation: spin 9s linear infinite; }
.eye::before, .eye::after, .eye .iris { content: ''; position: absolute; width: 18px; height: 18px; background: #000; border-radius: 50% 50% 50% 0; left: 51px; top: 14px; transform-origin: 9px 46px; }
.eye::after { transform: rotate(120deg); }
.eye .iris { transform: rotate(240deg); }
.eye.stage1::after, .eye.stage1 .iris { display: none; }
.eye.stage2 .iris { display: none; }
.eye.stage4, .eye.stage5, .eye.stage6, .eye.stage7, .eye.stage8 { background: radial-gradient(circle, #000 0 12%, #d40000 14% 30%, #000 31% 40%, #d40000 41% 64%, #120000 66% 70%, #8a0000 72%); }
.eye.stage9, .eye.stage11 { background: repeating-radial-gradient(circle, #b9a3e3 0 9px, #3a2a5a 10px 12px); animation: none; }
.eye.stage9::before, .eye.stage9::after, .eye.stage9 .iris, .eye.stage11::before, .eye.stage11::after, .eye.stage11 .iris { display: none; }
.eye.stage12 { background: radial-gradient(circle, #eef6ff, #9fb8d6 60%, #3c5574 72%); animation: none; }
.eye.stage12::before, .eye.stage12::after, .eye.stage12 .iris { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* misc */
.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.55); z-index: 20; padding: 16px; }
.modal ul { line-height: 1.8; }
.loader { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; background: rgba(8, 6, 4, 0.82); z-index: 50; font-weight: 600; }
.spin { width: 54px; height: 54px; border-radius: 50%; border: 4px solid #3a2a18; border-top-color: var(--orange); animation: spin 0.8s linear infinite; }
#toasts { position: fixed; top: calc(110px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 60; pointer-events: none; }
.toast { background: rgba(20, 14, 9, 0.92); border: 1px solid var(--line); padding: 8px 16px; border-radius: 10px; font-weight: 700; font-size: 14px; transition: opacity 0.5s, transform 0.5s; }
.toast.gold { color: var(--gold); border-color: var(--gold); font-size: 17px; }
.toast.out { opacity: 0; transform: translateY(-10px); }

@media (max-width: 720px) {
  .hud-top { gap: 6px; padding-left: 6px; padding-right: 6px; }
  .me { min-width: 0; flex: 1; padding: 5px 8px 5px 5px; }
  .lvbadge { width: 40px; height: 40px; font-size: 12px; }
  .meinfo small { display: none; }
  .where { display: none; }
  .res { min-width: 0; max-width: 42vw; font-size: 12px; padding: 5px 9px; }
  .res .small { font-size: 10px; }
  .bodies { grid-template-columns: repeat(2, 1fr); }
  .nav { left: 6px; right: 6px; transform: none; max-width: none; justify-content: space-between; padding: 4px; gap: 2px; }
  .navbtn { min-width: 0; flex: 1; padding: 4px 1px; font-size: 9.5px; white-space: normal; line-height: 1.15; text-align: center; }
  .navbtn i { font-size: 19px; line-height: 22px; }
  .eyeicon { width: 20px; height: 20px; }
  #panel { left: 6px; right: 6px; width: auto; top: calc(108px + env(safe-area-inset-top)); bottom: calc(66px + env(safe-area-inset-bottom)); }
  .quick { top: calc(66px + env(safe-area-inset-top)); left: 6px; }
  .pill { font-size: 12px; padding: 5px 10px; }
  #loot { bottom: calc(70px + env(safe-area-inset-bottom)); }
}
@media (max-height: 460px) {
  .quick { top: auto; bottom: calc(70px + env(safe-area-inset-bottom)); left: auto; right: 10px; }
  #panel { top: 64px; bottom: 66px; }
  .navbtn i { font-size: 17px; line-height: 20px; }
}

/* ---- v2: skills, quests, cultivation ---- */
.bar.mp { height: 9px; }
.bar.mp i { background: linear-gradient(#7cc4ff, #1d5fd1); }
.bar.mp span { font-size: 8px; line-height: 8px; }
.zqh { color: #c4b5fd; }
.qtrack { position: fixed; left: 10px; top: calc(118px + env(safe-area-inset-top)); max-width: 230px; background: rgba(20, 14, 9, 0.7); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: 8px; padding: 6px 9px; font-size: 12px; line-height: 1.45; cursor: pointer; }
.qtrack b { color: var(--gold); }
.buffs { position: fixed; right: 10px; top: calc(96px + env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 3px; align-items: flex-end; pointer-events: none; }
.buffs span { background: rgba(20, 14, 9, 0.7); border: 1px solid #3b5c2b; color: #bbf7d0; border-radius: 6px; padding: 2px 7px; font-size: 11px; }
.skillbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); display: flex; gap: 4px; pointer-events: none; }
.sbi { position: relative; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: rgba(20, 14, 9, 0.85); overflow: hidden; padding: 1px; }
.sbi.off { opacity: 0.35; }
.sbi .cdm { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0, 0, 0, 0.65); }
.ic.sk { border-radius: 7px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.tab { background: var(--panel2); border: 1px solid #3a2a18; border-radius: 8px; padding: 5px 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.tab.on { color: #2a1200; background: linear-gradient(#ffd27a, #ff9b33); border-color: #ffd27a; }
.sklist { display: flex; flex-direction: column; gap: 5px; }
.skrow { display: flex; gap: 9px; align-items: center; background: var(--panel2); border: 1px solid #3a2a18; border-radius: 10px; padding: 6px 8px; }
.skrow.off { opacity: 0.72; }
.skrow.on { border-color: #6b4a26; }
.skinfo { flex: 1; min-width: 0; }
.skinfo small { color: var(--orange2); }
.skbtn { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; max-width: 120px; text-align: right; }
.qcard { background: var(--panel2); border: 1px solid #6b4a26; border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.qcard.empty { opacity: 0.7; }
.qhead { display: flex; gap: 10px; align-items: center; }
.qtype { color: var(--gold); font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; font-size: 10px; }
.npcpic { display: inline-block; flex: none; border-radius: 10px; background: radial-gradient(circle at 50% 40%, #4a3320, #140e09); border: 1px solid var(--line); }
.npcpic.none { display: inline-grid; place-items: center; color: var(--muted); }
.qsay { margin: 8px 0; padding: 7px 10px; background: #1a120b; border-radius: 8px; font-style: italic; font-size: 13px; color: #f0e2c4; }
.qneed { margin: 8px 0; display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.qneed .ok { color: var(--green); }
.qrew { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; align-items: center; }
.qrew span { display: inline-flex; align-items: center; gap: 4px; }
.qlog { font-size: 12px; color: #d6c7a8; display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
.qlog div { border-bottom: 1px dashed #3a2a18; padding-bottom: 3px; }
.lockbox { background: #1a120b; border: 1px dashed var(--line); border-radius: 10px; padding: 12px; text-align: center; margin: 8px 0; }
.zq { color: #c4b5fd; margin-bottom: 8px; font-size: 13px; }
.zq small { color: var(--muted); }
.sysbanner { border-radius: 12px; padding: 12px; text-align: center; margin-bottom: 6px; background: linear-gradient(135deg, #2b1f15, #3a2715); border: 1px solid var(--line); }
.sysbanner small { color: var(--muted); }
.sysbanner.rq { background: linear-gradient(135deg, #10263a, #1f3c5a); border-color: #3b6b95; }
.sysbanner.lh { background: linear-gradient(135deg, #251a3a, #3b2a5c); border-color: #6d5a9e; }
.sysbanner.aq { background: linear-gradient(135deg, #1d2430, #34404f); border-color: #64748b; }
.sysbanner.mai { background: linear-gradient(135deg, #12301d, #1d4a2c); border-color: #3f8a55; }
.seals { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-bottom: 10px; }
.seal { text-align: center; padding: 6px 2px; border-radius: 8px; background: #1a120b; border: 1px solid #3a2a18; font-size: 12px; color: var(--muted); }
.seal.done { background: linear-gradient(#ffd27a, #c47a12); color: #2a1200; font-weight: 800; }
.seal.cur { border-color: var(--gold); color: var(--gold); }
.gates { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.gate { background: var(--panel2); border: 1px solid #3a2a18; border-radius: 10px; padding: 7px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.gate.full { border-color: #3f8a55; }
.gname { font-weight: 800; color: var(--orange2); }
.gbar { height: 6px; background: #0c0805; border-radius: 3px; overflow: hidden; }
.gbar i { display: block; height: 100%; background: linear-gradient(90deg, #22c55e, #a3e635); }
.gate .btn small { font-weight: 600; opacity: 0.8; }
@media (max-width: 720px) {
  .qtrack { top: calc(104px + env(safe-area-inset-top)); left: 6px; max-width: 58vw; font-size: 11px; }
  .buffs { top: calc(66px + env(safe-area-inset-top)); right: 6px; }
  .skillbar { bottom: calc(66px + env(safe-area-inset-bottom)); }
  .sbi { width: 32px; height: 32px; }
  .seals { grid-template-columns: repeat(4, 1fr); }
}
@media (max-height: 460px) {
  .qtrack { top: 62px; }
  .skillbar { left: auto; right: 150px; transform: none; bottom: 66px; }
}
@media (max-width: 720px) {
  #toasts { top: auto; bottom: calc(118px + env(safe-area-inset-bottom)); width: 86vw; }
  .toast { font-size: 12px; padding: 6px 12px; text-align: center; }
  .toast.gold { font-size: 14px; }
}
