:root {
  --bg: #07100f;
  --ink: #f6e8c5;
  --muted: #b6a887;
  --panel: #111615;
  --panel-2: #1b1713;
  --line: #5b4532;
  --gold: #e7ae3d;
  --gold-2: #f4d17a;
  --red: #9c2f2e;
  --red-2: #df5140;
  --green: #6d9d4e;
  --blue: #49b8d7;
  --shadow: rgba(0, 0, 0, 0.56);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(83, 124, 88, 0.18), transparent 32%),
    radial-gradient(circle at 84% 10%, rgba(63, 123, 147, 0.18), transparent 26%),
    linear-gradient(140deg, #07100f 0%, #120d12 48%, #07100f 100%);
  font-family:
    "Trebuchet MS",
    "Segoe UI",
    Arial,
    sans-serif;
  overflow: hidden;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: min(1760px, calc(100vw - 20px));
  height: calc(100vh - 20px);
  margin: 10px auto;
  border: 2px solid #3f3126;
  border-radius: var(--radius);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background:
    linear-gradient(rgba(10, 13, 13, 0.9), rgba(10, 13, 13, 0.95)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 8px);
  box-shadow: 0 24px 80px var(--shadow);
  overflow: hidden;
}

.topbar {
  position: relative;
  z-index: 12;
  display: grid;
  grid-template-columns: 82px minmax(180px, 240px) minmax(260px, 1fr) minmax(130px, 170px) minmax(170px, 220px) 44px;
  gap: 8px;
  align-items: stretch;
  padding: 8px;
  background:
    linear-gradient(180deg, rgba(31, 22, 18, 0.96), rgba(12, 15, 15, 0.96)),
    linear-gradient(90deg, rgba(231, 174, 61, 0.08), transparent 48%, rgba(74, 160, 181, 0.08));
  border-bottom: 2px solid #3b2d25;
}

.portrait-card,
.stat-card,
.title-card,
.resource-card,
.quest-card,
.icon-button,
.world-panel,
.side-panel,
.mini-card,
.skill-card,
.inventory-card,
.log-card,
.modal-panel {
  border: 2px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 18%),
    linear-gradient(180deg, #191817 0%, #0d1010 100%);
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.42),
    0 10px 30px rgba(0, 0, 0, 0.24);
}

.portrait-card,
.stat-card,
.title-card,
.resource-card,
.quest-card,
.mini-card,
.skill-card,
.inventory-card,
.log-card {
  outline: 1px solid rgba(231, 174, 61, 0.12);
}

.portrait-card {
  display: grid;
  place-items: center;
  min-height: 82px;
  border-radius: var(--radius);
}

canvas {
  image-rendering: pixelated;
}

.portrait-card canvas {
  width: 68px;
  height: 68px;
}

.stat-card,
.resource-card,
.quest-card {
  padding: 9px;
  border-radius: var(--radius);
}

.stat-line,
.resource-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
  line-height: 1.25;
}

.bar {
  height: 13px;
  margin: 4px 0 6px;
  padding: 3px;
  border: 1px solid #6a5941;
  border-radius: 4px;
  background: #080909;
  overflow: hidden;
}

.bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #9a2525, #f2644f);
  transition: width 180ms ease;
}

.bar.xp span {
  background: linear-gradient(90deg, #226c83, #52c1dd);
}

.bar.quest span {
  background: linear-gradient(90deg, #6d9d4e, #b3d45f);
}

.title-card {
  display: grid;
  place-items: center;
  align-content: center;
  min-width: 0;
  padding: 8px 14px;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.55), rgba(13, 27, 28, 0.78), rgba(0, 0, 0, 0.55)),
    radial-gradient(circle at center, rgba(231, 174, 61, 0.13), transparent 70%);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--gold-2);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 3vw, 44px);
  font-weight: 700;
  line-height: 1;
  text-align: center;
  text-shadow: 0 3px 0 #4b281d, 0 8px 24px rgba(0, 0, 0, 0.55);
}

.title-card p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 16px;
}

.title-card strong {
  margin-top: 6px;
  color: #fff4c9;
  font-size: 13px;
  letter-spacing: 0;
}

.resource-card {
  display: grid;
  gap: 8px;
}

.resource-line strong {
  color: var(--gold-2);
  font-size: 21px;
}

.coin-mark,
.potion-mark {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #fff1a8 0 16%, #f0b43e 17% 66%, #8a551a 67%);
}

.potion-mark {
  border-radius: 6px;
  background: radial-gradient(circle at 45% 35%, #ffe2d7 0 13%, #df5140 14% 66%, #79262a 67%);
}

.quest-card {
  position: relative;
}

.quest-title,
h2 {
  color: var(--gold-2);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.1;
}

.quest-card p {
  margin: 4px 0 5px;
  color: var(--muted);
  font-size: 14px;
}

.quest-card strong {
  position: absolute;
  right: 13px;
  bottom: 8px;
}

.icon-button {
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  font-size: 24px;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease;
}

.icon-button:hover {
  color: var(--gold-2);
  border-color: var(--gold);
  transform: translateY(-1px);
}

.main-layout {
  position: relative;
  z-index: 1;
  min-height: 0;
  display: block;
  padding: 10px 10px 124px;
  overflow: hidden;
}

.world-panel {
  position: absolute;
  inset: 10px;
  min-height: 0;
  padding: 10px;
  border-radius: var(--radius);
}

.world-panel::before {
  content: "";
  position: absolute;
  inset: 10px;
  z-index: 2;
  border: 1px solid rgba(244, 209, 122, 0.18);
  border-radius: 6px;
  pointer-events: none;
  box-shadow: inset 0 0 42px rgba(0, 0, 0, 0.35);
}

.world-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px solid #2e241d;
  border-radius: 6px;
  background: #0b1110;
  touch-action: none;
}

.world-hint {
  position: absolute;
  left: 22px;
  bottom: 154px;
  max-width: calc(100% - 44px);
  padding: 8px 10px;
  border: 1px solid rgba(244, 209, 122, 0.38);
  border-radius: 6px;
  color: #e9d7aa;
  background: rgba(9, 11, 10, 0.78);
  font-size: 13px;
  pointer-events: none;
}

.dialog-panel {
  position: absolute;
  left: 22px;
  right: 370px;
  bottom: 154px;
  z-index: 60;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 14px;
  min-height: 96px;
  padding: 13px 15px;
  border: 2px solid rgba(231, 174, 61, 0.72);
  border-radius: var(--radius);
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(31, 24, 18, 0.96), rgba(7, 10, 10, 0.95)),
    radial-gradient(circle at 18% 0%, rgba(244, 209, 122, 0.16), transparent 58%);
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.45),
    0 18px 40px rgba(0, 0, 0, 0.38);
}

.dialog-panel[hidden] {
  display: none;
}

.dialog-panel strong {
  color: var(--gold-2);
  font-size: 18px;
}

.dialog-panel p {
  grid-column: 1 / -1;
  color: #e4d4ac;
  font-size: 15px;
  line-height: 1.35;
}

.dialog-action {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  min-width: 106px;
  min-height: 44px;
  border: 2px solid #6a5135;
  border-radius: 7px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 32%),
    linear-gradient(180deg, #5b4126, #19130e);
  cursor: pointer;
  font-weight: 900;
}

.side-panel {
  position: absolute;
  z-index: 5;
  right: 24px;
  top: 20px;
  width: min(320px, calc(100% - 48px));
  max-height: calc(100% - 40px);
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 10px;
  border-radius: var(--radius);
  overflow: auto;
  backdrop-filter: blur(2px);
  scrollbar-color: #6a5135 #0a0d0c;
}

.mini-card {
  padding: 13px;
  border-radius: var(--radius);
}

.mini-card h2,
.skill-card h2,
.inventory-card h2,
.log-card h2 {
  margin-bottom: 10px;
}

#minimapCanvas {
  display: block;
  width: 100%;
  height: 170px;
  border: 1px solid #42352a;
  border-radius: 5px;
  background: #080d0c;
}

.route-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.route-button {
  min-height: 34px;
  border: 1px solid #5e4934;
  border-radius: 5px;
  color: #e9d7aa;
  background: rgba(10, 12, 11, 0.72);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.route-button:hover {
  border-color: var(--gold);
  color: var(--gold-2);
}

.route-button.active {
  border-color: var(--gold);
  color: #fff4c9;
  background:
    linear-gradient(180deg, rgba(244, 209, 122, 0.18), transparent 42%),
    rgba(62, 43, 22, 0.92);
}

.panel-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.panel-action,
.codex-tab {
  min-height: 34px;
  border: 1px solid #5e4934;
  border-radius: 5px;
  color: #e9d7aa;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 32%),
    rgba(10, 12, 11, 0.78);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.panel-action:hover,
.codex-tab:hover,
.codex-tab.active {
  border-color: var(--gold);
  color: #fff4c9;
}

.quest-list,
.log-card ol {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 22px;
}

.quest-list li,
.log-card li {
  color: #d9c9a8;
  font-size: 14px;
  line-height: 1.3;
}

.quest-list li.done {
  color: #9ecb7a;
  text-decoration: none;
}

.quest-list li.done::marker {
  color: #9ecb7a;
}

.shop-card {
  display: grid;
  gap: 8px;
}

.shop-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.shop-button,
.skill-button,
.primary-button,
.secondary-button {
  min-height: 48px;
  border: 2px solid #6a5135;
  border-radius: 7px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 30%),
    linear-gradient(180deg, #352318, #15120f);
  cursor: pointer;
  font-weight: 900;
  transition: transform 140ms ease, border-color 140ms ease, color 140ms ease, background 140ms ease, opacity 140ms ease;
}

.shop-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 14px;
  text-align: left;
}

.shop-button:disabled,
.skill-button:disabled {
  cursor: not-allowed;
  opacity: 0.44;
}

.shop-button:hover:not(:disabled),
.skill-button:hover:not(:disabled),
.primary-button:hover,
.secondary-button:hover {
  border-color: var(--gold);
  color: #fff4c9;
  transform: translateY(-1px);
}

.bottom-hud {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 12;
  display: grid;
  grid-template-columns: minmax(390px, 1.1fr) minmax(300px, 0.82fr) minmax(300px, 0.88fr);
  gap: 8px;
  padding: 0 8px 8px;
  min-height: 104px;
  pointer-events: auto;
  background:
    linear-gradient(180deg, rgba(8, 9, 8, 0), rgba(8, 9, 8, 0.72) 28%, rgba(8, 9, 8, 0.96));
}

.touch-controls {
  display: none;
}

.move-stick,
.touch-button,
.map-toggle-button {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-button {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.touch-button::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  height: var(--cooldown, 0%);
  background: rgba(223, 81, 64, 0.34);
  transition: height 0.08s linear;
}

.skill-card,
.inventory-card,
.log-card {
  min-width: 0;
  padding: 9px;
  border-radius: var(--radius);
}

.skill-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.skill-button {
  position: relative;
  display: grid;
  grid-template-rows: 28px auto;
  place-items: center;
  min-height: 52px;
  padding: 5px 6px 6px;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.05;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55);
  isolation: isolate;
}

.skill-button span {
  position: absolute;
  left: 5px;
  top: 5px;
  z-index: 2;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  border: 1px solid rgba(244, 209, 122, 0.55);
  border-radius: 3px;
  background: rgba(5, 7, 7, 0.66);
  color: var(--gold-2);
  font-size: 11px;
  line-height: 1;
}

.skill-button::before {
  content: "";
  z-index: 1;
  width: 27px;
  height: 27px;
  border-radius: 5px;
  box-shadow: 0 0 16px rgba(244, 209, 122, 0.16);
}

.skill-button::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--cooldown, 0%);
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 3;
}

.skill-button[data-skill="slash"]::before {
  background:
    linear-gradient(90deg, transparent 0 14%, #8c5a26 15% 20%, transparent 21%),
    linear-gradient(90deg, transparent 0 20%, #fff4c9 21% 68%, transparent 69%),
    linear-gradient(135deg, transparent 0 54%, #f4d17a 55% 72%, transparent 73%);
}

.skill-button[data-skill="heavy"]::before {
  background:
    conic-gradient(from -35deg, transparent 0 12%, #f4d17a 13% 18%, transparent 19% 28%, #d8f0ff 29% 34%, transparent 35% 44%, #f4d17a 45% 50%, transparent 51%),
    radial-gradient(circle at 50% 72%, #8a551a 0 13%, transparent 14%);
}

.skill-button[data-skill="dash"]::before {
  background:
    linear-gradient(135deg, transparent 0 28%, #b6f06a 29% 44%, transparent 45%),
    radial-gradient(circle at 66% 42%, #6dff76 0 24%, #17351c 25% 70%);
}

.skill-button[data-skill="magic"]::before {
  border-radius: 50%;
  background:
    radial-gradient(circle, #e8fbff 0 13%, #59d6ff 14% 34%, #204c9a 35% 54%, transparent 55%),
    conic-gradient(from 0deg, transparent, rgba(89, 214, 255, 0.8), transparent);
}

.skill-button[data-skill="potion"]::before {
  background:
    linear-gradient(180deg, #e8e5d9 0 16%, transparent 17%),
    radial-gradient(circle at 50% 58%, #ff7a58 0 34%, #861f25 35% 62%, transparent 63%);
}

.skill-button.danger {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 32%),
    linear-gradient(180deg, #7c2e24, #27130f);
}

.skill-button.magic {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 32%),
    linear-gradient(180deg, #24475c, #101820);
}

.skill-button.potion-skill {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 32%),
    linear-gradient(180deg, #47303b, #171012);
}

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

.gear-slot {
  display: grid;
  grid-template-rows: 46px auto;
  justify-items: center;
  align-items: center;
  min-height: 78px;
  padding: 6px;
  border: 1px solid #42352a;
  border-radius: 6px;
  background: rgba(4, 6, 6, 0.38);
  text-align: center;
}

.gear-slot canvas {
  width: 46px;
  height: 46px;
}

.gear-slot span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
}

.log-card ol {
  max-height: 74px;
  overflow: auto;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at center, rgba(46, 80, 75, 0.34), transparent 58%),
    rgba(3, 6, 6, 0.82);
}

.overlay[hidden] {
  display: none;
}

.modal-panel {
  width: min(560px, calc(100vw - 48px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 28px;
  border-radius: var(--radius);
  text-align: center;
}

.codex-overlay {
  z-index: 110;
}

.codex-panel {
  box-sizing: border-box;
  width: min(860px, calc(100vw - 64px));
  max-width: calc(100vw - 64px);
  max-height: min(740px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 18px;
  overflow: hidden;
  text-align: left;
}

.codex-header {
  display: grid;
  grid-template-columns: 1fr 44px;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.codex-panel .codex-header h2 {
  min-width: 0;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 3.2vw, 40px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.codex-close {
  min-height: 44px;
}

.codex-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
}

.codex-page {
  min-height: 0;
  display: none;
  gap: 12px;
  overflow: auto;
}

.codex-page.active {
  display: grid;
}

#bigMapCanvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: min(48vh, 360px);
  min-height: 230px;
  border: 2px solid #42352a;
  border-radius: 6px;
  background: #070d0c;
}

.codex-stats,
.codex-list,
.relic-grid,
.bestiary-grid,
.map-legend {
  display: grid;
  gap: 8px;
}

.codex-stat,
.codex-entry,
.relic-entry,
.bestiary-entry,
.legend-item {
  border: 1px solid #42352a;
  border-radius: 6px;
  padding: 10px 12px;
  color: #e4d4ac;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 34%),
    rgba(6, 8, 8, 0.46);
  font-size: 14px;
  line-height: 1.35;
}

.codex-stat strong,
.codex-entry strong,
.relic-entry strong,
.bestiary-entry strong,
.legend-item strong {
  color: var(--gold-2);
}

.relic-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bestiary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.map-legend {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  font-size: 12px;
}

.legend-dot {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border: 2px solid rgba(255, 244, 201, 0.5);
  background: var(--gold);
  box-shadow: 0 0 12px rgba(244, 209, 122, 0.36);
}

.legend-dot.hero {
  border-radius: 50%;
  background: #f4d17a;
}

.legend-dot.chest {
  border-radius: 3px;
  background: #d8993c;
}

.legend-dot.rune {
  transform: rotate(45deg);
  background: #59d6ff;
}

.legend-dot.enemy {
  border-radius: 50%;
  background: #df5140;
}

.legend-dot.route {
  width: 24px;
  height: 4px;
  flex-basis: 24px;
  border: 0;
  border-radius: 999px;
  background: #d0a05a;
}

.bestiary-entry {
  min-height: 96px;
}

.bestiary-entry .meta {
  display: block;
  margin-top: 6px;
  color: #b7a98b;
  font-size: 13px;
  line-height: 1.35;
}

.relic-entry.locked {
  color: #8d8068;
  opacity: 0.74;
}

.compact-actions {
  grid-template-columns: repeat(2, minmax(0, 220px));
  justify-content: start;
}

.modal-panel h2 {
  color: var(--gold-2);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 6vw, 58px);
}

.modal-panel p {
  max-width: 46ch;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.start-panel {
  width: min(780px, calc(100vw - 36px));
  text-align: left;
}

.start-panel h2 {
  text-align: center;
}

.setup-grid {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.hero-preview-card {
  position: relative;
  min-height: 128px;
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  border: 1px solid rgba(231, 174, 61, 0.34);
  border-radius: 7px;
  padding: 12px 14px;
  background:
    radial-gradient(circle at 70% 36%, rgba(89, 214, 255, 0.13), transparent 42%),
    linear-gradient(180deg, rgba(244, 209, 122, 0.11), rgba(6, 8, 8, 0.62));
  overflow: hidden;
}

.hero-preview-card strong {
  display: block;
  color: #fff4c9;
  font-size: 24px;
  line-height: 1.05;
}

.hero-preview-card p {
  margin: 8px 0 0;
  color: #d5c59e;
  font-size: 14px;
  line-height: 1.35;
}

.hero-preview-figure {
  position: relative;
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
}

.hero-preview-aura,
.hero-preview-shadow,
.hero-preview-body,
.hero-preview-weapon {
  position: absolute;
  display: block;
}

.hero-preview-aura {
  inset: 7px;
  border: 2px solid rgba(244, 209, 122, 0.34);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 209, 122, 0.18), transparent 66%);
  animation: previewPulse 1.8s ease-in-out infinite;
}

.hero-preview-shadow {
  width: 66px;
  height: 18px;
  left: 19px;
  bottom: 12px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.42);
}

.hero-preview-body {
  width: 44px;
  height: 68px;
  bottom: 24px;
  border: 2px solid rgba(25, 14, 10, 0.72);
  border-radius: 18px 18px 12px 12px;
  background:
    radial-gradient(circle at 50% 18%, #e0bb8c 0 14px, transparent 15px),
    linear-gradient(180deg, #704237 0 38%, #293b32 39% 100%);
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.18);
}

.hero-preview-weapon {
  width: 58px;
  height: 58px;
  right: 16px;
  top: 26px;
  border-right: 4px solid #f4d17a;
  border-radius: 50%;
  transform: rotate(12deg);
}

.hero-preview-card[data-class="knives"] .hero-preview-weapon {
  width: 54px;
  height: 5px;
  right: 8px;
  top: 42px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, #d8f0ff, #6a8798);
  box-shadow: -18px 20px 0 #d8f0ff;
}

.hero-preview-card[data-class="mage"] .hero-preview-weapon {
  width: 10px;
  height: 72px;
  right: 20px;
  top: 16px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #59d6ff, #315a66);
  box-shadow: 0 -7px 16px rgba(89, 214, 255, 0.7);
}

.hero-preview-card[data-class="fighter"] .hero-preview-weapon {
  width: 9px;
  height: 76px;
  right: 18px;
  top: 16px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff4c9, #8e7a54);
  transform: rotate(42deg);
}

@keyframes previewPulse {
  0%, 100% { transform: scale(0.96); opacity: 0.72; }
  50% { transform: scale(1.04); opacity: 1; }
}

.setup-field {
  display: grid;
  gap: 6px;
  color: var(--gold-2);
  font-weight: 900;
  font-size: 14px;
}

.setup-field input {
  width: 100%;
  min-height: 50px;
  border: 2px solid #5e4934;
  border-radius: 7px;
  padding: 0 13px;
  color: #fff4c9;
  background: rgba(6, 8, 8, 0.76);
  font: 900 18px "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  outline: none;
}

.setup-field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(231, 174, 61, 0.15);
}

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

.class-card,
.lobby-card,
.lobby-slot {
  border: 1px solid #5e4934;
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 34%),
    rgba(6, 8, 8, 0.56);
}

.class-card {
  min-height: 108px;
  padding: 12px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.class-card strong {
  display: block;
  color: var(--gold-2);
  font-size: 21px;
}

.class-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.class-card.active {
  border-color: var(--gold);
  background:
    linear-gradient(180deg, rgba(244, 209, 122, 0.18), transparent 48%),
    rgba(43, 31, 18, 0.86);
  box-shadow: inset 0 0 0 2px rgba(244, 209, 122, 0.12);
}

.lobby-slot.local {
  border-color: rgba(244, 209, 122, 0.72);
}

.lobby-slot.online {
  border-color: rgba(89, 214, 255, 0.72);
  background:
    linear-gradient(180deg, rgba(89, 214, 255, 0.12), transparent 46%),
    rgba(24, 31, 30, 0.9);
}

.lobby-card {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.lobby-head,
.lobby-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lobby-head strong {
  color: var(--gold-2);
  font-size: 18px;
}

.lobby-head span,
.lobby-slot span {
  color: #fff4c9;
  font-weight: 900;
}

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

.small-action {
  min-height: 42px;
  font-size: 15px;
}

.compact-field input {
  min-height: 42px;
  font-size: 15px;
}

.lobby-slots {
  display: grid;
  gap: 7px;
}

.lobby-slot {
  min-height: 42px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
}

.modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.primary-button,
.secondary-button {
  min-height: 58px;
  font-size: 22px;
}

.primary-button {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), transparent 32%),
    linear-gradient(180deg, #587c2f, #233014);
}

.secondary-button {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 32%),
    linear-gradient(180deg, #263536, #111616);
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 92px minmax(180px, 1fr) minmax(210px, 1.2fr) 56px;
  }

  .resource-card,
  .quest-card {
    grid-column: span 2;
  }

  .main-layout {
    display: block;
    padding-bottom: 132px;
  }

  .side-panel {
    width: min(300px, calc(100% - 42px));
  }

  .bottom-hud {
    grid-template-columns: 1fr;
    min-height: 116px;
  }

  .dialog-panel {
    right: 326px;
  }

  .inventory-card,
  .log-card {
    display: none;
  }
}

@media (max-width: 760px) {
  .game-shell {
    width: 100%;
    height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .topbar {
    grid-template-columns: 62px minmax(0, 1fr) 78px 38px;
    grid-template-rows: 62px;
    gap: 6px;
    padding: 6px;
  }

  .portrait-card {
    min-height: 62px;
    grid-column: 1;
    grid-row: 1;
  }

  .portrait-card canvas {
    width: 54px;
    height: 54px;
  }

  .stat-card {
    grid-column: 2;
    grid-row: 1;
    padding: 7px 9px;
  }

  .stat-line,
  .resource-line {
    gap: 6px;
    font-size: 13px;
  }

  .bar {
    height: 12px;
    margin: 3px 0 5px;
    padding: 2px;
  }

  .icon-button {
    grid-column: 4;
    grid-row: 1;
    min-height: 62px;
    font-size: 21px;
  }

  .title-card {
    display: none;
  }

  .resource-card {
    grid-column: 3;
    grid-row: 1;
    min-height: 62px;
    padding: 7px;
  }

  .quest-card {
    display: none;
  }

  h1 {
    font-size: 22px;
    line-height: 1.02;
  }

  .title-card p {
    display: none;
  }

  .title-card strong {
    margin-top: 3px;
    font-size: 11px;
  }

  .resource-card {
    gap: 4px;
  }

  .resource-line span:nth-of-type(2) {
    display: none;
  }

  .resource-line strong {
    font-size: 16px;
  }

  .coin-mark,
  .potion-mark {
    width: 18px;
    height: 18px;
  }

  .quest-title,
  h2 {
    font-size: 16px;
  }

  .quest-card p {
    margin: 3px 0 5px;
    font-size: 12px;
  }

  .quest-card strong {
    right: 8px;
    bottom: 6px;
    font-size: 12px;
  }

  .main-layout {
    padding: 7px;
    padding-bottom: 7px;
  }

  .world-panel {
    inset: 7px;
    padding: 7px;
  }

  .world-canvas {
    height: 100%;
  }

  .world-hint {
    display: none;
  }

  .dialog-panel {
    left: 12px;
    right: 12px;
    bottom: 126px;
    min-height: 78px;
    padding: 9px 10px;
    grid-template-columns: 1fr;
  }

  .dialog-panel strong {
    font-size: 14px;
  }

  .dialog-panel p {
    font-size: 12px;
  }

  .dialog-action {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
    min-width: 84px;
    min-height: 32px;
    font-size: 12px;
  }

  .side-panel,
  .equipment-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    top: 7px;
    right: 7px;
    width: 112px;
    max-height: calc(100% - 100px);
    gap: 6px;
    padding: 6px;
    transition: transform 0.18s ease, opacity 0.18s ease;
  }

  .game-shell.map-collapsed .side-panel {
    transform: translateX(calc(100% + 18px));
    opacity: 0;
    pointer-events: none;
  }

  .side-panel .mini-card {
    padding: 6px;
  }

  .side-panel .mini-card h2 {
    margin-bottom: 5px;
    font-size: 12px;
  }

  #minimapCanvas {
    height: 66px;
  }

  .route-row {
    gap: 4px;
    margin-top: 5px;
  }

  .route-button {
    min-height: 24px;
    font-size: 9px;
  }

  .panel-actions {
    grid-template-columns: 1fr;
    gap: 4px;
    margin-top: 5px;
  }

  .panel-action {
    min-height: 26px;
    font-size: 9px;
  }

  .side-panel .mini-card:nth-child(2) {
    display: none;
  }

  .quest-list {
    gap: 3px;
    padding-left: 17px;
  }

  .quest-list li,
  .log-card li {
    font-size: 11px;
    line-height: 1.15;
  }

  .shop-card {
    display: none;
  }

  .shop-card.active {
    display: grid;
  }

  .shop-card p {
    display: none;
  }

  .shop-button {
    min-height: 34px;
    padding: 5px 6px;
    font-size: 11px;
  }

  .bottom-hud {
    display: none;
  }

  .touch-controls {
    position: fixed;
    inset: 0;
    z-index: 95;
    display: block;
    pointer-events: none;
  }

  .move-stick {
    position: fixed;
    z-index: 96;
    left: max(16px, env(safe-area-inset-left));
    bottom: max(16px, env(safe-area-inset-bottom));
    width: 88px;
    height: 88px;
    border: 2px solid rgba(244, 209, 122, 0.32);
    border-radius: 50%;
    background:
      radial-gradient(circle at 50% 50%, rgba(244, 209, 122, 0.12), transparent 38%),
      rgba(7, 10, 10, 0.38);
    backdrop-filter: blur(3px);
    box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.2), 0 10px 22px rgba(0, 0, 0, 0.34);
    pointer-events: auto;
    touch-action: none;
  }

  .move-stick::before {
    content: "";
    position: absolute;
    inset: 25px;
    border: 1px solid rgba(255, 244, 201, 0.16);
    border-radius: 50%;
  }

  .move-stick span {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255, 244, 201, 0.52);
    border-radius: 50%;
    background:
      radial-gradient(circle at 38% 28%, rgba(255, 244, 201, 0.42), transparent 32%),
      linear-gradient(180deg, rgba(135, 96, 45, 0.92), rgba(38, 25, 17, 0.9));
    box-shadow: 0 7px 18px rgba(0, 0, 0, 0.42);
    transform: translate(-50%, -50%);
  }

  .touch-actions {
    position: fixed;
    z-index: 96;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    width: 188px;
    height: 142px;
    display: block;
    pointer-events: auto;
  }

  .touch-button,
  .map-toggle-button {
    min-width: 0;
    border: 2px solid rgba(244, 209, 122, 0.42);
    border-radius: 50%;
    background-color: rgba(12, 13, 12, 0.48);
    background-image:
      radial-gradient(circle at 36% 26%, rgba(255, 244, 201, 0.18), transparent 30%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0) 46%);
    color: #f3d99e;
    font-size: 16px;
    font-weight: 900;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.62);
    box-shadow: inset 0 0 0 1px rgba(244, 209, 122, 0.06), 0 8px 16px rgba(0, 0, 0, 0.36);
    pointer-events: auto;
    touch-action: manipulation;
    backdrop-filter: blur(3px);
  }

  .touch-button {
    position: absolute;
    width: 46px;
    height: 46px;
  }

  .touch-button:active,
  .map-toggle-button:active {
    transform: translateY(1px) scale(0.98);
  }

  .touch-button:disabled {
    color: rgba(232, 212, 165, 0.42);
    opacity: 0.2;
    transform: scale(0.88);
  }

  .primary-touch {
    right: 44px;
    bottom: 14px;
    width: 68px;
    height: 68px;
    border-color: rgba(223, 81, 64, 0.72);
    color: #fff4c9;
    background-color: rgba(104, 34, 27, 0.72);
    background-image: linear-gradient(180deg, rgba(255, 244, 201, 0.18), rgba(0, 0, 0, 0) 42%);
    font-size: 21px;
  }

  .touch-button[data-touch-skill="heavy"] {
    right: 104px;
    bottom: 98px;
  }

  .touch-button[data-touch-skill="dash"] {
    right: 52px;
    bottom: 116px;
  }

  .touch-button[data-touch-skill="magic"] {
    right: 4px;
    bottom: 98px;
  }

  .touch-button[data-touch-skill="potion"] {
    right: 4px;
    bottom: 36px;
    width: 46px;
    height: 46px;
  }

  .interact-touch {
    right: 126px;
    bottom: 36px;
    width: 46px;
    height: 46px;
    color: #59d6ff;
  }

  .map-toggle-button {
    position: fixed;
    z-index: 96;
    top: 76px;
    right: 114px;
    width: 76px;
    height: 34px;
    font-size: 12px;
    transition: right 0.18s ease;
  }

  body.map-collapsed .map-toggle-button {
    right: 10px;
  }

  .skill-card {
    padding: 8px;
  }

  .skill-card h2 {
    display: none;
  }

  .skill-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }

  .skill-button {
    min-height: 62px;
    padding: 6px 3px;
    font-size: 12px;
    line-height: 1.05;
  }

  .skill-button span {
    margin-bottom: 3px;
    font-size: 11px;
  }

  .modal-panel {
    width: min(440px, calc(100vw - 32px));
    padding: 22px;
  }

  .start-panel {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 14px;
    overflow: hidden;
  }

  .modal-panel h2 {
    max-width: 11ch;
    margin: 0 auto;
    font-size: 28px;
    line-height: 1.08;
  }

  .modal-panel p {
    font-size: 16px;
  }

  .modal-actions {
    grid-template-columns: 1fr;
    margin-top: 10px;
    padding-top: 9px;
    border-top: 1px solid rgba(244, 209, 122, 0.18);
    background: linear-gradient(180deg, rgba(15, 17, 16, 0), rgba(15, 17, 16, 0.84));
  }

  .setup-grid {
    min-height: 0;
    gap: 8px;
    margin-top: 12px;
    overflow-y: auto;
    padding: 0 2px 4px 0;
  }

  .setup-field {
    gap: 5px;
    font-size: 13px;
  }

  .setup-field input {
    min-height: 44px;
    font-size: 16px;
  }

  .primary-button,
  .secondary-button {
    min-height: 48px;
    font-size: 19px;
  }

  .hero-preview-card {
    min-height: 96px;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 9px;
    padding: 9px 10px;
  }

  .hero-preview-figure {
    width: 76px;
    height: 76px;
  }

  .hero-preview-card strong {
    font-size: 20px;
  }

  .hero-preview-card p {
    font-size: 12px;
    line-height: 1.25;
  }

  .lobby-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .class-select {
    grid-template-columns: 1fr;
    max-height: 128px;
    overflow-y: auto;
    padding-right: 2px;
  }

  .class-card {
    min-height: 64px;
    padding: 9px 10px;
  }

  .class-card strong {
    font-size: 15px;
  }

  .class-card span,
  .lobby-slot {
    font-size: 12px;
  }

  .class-card span {
    margin-top: 4px;
    line-height: 1.2;
  }

  .lobby-card {
    gap: 6px;
    padding: 9px 10px;
  }

  .lobby-head strong {
    font-size: 16px;
  }

  .small-action {
    min-height: 34px;
    font-size: 13px;
  }

  .compact-field {
    display: none;
  }

  .lobby-slots {
    display: none;
  }

  .codex-panel {
    width: min(360px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    padding: 12px;
    gap: 9px;
  }

  .codex-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .codex-tab {
    min-height: 32px;
    font-size: 11px;
  }

  #bigMapCanvas {
    min-height: 220px;
    height: 36vh;
  }

  .relic-grid,
  .bestiary-grid,
  .map-legend,
  .compact-actions {
    grid-template-columns: 1fr;
  }
}
