:root {
  color: #f5f7fb;
  background: #101214;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --panel: rgba(18, 24, 31, 0.9);
  --panel-strong: rgba(21, 31, 39, 0.96);
  --line: rgba(255, 255, 255, 0.14);
  --gold: #f5b743;
  --green: #6fc36c;
  --blue: #55b9f6;
  --red: #ef5b5b;
}

* {
  box-sizing: border-box;
}

html,
body,
.app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #101214;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #f8fafc;
  background: rgba(28, 39, 49, 0.92);
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

button:active {
  transform: translateY(1px);
}

button svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.svg-sprite {
  position: fixed;
  width: 0;
  height: 0;
  overflow: hidden;
}

.app {
  position: relative;
  background: #182023;
}

#world {
  width: 100vw;
  height: 100vh;
  display: block;
  image-rendering: pixelated;
}

.world-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.32);
}

.boot-screen,
.main-menu {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: rgba(10, 15, 18, 0.66);
  backdrop-filter: blur(10px);
}

.boot-logo,
.menu-logo {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.boot-logo img,
.menu-logo img {
  width: 74px;
  height: 74px;
  image-rendering: pixelated;
  filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.45));
}

.boot-logo strong,
.menu-logo strong {
  color: #fff7d6;
  font-size: clamp(32px, 7vw, 64px);
  line-height: 1;
}

.boot-logo span,
.menu-logo span {
  color: #c5d4d8;
  font-size: 14px;
}

.boot-bar {
  position: absolute;
  left: 50%;
  bottom: min(18vh, 128px);
  width: min(360px, calc(100vw - 44px));
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(-50%);
}

.boot-bar span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #55b9f6, #f5b743, #6fc36c);
  animation: bootLoad 3s linear forwards;
  transform-origin: left;
}

@keyframes bootLoad {
  from {
    transform: scaleX(0.04);
  }
  to {
    transform: scaleX(1);
  }
}

.main-menu {
  align-content: center;
  gap: 22px;
}

.menu-logo {
  grid-template-columns: 82px minmax(0, 1fr);
  justify-items: start;
  align-items: center;
  width: min(520px, calc(100vw - 28px));
  text-align: left;
}

.menu-logo strong {
  display: block;
}

.menu-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(520px, calc(100vw - 28px));
}

.menu-actions button {
  min-height: 58px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 0 14px;
  text-align: left;
  background: rgba(29, 42, 46, 0.92);
}

.menu-actions .menu-play {
  grid-column: 1 / -1;
  min-height: 66px;
  color: #101214;
  background: #f5b743;
  border-color: rgba(255, 247, 214, 0.72);
}

.menu-wallet {
  width: min(520px, calc(100vw - 28px));
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(14, 21, 24, 0.9);
}

.menu-wallet .tabs {
  margin-bottom: 0;
}

.hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  z-index: 10;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto 46px;
  gap: 12px;
  align-items: center;
  min-height: 66px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(22, 33, 39, 0.92), rgba(16, 22, 27, 0.84));
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
}

.portrait {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(245, 183, 67, 0.45);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 25%, rgba(245, 183, 67, 0.24), rgba(66, 99, 82, 0.72));
}

.portrait img {
  width: 34px;
  height: 34px;
  image-rendering: pixelated;
}

.identity {
  min-width: 0;
}

.identity strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#zone,
#tonBalance,
.slot small,
.metric small {
  color: #b7c4c8;
  font-size: 12px;
}

.bars {
  display: grid;
  gap: 4px;
  margin-top: 6px;
  max-width: 330px;
}

.bars span {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.bars span::before {
  content: "";
  display: block;
  width: var(--value, 100%);
  height: 100%;
  border-radius: inherit;
  background: var(--color, var(--green));
  box-shadow: 0 0 10px color-mix(in srgb, var(--color, var(--green)) 60%, transparent);
}

.wallet {
  display: grid;
  justify-items: end;
  gap: 2px;
  color: #fff7d6;
  white-space: nowrap;
}

.wallet strong {
  color: var(--gold);
}

.icon-button {
  min-width: 42px;
  width: 42px;
  padding: 0;
  display: grid;
  place-items: center;
}

.world-card {
  position: absolute;
  z-index: 8;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(14, 22, 24, 0.72);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.minimap {
  right: max(12px, env(safe-area-inset-right));
  top: 90px;
  width: 172px;
  height: 172px;
  padding: 7px;
}

.minimap canvas {
  width: 156px;
  height: 156px;
  display: block;
  border-radius: 6px;
  image-rendering: pixelated;
}

.focus-card {
  left: max(12px, env(safe-area-inset-left));
  top: 90px;
  display: grid;
  gap: 2px;
  min-width: 196px;
  padding: 10px 12px;
}

.focus-card span {
  color: #c6d1d5;
  font-size: 12px;
}

.focus-card strong {
  font-size: 14px;
}

.joystick {
  position: absolute;
  z-index: 9;
  left: max(18px, env(safe-area-inset-left));
  bottom: 106px;
  width: 118px;
  height: 118px;
  border: 2px solid rgba(85, 185, 246, 0.65);
  border-radius: 50%;
  background: rgba(17, 27, 33, 0.58);
  box-shadow: inset 0 0 24px rgba(85, 185, 246, 0.16), 0 10px 30px rgba(0, 0, 0, 0.25);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.joystick span {
  position: absolute;
  width: 42px;
  height: 42px;
  left: 36px;
  top: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #9fdcff, #4da3ee);
  box-shadow: 0 6px 18px rgba(85, 185, 246, 0.42);
}

.combat-strip {
  position: absolute;
  z-index: 11;
  left: 50%;
  bottom: 96px;
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 8px;
  width: min(440px, calc(100vw - 300px));
  transform: translateX(-50%);
}

.primary-action {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: center;
  justify-items: center;
  padding: 0 12px;
  background: linear-gradient(180deg, rgba(69, 86, 49, 0.95), rgba(37, 55, 40, 0.95));
  border-color: rgba(245, 183, 67, 0.42);
}

.primary-action:first-child {
  background: linear-gradient(180deg, rgba(103, 47, 48, 0.95), rgba(65, 37, 42, 0.95));
}

.dock {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(6, minmax(68px, 1fr));
  gap: 8px;
  width: min(720px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 8px;
  background: rgba(15, 21, 25, 0.86);
  backdrop-filter: blur(14px);
  transform: translateX(-50%);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.3);
}

.dock button {
  min-width: 0;
  min-height: 58px;
  display: grid;
  gap: 4px;
  place-items: center;
  padding: 5px;
  color: #e9f2ef;
  background: rgba(37, 53, 55, 0.76);
}

.dock button span {
  font-size: 11px;
}

.drawer {
  position: absolute;
  z-index: 20;
  top: 88px;
  right: max(12px, env(safe-area-inset-right));
  bottom: 92px;
  width: min(430px, calc(100vw - 24px));
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(20, 29, 34, 0.97), rgba(13, 19, 23, 0.97));
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
}

.hidden {
  display: none !important;
}

.drawer-head {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 10px;
  align-items: start;
  margin-bottom: 14px;
}

.drawer-head h2 {
  margin: 0;
  font-size: 20px;
}

.drawer-head p {
  margin: 3px 0 0;
  color: #b8c5c8;
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px;
}

.slot,
.order,
.metric {
  min-height: 82px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  padding: 11px;
  background: rgba(30, 42, 47, 0.82);
}

.empty-state {
  min-height: 118px;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  color: #c8d4d8;
  background: rgba(14, 20, 23, 0.55);
  text-align: center;
}

.quest-card,
.dungeon-card {
  display: grid;
  gap: 8px;
}

.quest-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.quest-progress span {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
}

.craft-icon {
  width: 42px;
  height: 42px;
  image-rendering: pixelated;
}

.craft-needs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.craft-needs span {
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.1);
}

.craft-needs .ok {
  color: #d7ffd0;
  background: rgba(111, 195, 108, 0.18);
}

.craft-needs .bad {
  color: #ffd1d1;
  background: rgba(239, 91, 91, 0.18);
}

.skin-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.skin-picker button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  text-align: left;
}

.skin-picker button.active {
  border-color: rgba(245, 183, 67, 0.72);
  background: rgba(67, 56, 30, 0.85);
}

.skin-picker img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.slot strong,
.order strong,
.metric strong {
  display: block;
  margin-bottom: 3px;
}

.slot button,
.order button,
.tabs button {
  width: 100%;
  margin-top: 8px;
}

.merchant {
  border-color: rgba(245, 183, 67, 0.68);
  box-shadow: inset 0 0 0 1px rgba(245, 183, 67, 0.12);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.chat {
  display: grid;
  gap: 8px;
}

.toast {
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: 176px;
  max-width: min(420px, calc(100vw - 24px));
  padding: 10px 14px;
  border: 1px solid rgba(245, 183, 67, 0.4);
  border-radius: 8px;
  background: rgba(26, 32, 28, 0.94);
  color: #fff7d6;
  transform: translateX(-50%);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.26);
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(10, 14, 17, 0.82);
  color: #f8fafc;
  padding: 9px 10px;
}

textarea {
  min-height: 130px;
}

.error {
  display: block;
  color: #ff9b9b;
  margin: 8px 0;
}

.admin-body {
  overflow: auto;
}

.admin-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 100vh;
  background: #11161b;
}

.admin-side {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  background: #171f26;
}

.admin-side h1 {
  font-size: 20px;
}

.admin-content {
  padding: 22px;
}

.admin-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

.admin-title h2,
.admin-title p {
  margin: 0;
}

.admin-title p {
  color: #b8c5c8;
  margin-top: 4px;
}

.admin-two {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 14px;
}

.admin-list {
  display: grid;
  align-content: start;
  gap: 10px;
}

.admin-player-card {
  width: 100%;
  text-align: left;
}

.admin-player-card.active {
  border-color: rgba(245, 183, 67, 0.7);
  background: rgba(64, 55, 32, 0.78);
}

.admin-editor {
  display: grid;
  gap: 10px;
}

.admin-editor textarea {
  min-height: 150px;
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

pre {
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  color: #c8d4d8;
}

.login-card {
  max-width: 420px;
  margin: 12vh auto;
  padding: 22px;
  border: 1px solid rgba(85, 185, 246, 0.35);
  border-radius: 8px;
  background: #182126;
}

.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  color: #c8d4d8;
}

.remember input {
  width: auto;
  min-height: auto;
}

@media (max-width: 820px) {
  .menu-logo {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .menu-logo img {
    width: 54px;
    height: 54px;
  }

  .menu-actions {
    grid-template-columns: 1fr;
  }

  .hud {
    grid-template-columns: 44px minmax(0, 1fr) auto;
  }

  .admin-link {
    display: none;
  }

  .wallet {
    font-size: 12px;
  }

  .focus-card {
    display: none;
  }

  .minimap {
    top: 84px;
    width: 118px;
    height: 118px;
  }

  .minimap canvas {
    width: 102px;
    height: 102px;
  }

  .joystick {
    width: 106px;
    height: 106px;
    bottom: 118px;
  }

  .joystick span {
    width: 38px;
    height: 38px;
    left: 32px;
    top: 32px;
  }

  .combat-strip {
    left: auto;
    right: 12px;
    bottom: 119px;
    width: min(236px, calc(100vw - 142px));
    grid-template-columns: 1fr;
    transform: none;
  }

  .primary-action {
    min-height: 44px;
  }

  .dock {
    overflow-x: auto;
    grid-template-columns: repeat(6, 64px);
    justify-content: start;
    scrollbar-width: none;
  }

  .dock::-webkit-scrollbar {
    display: none;
  }

  .drawer {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 86px;
    width: auto;
    max-height: min(62vh, 520px);
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-side {
    position: sticky;
    top: 0;
    z-index: 2;
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .hud {
    gap: 8px;
    padding: 8px;
  }

  .portrait {
    width: 40px;
    height: 40px;
  }

  .identity strong {
    font-size: 14px;
  }

  .bars {
    max-width: 160px;
  }

  .combat-strip {
    width: min(196px, calc(100vw - 132px));
  }

  .primary-action span {
    font-size: 12px;
  }
}
