:root {
  --parch: #ffd7a8; --tan: #e5b67f; --ink: #493333; --ink2: #45292a; --mid: #634041; --rose: #825f60;
  --gold: #ffd23f; --red: #d9453b;
  --font: "Courier New", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1c1417; color: var(--ink); font-family: var(--font); font-weight: 700; user-select: none; -webkit-user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; display: block; outline: none; }
.hidden { display: none !important; }
img, canvas { image-rendering: pixelated; }

/* Пергаментная панель из пака UI (9-slice) */
.panel {
  border: 12px solid transparent;
  border-image: url(/assets/ui/Popup01a.png) 4 fill / 12px / 0 stretch;
  image-rendering: pixelated; color: var(--ink); padding: 2px 6px;
}
.btn {
  font: inherit; color: var(--ink); cursor: pointer; padding: 4px 12px; margin: 0;
  border: 9px solid transparent; border-image: url(/assets/ui/FrameSelect01a.png) 3 fill / 9px / 0 stretch; background: none;
  text-shadow: 0 1px 0 rgba(255,255,255,.35); line-height: 1.1; min-height: 34px;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn.big { font-size: 16px; padding: 6px 18px; }
.btn.danger { color: #8a1f17; }
.btn[disabled] { filter: grayscale(.8); cursor: default; }
.field {
  width: 100%; font: inherit; color: var(--parch); background: none; outline: none; margin-top: 4px;
  border: 8px solid transparent; border-image: url(/assets/ui/Slot01a.png) 4 fill / 8px / 0 stretch; padding: 3px 4px; user-select: text; -webkit-user-select: text;
}
.field::placeholder { color: var(--rose); }
.field:focus { filter: brightness(1.25); }
textarea.field { resize: none; }
.err { color: #9c1e14; min-height: 18px; margin: 6px 0; font-size: 13px; }
.ok { color: #1d6b2b; }
.hint { font-size: 11px; color: var(--mid); margin: 10px 0 0; line-height: 1.35; }
.sub { margin: 0 0 12px; color: var(--mid); }
h1 { margin: 6px 0 0; font-size: 28px; letter-spacing: 1px; text-shadow: 2px 2px 0 var(--tan); }
h2 { margin: 4px 0 8px; font-size: 17px; }
label { display: block; margin: 8px 0; font-size: 13px; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(20, 12, 16, .62); z-index: 20; }
.login-card { width: min(380px, 92vw); padding: 10px 14px 12px; text-align: center; }
.login-card label { text-align: left; }
.fb-card { width: min(460px, 94vw); padding: 8px 12px 12px; }
.tabs { display: flex; gap: 6px; margin: 8px 0; }
.tab { flex: 1; font: inherit; cursor: pointer; padding: 5px 4px; color: var(--mid); background: var(--tan); border: 2px solid var(--ink); }
.tab.on { background: var(--ink); color: var(--parch); }
.btnrow { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
.stats { position: absolute; left: 8px; top: 8px; width: 230px; font-size: 14px; }
.stats .row { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.stats .name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.ico { width: 22px; height: auto; flex: none; }
.bar { position: relative; flex: 1; height: 16px; border: 6px solid transparent; border-image: url(/assets/ui/Bar01a.png) 2 fill / 6px / 0 stretch; }
.bar.thin { height: 10px; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; transition: width .15s linear; }
.bar .fill.hp { background: var(--red); }
.bar .fill.xp { background: #4aa3ff; }
.bar b { position: absolute; inset: -4px 0 0; text-align: center; font-size: 10px; color: #fff; text-shadow: 1px 1px 0 #000; line-height: 14px; }
.mini { position: absolute; right: 8px; top: 8px; text-align: center; font-size: 11px; padding: 0 4px 2px; }
.mini canvas { width: 160px; height: 160px; display: block; margin: 2px auto; }
.chat { position: absolute; left: 8px; bottom: 8px; width: min(430px, 56vw); }
#chatLog { max-height: 190px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; font-size: 13px; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; color: #fff; user-select: text; }
#chatLog div { padding: 1px 4px; background: rgba(20,12,16,.35); margin-top: 1px; word-break: break-word; transition: opacity 1s; }
#chatLog div.old { opacity: 0; }
.chat.focus #chatLog div.old { opacity: 1; }
#chatLog .sys { color: #9be7ff; } #chatLog .gold { color: var(--gold); }
#chatLog .adm .n { color: var(--gold); }
.chat .field { margin-top: 4px; opacity: .85; }
.dock { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; }
.plist { position: absolute; left: 50%; top: 56px; transform: translateX(-50%); width: min(420px, 94vw); max-height: 70vh; overflow: auto; font-size: 14px; }
.plist h2 small { font-weight: 400; color: var(--mid); }
.prow { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-bottom: 1px dashed var(--tan); }
.prow .lv { margin-left: auto; color: var(--mid); }
.prow.me { background: rgba(255,255,255,.35); }
.prow.adm { background: linear-gradient(90deg, rgba(255,210,63,.55), rgba(255,210,63,.1)); }
.prow.adm .pn { color: #7a4b00; text-shadow: 0 0 0 #000; }
.tag { font-size: 10px; padding: 1px 5px; background: var(--ink); color: var(--gold); letter-spacing: .5px; }
.dead { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(120, 10, 10, .35); text-align: center; z-index: 8; pointer-events: none !important; }
#toasts { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--parch); padding: 6px 12px; border: 2px solid var(--tan); font-size: 13px; max-width: 90vw; }

@media (max-width: 720px) { .mini { display: none; } .stats { width: 190px; } .chat { width: 62vw; } }
