:root {
  color-scheme: dark;
  font-family: "Segoe UI", Arial, sans-serif;
  background: #15191b;
  color: #eef3ef;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(66, 116, 91, 0.22), transparent 28%),
    linear-gradient(135deg, #15191b, #22251f 55%, #171d22);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid #7ab08e;
  border-radius: 7px;
  background: #2f7d56;
  color: #f7fff9;
  cursor: pointer;
  padding: 8px 12px;
}

button.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #eaf7ee;
}

button.danger {
  border-color: rgba(255, 124, 102, 0.72);
  background: rgba(130, 46, 38, 0.88);
  color: #fff1ed;
}

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

input,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
  background: rgba(10, 14, 13, 0.74);
  color: #f5fff7;
  padding: 9px 10px;
}

label {
  display: grid;
  gap: 6px;
  color: #c9d8ce;
  font-size: 13px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  margin-bottom: 10px;
  font-size: 15px;
  color: #dcece1;
}

.game-shell {
  display: block;
  height: 100vh;
  padding: 14px;
}

.game-frame {
  position: relative;
  min-width: 0;
  height: calc(100vh - 28px);
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #0b1110;
  overflow: hidden;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.42);
}

.auth-login .game-shell,
.character-select .game-shell {
  height: 100vh;
  padding: 0;
}

.auth-login .game-frame,
.character-select .game-frame {
  height: 100vh;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(rgba(9, 18, 15, 0.72), rgba(9, 18, 15, 0.82)),
    radial-gradient(circle at 22% 22%, rgba(104, 151, 111, 0.24), transparent 28%),
    radial-gradient(circle at 76% 34%, rgba(202, 176, 107, 0.18), transparent 30%),
    linear-gradient(135deg, #16231d, #20261e 46%, #18242b);
  box-shadow: none;
}

.auth-login canvas,
.auth-login .hud,
.auth-login .bottom-dock,
.auth-login .bottom-panel,
.auth-login .npc-dialog-panel,
.auth-login .toast-log,
.auth-login .battle,
.auth-login .world-map,
.character-select canvas,
.character-select .hud,
.character-select .bottom-dock,
.character-select .bottom-panel,
.character-select .npc-dialog-panel,
.character-select .toast-log,
.character-select .battle,
.character-select .world-map {
  display: none;
}

.auth-login .auth,
.character-select .auth {
  position: static;
  width: min(520px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 28px;
}

.character-select .auth {
  width: min(620px, calc(100% - 32px));
}

canvas {
  width: min(100%, calc((100vh - 28px) * 16 / 9));
  height: auto;
  aspect-ratio: 16 / 9;
  image-rendering: auto;
  border-radius: 6px;
}

.hud,
.overlay {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(13, 20, 17, 0.84);
  backdrop-filter: blur(12px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

.hud {
  position: absolute;
  z-index: 3;
  min-width: 220px;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

.top-left {
  top: 14px;
  left: 14px;
}

.top-right {
  top: 14px;
  right: 14px;
  min-width: 150px;
  text-align: right;
}

.title {
  margin-bottom: 4px;
  font-weight: 700;
  font-size: 16px;
}

.logout {
  min-height: 30px;
  margin-top: 9px;
  padding: 5px 10px;
  font-size: 12px;
}

.meter {
  height: 8px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  background: #e85b4f;
}

.meter.mp span {
  background: #58a6e8;
}

.overlay {
  position: absolute;
  z-index: 5;
  width: min(440px, calc(100% - 28px));
  border-radius: 8px;
  padding: 20px;
}

.auth {
  display: grid;
  gap: 12px;
}

.panel-subtitle {
  margin-top: 4px;
  color: #ffe07a;
  font-size: 13px;
  font-weight: 700;
}

.character-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.055);
  padding: 10px;
}

.character-meta {
  min-width: 0;
}

.character-meta strong,
.character-meta span {
  display: block;
}

.character-meta strong {
  color: #fff8c8;
}

.character-meta span {
  margin-top: 3px;
  color: #c9d8ce;
  font-size: 13px;
}

.character-actions {
  display: flex;
  gap: 8px;
}

.battle {
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: grid;
  gap: 14px;
}

.mini-map {
  position: relative;
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  margin-left: auto;
  margin-bottom: 8px;
  border-radius: 999px;
  border: 2px solid rgba(255, 230, 142, 0.72);
  background:
    radial-gradient(circle at 35% 30%, rgba(129, 195, 145, 0.95), rgba(53, 95, 72, 0.9) 43%, rgba(31, 48, 57, 0.96) 70%),
    linear-gradient(135deg, #456b59, #293845);
  box-shadow: 0 0 24px rgba(255, 230, 142, 0.22), inset 0 0 18px rgba(0, 0, 0, 0.28);
  color: #fff7c8;
  font-size: 12px;
  line-height: 1.2;
  padding: 18px;
  text-align: center;
  overflow: hidden;
}

.mini-map > span:last-child {
  position: relative;
  z-index: 2;
  display: block;
  max-width: 78px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(8, 18, 15, 0.48);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
}

.mini-map:hover {
  transform: translateY(-1px);
  border-color: #ffe68e;
}

.mini-map-dots {
  position: absolute;
  inset: 0;
}

.mini-map-dot {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(191, 243, 188, 0.88);
  box-shadow: 0 0 8px rgba(191, 243, 188, 0.5);
}

.mini-map-dot.current {
  width: 11px;
  height: 11px;
  background: #ffe07a;
  box-shadow: 0 0 12px rgba(255, 224, 122, 0.78);
}

.bottom-dock {
  position: absolute;
  right: 26px;
  bottom: 18px;
  z-index: 4;
  display: flex;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(12, 18, 16, 0.78);
  backdrop-filter: blur(12px);
}

.bottom-dock button {
  min-width: 108px;
  border-radius: 999px;
}

.bottom-panel {
  right: 26px;
  bottom: 82px;
  width: min(560px, calc(100% - 28px));
  max-height: min(420px, calc(100% - 128px));
  overflow: auto;
}

.npc-dialog-panel {
  left: 50%;
  right: auto;
  bottom: 22px;
  width: min(720px, calc(100% - 40px));
  max-height: min(300px, calc(100% - 44px));
  overflow: hidden;
  transform: translateX(-50%);
}

#inventoryPanel {
  width: min(560px, calc(100% - 28px));
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.toast-log {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 4;
  display: flex;
  width: min(360px, calc(100% - 36px));
  max-height: 128px;
  flex-direction: column-reverse;
  gap: 6px;
  pointer-events: none;
  overflow: hidden;
}

.toast-log .log-entry {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: rgba(13, 20, 17, 0.76);
  backdrop-filter: blur(10px);
  padding: 8px 10px;
}

.world-map {
  width: min(920px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  overflow: hidden;
  display: grid;
  gap: 14px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

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

.hidden {
  display: none !important;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.map-header p {
  margin-top: 4px;
  color: #b9c9be;
  font-size: 13px;
}

.map-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 14px;
  min-height: 480px;
}

.world-map-canvas {
  position: relative;
  min-height: 480px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background:
    radial-gradient(circle at 20% 15%, rgba(94, 151, 127, 0.28), transparent 30%),
    radial-gradient(circle at 78% 76%, rgba(107, 89, 157, 0.24), transparent 32%),
    linear-gradient(135deg, rgba(19, 32, 30, 0.96), rgba(27, 30, 42, 0.96));
}

.map-route {
  position: absolute;
  height: 3px;
  transform-origin: left center;
  border-radius: 999px;
  background: rgba(218, 200, 130, 0.26);
}

.map-route.visited {
  background: rgba(237, 216, 123, 0.88);
  box-shadow: 0 0 12px rgba(237, 216, 123, 0.35);
}

.map-node {
  position: absolute;
  width: 112px;
  min-height: 54px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #b8c5bc;
  padding: 8px;
  text-align: center;
  font-size: 12px;
}

.map-node.visited {
  border-color: rgba(146, 220, 165, 0.72);
  background: rgba(53, 113, 78, 0.82);
  color: #f0fff4;
}

.map-node.current {
  border-color: #ffe07a;
  background: rgba(133, 111, 42, 0.92);
  box-shadow: 0 0 24px rgba(255, 224, 122, 0.38);
}

.map-node strong {
  display: block;
  margin-bottom: 3px;
}

.map-node span {
  display: block;
  color: rgba(255, 255, 255, 0.72);
}

.map-sidebar {
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: auto;
}

.legend {
  display: grid;
  gap: 7px;
  color: #cad8ce;
  font-size: 13px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.dot.current {
  background: #ffe07a;
}

.dot.visited {
  background: #73d08c;
}

.dot.unknown {
  background: #69736f;
}

.message {
  min-height: 20px;
  color: #f3d28c;
  font-size: 13px;
}

.info-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  padding: 10px;
  color: #d8e6dc;
  font-size: 13px;
}

.info-card strong {
  display: block;
  color: #ffffff;
  margin-bottom: 3px;
}

.quest-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.quest-entry-content {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.quest-entry-main {
  display: grid;
  gap: 3px;
  text-align: left;
}

.quest-entry-main strong {
  color: #fff8c8;
  font-size: 14px;
}

.quest-entry-main span {
  color: #e2d59e;
  font-size: 12px;
}

.quest-entry-main small {
  color: #aebdb4;
  font-size: 12px;
}

.quest-entry.selected .quest-entry-main {
  border-color: #ffe07a;
  color: #ffeeb0;
}

.quest-entry-action {
  min-width: 92px;
}

.section-title {
  margin-top: 6px;
  padding: 6px 2px 2px;
  color: #ffe07a;
  font-size: 13px;
  font-weight: 700;
}

.quest-detail {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(255, 224, 122, 0.38);
  border-radius: 8px;
  background: rgba(74, 62, 28, 0.38);
  padding: 12px;
  color: #eaf4ec;
  font-size: 13px;
  line-height: 1.45;
}

.quest-detail strong {
  color: #ffe68e;
}

.quest-detail span {
  color: #cddbd2;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.equipment-summary {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 4px;
}

.equipment-cell {
  min-width: 0;
  border: 1px solid rgba(255, 224, 122, 0.22);
  border-radius: 7px;
  background: rgba(68, 57, 31, 0.36);
  padding: 8px;
}

.equipment-cell span,
.equipment-cell small {
  display: block;
  color: #b9c9be;
  font-size: 12px;
}

.equipment-cell strong {
  display: block;
  margin: 2px 0;
  color: #fff1a8;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-slot {
  position: relative;
  min-width: 0;
  min-height: 48px;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 7px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.inventory-slot:disabled {
  opacity: 1;
  cursor: default;
  background: rgba(255, 255, 255, 0.035);
}

.inventory-slot strong {
  max-width: 100%;
  color: #fff6c5;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-slot span {
  position: absolute;
  right: 5px;
  bottom: 3px;
  color: #f4e2a0;
  font-size: 11px;
}

.inventory-slot:not(:disabled):hover {
  border-color: #ffe07a;
  box-shadow: 0 0 14px rgba(255, 224, 122, 0.24);
}

.inventory-slot.equipment-item {
  border-color: rgba(255, 224, 122, 0.42);
  background: rgba(78, 63, 28, 0.38);
}

.npc-card span {
  display: block;
  margin-bottom: 7px;
  color: #f1d58a;
}

.npc-card p {
  color: #dbe9de;
  line-height: 1.45;
}

.npc-quest-dialogue {
  display: grid;
  gap: 10px;
  grid-template-rows: auto minmax(88px, 1fr) auto;
  border-color: rgba(255, 224, 122, 0.28);
  background: rgba(48, 58, 35, 0.48);
}

.npc-quest-dialogue p {
  min-height: 88px;
  max-height: 112px;
  overflow: auto;
  color: #edf7ec;
  line-height: 1.55;
}

.npc-quest-dialogue span {
  color: #f1d58a;
  font-size: 13px;
}

.dialog-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.dialog-controls button {
  min-width: 88px;
}

.dialog-controls button:last-child {
  min-width: 112px;
}

.dialog-controls .reserved-action {
  opacity: 0.42;
}

.dialog-page {
  min-width: 44px;
  text-align: center;
  color: #f1d58a;
  font-size: 13px;
}

.log {
  display: flex;
  flex-direction: column-reverse;
  gap: 7px;
  max-height: 190px;
  overflow: auto;
  color: #c9d8ce;
  font-size: 13px;
}

.log-entry {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 7px;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .game-shell {
    height: auto;
    min-height: 100vh;
  }

  .game-frame {
    height: calc(100vh - 24px);
    min-height: 620px;
  }

  .map-body {
    grid-template-columns: 1fr;
  }
}
