:root {
  --gold: #e8c26a;
  --panel: rgba(20, 16, 12, 0.72);
  --edge: rgba(232, 194, 106, 0.35);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #14110f; color: #f3ead8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- Вход ---------- */
#login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(30, 24, 16, 0.55), rgba(10, 8, 6, 0.92));
  padding: 16px; overflow-y: auto; touch-action: pan-y;
}
.card {
  width: min(460px, 100%); padding: 22px 20px; border-radius: 18px; background: var(--panel);
  border: 1px solid var(--edge); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); text-align: center;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.card h1 {
  margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 40px; letter-spacing: 2px;
  color: var(--gold); text-shadow: 0 2px 0 #6b4a16, 0 0 24px rgba(232, 194, 106, 0.35);
}
.card .sub { margin: 4px 0 16px; opacity: 0.75; font-style: italic; }
#name {
  width: 100%; font-size: 18px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--edge);
  background: rgba(0, 0, 0, 0.4); color: #fff; outline: none; text-align: center; user-select: text; -webkit-user-select: text;
}
#classes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.cls {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 6px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.05); color: inherit; font: inherit; cursor: pointer;
}
.cls span { font-size: 28px; }
.cls small { font-size: 11px; opacity: 0.7; line-height: 1.25; }
.cls.sel { border-color: var(--gold); background: rgba(232, 194, 106, 0.16); box-shadow: 0 0 0 1px var(--gold) inset; }
#play {
  width: 100%; font-size: 20px; font-weight: 700; padding: 14px; border: 0; border-radius: 12px; cursor: pointer;
  background: linear-gradient(#e8c26a, #b8892f); color: #2a1c06; box-shadow: 0 4px 0 #6b4a16;
}
#play:active { transform: translateY(2px); box-shadow: 0 2px 0 #6b4a16; }
#err { color: #ff8a7a; min-height: 1.2em; margin: 10px 0 0; }
.hint { font-size: 12px; opacity: 0.55; margin: 6px 0 0; }

/* ---------- HUD ---------- */
#panel {
  position: fixed; top: calc(8px + var(--sat)); left: calc(8px + var(--sal)); width: 190px; padding: 8px 10px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; font-size: 13px;
}
#panel .row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
#panel .row.small { margin: 4px 0 0; font-size: 12px; }
#plvl { color: var(--gold); font-size: 12px; }
.bar { position: relative; height: 14px; border-radius: 7px; background: rgba(0, 0, 0, 0.55); overflow: hidden; margin: 3px 0; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: 7px; transition: width 0.15s; }
.bar span { position: relative; display: block; text-align: center; font-size: 10px; line-height: 14px; text-shadow: 0 1px 1px #000; }
.bar.hp i { background: linear-gradient(#e0574a, #9e2a22); }
.bar.mp i { background: linear-gradient(#5b8de8, #2a4fa0); }
.bar.xp { height: 5px; }
.bar.xp i { background: linear-gradient(#f2d27a, #c49431); }

#mapwrap {
  position: fixed; top: calc(8px + var(--sat)); right: calc(8px + var(--sar)); width: 136px; height: 76px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 12px;
}
#minimap { width: 96px; height: 96px; image-rendering: pixelated; transform: scaleY(0.5) rotate(45deg) scale(0.98); }
#zone {
  position: fixed; top: calc(90px + var(--sat)); right: calc(8px + var(--sar)); width: 136px; text-align: center;
  font-size: 11px; color: var(--gold); text-shadow: 0 1px 2px #000;
}

#chatlog {
  position: fixed; left: calc(8px + var(--sal)); bottom: calc(178px + var(--sab)); width: min(340px, 60vw);
  font-size: 12px; line-height: 1.35; pointer-events: none; text-shadow: 0 1px 2px #000;
}
#chatlog div { background: rgba(0, 0, 0, 0.35); padding: 2px 6px; border-radius: 6px; margin-top: 2px; transition: opacity 1s; }
#chatlog .sys { color: var(--gold); }
#chatlog b { color: #9fd0ff; }

#toast {
  position: fixed; left: 50%; top: calc(18% + var(--sat)); transform: translateX(-50%); pointer-events: none;
  font-weight: 700; text-shadow: 0 2px 4px #000; font-size: 15px; opacity: 0; transition: opacity 0.25s; white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ---------- Кнопки ---------- */
#buttons { position: fixed; right: calc(12px + var(--sar)); bottom: calc(14px + var(--sab)); width: 210px; height: 200px; }
.btn {
  position: absolute; border-radius: 50%; border: 2px solid var(--edge); background: var(--panel); color: #fff;
  display: flex; align-items: center; justify-content: center; padding: 0; overflow: hidden; touch-action: none;
}
.btn:active, .btn.down { transform: scale(0.93); border-color: var(--gold); }
.btn span { font-size: 26px; pointer-events: none; }
.btn.big { width: 92px; height: 92px; right: 0; bottom: 0; }
.btn.big span { font-size: 40px; }
.btn.mid { width: 70px; height: 70px; right: 104px; bottom: 6px; }
.btn.small { width: 52px; height: 52px; }
#btn-pot { right: 20px; bottom: 108px; }
#btn-chat { right: 120px; bottom: 96px; }
#btn-pot b { position: absolute; bottom: 4px; right: 9px; font-size: 11px; color: var(--gold); }
.btn em { position: absolute; bottom: -1px; font-size: 9px; font-style: normal; opacity: 0.85; }
.cd { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); transform-origin: bottom; transform: scaleY(0); pointer-events: none; }

#stick {
  position: fixed; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18); background: rgba(0, 0, 0, 0.18); pointer-events: none;
  left: calc(90px + var(--sal)); top: calc(100% - 100px - var(--sab)); opacity: 0.55;
}
#stick.active { opacity: 1; }
#knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f6e2a8, #b8892f); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

#chatform {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(10px + var(--sat)); width: min(520px, 92vw);
  display: flex; gap: 6px; z-index: 5;
}
#chatform input {
  flex: 1; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--gold);
  background: rgba(0, 0, 0, 0.8); color: #fff; outline: none; user-select: text; -webkit-user-select: text;
}
#chatform button { font-size: 18px; border-radius: 10px; border: 0; padding: 0 16px; background: var(--gold); color: #2a1c06; }

#death {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(60, 0, 0, 0.45); pointer-events: none;
}
#death h2 { font-family: Georgia, serif; font-size: 38px; margin: 0; color: #ffb4a8; text-shadow: 0 2px 8px #000; }
#death p { margin: 8px 0 0; opacity: 0.85; }

@media (max-height: 500px) {
  #login { align-items: flex-start; }
  .card { padding: 12px 16px; }
  .card h1 { font-size: 28px; }
  .card .sub { margin: 0 0 8px; }
  #name { padding: 8px 12px; font-size: 16px; }
  #classes { margin: 8px 0; }
  .cls { padding: 6px; flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .cls span { font-size: 20px; }
  #play { padding: 10px; font-size: 18px; }
  .hint { display: none; }
}
@media (max-height: 430px) {
  #panel { width: 170px; padding: 6px 8px; }
  #chatlog { bottom: calc(150px + var(--sab)); }
}

/* ================= Инвентарь ================= */
#inv {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.45); --cell: 36px;
}
.inv-box {
  position: relative; padding: 8px 12px 10px; border-radius: 10px;
  background:
    linear-gradient(rgba(255,255,255,0.03), rgba(0,0,0,0.25)),
    repeating-linear-gradient(45deg, #1b1612 0 6px, #1e1915 6px 12px);
  border: 2px solid #6b5326; box-shadow: 0 0 0 1px #000, inset 0 0 0 1px #2c2216, inset 0 0 30px rgba(0,0,0,0.7), 0 20px 50px rgba(0,0,0,0.7);
}
.inv-box::before, .inv-box::after {
  content: ''; position: absolute; width: 18px; height: 18px; border: 2px solid #e8c26a; pointer-events: none;
}
.inv-box::before { top: -3px; left: -3px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.inv-box::after { bottom: -3px; right: -3px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
.inv-head {
  display: grid; grid-template-columns: calc(var(--cell) * 8) calc(var(--cell) * 8) auto; gap: calc(var(--cell) * 0.6);
  align-items: center; margin-bottom: 6px; font-family: Georgia, serif; color: #e8c26a; letter-spacing: 1px;
  text-shadow: 0 1px 0 #000; font-size: 15px; text-align: center;
}
#inv-close {
  position: absolute; right: 6px; top: 4px; width: 30px; height: 30px; border-radius: 6px; border: 1px solid #6b5326;
  background: #2a1f14; color: #e8c26a; font-size: 15px;
}
.inv-body { display: flex; gap: calc(var(--cell) * 0.6); }
.inv-col { display: flex; flex-direction: column; gap: 6px; }
.doll { position: relative; width: calc(var(--cell) * 8); height: calc(var(--cell) * 8); }
#doll-preview { position: absolute; left: 0; top: 0; border-radius: 8px; background: radial-gradient(circle at 50% 70%, rgba(232,194,106,0.18), transparent 70%); }
.slot {
  position: absolute; display: flex; align-items: center; justify-content: center; border-radius: 4px;
  background: linear-gradient(#0d0a08, #18120d); border: 1px solid #4a3a1e; box-shadow: inset 0 0 8px #000;
}
.slot > span { font-size: 9px; color: rgba(232,194,106,0.35); text-transform: uppercase; letter-spacing: 0.5px; pointer-events: none; text-align: center; }
.slot.filled > span { display: none; }
.slot.disabled { opacity: 0.35; }
.slot .item { position: relative; }
.grid {
  position: relative; width: calc(var(--cell) * 8); height: calc(var(--cell) * 8);
  background-color: #0c0907;
  background-image: linear-gradient(#3a2d17 1px, transparent 1px), linear-gradient(90deg, #3a2d17 1px, transparent 1px);
  background-size: var(--cell) var(--cell); border: 1px solid #4a3a1e; box-shadow: inset 0 0 12px #000;
}
.item { position: absolute; display: flex; align-items: center; justify-content: center; border-radius: 3px; touch-action: none; cursor: grab; }
.item canvas { pointer-events: none; }
.grid .item { background: rgba(255,255,255,0.035); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06); }
/* редкость — только тонкая линия снизу ячейки, свечение даёт сам предмет */
.item.r1 { box-shadow: inset 0 -2px 0 rgba(111,168,255,0.55) !important; }
.item.r2 { box-shadow: inset 0 -2px 0 rgba(244,227,107,0.55) !important; }
.item.r3 { box-shadow: inset 0 -2px 0 rgba(255,165,61,0.7) !important; }
.item .plus { position: absolute; left: 2px; top: 1px; font-style: normal; font-size: 10px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000, 0 0 4px #000; pointer-events: none; }
.item .count { position: absolute; right: 2px; bottom: 0; font-style: normal; font-size: 10px; font-weight: 700; color: #ffe7a0; text-shadow: 0 1px 2px #000; pointer-events: none; }
.item.ghost { position: fixed; z-index: 30; pointer-events: none; opacity: 0.9; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.7)); }
.item.enh-target { outline: 1px dashed rgba(111,208,255,0.8); animation: pulse 1s infinite; }
.item.enh-src { outline: 2px solid #6fd0ff; }
@keyframes pulse { 50% { box-shadow: inset 0 0 12px rgba(111,208,255,0.5); } }
.hl-ok { box-shadow: inset 0 0 0 2px #5fe07a, 0 0 10px rgba(95,224,122,0.5) !important; }
.hl-bad { box-shadow: inset 0 0 0 2px #e05f5f !important; }
.item.flash-ok { animation: flashOk 0.9s; }
.item.flash-fail { animation: flashFail 0.6s; }
@keyframes flashOk { 0% { filter: brightness(3) drop-shadow(0 0 12px #ffe27a); } 100% { filter: none; } }
@keyframes flashFail { 0%, 50% { filter: grayscale(1) brightness(0.5); transform: translateX(-3px); } 25%, 75% { transform: translateX(3px); } 100% { filter: none; } }

.inv-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; font-size: 12px; color: #cdbf9e; padding: 4px 2px; }
.inv-stats b { color: #fff; }
.inv-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 13px; flex-wrap: wrap; }
.inv-foot .gold b { color: #ffe27a; }
.shop { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.shop-label { font-size: 11px; color: #a89670; }
.shop button, .enh-bar button, .t-btns button {
  font: inherit; font-size: 12px; padding: 5px 9px; border-radius: 6px; border: 1px solid #6b5326; color: #f3ead8;
  background: linear-gradient(#3a2c1a, #221a10);
}
.shop button:active, .t-btns button:active { filter: brightness(1.4); }
.enh-bar {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: -42px; white-space: nowrap; padding: 6px 10px; border-radius: 8px;
  background: rgba(10,30,40,0.92); border: 1px solid #6fd0ff; color: #bfeeff; font-size: 13px; display: flex; gap: 8px; align-items: center;
}

.tip {
  position: fixed; z-index: 40; min-width: 200px; max-width: 280px; padding: 10px 12px; text-align: center; font-size: 12.5px; line-height: 1.45;
  background: rgba(8, 6, 4, 0.94); border: 1px solid #6b5326; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,0.8); color: #ddd2bb;
}
.tip .t-name { font-weight: 800; font-size: 14.5px; text-shadow: 0 0 6px rgba(0,0,0,0.9); }
.tip .t-sub { font-size: 11px; opacity: 0.85; margin-bottom: 4px; }
.tip b { color: #fff; }
.tip em { color: #8d826b; font-style: normal; font-size: 11px; }
.tip .t-opt { color: #7fb8ff; }
.tip .t-desc { color: #bfeeff; margin: 2px 0; }
.tip .t-req { color: #a89670; font-size: 11.5px; }
.tip .t-bad { color: #ff6b5b; font-size: 11.5px; }
.tip .t-enh { color: #6fd0ff; font-size: 11.5px; margin-top: 4px; }
.tip .t-warn { color: #ffb36b; font-size: 11px; }
.tip .t-price { color: #ffe27a; font-size: 11.5px; margin-top: 4px; }
.t-btns { display: flex; gap: 5px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.t-btns .danger { border-color: #8a3a2a; color: #ffb4a8; }

.enh-fx {
  position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%) scale(0.6); z-index: 50; pointer-events: none; opacity: 0;
  display: flex; flex-direction: column; align-items: center; text-align: center; transition: opacity 0.2s, transform 0.25s;
}
.enh-fx.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.enh-fx b { font-family: Georgia, serif; font-size: 44px; letter-spacing: 2px; }
.enh-fx span { font-size: 16px; font-weight: 700; text-shadow: 0 2px 6px #000; }
.enh-fx.ok b { color: #ffe27a; text-shadow: 0 0 20px rgba(255,210,90,0.9), 0 3px 0 #6b4a16; }
.enh-fx.fail b { color: #ff6b5b; text-shadow: 0 0 16px rgba(255,60,40,0.7), 0 3px 0 #4a0a06; }

#inv.portrait .inv-body { flex-direction: column; gap: 6px; }
#inv.portrait .inv-head { grid-template-columns: 1fr; }
#inv.portrait #inv-title-bag { display: none; }
#inv.portrait .inv-box { padding-top: 34px; }
#inv.portrait .inv-head b { position: absolute; top: 9px; left: 14px; }

#btn-inv { right: 76px; bottom: 152px; }
#inv.portrait .inv-col { align-items: center; }
#inv.portrait .inv-foot { width: calc(var(--cell) * 8); justify-content: center; }
#inv.portrait .inv-stats { width: calc(var(--cell) * 8); }

/* ===== Заточка: перелив +10..+15 ===== */
.item canvas.gb-glow { animation: gbGlow 1.8s ease-in-out infinite; }
@keyframes gbGlow {
  0%, 100% { filter: drop-shadow(0 0 var(--gl) rgba(255, 205, 70, 0.95)); }
  50% { filter: drop-shadow(0 0 var(--gl) rgba(70, 160, 255, 0.95)); }
}
.item .shimmer {
  position: absolute; pointer-events: none; opacity: var(--sh);
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  background: linear-gradient(115deg,
    rgba(255,215,80,0.0) 0%, rgba(255,215,80,0.85) 18%, rgba(255,250,210,0.95) 26%,
    rgba(60,150,255,0.9) 40%, rgba(150,210,255,0.95) 50%, rgba(255,205,60,0.9) 62%,
    rgba(40,120,255,0.85) 78%, rgba(255,215,80,0.0) 100%);
  background-size: 300% 300%; mix-blend-mode: screen;
  animation: shimmer var(--sp) linear infinite;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: -200% 50%; } }
.item .luck { position: absolute; right: 2px; top: 0; font-style: normal; font-size: 11px; color: #7fe08a; text-shadow: 0 0 3px #000, 0 1px 2px #000; pointer-events: none; }
.tip .t-luck { color: #7fb8ff; }
.tip .t-hx { color: #f0a8ff; font-weight: 700; text-shadow: 0 0 6px rgba(200,100,255,0.5); }
.enh-fx span.hx { color: #f0a8ff; font-size: 14px; margin-top: 2px; }

/* ===== Кузнец ===== */
#inv.forge-mode .inv-box { border-color: #8a5a26; }
.forge { width: calc(var(--cell) * 8); display: flex; gap: 10px; align-items: flex-start; }
.anvil {
  position: relative; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: 10px; border: 1px solid #6b5326;
  background: radial-gradient(circle at 50% 75%, rgba(255,120,30,0.28), transparent 60%), linear-gradient(#120d09, #1d140c);
  box-shadow: inset 0 0 18px #000, inset 0 -8px 20px rgba(255,100,20,0.15);
}
.anvil::after { content: ''; position: absolute; left: 12%; right: 12%; bottom: 8%; height: 10%; border-radius: 4px 4px 2px 2px; background: linear-gradient(#55524d, #2a2826); box-shadow: 0 -2px 0 #77736c inset; pointer-events: none; }
.anvil .item { position: relative; z-index: 1; margin-bottom: 12%; }
.anvil-empty { font-size: 40px; opacity: 0.25; margin-bottom: 14%; }
.f-name { position: absolute; top: 4px; left: 4px; right: 4px; text-align: center; font-size: 11px; font-weight: 800; text-shadow: 0 1px 2px #000; }
.anvil.hit-ok { animation: anvilOk 0.9s; }
.anvil.hit-burn { animation: anvilBurn 1.1s; }
@keyframes anvilOk { 0% { box-shadow: inset 0 0 40px rgba(255,220,90,1), 0 0 30px rgba(255,210,80,0.9); } 100% { } }
@keyframes anvilBurn { 0% { box-shadow: inset 0 0 60px rgba(255,60,0,1), 0 0 40px rgba(255,80,0,1); filter: brightness(1.6); } 60% { box-shadow: inset 0 0 30px rgba(120,20,0,1); } 100% { } }
.f-info { flex: 1; font-size: 12.5px; line-height: 1.5; color: #ddd2bb; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.f-info em { color: #8d826b; font-style: normal; font-size: 11px; }
.f-step { font-size: 20px; font-weight: 800; color: #cdbf9e; }
.f-step .f-next { color: #ffd34a; text-shadow: 0 0 8px rgba(80,160,255,0.8); }
.f-chance b { color: #7fe08a; font-size: 15px; }
.f-bad { color: #ff6b5b; }
.f-hx { color: #f0a8ff; }
.f-ward { display: block; font-size: 11.5px; line-height: 1.35; }
.f-ward input { vertical-align: middle; margin: 0 4px 0 0; }
.anvil .item .plus { display: none; }
.f-ward.f-off { opacity: 0.45; }
.f-warn { color: #ffb36b; font-size: 11.5px; font-weight: 700; }
#f-go {
  margin-top: 4px; font: inherit; font-size: 15px; font-weight: 800; padding: 9px; border-radius: 8px; border: 1px solid #b8862a;
  color: #2a1c06; background: linear-gradient(#ffd56a, #c48a22); box-shadow: 0 3px 0 #6b4a16;
}
#f-go:disabled { filter: grayscale(1) brightness(0.6); }
.f-hint { color: #cdbf9e; font-size: 12px; }
.f-table { display: grid; grid-template-columns: auto auto auto auto; gap: 1px 8px; font-size: 11.5px; margin-top: 6px; color: #a89670; }
.f-table span:nth-child(4n+1) { color: #ffd34a; font-weight: 700; }
.f-table span:nth-child(4n+2) { color: #7fe08a; }
.item.forge-ok { outline: 1px dashed rgba(255,190,80,0.8); animation: pulse 1.2s infinite; }
.item.in-forge { opacity: 0.35; }
.enh-fx.burn b { color: #ff7a2a; text-shadow: 0 0 22px rgba(255,80,0,1), 0 3px 0 #4a0a06; }
.enh-fx.saved b { color: #9fd0ff; text-shadow: 0 0 16px rgba(80,160,255,0.8), 0 3px 0 #0a2040; }
#inv.portrait .forge { flex-direction: column; align-items: center; }

/* кнопка Кузнеца в HUD */
#btn-smith {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + var(--sab)); z-index: 3;
  font: inherit; font-weight: 800; font-size: 15px; padding: 10px 18px; border-radius: 22px; border: 1px solid #e8c26a;
  color: #2a1c06; background: linear-gradient(#ffd56a, #c48a22); box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}
img.mini { width: 16px; height: 16px; vertical-align: -3px; }
.shop button img.mini { margin-right: 2px; }
.f-req b { color: #fff; }
.f-table { grid-template-columns: auto auto auto auto auto !important; }
.item .shimmer.fortune {
  background: linear-gradient(115deg, rgba(160,90,255,0) 0%, rgba(170,100,255,0.9) 20%, rgba(255,240,200,0.95) 32%,
    rgba(60,130,255,0.9) 46%, rgba(255,215,80,0.9) 60%, rgba(150,80,255,0.9) 76%, rgba(60,130,255,0) 100%);
  background-size: 300% 300%;
}
.item .lifeo { position: absolute; left: 2px; bottom: 0; font-style: normal; font-size: 9px; font-weight: 800; color: #ff7a9a; text-shadow: 0 1px 2px #000; pointer-events: none; }
.tip .t-life { color: #ff8aa8; font-weight: 700; }

/* ===== Задания ===== */
#quests { position: fixed; inset: 0; z-index: 12; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.45); }
.q-box {
  width: min(560px, 94vw); max-height: 92vh; display: flex; flex-direction: column; border-radius: 10px; padding: 8px 10px 10px;
  background: repeating-linear-gradient(45deg, #1b1612 0 6px, #1e1915 6px 12px); border: 2px solid #6b5326;
  box-shadow: 0 0 0 1px #000, inset 0 0 30px rgba(0,0,0,0.7), 0 20px 50px rgba(0,0,0,0.7);
}
.q-head { display: flex; justify-content: space-between; align-items: center; font-family: Georgia, serif; color: #e8c26a; font-size: 16px; padding: 2px 4px 8px; }
.q-head button { width: 30px; height: 30px; border-radius: 6px; border: 1px solid #6b5326; background: #2a1f14; color: #e8c26a; }
.q-list { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; touch-action: pan-y; padding-right: 2px; }
.q-card { border: 1px solid #4a3a1e; border-radius: 8px; padding: 8px 10px; background: rgba(0,0,0,0.35); font-size: 12.5px; color: #ddd2bb; }
.q-card.active { border-color: #e8c26a; box-shadow: 0 0 12px rgba(232,194,106,0.25) inset; }
.q-card.locked { opacity: 0.5; }
.q-title { font-weight: 800; color: #ffe7a0; font-size: 14px; }
.q-text { margin: 3px 0; color: #bfb39a; font-style: italic; }
.q-goal { color: #9fd0ff; }
.q-rew { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; color: #ffe27a; }
.q-btns { margin-top: 6px; display: flex; justify-content: flex-end; }
.q-btns button { font: inherit; font-weight: 700; padding: 6px 14px; border-radius: 7px; border: 1px solid #6b5326; color: #f3ead8; background: linear-gradient(#3a2c1a, #221a10); }
.q-btns button:disabled { opacity: 0.4; }
.q-btns .q-turn { color: #2a1c06; background: linear-gradient(#ffd56a, #c48a22); border-color: #e8c26a; }
.q-lock { color: #a89670; font-size: 11.5px; }
.q-foot { text-align: center; font-size: 11px; color: #8d826b; padding: 4px; }
#qtrack {
  position: fixed; top: calc(108px + var(--sat)); right: calc(8px + var(--sar)); width: 160px; padding: 5px 8px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--edge); font-size: 11px; display: flex; flex-direction: column; gap: 1px; pointer-events: none;
}
#qtrack b { color: #ffe7a0; font-size: 11.5px; }
#qtrack.ready { border-color: #7fe08a; }
#qtrack.ready span { color: #7fe08a; }
#btn-quest {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + var(--sab)); z-index: 3;
  font: inherit; font-weight: 800; font-size: 15px; padding: 10px 18px; border-radius: 22px; border: 1px solid #9fd0ff;
  color: #0a1a2a; background: linear-gradient(#bfe6ff, #5aa0d8); box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}
#inv:not(.portrait) .inv-stats { grid-template-columns: 1fr 1fr 1fr; font-size: 11px; gap: 1px 8px; }

/* ===== SD, боссы, нашествие, Excellent ===== */
.bar.sd { height: 8px; }
.bar.sd span { font-size: 8px; line-height: 8px; }
.bar.sd i { background: linear-gradient(#c8f0ff, #4aa8d8); }
#btn-world { position: fixed; top: calc(8px + var(--sat)); left: calc(206px + var(--sal)); width: 40px; height: 40px; }
#btn-world span { font-size: 20px; }
#world {
  position: fixed; top: calc(54px + var(--sat)); left: calc(206px + var(--sal)); width: 250px; z-index: 6; padding: 8px 10px; border-radius: 10px;
  background: rgba(14,10,8,0.92); border: 1px solid var(--edge); font-size: 12px; display: flex; flex-direction: column; gap: 5px;
}
#world .w-row { display: flex; justify-content: space-between; gap: 6px; }
#world .w-row b { color: #ffe7a0; }
#world .w-boss { color: #ff8a6b; font-weight: 700; }
#world .w-guard { color: #ffd34a; }
#world .w-cd { color: #9a9080; }
#world .w-ev { border-top: 1px solid #4a3a1e; padding-top: 5px; color: #b8f0a0; }
#world .w-ev.on { color: #ffd34a; font-weight: 800; text-shadow: 0 0 8px rgba(255,210,80,0.6); }
#zonebanner {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(10px + var(--sat)); padding: 6px 14px; border-radius: 16px;
  background: rgba(60,8,4,0.85); border: 1px solid #ff6a3a; color: #ffd0b0; font-weight: 800; font-size: 13px; pointer-events: none; white-space: nowrap;
}
.item .shimmer.exc {
  background: linear-gradient(115deg, rgba(60,220,110,0) 0%, rgba(80,240,130,0.85) 22%, rgba(230,255,220,0.95) 34%,
    rgba(40,200,90,0.85) 48%, rgba(255,255,255,0.6) 56%, rgba(70,230,120,0.85) 70%, rgba(60,220,110,0) 100%);
  background-size: 300% 300%;
}
.item.exc { box-shadow: inset 0 -2px 0 rgba(75,224,122,0.75) !important; }
.tip .t-exc-h { color: #4be07a; font-weight: 800; letter-spacing: 1px; margin-top: 2px; }
.tip .t-exc { font-weight: 700; }
.tip .t-exc em { font-size: 10px; opacity: 0.8; }
.t-btns .q-turn { color: #0a2a10; background: linear-gradient(#a8ffbe, #3fbf6a); border-color: #7fe08a; font-weight: 800; }

/* ===== Характеристики и Gear Score ===== */
#inv-tab { position: absolute; right: 44px; top: 4px; height: 30px; padding: 0 10px; border-radius: 6px; border: 1px solid #6b5326; background: #2a1f14; color: #e8c26a; font: inherit; font-size: 12px; font-weight: 700; }
#inv-tab.pulse { animation: tabPulse 1.2s infinite; border-color: #7fe08a; color: #b8ffcc; }
@keyframes tabPulse { 50% { box-shadow: 0 0 12px rgba(127,224,138,0.8); } }
.inv-mini { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: #cdbf9e; padding: 2px; width: calc(var(--cell) * 8); }
.inv-mini b { color: #fff; }
.inv-mini .pts { color: #7fe08a; font-weight: 800; }
.gs-val { color: #ffd34a !important; text-shadow: 0 0 6px rgba(255,211,74,0.5); }
.inv-stats:not(.hidden) { display: flex !important; flex-direction: column; gap: 8px; width: calc(var(--cell) * 8); height: calc(var(--cell) * 8); overflow-y: auto; font-size: 12.5px !important; }
.stats-box, .gs-box { border: 1px solid #4a3a1e; border-radius: 8px; padding: 6px 8px; background: rgba(0,0,0,0.35); }
.stats-head, .gs-head { font-family: Georgia, serif; color: #e8c26a; font-weight: 700; margin-bottom: 4px; }
.stats-head em, .gs-head em { color: #7fe08a; font-style: normal; font-size: 11px; font-family: inherit; }
.stat-row { display: grid; grid-template-columns: 1fr auto 30px; align-items: center; gap: 8px; padding: 2px 0; }
.stat-row b { color: #fff; font-size: 14px; }
.stat-row button { width: 28px; height: 24px; border-radius: 6px; border: 1px solid #3fbf6a; background: linear-gradient(#5adf8a, #2a8a4a); color: #fff; font-weight: 900; font-size: 15px; padding: 0; }
.stat-mini, .stat-extra { display: flex; flex-wrap: wrap; gap: 3px 12px; margin-top: 4px; color: #cdbf9e; font-size: 11.5px; }
.gs-box { background: linear-gradient(rgba(40,30,10,0.6), rgba(0,0,0,0.4)); border-color: #8a6a26; }
.gs-box div { line-height: 1.55; }
.gs-box .up { color: #4be07a; }
.tip .t-gs { color: #ffd34a; font-weight: 700; }
.tip .t-set { color: #b8a6ff; font-size: 11.5px; }
.tip .t-gem-big { margin: 2px 0 0; }
.tip img.gem-big { width: 64px; height: 64px; filter: drop-shadow(0 0 10px rgba(255,255,255,0.35)); animation: gemFloat 2.4s ease-in-out infinite; }
@keyframes gemFloat { 50% { transform: translateY(-3px) scale(1.04); } }
.tip .t-gem-kind { font-weight: 800; font-size: 12px; margin-bottom: 4px; }
.tip .t-gem-use { text-align: left; background: rgba(255,255,255,0.04); border-radius: 6px; padding: 6px 8px; line-height: 1.5; }
.tip .t-gem-use .ok { color: #7fe08a; }
.tip .t-gem-use .bad { color: #ff8a6b; }
.tip .t-gem-how { color: #9fd0ff; font-size: 11px; margin-top: 4px; font-style: italic; }
/* Перелив и свечение — цветом самой вещи */
.item .shimmer:not(.exc):not(.fortune) {
  background: linear-gradient(115deg, transparent 0%, var(--c1, #ffd34a) 22%, rgba(255,255,255,0.45) 32%, var(--c2, #4f9bff) 46%,
    var(--c1, #ffd34a) 60%, rgba(255,255,255,0.3) 70%, transparent 100%);
  background-size: 300% 300%;
}
.item canvas.gb-glow { animation: gbGlow2 2s ease-in-out infinite; }
.gs-box { order: -1; }
@keyframes gbGlow2 {
  0%, 100% { filter: drop-shadow(0 0 var(--gl) var(--gc1, #ffd34a)); }
  50% { filter: drop-shadow(0 0 calc(var(--gl) * 1.6) var(--gc2, #4f9bff)) brightness(1.15); }
}
/* Камни мерцают в сумке */
.item.gemstone canvas { animation: gemTwinkle 2.2s ease-in-out infinite; }
@keyframes gemTwinkle { 0%, 100% { filter: drop-shadow(0 0 2px rgba(255,255,255,0.3)); } 50% { filter: drop-shadow(0 0 7px rgba(255,255,255,0.75)) brightness(1.2); } }
.item.gemstone::after { content: '✦'; position: absolute; right: 3px; top: 1px; font-size: 9px; color: #fff; opacity: 0; animation: twinkle 2.2s infinite; pointer-events: none; text-shadow: 0 0 4px #fff; }
@keyframes twinkle { 40%, 60% { opacity: 1; } 0%, 100% { opacity: 0; } }

#gates { position: fixed; inset: 0; z-index: 12; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.5); }
#btn-gate {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + var(--sab)); z-index: 3;
  font: inherit; font-weight: 800; font-size: 15px; padding: 10px 18px; border-radius: 22px; border: 1px solid #9fd8ff; margin-bottom: 56px;
  color: #06203a; background: linear-gradient(#cfeaff, #5aa0e8); box-shadow: 0 4px 18px rgba(90,160,255,0.5);
}

#panel .row { gap: 6px; }
#pname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
#plvl { white-space: nowrap; font-size: 11px !important; }

/* ===== HUD: шары здоровья и маны ===== */
#panel .bar.hp, #panel .bar.mp, #panel .bar.sd { display: none; }
#orbs { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(6px + var(--sab)); display: flex; align-items: flex-end; gap: 6px; pointer-events: none; z-index: 2; }
.orb { position: relative; width: 70px; height: 70px; }
.orb .glass { position: absolute; inset: 5px; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 50% 60%, #120a08, #000);
  box-shadow: 0 0 0 2px #2a2016, 0 0 0 4px #8a6a2a, 0 0 0 5px #1a1208, 0 4px 14px rgba(0,0,0,0.7), inset 0 0 14px rgba(0,0,0,0.9); }
.orb .liquid { position: absolute; left: 0; right: 0; bottom: 0; height: 100%; transition: height 0.25s; }
.orb.hp .liquid { background: radial-gradient(circle at 40% 30%, #ff6a5a, #b0141a 55%, #4a0408); }
.orb.mp .liquid { background: radial-gradient(circle at 40% 30%, #6aa8ff, #1a3ab8 55%, #060c4a); }
.orb .liquid i { position: absolute; left: -50%; top: -6px; width: 200%; height: 12px; border-radius: 45%;
  background: rgba(255,255,255,0.18); animation: wave 3s linear infinite; }
@keyframes wave { from { transform: translateX(0) rotate(0); } to { transform: translateX(25%) rotate(360deg); } }
.orb .glass::after { content: ''; position: absolute; left: 14%; top: 8%; width: 44%; height: 28%; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 40%, rgba(255,255,255,0.55), rgba(255,255,255,0)); }
.orb b { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000, 0 0 4px #000; }
.sdring { position: absolute; inset: 0; transform: rotate(-90deg); }
.sdring .sd-bg { fill: none; stroke: rgba(0,0,0,0.5); stroke-width: 4; }
.sdring .sd-fg { fill: none; stroke: #bfeaff; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 295.3; stroke-dashoffset: 0; filter: drop-shadow(0 0 3px #7ad0ff); transition: stroke-dashoffset 0.25s; }
.xpwrap { display: flex; flex-direction: column; align-items: center; gap: 2px; padding-bottom: 8px; }
.xpwrap .lvl { font-family: Georgia, serif; font-weight: 800; color: #ffe27a; font-size: 15px; text-shadow: 0 1px 2px #000, 0 0 8px rgba(255,200,80,0.5);
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: radial-gradient(#3a2a12, #120a04); box-shadow: 0 0 0 2px #8a6a2a; }
.xpbar2 { width: 110px; height: 7px; border-radius: 4px; background: rgba(0,0,0,0.7); box-shadow: 0 0 0 1px #8a6a2a; overflow: hidden; }
.xpbar2 i { display: block; height: 100%; width: 0; background: linear-gradient(#ffe27a, #b8862a); transition: width 0.3s; }
.xptxt { font-size: 9px; color: #cdbf9e; text-shadow: 0 1px 1px #000; }
#btn-smith, #btn-quest, #btn-gate { bottom: calc(96px + var(--sab)) !important; }
@media (max-height: 430px) { .orb { width: 62px; height: 62px; } .xpbar2 { width: 96px; } }
#panel .bar.xp { display: none; }

#btn-buff { right: 182px; bottom: 84px; }
#btn-buff .cd { border-radius: 50%; }
#btn-sound { position: fixed; top: calc(8px + var(--sat)); left: calc(252px + var(--sal)); width: 40px; height: 40px; }
#btn-sound span { font-size: 18px; }
#bufbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--sab)); display: flex; gap: 4px; pointer-events: none; z-index: 2; }
#bufbar .bf { width: 30px; height: 30px; border-radius: 6px; background: rgba(10,8,6,0.85); border: 1px solid #8a6a2a; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 14px; line-height: 1; }
#bufbar .bf i { font-style: normal; font-size: 9px; color: #ffe7a0; }

#btn-rank { position: fixed; top: calc(8px + var(--sat)); left: calc(298px + var(--sal)); width: 40px; height: 40px; }
#btn-rank span { font-size: 18px; }
#rank { position: fixed; inset: 0; z-index: 12; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.5); }
.r-tabs { display: flex; gap: 6px; margin-bottom: 6px; }
.r-tabs button { flex: 1; font: inherit; font-weight: 700; padding: 6px; border-radius: 7px; border: 1px solid #6b5326; background: #221a10; color: #cdbf9e; }
.r-tabs button.on { background: linear-gradient(#ffd56a, #c48a22); color: #2a1c06; }
.r-row { display: grid; grid-template-columns: 30px 1fr auto auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 7px; background: rgba(0,0,0,0.3); font-size: 13px; }
.r-row:nth-child(1) { background: linear-gradient(90deg, rgba(255,211,74,0.25), rgba(0,0,0,0.3)); }
.r-row:nth-child(2) { background: linear-gradient(90deg, rgba(200,210,230,0.2), rgba(0,0,0,0.3)); }
.r-row:nth-child(3) { background: linear-gradient(90deg, rgba(200,130,60,0.22), rgba(0,0,0,0.3)); }
.r-row .pos { font-weight: 900; color: #ffe27a; text-align: center; }
.r-row .nm b { color: #fff; } .r-row .nm em { font-style: normal; font-size: 11px; color: #a89670; }
.r-row .gs { color: #ffd34a; font-weight: 800; } .r-row .lv { color: #9fd0ff; }
.r-row .on { color: #7fe08a; font-size: 11px; }
#party { position: fixed; top: calc(118px + var(--sat)); left: calc(8px + var(--sal)); width: 150px; display: flex; flex-direction: column; gap: 4px; z-index: 2; }
#party .pm { background: var(--panel); border: 1px solid var(--edge); border-radius: 8px; padding: 4px 7px; font-size: 11px; }
#party .pm .hpb { height: 5px; border-radius: 3px; background: rgba(0,0,0,0.6); margin-top: 3px; overflow: hidden; }
#party .pm .hpb i { display: block; height: 100%; background: linear-gradient(#5fd35a, #2a8a2a); }
#party button { font: inherit; font-size: 11px; padding: 4px; border-radius: 6px; border: 1px solid #6b5326; background: #221a10; color: #cdbf9e; }
#pmenu, #pinvite { position: fixed; z-index: 20; background: rgba(10,8,6,0.95); border: 1px solid #8a6a2a; border-radius: 10px; padding: 8px 10px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
#pinvite { left: 50%; top: 22%; transform: translateX(-50%); text-align: center; }
#pmenu button, #pinvite button { font: inherit; font-weight: 700; padding: 7px 12px; border-radius: 7px; border: 1px solid #6b5326; background: linear-gradient(#3a2c1a, #221a10); color: #f3ead8; }
#pinvite .row2 { display: flex; gap: 6px; justify-content: center; }
#pinvite .yes { background: linear-gradient(#a8ffbe, #3fbf6a); color: #0a2a10; }

.cls-pic { display: block; margin: -4px auto 0; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.6)); }
@media (max-height: 500px) { .cls-pic { width: 46px !important; height: 50px !important; } }
@media (max-height: 500px) { .cls { flex-direction: column !important; flex-wrap: nowrap !important; } .cls small { display: none; } }
:root {
  --orn-tl: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23fff1b8'/%3E%3Cstop offset='.45' stop-color='%23e2b95c'/%3E%3Cstop offset='1' stop-color='%236b4612'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg %3E%3Cpath d='M2 30V9Q2 2 9 2H30' fill='none' stroke='%230c0804' stroke-width='5'/%3E%3Cpath d='M2 30V9Q2 2 9 2H30' fill='none' stroke='url%28%23g%29' stroke-width='2.4'/%3E%3Cpath d='M7 25V11Q7 7 11 7H25' fill='none' stroke='url%28%23g%29' stroke-width='1' opacity='.75'/%3E%3Cpath d='M13 7.5q5 4 0 8.5q-3.5 2.5 -5.5 -0.5' fill='none' stroke='url%28%23g%29' stroke-width='1.3'/%3E%3Cpath d='M30 2l-4 -1.6v3.2zM2 30l-1.6 -4h3.2z' fill='url%28%23g%29'/%3E%3Ccircle cx='6.5' cy='6.5' r='3.6' fill='%237a0f0c' stroke='url%28%23g%29' stroke-width='1.5'/%3E%3Ccircle cx='5.6' cy='5.6' r='1.1' fill='%23ffc0b0'/%3E%3C/g%3E%3C/svg%3E");
  --orn-tr: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23fff1b8'/%3E%3Cstop offset='.45' stop-color='%23e2b95c'/%3E%3Cstop offset='1' stop-color='%236b4612'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg transform='translate%2832%2C0%29 scale%28-1%2C1%29'%3E%3Cpath d='M2 30V9Q2 2 9 2H30' fill='none' stroke='%230c0804' stroke-width='5'/%3E%3Cpath d='M2 30V9Q2 2 9 2H30' fill='none' stroke='url%28%23g%29' stroke-width='2.4'/%3E%3Cpath d='M7 25V11Q7 7 11 7H25' fill='none' stroke='url%28%23g%29' stroke-width='1' opacity='.75'/%3E%3Cpath d='M13 7.5q5 4 0 8.5q-3.5 2.5 -5.5 -0.5' fill='none' stroke='url%28%23g%29' stroke-width='1.3'/%3E%3Cpath d='M30 2l-4 -1.6v3.2zM2 30l-1.6 -4h3.2z' fill='url%28%23g%29'/%3E%3Ccircle cx='6.5' cy='6.5' r='3.6' fill='%237a0f0c' stroke='url%28%23g%29' stroke-width='1.5'/%3E%3Ccircle cx='5.6' cy='5.6' r='1.1' fill='%23ffc0b0'/%3E%3C/g%3E%3C/svg%3E");
  --orn-bl: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23fff1b8'/%3E%3Cstop offset='.45' stop-color='%23e2b95c'/%3E%3Cstop offset='1' stop-color='%236b4612'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg transform='translate%280%2C32%29 scale%281%2C-1%29'%3E%3Cpath d='M2 30V9Q2 2 9 2H30' fill='none' stroke='%230c0804' stroke-width='5'/%3E%3Cpath d='M2 30V9Q2 2 9 2H30' fill='none' stroke='url%28%23g%29' stroke-width='2.4'/%3E%3Cpath d='M7 25V11Q7 7 11 7H25' fill='none' stroke='url%28%23g%29' stroke-width='1' opacity='.75'/%3E%3Cpath d='M13 7.5q5 4 0 8.5q-3.5 2.5 -5.5 -0.5' fill='none' stroke='url%28%23g%29' stroke-width='1.3'/%3E%3Cpath d='M30 2l-4 -1.6v3.2zM2 30l-1.6 -4h3.2z' fill='url%28%23g%29'/%3E%3Ccircle cx='6.5' cy='6.5' r='3.6' fill='%237a0f0c' stroke='url%28%23g%29' stroke-width='1.5'/%3E%3Ccircle cx='5.6' cy='5.6' r='1.1' fill='%23ffc0b0'/%3E%3C/g%3E%3C/svg%3E");
  --orn-br: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23fff1b8'/%3E%3Cstop offset='.45' stop-color='%23e2b95c'/%3E%3Cstop offset='1' stop-color='%236b4612'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg transform='translate%2832%2C32%29 scale%28-1%2C-1%29'%3E%3Cpath d='M2 30V9Q2 2 9 2H30' fill='none' stroke='%230c0804' stroke-width='5'/%3E%3Cpath d='M2 30V9Q2 2 9 2H30' fill='none' stroke='url%28%23g%29' stroke-width='2.4'/%3E%3Cpath d='M7 25V11Q7 7 11 7H25' fill='none' stroke='url%28%23g%29' stroke-width='1' opacity='.75'/%3E%3Cpath d='M13 7.5q5 4 0 8.5q-3.5 2.5 -5.5 -0.5' fill='none' stroke='url%28%23g%29' stroke-width='1.3'/%3E%3Cpath d='M30 2l-4 -1.6v3.2zM2 30l-1.6 -4h3.2z' fill='url%28%23g%29'/%3E%3Ccircle cx='6.5' cy='6.5' r='3.6' fill='%237a0f0c' stroke='url%28%23g%29' stroke-width='1.5'/%3E%3Ccircle cx='5.6' cy='5.6' r='1.1' fill='%23ffc0b0'/%3E%3C/g%3E%3C/svg%3E");
  --orn-crest: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='20' viewBox='0 0 96 20'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23fff1b8'/%3E%3Cstop offset='.45' stop-color='%23e2b95c'/%3E%3Cstop offset='1' stop-color='%236b4612'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M4 10H34M62 10H92' stroke='%230c0804' stroke-width='4'/%3E%3Cpath d='M4 10H34M62 10H92' stroke='url%28%23g%29' stroke-width='1.6'/%3E%3Cpath d='M34 10q6 -8 14 -8q8 0 14 8q-6 8 -14 8q-8 0 -14 -8z' fill='%231a1208' stroke='url%28%23g%29' stroke-width='1.6'/%3E%3Cpath d='M22 10q4 -5 10 -3M74 10q-4 -5 -10 -3M22 10q4 5 10 3M74 10q-4 5 -10 3' fill='none' stroke='url%28%23g%29' stroke-width='1.2'/%3E%3Cpath d='M48 3l6 7l-6 7l-6 -7z' fill='%23b81a14' stroke='%23ffe9a8' stroke-width='.8'/%3E%3Cpath d='M48 3l6 7h-12z' fill='%23ff6a4a' opacity='.7'/%3E%3Ccircle cx='46.5' cy='7' r='1' fill='%23fff'/%3E%3Ccircle cx='4' cy='10' r='2' fill='url%28%23g%29'/%3E%3Ccircle cx='92' cy='10' r='2' fill='url%28%23g%29'/%3E%3C/svg%3E");
  --orn-div: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='12' viewBox='0 0 120 12'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23fff1b8'/%3E%3Cstop offset='.45' stop-color='%23e2b95c'/%3E%3Cstop offset='1' stop-color='%236b4612'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M2 6H50M70 6H118' stroke='url%28%23g%29' stroke-width='1.2'/%3E%3Cpath d='M50 6l10 -5l10 5l-10 5z' fill='%231a1208' stroke='url%28%23g%29' stroke-width='1.2'/%3E%3Ccircle cx='60' cy='6' r='2' fill='%23ffe27a'/%3E%3C/svg%3E");
}

/* =====================================================================
   Тема «тёмный металл и золото»: рамки с орнаментом, кнопки-самоцветы, экран входа
   ===================================================================== */
:root {
  --metal: linear-gradient(#221d18, #14110d 55%, #0e0b09);
  --brush: repeating-linear-gradient(90deg, rgba(255,255,255,0.014) 0 1px, transparent 1px 3px);
  --frame-in: inset 0 0 0 1px rgba(255,226,150,0.22), inset 0 0 0 3px #0b0806, inset 0 0 0 4px rgba(201,162,74,0.28), inset 0 0 36px rgba(0,0,0,0.75);
  --frame-out: 0 0 0 1px #000, 0 0 0 2px #9a7430, 0 0 0 3px #3a2a10, 0 0 0 4px #000, 0 18px 50px rgba(0,0,0,0.75);
  --corners: var(--orn-tl) left top / 30px 30px no-repeat, var(--orn-tr) right top / 30px 30px no-repeat,
             var(--orn-bl) left bottom / 30px 30px no-repeat, var(--orn-br) right bottom / 30px 30px no-repeat;
}
/* --- окна --- */
.inv-box, .q-box {
  border: 1px solid #5a4420; border-radius: 4px;
  background: var(--corners),
    radial-gradient(ellipse 70% 40px at 50% 0, rgba(232,194,106,0.13), transparent),
    var(--brush), var(--metal);
  background-origin: border-box;
  box-shadow: var(--frame-in), var(--frame-out);
}
.inv-box::before, .inv-box::after, .q-box::before {
  content: ''; position: absolute; pointer-events: none; border: 0; border-radius: 0; z-index: 2;
  left: 50%; width: 96px; height: 20px; margin-left: -48px; background: var(--orn-crest) center / contain no-repeat;
}
.inv-box::before, .q-box::before { top: -11px; }
.inv-box::after { top: auto; bottom: -9px; right: auto; width: 120px; height: 12px; margin-left: -60px; background: var(--orn-div) center / contain no-repeat; }
.q-box { position: relative; }
.inv-head, .q-head {
  font-family: "Palatino Linotype", Palatino, Georgia, serif; font-weight: 700; letter-spacing: 1.5px;
  color: #f2d27a; text-shadow: 0 1px 0 #000, 0 0 10px rgba(232,194,106,0.35);
}
.q-head b, .inv-head b { background: linear-gradient(#fff4c8, #e8c26a 50%, #a8782a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 1px 0 #000); }
#inv-close, .q-head button, #inv-tab, #r-close {
  border: 1px solid #a8823a; border-radius: 4px; color: #ffe7a0; font-weight: 800;
  background: linear-gradient(#3a2e20, #1a140d 60%, #0e0a06);
  box-shadow: inset 0 1px 0 rgba(255,236,180,0.3), inset 0 -2px 3px rgba(0,0,0,0.6), 0 0 0 1px #000, 0 2px 4px rgba(0,0,0,0.6);
}
#inv-close:active, .q-head button:active, #inv-tab:active { filter: brightness(1.4); }
.grid, .slot { border-color: #5a4420; box-shadow: inset 0 0 14px #000, 0 0 0 1px #000, 0 0 0 2px rgba(154,116,48,0.35); }
.slot { background: radial-gradient(circle at 50% 45%, #1e1712, #0b0806 75%); }
.q-card, .stats-box, .gs-box {
  border-color: #4a3a1e; background: linear-gradient(rgba(255,236,180,0.04), rgba(0,0,0,0.35)), rgba(0,0,0,0.3);
  box-shadow: inset 0 1px 0 rgba(255,236,180,0.06), 0 0 0 1px #000;
}
.q-card.active { border-color: #e8c26a; box-shadow: inset 0 0 14px rgba(232,194,106,0.22), 0 0 0 1px #000, 0 0 10px rgba(232,194,106,0.25); }
.q-btns button, .shop button, .enh-bar button, .t-btns button, #pmenu button, #pinvite button, #party button, .r-tabs button {
  border: 1px solid #8a6a2a; box-shadow: inset 0 1px 0 rgba(255,236,180,0.22), inset 0 -2px 3px rgba(0,0,0,0.5), 0 0 0 1px #000;
}
.tip {
  border: 1px solid #7a5c26; border-radius: 3px;
  background: var(--orn-tl) left top / 20px 20px no-repeat, var(--orn-tr) right top / 20px 20px no-repeat,
    var(--orn-bl) left bottom / 20px 20px no-repeat, var(--orn-br) right bottom / 20px 20px no-repeat,
    linear-gradient(rgba(16,12,8,0.97), rgba(6,5,3,0.97));
  background-origin: border-box;
  box-shadow: inset 0 0 0 2px #000, inset 0 0 0 3px rgba(201,162,74,0.2), 0 0 0 1px #000, 0 12px 30px rgba(0,0,0,0.85);
}
.tip .t-name { letter-spacing: 0.3px; }
#world, #pmenu, #pinvite, #party .pm {
  border: 1px solid #7a5c26; border-radius: 4px;
  background: var(--brush), linear-gradient(rgba(30,24,18,0.95), rgba(10,8,6,0.95));
  box-shadow: inset 0 0 0 1px rgba(255,226,150,0.12), 0 0 0 1px #000, 0 8px 22px rgba(0,0,0,0.7);
}

/* --- панель героя, мини-карта --- */
#panel, #mapwrap {
  border: 1px solid #7a5c26; border-radius: 6px;
  background: var(--orn-tl) left top / 18px 18px no-repeat, var(--orn-br) right bottom / 18px 18px no-repeat,
    var(--brush), linear-gradient(rgba(34,28,22,0.86), rgba(12,10,8,0.86));
  background-origin: border-box;
  box-shadow: inset 0 0 0 1px rgba(255,226,150,0.12), 0 0 0 1px #000, 0 4px 14px rgba(0,0,0,0.55);
}
#pname { color: #fff4d6; text-shadow: 0 1px 0 #000; }
#plvl { color: #f2d27a; }
#zone { font-family: Georgia, serif; letter-spacing: 0.5px; }

/* --- кнопки: самоцветы в золотой оправе --- */
.btn {
  --g1: #8a7050; --g2: #3a2a18; --g3: #0e0905;
  border: 0; color: #fff;
  background:
    radial-gradient(ellipse 46% 26% at 50% 24%, rgba(255,255,255,0.42), rgba(255,255,255,0) 100%),
    radial-gradient(circle closest-side at 50% 50%, var(--g1) 0%, var(--g2) 55%, var(--g3) 77%, #000 79%, transparent 81%),
    conic-gradient(from 200deg, #6b4612, #fff1b8, #d9a940, #5a3a0e, #f2d27a, #8a5e1a, #fff1b8, #6b4612);
  box-shadow: 0 0 0 1px #000, 0 4px 10px rgba(0,0,0,0.65), inset 0 0 0 1px rgba(0,0,0,0.6);
}
.btn span { filter: drop-shadow(0 2px 2px rgba(0,0,0,0.8)); }
.btn:active, .btn.down { filter: brightness(1.35); border-color: transparent; }
.btn .cd { border-radius: 50%; }
#btn-atk { --g1: #ff7a5a; --g2: #a8140e; --g3: #3a0404; box-shadow: 0 0 0 1px #000, 0 0 16px rgba(255,80,40,0.35), 0 4px 10px rgba(0,0,0,0.65); }
#btn-skill { --g1: #c69aff; --g2: #5a1ab0; --g3: #1a0440; box-shadow: 0 0 0 1px #000, 0 0 14px rgba(160,100,255,0.35), 0 4px 10px rgba(0,0,0,0.65); }
#btn-buff { --g1: #ffd27a; --g2: #c46a0a; --g3: #3a1a02; }
#btn-pot { --g1: #ff7a8a; --g2: #8a0a2a; --g3: #2a0008; }
#btn-inv { --g1: #c8945a; --g2: #6a3e1a; --g3: #1e1006; }
#btn-chat { --g1: #8ac8ff; --g2: #1a4aa8; --g3: #04103a; }
#btn-world, #btn-sound, #btn-rank { --g1: #6a6a78; --g2: #24242e; --g3: #08080c; }
#btn-world { --g1: #ffe08a; --g2: #8a5a10; --g3: #2a1804; }
.btn em { bottom: 3px; font-weight: 800; color: #fff4d6; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
#btn-pot b { color: #ffe27a; text-shadow: 0 1px 2px #000; }
#btn-smith, #btn-quest, #btn-gate { box-shadow: 0 0 0 1px #000, 0 0 0 2px #c9a24a, 0 0 0 3px #3a2a10, 0 4px 16px rgba(0,0,0,0.6); letter-spacing: 0.3px; }

/* --- шары здоровья и маны: золотая оправа --- */
.orb::before {
  content: ''; position: absolute; inset: 3px; border-radius: 50%;
  background: conic-gradient(from 200deg, #6b4612, #fff1b8, #d9a940, #5a3a0e, #f2d27a, #8a5e1a, #fff1b8, #6b4612);
  box-shadow: 0 0 0 1px #000, 0 4px 12px rgba(0,0,0,0.7);
}
.orb .glass { box-shadow: 0 0 0 1px #000, inset 0 0 14px rgba(0,0,0,0.9), inset 0 -6px 12px rgba(0,0,0,0.6); }
.xpwrap .lvl { box-shadow: 0 0 0 1px #000, 0 0 0 3px #c9a24a, 0 0 0 4px #000; }
.xpbar2 { box-shadow: 0 0 0 1px #000, 0 0 0 2px #8a6a2a; }
#bufbar .bf { border-color: #c9a24a; box-shadow: inset 0 0 6px #000, 0 0 0 1px #000; }
#toast { color: #fff4d6; text-shadow: 0 2px 4px #000, 0 0 12px rgba(232,194,106,0.45); }

/* --- экран входа --- */
#login {
  background:
    radial-gradient(ellipse 60% 45% at 50% 38%, rgba(255,170,60,0.18), transparent 70%),
    radial-gradient(ellipse at 50% 120%, rgba(120,20,10,0.45), transparent 60%),
    radial-gradient(ellipse at center, rgba(22,16,12,0.7), rgba(4,3,2,0.96));
}
#login::before {
  content: ''; position: fixed; left: 50%; top: 42%; width: 720px; height: 720px; margin: -360px 0 0 -360px; border-radius: 50%; pointer-events: none;
  background:
    radial-gradient(circle, transparent 58%, rgba(232,194,106,0.22) 58.4%, transparent 59.2%, transparent 64%, rgba(232,194,106,0.14) 64.4%, transparent 65%),
    repeating-conic-gradient(rgba(232,194,106,0.16) 0 1deg, transparent 1deg 15deg);
  -webkit-mask: radial-gradient(circle, transparent 57%, #000 57.5%, #000 66%, transparent 66.5%); mask: radial-gradient(circle, transparent 57%, #000 57.5%, #000 66%, transparent 66.5%);
  animation: runeSpin 90s linear infinite; opacity: 0.8;
}
#login::after {
  content: ''; position: fixed; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 12% 80%, #ffcf6a, transparent), radial-gradient(1.5px 1.5px at 30% 90%, #ff9a3a, transparent),
    radial-gradient(2px 2px at 55% 85%, #ffe08a, transparent), radial-gradient(1.5px 1.5px at 72% 95%, #ff8a2a, transparent),
    radial-gradient(2px 2px at 88% 82%, #ffd27a, transparent), radial-gradient(1.5px 1.5px at 44% 98%, #ffb04a, transparent);
  animation: embers 7s linear infinite;
}
@keyframes runeSpin { to { transform: rotate(360deg); } }
@keyframes embers { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-70vh); opacity: 0; } }
.card {
  position: relative; z-index: 1; border-radius: 4px; border: 1px solid #5a4420;
  background: var(--corners), radial-gradient(ellipse 80% 60px at 50% 0, rgba(232,194,106,0.16), transparent), var(--brush),
    linear-gradient(rgba(30,24,18,0.92), rgba(10,8,6,0.94));
  background-origin: border-box;
  box-shadow: var(--frame-in), var(--frame-out), 0 0 80px rgba(255,160,60,0.12);
}
.card::before { content: ''; position: absolute; top: -11px; left: 50%; width: 96px; height: 20px; margin-left: -48px; background: var(--orn-crest) center / contain no-repeat; pointer-events: none; }
.card h1 {
  font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif; font-weight: 700; letter-spacing: 6px; text-transform: uppercase;
  background: linear-gradient(#fffbe0 10%, #f2d27a 45%, #b8862a 55%, #ffe9a8 85%); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: none; filter: drop-shadow(0 2px 0 #3a2208) drop-shadow(0 0 14px rgba(255,190,80,0.45));
}
.card .sub { color: #d8c49a; letter-spacing: 2px; padding-bottom: 12px; background: var(--orn-div) center bottom / 120px 12px no-repeat; }
#name { border: 1px solid #7a5c26; border-radius: 4px; background: rgba(0,0,0,0.55); box-shadow: inset 0 2px 6px rgba(0,0,0,0.8), 0 0 0 1px #000; }
#name:focus { border-color: #e8c26a; box-shadow: inset 0 2px 6px rgba(0,0,0,0.8), 0 0 10px rgba(232,194,106,0.4); }
.cls {
  border-radius: 4px; border: 1px solid #4a3a1e;
  background: radial-gradient(ellipse at 50% 30%, rgba(255,236,180,0.06), transparent 70%), linear-gradient(#1e1813, #0e0b08);
  box-shadow: inset 0 1px 0 rgba(255,236,180,0.08), 0 0 0 1px #000; transition: box-shadow 0.2s, border-color 0.2s;
}
.cls b { color: #e8dcc0; }
.cls.sel {
  border-color: #e8c26a; background: radial-gradient(ellipse at 50% 30%, rgba(255,200,90,0.25), transparent 70%), linear-gradient(#2a2016, #120d08);
  box-shadow: inset 0 0 0 1px rgba(255,226,150,0.5), inset 0 0 18px rgba(255,190,80,0.25), 0 0 0 1px #000, 0 0 14px rgba(255,190,80,0.35);
}
.cls.sel b { color: #ffe27a; }
#play {
  position: relative; overflow: hidden; border-radius: 4px; letter-spacing: 3px; text-transform: uppercase;
  font-family: "Palatino Linotype", Palatino, Georgia, serif; font-weight: 800; color: #2a1404;
  background: linear-gradient(#fff1b8, #e8c26a 40%, #b8862a 60%, #8a5a18);
  border: 1px solid #fff1b8;
  box-shadow: 0 0 0 1px #000, 0 0 0 3px #6b4612, 0 0 0 4px #000, 0 4px 0 4px #2a1804, 0 0 24px rgba(255,190,80,0.4);
  text-shadow: 0 1px 0 rgba(255,250,220,0.6);
}
#play::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.65), transparent); animation: playShine 3.2s ease-in-out infinite;
}
@keyframes playShine { 0%, 55% { left: -60%; } 100% { left: 130%; } }
#play:active { transform: translateY(2px); box-shadow: 0 0 0 1px #000, 0 0 0 3px #6b4612, 0 0 0 4px #000, 0 2px 0 4px #2a1804; }
@media (max-height: 500px) {
  .card h1 { letter-spacing: 4px; }
  .card .sub { padding-bottom: 10px; }
  #login::before { width: 520px; height: 520px; margin: -260px 0 0 -260px; }
}
/* портрет iPhone: шары поднимаются над кнопками действий, чат — над шарами */
@media (orientation: portrait) and (max-width: 500px) {
  #orbs { bottom: calc(214px + var(--sab)); transform: translateX(-50%) scale(0.9); transform-origin: 50% 100%; }
  #chatlog { bottom: calc(300px + var(--sab)); }
  #inv.portrait .inv-head, #inv.portrait .inv-head b { letter-spacing: 0.3px; font-size: 13px; }
}

#tpfade { position: fixed; inset: 0; z-index: 30; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.95), rgba(140,200,255,0.9) 25%, rgba(30,40,90,0.96) 70%); }
#tpfade.on { animation: tpFade 0.9s ease-out; }
@keyframes tpFade { 0% { opacity: 0; transform: scale(1.2); } 25% { opacity: 1; transform: scale(1); } 100% { opacity: 0; } }
@media (orientation: portrait) { #btn-smith, #btn-quest, #btn-gate { bottom: calc(190px + var(--sab)) !important; } }
