:root {
  --glass: rgba(14, 20, 28, 0.66); --glass2: rgba(255, 255, 255, 0.07); --edge: rgba(255, 255, 255, 0.14);
  --text: #f3f5f7; --muted: #a9b3bf; --gold: #f5b942; --gold2: #e08a1e; --teal: #34d3b4; --red: #ef5b6b;
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif; --head: 'Nunito', 'Inter', sans-serif;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35); --blur: blur(14px) saturate(1.3);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e141c; font-family: var(--font); color: var(--text); -webkit-tap-highlight-color: transparent; user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font-family: var(--font); cursor: pointer; color: var(--text); }
input { font-family: var(--font); }
b { font-weight: 700; }
a { color: var(--gold); }

/* ---- shared ---- */
.panel { background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--edge); border-radius: 20px; box-shadow: var(--shadow); }
.btn { background: var(--glass2); border: 1px solid var(--edge); border-radius: 999px; padding: 11px 22px; font-size: 16px; font-weight: 700; transition: transform .08s, background .15s; }
.btn:hover { background: rgba(255, 255, 255, 0.14); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(180deg, #ffd36b, var(--gold) 55%, var(--gold2)); color: #23180a; border-color: rgba(255, 220, 140, 0.6); box-shadow: 0 6px 18px rgba(245, 185, 66, 0.35); }
.btn.green { background: linear-gradient(180deg, #59e6c8, var(--teal)); color: #06231d; }
.btn.small { padding: 7px 14px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: default; }
.err { color: #ff8b97; min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.word { font-family: var(--head); font-weight: 900; font-size: 40px; letter-spacing: 3px; margin: 14px 0 4px; background: linear-gradient(180deg, #fff3c4, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 8px rgba(0,0,0,.5)); }
.small-caps { font-size: 12px; letter-spacing: 4px; color: var(--muted); text-transform: uppercase; }
.type { display: inline-block; padding: 2px 9px; border-radius: 999px; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; }
.rar { font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); margin-left: 4px; }
.rar.new { color: var(--teal); }
.rar-common { color: #b8c0ca; } .rar-rare { color: #b39dff; } .rar-legendary { color: var(--gold); }

/* ---- screens ---- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; z-index: 50; padding: 16px; }
#loading { background: radial-gradient(ellipse at 50% 40%, #1d2a38, #0b1017); }
.load-logo { width: 132px; height: 132px; border-radius: 30px; box-shadow: 0 14px 40px rgba(0,0,0,.5); animation: float 2.4s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
#title { background: linear-gradient(180deg, rgba(8,12,18,0) 30%, rgba(8,12,18,.55)); }
.title-card { width: min(440px, 100%); padding: 0 24px 20px; text-align: center; overflow: hidden; }
.title-banner { width: calc(100% + 48px); margin: 0 -24px 14px; display: block; }
.tag { font-size: 16px; line-height: 1.5; margin: 4px 0 18px; color: #dfe5ea; }
.title-card .btn.primary { width: 100%; font-size: 18px; padding: 14px; }
.or { margin: 16px 0 10px; font-size: 13px; color: var(--muted); }
#guest-form { display: flex; gap: 8px; }
#guest-form input, .modal input { flex: 1; min-width: 0; border: 1px solid var(--edge); border-radius: 999px; padding: 11px 16px; font-size: 16px; background: rgba(255,255,255,.08); color: var(--text); outline: none; }
#guest-form input:focus, .modal input:focus { border-color: var(--gold); }
.fine { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
.starter-card { width: min(680px, 100%); padding: 22px; text-align: center; max-height: 100%; overflow: auto; }
.starter-card h2 { font-family: var(--head); font-weight: 900; font-size: 24px; margin: 2px 0 16px; }
.starter-card h3 { font-family: var(--head); font-size: 16px; margin: 18px 0 10px; color: var(--muted); }
.starter-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.starter-list button { background: var(--glass2); border: 1px solid var(--edge); border-radius: 16px; padding: 10px 8px 12px; transition: transform .12s, border-color .12s; }
.starter-list button:hover { transform: translateY(-3px); }
.starter-list button.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 10px 26px rgba(245,185,66,.25); }
.starter-list img { width: 100%; max-width: 140px; aspect-ratio: 1; border-radius: 12px; background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.18), transparent 70%); }
.starter-list b { display: block; font-size: 18px; margin: 4px 0; }
.starter-list small { font-size: 12px; color: var(--muted); line-height: 1.4; display: block; margin-top: 6px; }
.looks { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-bottom: 16px; }
.looks label { display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: 14px; color: var(--muted); }
.swatches { display: flex; gap: 7px; }
.swatches i { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); cursor: pointer; display: block; }
.swatches i.on { box-shadow: 0 0 0 3px var(--gold); border-color: #fff; }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
.top-left { position: absolute; left: 14px; top: 14px; display: flex; gap: 8px; flex-wrap: wrap; max-width: calc(100% - 230px); }
.chip { background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--edge); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--text); text-decoration: none; }
.chip.brand { font-family: var(--head); font-weight: 900; letter-spacing: 1.5px; }
.chip.brand img { width: 22px; height: 22px; border-radius: 6px; }
.chip.money { color: #8ff0cf; }
.top-right { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.top-right .row { display: flex; gap: 8px; }
#minimap { width: 176px; height: 176px; border-radius: 50%; border: 3px solid rgba(255,255,255,.75); box-shadow: var(--shadow); cursor: pointer; background: #4f7a3a; }
.zone-pill { background: var(--glass); backdrop-filter: var(--blur); border: 1px solid var(--edge); border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: 13px; margin-top: -24px; position: relative; align-self: center; margin-right: 26px; }
.side-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 200px; }
.sbtn { background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--edge); border-radius: 12px; padding: 8px 10px; font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.sbtn:hover { background: rgba(30,40,52,.8); }
.sbtn b { width: 22px; height: 22px; border-radius: 7px; background: rgba(255,255,255,.12); display: grid; place-items: center; font-size: 12px; }
.sbtn.wide { grid-column: span 2; justify-content: center; background: linear-gradient(180deg, rgba(52,211,180,.85), rgba(22,150,125,.85)); color: #04201a; }
.sbtn.wide b { background: rgba(0,0,0,.15); }
.online { position: absolute; left: 16px; top: 58px; font-size: 13px; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.7); font-weight: 600; }
#chat { position: absolute; left: 14px; bottom: 14px; width: min(360px, calc(100% - 28px)); }
#chat-log { max-height: 150px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; margin-bottom: 6px; }
#chat-log div { background: rgba(10,14,20,.55); backdrop-filter: blur(6px); color: #fff; border-radius: 10px; padding: 4px 10px; font-size: 13px; width: fit-content; max-width: 100%; }
#chat-log div.sys { background: rgba(245,185,66,.88); color: #23180a; font-weight: 600; }
#chat-log b { color: var(--gold); }
#chat-input { width: 100%; border: 1px solid var(--edge); border-radius: 999px; padding: 9px 14px; font-size: 14px; background: var(--glass); backdrop-filter: var(--blur); color: var(--text); outline: none; }
.door-card { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--edge); border-radius: 18px; padding: 12px 14px 12px 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); animation: up .25s ease-out; max-width: calc(100% - 28px); }
.door-card b { font-size: 16px; white-space: nowrap; font-family: var(--head); font-weight: 800; }
.door-card span { font-size: 13px; color: var(--muted); }
@keyframes up { from { transform: translate(-50%, 24px); opacity: 0; } }
.help { position: absolute; left: 50%; transform: translateX(-50%); bottom: 6px; color: rgba(255,255,255,.75); font-size: 12px; text-shadow: 0 1px 4px rgba(0,0,0,.7); white-space: nowrap; pointer-events: none !important; }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.tagl { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: rgba(10,14,20,.6); color: #fff; backdrop-filter: blur(6px); }
.tagl small { color: var(--muted); font-weight: 600; }
.tagl.wild.rare { background: rgba(108,80,220,.75); }
.tagl.wild.legendary { background: linear-gradient(90deg, rgba(245,185,66,.9), rgba(239,91,107,.9)); color: #1b1208; }
.tagl.wild.legendary small { color: #3b2a12; }

/* ---- dialog ---- */
.dialog { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); width: min(640px, calc(100% - 28px)); background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--edge); border-radius: 20px; padding: 18px 22px 30px; z-index: 40; box-shadow: var(--shadow); cursor: pointer; }
.dialog p { margin: 0; font-size: 17px; line-height: 1.55; }
.dialog .more { position: absolute; right: 18px; bottom: 9px; font-size: 11px; letter-spacing: 2px; color: var(--muted); }

/* ---- battle ---- */
#battle { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#battle > * { pointer-events: auto; }
.bbox { position: absolute; background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--edge); border-radius: 16px; padding: 11px 14px 12px; width: min(310px, 46vw); box-shadow: var(--shadow); }
.bbox.wild { right: 18px; top: 18px; }
.bbox.mine { left: 18px; bottom: 196px; }
.bname { display: flex; justify-content: space-between; align-items: baseline; font-size: 17px; font-weight: 800; gap: 8px; font-family: var(--head); }
.bname span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bname span:last-child { font-size: 13px; color: var(--muted); font-family: var(--font); }
.btype { margin: 4px 0 6px; }
.hp { height: 8px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; margin-top: 6px; }
.hp i { display: block; height: 100%; width: 100%; border-radius: 999px; background: linear-gradient(90deg, #2fd27e, #7cf0a8); transition: width .6s cubic-bezier(.2,.8,.2,1), background .3s; }
.hp i.mid { background: linear-gradient(90deg, #f0b429, #ffd36b); } .hp i.low { background: linear-gradient(90deg, #e5484d, #ff8a8f); }
.hpnum { text-align: right; font-size: 12px; font-weight: 700; color: var(--muted); margin-top: 4px; }
.xp { height: 4px; background: rgba(255,255,255,.1); border-radius: 999px; overflow: hidden; margin-top: 5px; }
.xp i { display: block; height: 100%; background: linear-gradient(90deg, #4f8cff, #8ab4ff); width: 0; transition: width .6s; }
.bpanel { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(780px, calc(100% - 28px)); background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--edge); border-radius: 22px; padding: 14px; display: flex; gap: 14px; align-items: stretch; box-shadow: var(--shadow); min-height: 150px; }
.btext { flex: 1; margin: 0; font-size: 18px; line-height: 1.5; align-self: center; padding-left: 8px; }
.bmenu { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 310px; flex-shrink: 0; }
.bmenu button { border: 1px solid var(--edge); border-radius: 14px; background: rgba(255,255,255,.08); font-size: 15px; font-weight: 800; padding: 10px; letter-spacing: .5px; transition: background .12s, transform .08s; }
.bmenu button:hover { background: rgba(255,255,255,.16); }
.bmenu button:active { transform: scale(.97); }
.bmenu button:disabled { opacity: .35; }
.bmenu .bfight { background: linear-gradient(180deg, rgba(239,91,107,.9), rgba(196,52,70,.9)); }
.bmenu .bball { background: linear-gradient(180deg, #ffd36b, var(--gold2)); color: #23180a; }
.bmenu button[data-a=run] { grid-column: span 2; }
.bmenu.sub button { text-align: left; padding: 9px 12px; }
.bmenu.sub button small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 2px; letter-spacing: 0; }
.bmenu.sub button.back { grid-column: span 2; text-align: center; background: rgba(255,255,255,.05); }

/* ---- modal ---- */
.modal { position: fixed; inset: 0; background: rgba(5,8,12,.5); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 14px; }
.modal-card { position: relative; width: min(780px, 100%); max-height: 100%; overflow: auto; padding: 22px; background: rgba(16,22,30,.86); }
.modal-card h2 { font-family: var(--head); font-weight: 900; font-size: 22px; margin: 0 0 12px; }
.modal-card p { color: #d9e0e6; line-height: 1.5; }
.x { position: absolute; right: 14px; top: 14px; border: 1px solid var(--edge); background: rgba(255,255,255,.08); border-radius: 50%; width: 36px; height: 36px; font-size: 15px; font-weight: 700; }
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.dex .cell { background: rgba(255,255,255,.06); border: 1px solid var(--edge); border-radius: 14px; padding: 6px 6px 8px; text-align: center; font-size: 13px; font-weight: 700; cursor: pointer; transition: transform .12s, background .12s; }
.dex .cell:hover { transform: translateY(-2px); background: rgba(255,255,255,.1); }
.dex .cell img { width: 100%; aspect-ratio: 1; display: block; border-radius: 10px; background: radial-gradient(circle at 50% 45%, rgba(255,255,255,.14), transparent 70%); }
.dex .cell.unseen img { filter: brightness(0) opacity(.45); }
.dex .cell.seen img { filter: grayscale(1) opacity(.65); }
.dex .cell .no { font-size: 10px; color: var(--muted); }
.mon-row { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,.06); border: 1px solid var(--edge); border-radius: 14px; padding: 8px 12px; margin-bottom: 8px; }
.mon-row img { width: 64px; height: 64px; border-radius: 10px; background: radial-gradient(circle, rgba(255,255,255,.12), transparent 70%); }
.mon-row .info { flex: 1; min-width: 0; }
.mon-row .info b { font-size: 16px; font-family: var(--head); }
.mon-row small { color: var(--muted); }
.mon-row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.shop-row { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,.06); border: 1px solid var(--edge); border-radius: 14px; padding: 10px 14px; margin-bottom: 8px; flex-wrap: wrap; }
.shop-row .info { flex: 1; min-width: 180px; }
.shop-row small { color: var(--muted); }
.big-num { font-size: 34px; font-weight: 800; font-family: var(--head); color: #8ff0cf; }
.note { background: rgba(245,185,66,.12); border: 1px solid rgba(245,185,66,.35); border-radius: 14px; padding: 10px 14px; font-size: 14px; margin: 12px 0; line-height: 1.5; }
.dex-detail { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.dex-detail img { width: 190px; height: 190px; background: radial-gradient(circle at 50% 45%, rgba(255,255,255,.16), rgba(255,255,255,.03) 70%); border: 1px solid var(--edge); border-radius: 18px; }
.bigmap { width: 100%; max-width: 520px; aspect-ratio: 1; border-radius: 16px; display: block; margin: 0 auto 12px; border: 1px solid var(--edge); }
.places { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

#toasts { position: fixed; left: 50%; top: 74px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(520px, calc(100% - 28px)); }
.toast { background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--edge); border-radius: 999px; padding: 9px 18px; font-size: 14px; box-shadow: var(--shadow); animation: drop .3s ease-out; text-align: center; }
.toast.gold { border-color: rgba(245,185,66,.6); } .toast.green { border-color: rgba(52,211,180,.7); color: #b8fbe8; }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } }
.flash { position: fixed; inset: 0; background: #fff; z-index: 30; pointer-events: none; animation: flash .8s ease-out forwards; }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }

@media (max-width: 700px) {
  .top-left { max-width: calc(100% - 140px); gap: 5px; }
  .chip { font-size: 12px; padding: 5px 10px; }
  #btn-sound { display: none; }
  #minimap { width: 112px; height: 112px; }
  .side-btns { width: 124px; grid-template-columns: 1fr; gap: 4px; }
  .sbtn { font-size: 12px; padding: 5px 8px; }
  .sbtn.wide { grid-column: span 1; }
  .zone-pill { font-size: 11px; margin-right: 4px; }
  .help { display: none; }
  #chat { width: calc(100% - 150px); }
  #chat-log { max-height: 90px; }
  #chat-log div { font-size: 11px; }
  .bpanel { flex-direction: column; min-height: 0; }
  .bmenu { width: 100%; }
  .btext { font-size: 15px; }
  .bbox.mine { bottom: 262px; }
  .bname { font-size: 15px; }
  .word { font-size: 30px; }
  .door-card { flex-wrap: wrap; justify-content: center; text-align: center; bottom: 110px; }
  .starter-list b { font-size: 15px; }
}
.x-btn { display: block; margin-top: 12px; text-decoration: none; color: var(--text); font-size: 15px; }
.x-chip { font-size: 15px; }
.buy-btn { display: block; margin-top: 12px; text-decoration: none; background: linear-gradient(180deg, #59e6c8, var(--teal)); color: #06231d; border-color: rgba(120,240,210,.6); font-size: 16px; }
.ca-box { display: flex; align-items: center; gap: 8px; margin-top: 8px; background: rgba(255,255,255,.06); border: 1px solid var(--edge); border-radius: 999px; padding: 5px 5px 5px 14px; }
.ca-box span { font-size: 11px; font-weight: 800; color: var(--muted); }
.ca-box code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; text-align: left; }
.ca-box button { border: 0; border-radius: 999px; background: rgba(255,255,255,.14); padding: 6px 12px; font-weight: 700; font-size: 12px; }
.buy-chip { background: linear-gradient(180deg, rgba(89,230,200,.92), rgba(40,180,150,.92)); color: #06231d; }
@media (max-width: 700px) { .buy-chip { font-size: 11px; } }
