:root {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: #e9e9e9;
  background: #10151f;
}
* { box-sizing: border-box; }
body { margin: 0; overflow: hidden; }

.panel {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(460px, 90vw);
  height: fit-content;
  padding: 24px;
  border-radius: 12px;
  background: rgba(12, 18, 28, 0.92);
  border: 1px solid #284266;
  display: grid;
  gap: 10px;
  z-index: 10;
  overflow: hidden;
}
#login-banner { width: 100%; border-radius: 10px; border: 1px solid #3f5f8e; }
.title {
  margin: 0;
  text-align: center;
  font-family: Cinzel, Georgia, serif;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #fff0a8 0%, #f2c96a 50%, #b3831f 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 12px rgba(43, 92, 170, 0.45);
}

form { display: grid; gap: 8px; }
input, button {
  border-radius: 8px;
  border: 1px solid #4e678d;
  background: linear-gradient(180deg, #18253c 0%, #101a2d 100%);
  color: #f4f6fb;
  padding: 10px 12px;
  box-shadow: inset 0 0 0 1px rgba(173, 197, 230, 0.08), 0 1px 3px rgba(0, 0, 0, 0.45);
  transition: background 140ms ease, border-color 140ms ease, transform 120ms ease, box-shadow 140ms ease;
}
input::placeholder { color: #9fb4d2; }
input:focus {
  outline: none;
  border-color: #7aa6df;
  box-shadow: 0 0 0 2px rgba(80, 143, 219, 0.26), inset 0 0 0 1px rgba(175, 205, 238, 0.12);
}
button {
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.2px;
}
button:hover {
  border-color: #7a98bf;
  background: linear-gradient(180deg, #22375c 0%, #162846 100%);
  box-shadow: inset 0 0 0 1px rgba(186, 211, 243, 0.15), 0 2px 8px rgba(0, 0, 0, 0.48);
}
button:active {
  transform: translateY(1px);
  background: linear-gradient(180deg, #14243f 0%, #0f1d35 100%);
}
button:disabled { opacity: 0.65; cursor: not-allowed; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#auth-message { min-height: 20px; color: #f8d482; }
#version-tag {
  position: absolute; left: 10px; bottom: 8px; font-size: 12px; letter-spacing: .6px;
  color: #a8c8ff; background: rgba(5, 10, 18, 0.7); border: 1px solid #355278; border-radius: 999px; padding: 2px 8px;
}

#hud {
  position: fixed; top: 10px; left: 10px; z-index: 6; display: flex; gap: 10px;
  padding: 8px 12px; border-radius: 8px; flex-wrap: wrap; max-width: min(90vw, 980px);
  background: rgba(6, 10, 18, 0.72); border: 1px solid #2c466d;
}

#chat-box {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 8;
  width: min(420px, 92vw);
  border-radius: 10px;
  border: 1px solid #4b668f;
  background:
    linear-gradient(180deg, rgba(13, 19, 31, 0.96) 0%, rgba(8, 13, 24, 0.96) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(149, 171, 206, 0.16),
    0 5px 20px rgba(0, 0, 0, 0.45);
  padding: 10px;
}
#chat-box.panel-theme--chat {
  border-color: #4f678d;
}
#chat-log {
  height: 180px;
  overflow-y: auto;
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 13px;
  color: #d9e2f1;
  border: 1px solid #334a6d;
  background: rgba(4, 8, 15, 0.55);
  border-radius: 8px;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: #5d7597 rgba(8, 14, 24, 0.88);
}
#chat-log::-webkit-scrollbar {
  width: 10px;
}
#chat-log::-webkit-scrollbar-track {
  background: rgba(8, 14, 24, 0.88);
  border-left: 1px solid #233650;
  border-radius: 999px;
}
#chat-log::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #6a83a8 0%, #4f678c 100%);
  border: 1px solid #324968;
  border-radius: 999px;
  min-height: 28px;
}
#chat-log::-webkit-scrollbar-thumb:hover,
#chat-log::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, #7c97bf 0%, #5e789f 100%);
  border-color: #416089;
}
.chat-line { line-height: 1.35; word-break: break-word; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
.chat-line.system { color: #9dc0ff; }
.chat-line.command { color: #b3e9a7; }
#chat-input { width: 100%; }

.overlay {
  position: fixed; right: 12px; top: 60px; z-index: 7; min-width: 270px; max-width: min(560px, 96vw);
  padding: 12px;
  border-radius: 10px;
  background: rgba(8, 13, 24, 0.93);
  border: 1px solid #2c466d;
  box-shadow:
    inset 0 0 0 1px rgba(130, 160, 198, 0.16),
    0 8px 24px rgba(0, 0, 0, 0.4);
}
.overlay.draggable h3 { cursor: move; margin-top: 2px; user-select: none; }
.overlay h4 { margin: 10px 0 6px; }
.overlay ul { margin: 6px 0; padding-left: 0; list-style: none; }
.overlay li {
  margin: 4px 0;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid rgba(80, 106, 145, 0.65);
  background: rgba(15, 24, 40, 0.78);
}
.overlay li::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
  border-radius: 3px;
  border: 1px solid rgba(160, 181, 214, 0.55);
  background: rgba(25, 38, 61, 0.95);
}
.overlay.centered {
  left: 50%; right: auto; top: 50%; transform: translate(-50%, -50%); min-width: 280px; z-index: 30;
}
.panel-theme h3, .panel-theme h4 {
  font-family: Cinzel, Georgia, serif;
  letter-spacing: 0.45px;
  color: #f7e6bc;
}

#inventory-menu.panel-theme--inventory {
  border-color: #60523e;
  background:
    linear-gradient(145deg, rgba(42, 33, 25, 0.93) 0%, rgba(23, 28, 40, 0.95) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(187, 156, 106, 0.22),
    inset 0 0 0 4px rgba(57, 45, 32, 0.65),
    0 8px 25px rgba(0, 0, 0, 0.48);
}
#inventory-gold {
  margin: 0 0 8px;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid rgba(172, 139, 80, 0.75);
  background: linear-gradient(180deg, rgba(61, 45, 27, 0.9) 0%, rgba(34, 26, 16, 0.9) 100%);
  color: #ffdc91;
  font-weight: 600;
  letter-spacing: 0.25px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}
#controls-btn, #logout-btn, #controls-ok-btn { width: 100%; }
#controls-btn { margin-bottom: 8px; }
#controls-ok-btn { margin-top: 8px; }
#inventory-menu { top: 220px; }
#skills-menu {
  display: grid;
  gap: 10px;
  width: min(340px, 94vw);
}
#skills-menu.panel-theme--skills {
  border-color: #7d6a42;
  background:
    linear-gradient(155deg, rgba(67, 54, 35, 0.92) 0%, rgba(30, 24, 18, 0.95) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(220, 188, 133, 0.25),
    inset 0 0 0 4px rgba(93, 72, 42, 0.45),
    0 10px 24px rgba(0, 0, 0, 0.45);
}
#skills-menu h3 { margin-bottom: 2px; }
.skill-card {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #796443;
  background:
    linear-gradient(145deg, rgba(77, 64, 44, 0.95) 0%, rgba(43, 34, 23, 0.95) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(176, 152, 109, 0.18),
    0 2px 8px rgba(0, 0, 0, 0.35);
}
.skill-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-family: Cinzel, Georgia, serif;
  letter-spacing: 0.5px;
  color: #f6e8c8;
}
.skill-name { font-size: 14px; }
.skill-level {
  font-size: 12px;
  color: #ffdd8a;
  text-shadow: 0 0 8px rgba(219, 169, 71, 0.3);
}
.skill-xp-track {
  height: 10px;
  border-radius: 999px;
  border: 1px solid #2d3d53;
  background: linear-gradient(180deg, #1a2332 0%, #0d1421 100%);
  overflow: hidden;
}
.skill-xp-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4ea1d8 0%, #8be07a 100%);
  box-shadow: 0 0 10px rgba(115, 213, 141, 0.45);
  transition: width 180ms ease-out;
}
.skill-xp-text {
  margin: 7px 0 0;
  font-size: 12px;
  letter-spacing: 0.3px;
  color: #ddd1b2;
}
#shop-menu { top: 60px; right: 350px; }
#shop-menu.panel-theme--shop,
#potion-menu.panel-theme--potion,
#upgrade-menu.panel-theme--upgrade,
#smeltery-menu.panel-theme--smeltery {
  border-color: #5f4c31;
  background:
    linear-gradient(160deg, rgba(46, 33, 23, 0.94) 0%, rgba(27, 24, 33, 0.95) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(189, 157, 103, 0.2),
    0 8px 24px rgba(0, 0, 0, 0.46);
}
#shop-menu h4,
#potion-menu h4,
#upgrade-menu h4,
#smeltery-menu h4 {
  margin-top: 2px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid rgba(144, 112, 72, 0.72);
  background: linear-gradient(180deg, rgba(82, 57, 34, 0.8) 0%, rgba(51, 37, 25, 0.9) 100%);
}
#shop-search { width: 100%; margin-bottom: 8px; }
#upgrade-stock { color: #ffe6a0; font-weight: 600; margin: 6px 0 8px; }
#shop-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shop-column { min-width: 0; }
#potion-menu { top: 210px; right: 350px; }
#potion-list button { width: 100%; text-align: left; margin-bottom: 6px; }
#upgrade-menu { top: 420px; right: 350px; }
#smeltery-menu { top: 520px; right: 350px; }
#shop-buy-list button, #shop-sell-list button, #upgrade-list button {
  width: 100%; text-align: left; margin-bottom: 6px;
}
#smeltery-list button { width: 100%; text-align: left; margin-bottom: 6px; }
#shop-buy-list button,
#shop-sell-list button,
#upgrade-list button,
#smeltery-list button,
#potion-list button {
  position: relative;
  padding-left: 36px;
  font-size: 13px;
  border-color: #6f5a3d;
  background: linear-gradient(180deg, #2d2218 0%, #221b16 100%);
}
#shop-buy-list button::before,
#shop-sell-list button::before,
#upgrade-list button::before,
#smeltery-list button::before,
#potion-list button::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  border-radius: 4px;
  border: 1px solid rgba(201, 172, 120, 0.72);
  background: linear-gradient(180deg, rgba(79, 60, 37, 0.95) 0%, rgba(48, 38, 27, 0.95) 100%);
}
#inventory-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}
.inventory-slot {
  height: 44px;
  border: 1px solid #6f5f45;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background:
    linear-gradient(145deg, rgba(45, 35, 24, 0.92) 0%, rgba(22, 29, 41, 0.94) 100%);
  box-shadow: inset 0 0 0 1px rgba(167, 135, 93, 0.15);
}
.inventory-slot.has-item {
  cursor: grab;
  border-color: #a3895f;
  background: linear-gradient(145deg, rgba(77, 57, 35, 0.95) 0%, rgba(43, 54, 74, 0.95) 100%);
}
.inventory-slot.dragging { opacity: 0.45; }
.slot-count { color: #ffd27a; font-weight: 600; }
.hidden { display: none !important; }
#game-canvas { width: 100vw; height: 100vh; display: block; }

#map-menu { min-width: 340px; z-index: 35; }

#map-image { width: min(520px, 80vw); aspect-ratio: 1 / 1; object-fit: contain; border: 1px solid #45658d; border-radius: 8px; display: block; margin-bottom: 8px; background: #0e1726; }

@media (max-width: 640px) {
  #skills-menu {
    right: 8px;
    left: 8px;
    top: 56px;
    width: auto;
    max-width: none;
  }
  .skill-card { padding: 9px 10px; }
}
