:root {
  --ink: #f5ead0;
  --muted: #c9b98e;
  --panel: rgba(22, 18, 14, 0.82);
  --panel-strong: rgba(35, 27, 20, 0.92);
  --line: rgba(232, 190, 105, 0.26);
  --gold: #e0b45a;
  --gold-strong: #f4cd70;
  --red: #9e3c35;
  --green: #3f7a55;
  --shadow: rgba(0, 0, 0, 0.42);
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(10, 8, 7, 0.58), rgba(10, 8, 7, 0.92)),
    url("assets/quest-map-background.png") center / cover fixed;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.hero-panel {
  min-height: 190px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 26px 0;
}

.crest {
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: radial-gradient(circle at 35% 28%, #f4d786, #9b6534 56%, #301a14);
  clip-path: polygon(50% 0, 88% 24%, 100% 70%, 50% 100%, 0 70%, 12% 24%);
  color: #190f0b;
  font-family: Cinzel, serif;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 0 18px 42px var(--shadow);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--gold-strong);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: Cinzel, Georgia, serif;
}

h1 {
  max-width: 760px;
  margin-bottom: 8px;
  font-size: clamp(2.2rem, 7vw, 5.2rem);
  line-height: 0.96;
  letter-spacing: 0;
  text-shadow: 0 6px 28px rgba(0, 0, 0, 0.72);
}

h2 {
  margin-bottom: 0;
  font-size: 1.28rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.intro {
  max-width: 520px;
  margin-bottom: 0;
  color: #e4d6b6;
  font-size: 1.05rem;
}

.dashboard,
.main-grid {
  display: grid;
  gap: 16px;
}

.dashboard {
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  margin-bottom: 16px;
}

.main-grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel), rgba(14, 12, 10, 0.88));
  box-shadow: 0 20px 60px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(10px);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 0;
}

.character-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  padding-bottom: 18px;
}

.character-panel .panel-head,
.character-panel .class-picker,
.character-panel .stat-grid,
.character-panel .progress-block {
  grid-column: 2;
}

.avatar-ring {
  grid-row: 1 / span 4;
  width: 150px;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding-left: 18px;
}

.avatar-core {
  width: 108px;
  height: 108px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(244, 205, 112, 0.42);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(224, 180, 90, 0.25), rgba(158, 60, 53, 0.34) 58%, rgba(0, 0, 0, 0.4));
  color: var(--gold-strong);
  font-family: Cinzel, serif;
  font-size: 2.2rem;
  font-weight: 700;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.class-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 0 18px;
}

.class-option {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  text-align: left;
}

.class-option.active {
  border-color: rgba(244, 205, 112, 0.75);
  background: rgba(224, 180, 90, 0.16);
}

.class-option span,
.class-option strong,
.class-option small {
  display: block;
}

.class-option span {
  margin-bottom: 7px;
  color: var(--gold-strong);
  font-size: 1.2rem;
}

.class-option small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 18px;
}

.stat {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.22);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.stat strong {
  display: block;
  margin-top: 6px;
  color: var(--gold-strong);
  font-size: clamp(1.2rem, 3vw, 1.8rem);
}

.progress-block {
  padding: 0 18px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(244, 205, 112, 0.3);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold-strong), var(--red));
  transition: width 320ms ease;
}

.unlock-panel {
  padding-bottom: 18px;
}

.keyword-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 18px 18px 0;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  background: rgba(0, 0, 0, 0.32);
  color: var(--ink);
  outline: none;
}

button[type="submit"],
.keyword-form button,
.dialog-actions button:first-child,
.quick-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

button[type="submit"],
.keyword-form button,
.dialog-actions button:last-child {
  border-color: rgba(244, 205, 112, 0.6);
  background: linear-gradient(180deg, #d6a64b, #8a552f);
  color: #1b100b;
  font-weight: 800;
}

.status-line {
  min-height: 42px;
  margin: 14px 18px 0;
  color: var(--muted);
}

.status-line[data-type="success"] {
  color: #9de0aa;
}

.status-line[data-type="error"] {
  color: #ffb2a9;
}

.quick-actions {
  display: flex;
  gap: 10px;
  padding: 0 18px;
}

.map-panel {
  min-height: 590px;
}

.map-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, 112px);
  gap: 10px;
  padding: 18px;
}

.map-fragment {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(232, 190, 105, 0.25);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  text-align: left;
}

.map-fragment::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("assets/quest-map-background.png") center / cover;
  opacity: 0.22;
}

.map-fragment.locked {
  background: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.55) 9px, rgba(45, 35, 26, 0.62) 9px, rgba(45, 35, 26, 0.62) 18px);
}

.map-fragment.unlocked {
  border-color: rgba(244, 205, 112, 0.7);
  background: rgba(191, 145, 70, 0.2);
}

.map-fragment span,
.map-fragment small {
  position: relative;
  display: block;
  text-shadow: 0 2px 10px black;
}

.map-fragment span {
  font-family: Cinzel, serif;
  font-size: 1.05rem;
}

.map-fragment small {
  max-width: 28ch;
  margin-top: 8px;
  color: #eadbb7;
  line-height: 1.35;
}

.pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--gold-strong);
  background: rgba(0, 0, 0, 0.22);
  font-weight: 800;
  font-size: 0.8rem;
}

.quest-list,
.reward-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.quest,
.reward {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: rgba(0, 0, 0, 0.24);
}

.quest.done {
  border-color: rgba(103, 180, 121, 0.48);
  background: rgba(63, 122, 85, 0.14);
}

.quest-marker {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(224, 180, 90, 0.18);
  color: var(--gold-strong);
  font-weight: 800;
}

.quest p,
.reward p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.quest-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.quest-meta span {
  border: 1px solid rgba(232, 190, 105, 0.18);
  border-radius: 999px;
  padding: 5px 8px;
  color: #eadbb7;
  font-size: 0.75rem;
}

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

.empty-state {
  margin: 18px;
  border: 1px dashed rgba(232, 190, 105, 0.28);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.18);
}

dialog {
  width: min(520px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: var(--panel-strong);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.dialog-card {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.dialog-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.code-list {
  display: grid;
  gap: 8px;
}

.code-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.22);
}

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

.code-list span {
  color: var(--muted);
  text-align: right;
}

@media (max-width: 940px) {
  .dashboard,
  .main-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 16px;
  }

  .hero-panel,
  .character-panel {
    display: block;
  }

  .crest {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
  }

  .avatar-ring {
    width: auto;
    min-height: auto;
    padding: 14px 18px 0;
  }

  .class-picker,
  .stat-grid,
  .keyword-form {
    grid-template-columns: 1fr;
  }

  .map-board {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  .map-fragment {
    grid-area: auto !important;
    min-height: 112px;
  }

  .dialog-actions,
  .quick-actions,
  .code-list div {
    flex-direction: column;
  }

  .code-list span {
    text-align: left;
  }
}
