/* Веб-клиент R2: Исток — интерфейс в стиле клиента R2 17.03. Спрайты — из gui.rfs (var/webassets/gui/skin.png, ops/webclient/export_gui.py).
   Окно игры клиента — 1024×768: элементы стоят в его пикселях, а контейнер масштабируется (--s, задаёт ui.js). Шрифты — системные (без Google Fonts). */
:root {
  --s: 1;
  --font: Tahoma, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans CJK KR", sans-serif;
  --gold: #e8c77a;
  --text: #f2ead8;
  --dim: #b5a98c;
  --shadow: 0 0 2px #000, 1px 1px 1px #000;
  --bg: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: var(--text); font: 12px/1.35 var(--font); overflow: hidden;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

.sk { background-repeat: no-repeat; image-rendering: auto; }

/* ---- экраны ---- */
.screen { position: fixed; inset: 0; }
.screen.bg { background: #10140f var(--bg) center / cover no-repeat; }
.design { position: absolute; left: 50%; top: 50%; width: 1024px; height: 768px; transform: translate(-50%, -50%) scale(var(--s)); transform-origin: 50% 50%; }

.load-box { position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%) scale(var(--s)); transform-origin: 50% 100%; width: 600px; text-align: center; }
.loadbar { position: relative; margin: 0 auto; }
.load-fill { position: absolute; left: 13px; right: 13px; top: 23px; height: 12px; overflow: hidden; }
.load-fill i { display: block; height: 100%; width: 0; background: linear-gradient(#f3d98a, #b98a2e 60%, #6d4c14); transition: width .2s; box-shadow: 0 0 6px #e8b54a; }
.load-text { margin-top: 8px; text-shadow: var(--shadow); font-size: 13px; color: var(--gold); }

/* окно входа: 10 cid 0 на x=354 y=571 (317×132); поля 460,602 / 460,631 */
.login-panel { position: absolute; left: 354px; top: 571px; }
.lp-row { position: absolute; left: 25px; width: 280px; height: 17px; display: flex; align-items: center; }
.lp-row span { width: 72px; text-align: center; color: var(--gold); text-shadow: var(--shadow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-row input { position: absolute; left: 81px; width: 112px; height: 17px; border: 0; padding: 0 3px; background: transparent; color: #fff; outline: none; }
.lp-enter { position: absolute; left: 224px; top: 27px; }   /* 10 cid 10001: x=578 y=598 в окне 1024×768 */
body.login-site .lp-row { display: none; }   /* вход через сайт (src/sitelogin.js): полей логина и билета нет */
/* рамки полей — часть картинки панели (10 cid 0): в режиме «Через сайт» закрываем их плашкой с пояснением */
.lp-site { display: none; position: absolute; left: 12px; top: 24px; width: 202px; height: 58px; box-sizing: border-box; padding: 0 10px;
  align-items: center; justify-content: center; text-align: center; font-size: 12px; line-height: 1.35; color: var(--gold); text-shadow: var(--shadow);
  background: linear-gradient(#2e2a23, #24211b); box-shadow: 0 0 6px 4px #29251f; border-radius: 3px; }
body.login-site .lp-site { display: flex; }
.lp-langs { position: absolute; left: 22px; top: 92px; display: flex; gap: 6px; }
.lp-langs button { background: rgba(0,0,0,.45); border: 1px solid #6d5d3b; color: var(--dim); padding: 1px 8px; border-radius: 2px; }
.lp-langs button.on { color: #fff; border-color: var(--gold); }
.login-hint { position: absolute; left: 304px; top: 708px; width: 416px; text-align: center; color: var(--dim); text-shadow: var(--shadow); font-size: 11px; }
.login-status { position: absolute; left: 304px; top: 540px; width: 416px; text-align: center; color: #ffd36a; text-shadow: var(--shadow); font-size: 13px; }

.r2btn { border: 0; padding: 0; color: #f6e7c0; text-shadow: 0 0 2px #000, 0 0 2px #000; font-weight: bold; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.r2btn:hover { filter: brightness(1.15); }
.r2btn:disabled { filter: grayscale(.8) brightness(.7); cursor: default; }

/* выбор персонажа: ячейки 316×202 справа (как 651/653/655) */
.chars-right { position: absolute; right: 12px; top: 50%; transform: translateY(-50%) scale(var(--s)); transform-origin: 100% 50%; width: 316px; }
.chars-title { color: var(--gold); text-shadow: var(--shadow); font-size: 16px; font-weight: bold; text-align: center; margin-bottom: 6px; }
.slot { position: relative; width: 316px; height: 202px; margin-bottom: 6px; cursor: pointer; }
.slot .s-title { position: absolute; left: 25px; top: 5px; color: var(--dim); font-weight: bold; text-shadow: var(--shadow); }
.slot .s-name { position: absolute; left: 15px; top: 35px; width: 180px; color: #fff; font-size: 15px; font-weight: bold; text-shadow: var(--shadow); white-space: nowrap; overflow: hidden; }
.slot .s-row { position: absolute; left: 15px; width: 170px; display: flex; justify-content: space-between; color: var(--dim); text-shadow: var(--shadow); }
.slot .s-row b { color: #fff; font-weight: normal; }
.slot .s-start { position: absolute; left: 199px; top: 145px; }
.slot:not(.on) .s-start { display: none; }
.chars-btns { display: flex; justify-content: center; }
.new-slot .ns-name { position: absolute; left: 15px; top: 32px; width: 170px; height: 22px; background: rgba(0,0,0,.55); border: 1px solid #6d5d3b; color: #fff; padding: 0 5px; outline: none; }
.new-slot .ns-rule { position: absolute; left: 15px; top: 57px; width: 180px; font-size: 10px; color: var(--dim); text-shadow: var(--shadow); }
.new-slot .ns-cls, .new-slot .ns-sex { position: absolute; left: 12px; width: 300px; display: flex; flex-wrap: wrap; gap: 3px; }
.new-slot .ns-cls { top: 88px; width: 185px; } .new-slot .ns-sex { top: 150px; width: 185px; }
.new-slot button:not(.r2btn) { background: rgba(0,0,0,.5); border: 1px solid #6d5d3b; color: var(--dim); padding: 1px 6px; font-size: 11px; border-radius: 2px; }
.new-slot button.on { color: #fff; border-color: var(--gold); }
.new-slot .s-start { display: inline-flex !important; }
.chars-empty { padding: 20px; background: rgba(0,0,0,.7); border: 1px solid #6d5d3b; color: var(--dim); text-align: center; }

/* ---- интерфейс мира ---- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-bottom { position: absolute; left: 0; bottom: 0; height: 218px; width: calc(100vw / var(--s)); transform: scale(var(--s)); transform-origin: 0 100%; pointer-events: none; }
.hud-bottom > * { pointer-events: auto; }
/* 4800 «채팅출력창» x=0 y=550 391×110, 4801 x=0 y=660 391×19, 4701 x=0 y=717, 501 x=248 y=698, 506 x=248 y=760 */
.chat-out { position: absolute; left: 0; top: 0; width: 391px; height: 110px; pointer-events: none; }
.chat-bg { position: absolute; inset: 0; opacity: .85; }
.chat-lines { position: absolute; left: 4px; top: 10px; right: 4px; bottom: 2px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end;
  font-size: 12px; text-shadow: var(--shadow); word-break: break-word; }
.chat-lines div { padding: 0 1px; }
.chat-lines .sys { color: #ffe36a; }
.chat-lines .me { color: #c8ffb0; }
.chat-lines .n { color: #fff; }
.chat-lines .n b { color: #f0d890; font-weight: normal; }
.chat-in { position: absolute; left: 0; top: 110px; width: 391px; height: 19px; }
.chat-ind { position: absolute; left: 0; top: 0; width: 18px; height: 19px; text-align: center; line-height: 19px; color: #fff; font-size: 11px; }
.chat-type { position: absolute; left: 19px; top: 1px; width: 55px; height: 17px; text-align: center; line-height: 17px; font-size: 11px; color: #fff; text-shadow: var(--shadow); }
#chat-input { position: absolute; left: 76px; top: -1px; width: 310px; height: 20px; border: 0; background: transparent; color: #fff; outline: none; padding: 0 2px; }
#chat-input::placeholder { color: rgba(255,255,255,.35); }
.menu-btn { position: absolute; left: 0; top: 167px; width: 51px; height: 51px; border: 0; padding: 0; background-color: transparent; }
.main-info { position: absolute; left: 248px; top: 148px; width: 350px; height: 70px; }
.mi-lv { position: absolute; left: 51px; top: 2px; width: 125px; height: 14px; line-height: 14px; text-shadow: var(--shadow); white-space: nowrap; }
.mi-name { position: absolute; left: 190px; top: 2px; width: 150px; height: 14px; line-height: 14px; color: #fff; font-weight: bold; text-shadow: var(--shadow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mi-bar { position: absolute; left: 184px; width: 159px; height: 13px; }
.mi-fill { position: absolute; left: 0; top: 0; height: 13px; transition: width .3s; }
.mi-bar span { position: absolute; inset: 0; text-align: center; line-height: 13px; font-size: 10px; color: #fff; text-shadow: var(--shadow); }
.mi-run { position: absolute; left: 58px; top: 22px; width: 92px; height: 26px; background: rgba(0,0,0,.35); border: 1px solid #6d5d3b; border-radius: 3px; color: var(--gold); font-size: 11px; text-shadow: var(--shadow); }
.exp { position: absolute; left: 248px; right: 0; top: 210px; height: 8px; }
.exp-bg { position: absolute; left: 350px; right: 0; top: 0; height: 8px; }
.exp-track { position: absolute; left: 6px; right: 0; top: 3px; height: 4px; overflow: hidden; background: rgba(0,0,0,.6); }
.exp-fill { height: 4px; width: 0; }

.hud-tr { position: absolute; right: 0; top: 0; transform: scale(var(--s)); transform-origin: 100% 0; pointer-events: none; }
.minimap { position: relative; width: 214px; height: 214px; }
#minimap { position: absolute; left: 17px; top: 17px; width: 180px; height: 180px; border-radius: 50%; }
.mm-ring { position: absolute; left: 0; top: 0; }
.mm-place { position: absolute; left: 0; right: 0; top: 214px; text-align: center; color: var(--gold); text-shadow: var(--shadow); font-weight: bold; }

.fps { position: absolute; left: 4px; top: 4px; font: 11px/1.3 Consolas, monospace; color: #8f8; text-shadow: var(--shadow); pointer-events: none; white-space: pre; }

/* имена и реплики над головой */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.nameplate { position: absolute; left: 0; top: 0; transform-origin: 50% 100%; white-space: nowrap; text-align: center; will-change: transform; }
.nameplate .nm { font-size: 12px; color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000, 1px 1px 1px #000; }
.nameplate.me .nm { color: #fff7a8; }
.nameplate .bubble { display: inline-block; max-width: 220px; white-space: normal; margin-bottom: 3px; padding: 3px 7px; background: rgba(20,16,10,.82);
  border: 1px solid #a08850; border-radius: 6px; color: #fff; font-size: 12px; text-shadow: 0 0 2px #000; }
.click-mark { position: fixed; pointer-events: none; }

/* ---- бой (этап 2) ---- */
/* 510 «퀵슬롯1» x=599 y=712 (ряд 1–8) и 511 y=663 (9, 0): ячейки 48×48 через 49 px */
.skillbar { position: absolute; left: 633px; top: 113px; width: 391px; display: grid; grid-template-columns: repeat(8, 48px); gap: 1px;
  direction: ltr; pointer-events: auto; }
.skillbar .sb-cell:nth-child(n+9) { grid-row: 1; }
.skillbar .sb-cell:nth-child(-n+8) { grid-row: 2; }
.sb-cell { position: relative; width: 48px; height: 48px; border: 0; padding: 0; background-color: transparent; }
.sb-cell img { position: absolute; left: 4px; top: 4px; width: 40px; height: 40px; }
.sb-cell.empty { opacity: .55; }
.sb-cell b { position: absolute; left: 3px; top: 1px; font-size: 10px; color: #fff; text-shadow: var(--shadow); font-weight: bold; }
.sb-cd { position: absolute; left: 4px; top: 4px; width: 40px; height: 40px; display: none; background: conic-gradient(rgba(0,0,0,.72) var(--p, 0deg), rgba(0,0,0,0) 0);
  color: #ffe07a; font: bold 13px/40px var(--font); text-align: center; text-shadow: var(--shadow); font-style: normal; }
.sb-cell:hover img { filter: brightness(1.2); }

/* 4590 «타겟다이얼로그» x=408 y=595 200×50, border=4 — вверху по центру, как у клиента при выборе цели */
.target { position: absolute; left: 50%; top: 8px; width: 220px; transform: translateX(-50%) scale(var(--s)); transform-origin: 50% 0;
  background: rgba(12,10,8,.82); border: 1px solid #8a7547; box-shadow: inset 0 0 0 1px #2a2318, 0 0 0 1px #000; padding: 6px 10px 8px; pointer-events: none; }
.tg-name { text-align: center; color: #ffd0b0; font-weight: bold; text-shadow: var(--shadow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-name small { color: var(--dim); font-weight: normal; }
.tg-bar { position: relative; width: 159px; height: 13px; margin: 4px auto 0; background: rgba(0,0,0,.6); overflow: hidden; }   /* спрайт hp_bar — 159×13 */
.target.npc .tg-bar { display: none; }
.tg-fill { position: absolute; left: 0; top: 0; height: 13px; width: 100%; transition: width .2s; }
.tg-bar span { position: absolute; inset: 0; text-align: center; line-height: 13px; font-size: 10px; color: #fff; text-shadow: var(--shadow); }

/* имена монстров, полоска HP над головой, выбранная цель */
.nameplate.mon .nm { color: #ffd2b8; }
.nameplate.npc .nm { color: #a8ff9a; }
.nameplate .np-title { font-size: 11px; color: #e8d690; text-shadow: 0 0 2px #000; }
.nameplate.tgt .nm { color: #ffef7a; text-decoration: underline; text-underline-offset: 3px; }
.nameplate.dead { opacity: .45; }
.nameplate.item .nm { color: #ffe9a8; font-size: 11px; }
.np-hp { width: 54px; height: 5px; margin: 2px auto 0; background: rgba(0,0,0,.7); border: 1px solid rgba(0,0,0,.9); }
.np-hp i { display: block; height: 100%; width: 100%; background: linear-gradient(#ff6a5a, #a8150c); }

/* числа урона */
.dmg { position: absolute; left: 0; top: 0; font: bold 18px/1 var(--font); color: #fff; text-shadow: 0 0 3px #000, 1px 1px 1px #000; white-space: nowrap; pointer-events: none; will-change: transform; text-align: center; }
.dmg.tome { color: #ff6b5b; }
.dmg.crit { color: #ffd24a; font-size: 24px; }
.dmg.crit small { display: block; font-size: 11px; color: #ffe9a0; }
.dmg.miss, .dmg.block { color: #c8c8c8; font-size: 14px; }

/* смерть: окно воскрешения */
#death { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(40,0,0,.25); z-index: 21; }
#death .r2win-btns { flex-wrap: wrap; }

/* телефон: кнопки боя (справа, над панелью умений) */
.touch-fight { display: none; }
body.touch .touch-fight { display: flex; position: absolute; right: 2vh; bottom: 42vh; gap: 8px; align-items: flex-end; pointer-events: auto; }
.touch-fight button { width: 52px; height: 52px; border-radius: 50%; border: 1px solid #a08850; background: rgba(15,12,8,.78); color: var(--gold);
  font-size: 11px; text-shadow: var(--shadow); padding: 0; }
.touch-fight button.big { width: 72px; height: 72px; font-size: 13px; font-weight: bold; background: radial-gradient(circle at 40% 35%, #6a2a18, #2a0e06); }
body.touch .skillbar { left: auto; right: 6px; top: 52px; grid-template-columns: repeat(5, 48px); width: auto; }
body.touch .skillbar .sb-cell:nth-child(n) { grid-row: auto; }

/* окна «border=4» клиента: тёмная подложка, тонкая рамка */
#modal, #menu { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.25); z-index: 20; }
.r2win { min-width: 300px; max-width: 420px; background: rgba(12,10,8,.9); border: 1px solid #8a7547; box-shadow: inset 0 0 0 1px #2a2318, inset 0 0 0 3px rgba(0,0,0,.6), 0 0 0 1px #000, 0 6px 20px rgba(0,0,0,.6);
  transform: scale(var(--s)); padding: 0 0 12px; }
.r2win-title { height: 28px; line-height: 28px; text-align: center; color: var(--gold); font-weight: bold; text-shadow: var(--shadow);
  background: linear-gradient(#3b3222, #1c1711); border-bottom: 1px solid #5a4b2e; }
.r2win-body { padding: 14px 16px 6px; text-align: center; color: var(--text); text-shadow: var(--shadow); }
.r2win-btns { display: flex; justify-content: center; gap: 8px; padding-top: 8px; }
.menu-win .r2win-body { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.menu-langs { display: flex; gap: 6px; }

/* сенсорное управление */
.joy, .touch-chat { display: none; }
body.touch .joy { display: block; position: absolute; left: 4vh; bottom: 6vh; width: 34vh; height: 34vh; max-width: 170px; max-height: 170px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,0,0,.15) 40%, rgba(0,0,0,.35) 70%); border: 2px solid rgba(232,199,122,.45); touch-action: none; }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 42%; height: 42%; margin: -21% 0 0 -21%; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #f6deaa, #a5803e 60%, #50391a); border: 1px solid #2a1e0c; box-shadow: 0 2px 6px rgba(0,0,0,.6); }
body.touch .touch-chat { display: block; position: absolute; left: 1vh; top: 1vh; width: 44px; height: 44px; border-radius: 50%; border: 1px solid #a08850;
  background: rgba(15,12,8,.75); color: var(--gold); font-size: 20px; }
body.touch .hud-bottom .menu-btn { top: 158px; left: auto; right: 362px; }
body.touch .chat-out { top: -160px; opacity: .9; }
body.touch .chat-in { display: none; }
body.touch.chat-open .chat-in { display: block; top: -50px; }
body.touch .main-info { left: auto; right: 6px; top: 148px; }

#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { display: flex; position: fixed; inset: 0; z-index: 50; background: #000 var(--bg) center / cover; align-items: center; justify-content: center; text-align: center; padding: 30px; }
  #rotate b { font-size: 20px; color: var(--gold); text-shadow: var(--shadow); }
  #rotate p { color: var(--text); text-shadow: var(--shadow); }
}

/* ---------- этап 3: окна gui.txt (gui.js, world3.js) ---------- */
#gwins { position: fixed; inset: 0; pointer-events: none; z-index: 19; }   /* над HUD, под меню/окном сообщения (20) и смертью (21) */
.gwin { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: auto; color: var(--text); text-shadow: var(--shadow);
  font-size: 12px; user-select: none; -webkit-user-select: none; touch-action: none; }
.gwin.r2win { min-width: 0; max-width: none; }
.gwin.hidden { display: none; }
.gwin-cap { cursor: move; }
.gc { position: absolute; box-sizing: border-box; overflow: hidden; white-space: nowrap; line-height: 1.25; }
.gc.hidden { display: none; }
.g-static { text-overflow: ellipsis; }
.g-bold { color: var(--gold); font-weight: bold; }
.g-button, .g-tabbtn { font: inherit; color: #f1e3c0; text-shadow: var(--shadow); border: 0; padding: 0; cursor: pointer; }
.g-tabbtn { background: rgba(0,0,0,.45); border: 1px solid #5d4f33; color: var(--dim); }
.g-tabbtn.on { color: #fff; border-color: var(--gold); }
.g-close { cursor: pointer; }
.g-box { overflow-y: auto; white-space: normal; padding: 6px 8px; touch-action: pan-y; background: rgba(0,0,0,.25); }
.g-npc-text { margin: 0 0 10px; line-height: 1.45; color: #f3ead2; white-space: pre-wrap; }
.g-npc-item { display: block; padding: 4px 2px; color: #ffd66e; text-decoration: none; cursor: pointer; }
.g-npc-item:hover { color: #fff; text-decoration: underline; }
.g-slot { width: 48px; height: 48px; cursor: pointer; }
.g-slot img { width: 48px; height: 48px; display: block; pointer-events: none; }
.g-slot b { position: absolute; right: 2px; bottom: 0; font-size: 11px; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; }
.g-slot.sel, .g-row.sel { outline: 2px solid var(--gold); outline-offset: -2px; }
.g-grid { position: absolute; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 3px; overflow-y: auto; touch-action: pan-y; }
.g-grid > .g-slot { position: relative; flex: 0 0 48px; }
.g-row { padding: 3px 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-row:hover { background: rgba(255,214,110,.12); }
.g-empty { padding: 8px; color: var(--dim); white-space: normal; }
.g-goal { color: #ffd66e; }
.g-coin { background: var(--coin) center / contain no-repeat; }
.g-red { color: #ff6b5a !important; }
.g-input { width: 100%; height: 100%; box-sizing: border-box; background: rgba(0,0,0,.6); border: 1px solid #6d5d3b; color: #fff; font: inherit; padding: 0 4px; }
.g-cnt { width: 70px; height: 20px; display: inline-block; }
#qtrack { position: absolute; right: 8px; top: calc(220px * var(--s)); width: 280px; transform: scale(var(--s)); transform-origin: 100% 0;
  pointer-events: none; font-size: 12px; text-shadow: var(--shadow); color: #e8dcc0; }
#qtrack b { display: block; color: var(--gold); margin-top: 4px; }
#qtrack div { padding-left: 8px; }
#qtrack .ok { color: #8fe08a; }
.gwin-tc .gwin-cap { position: absolute; left: 0; right: 0; top: 0; height: 28px; background: linear-gradient(#2a2318, #14110c); border: 1px solid #8a7547; box-sizing: border-box; }
.gwin-bg { pointer-events: none; }
.g-box:has(> .g-input) { padding: 0; background: none; overflow: hidden; }
