:root {
  color-scheme: dark;
  --bg: #101214;
  --ink: #f2efe6;
  --muted: #a7aca4;
  --panel: #1c211e;
  --panel-2: #252b27;
  --edge: #384136;
  --gold: #e4b84a;
  --mint: #6ee7b7;
  --red: #ef6767;
  --blue: #6cb5ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: #050706;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.onboarding .quickbar,
body.onboarding .toast {
  display: none;
}

button {
  border: 1px solid #4b5649;
  background: #30382f;
  color: var(--ink);
  min-height: 38px;
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
  cursor: pointer;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #4b5649;
  border-radius: 6px;
  background: #111512;
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
}

a {
  color: var(--ink);
  text-decoration: none;
}

button:hover {
  border-color: var(--gold);
  background: #3a4438;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 5px;
  border: 1px solid #596254;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #111512;
  color: #fff7db;
  text-align: center;
  font-size: 0.86em;
}

.shell {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0;
}

.game-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #07100a;
  display: grid;
  place-items: center;
}

canvas {
  display: block;
  width: min(100vw, 150vh);
  height: min(100vh, 66.6667vw);
  border: 0;
  border-radius: 0;
  background: #142016;
  image-rendering: pixelated;
  box-shadow: none;
  object-fit: contain;
}

body.onboarding canvas {
  filter: saturate(0.9) brightness(0.58);
  transform: scale(1.04);
}

.site-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  overflow: auto;
  background:
    linear-gradient(90deg, rgba(4, 10, 7, 0.9) 0%, rgba(4, 10, 7, 0.62) 45%, rgba(4, 10, 7, 0.32) 100%),
    radial-gradient(circle at 72% 22%, rgba(40, 230, 160, 0.12), transparent 34%);
}

body:not(.onboarding) .site-overlay {
  display: none;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 50px;
}

.site-nav strong {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #fff4d6;
  font-size: 20px;
}

.sigil {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid #8bdc9a;
  background: #0c2e22;
  color: var(--mint);
  box-shadow: inset 0 0 0 3px #1d5c3b, 0 0 18px rgba(40, 230, 160, 0.22);
}

.site-nav div,
.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--muted);
  font-size: 14px;
}

.site-grid {
  display: grid;
  grid-template-columns: minmax(300px, 680px) minmax(300px, 430px);
  gap: 28px;
  align-items: start;
  margin-top: min(8vh, 72px);
}

.hero-copy h1 {
  max-width: 680px;
  margin: 6px 0 16px;
  color: #fff9e8;
  font-size: clamp(42px, 7vw, 82px);
  line-height: 0.94;
}

.hero-copy p {
  max-width: 640px;
  color: #d5dbcc;
  font-size: 18px;
  line-height: 1.48;
}

.hud-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.hud-strip span {
  border: 1px solid rgba(248, 223, 148, 0.28);
  border-radius: 6px;
  background: rgba(17, 21, 18, 0.78);
  padding: 8px 10px;
  color: #fff4d6;
  font-size: 13px;
}

.entry-column {
  display: grid;
  gap: 12px;
}

.entry-panel,
.character-card,
.lore-board article {
  border: 1px solid rgba(248, 223, 148, 0.26);
  border-radius: 8px;
  background: rgba(15, 19, 16, 0.86);
  padding: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

.character-card {
  display: grid;
  grid-template-columns: 146px 1fr;
  gap: 15px;
  align-items: center;
}

.pixel-diorama {
  position: relative;
  height: 134px;
  border: 1px solid #344536;
  border-radius: 6px;
  background:
    linear-gradient(135deg, #163821 0 25%, #1f5630 25% 50%, #17452a 50% 75%, #213f2a 75%),
    #15321f;
  image-rendering: pixelated;
  overflow: hidden;
}

.pixel-diorama::before {
  content: "";
  position: absolute;
  inset: 82px 0 0;
  background: repeating-linear-gradient(90deg, #8d7650 0 10px, #b4a169 10px 19px);
  opacity: 0.76;
}

.pixel-shadow {
  position: absolute;
  left: 44px;
  top: 101px;
  width: 48px;
  height: 10px;
  background: rgba(0,0,0,0.34);
}

.pixel-hero {
  position: absolute;
  left: 50px;
  top: 39px;
  width: 38px;
  height: 70px;
}

.pixel-hero span,
.pixel-slime,
.pixel-rune {
  position: absolute;
  display: block;
}

.pixel-hero .hair {
  left: 9px;
  top: 0;
  width: 20px;
  height: 10px;
  background: #6c492d;
}

.pixel-hero .face {
  left: 10px;
  top: 8px;
  width: 18px;
  height: 17px;
  background: #f0c796;
}

.pixel-hero .body {
  left: 7px;
  top: 25px;
  width: 24px;
  height: 26px;
  background: var(--preview-body, #55d36f);
  box-shadow: inset 6px 0 rgba(255,255,255,0.16);
}

.pixel-hero .shield {
  left: 0;
  top: 29px;
  width: 10px;
  height: 16px;
  background: var(--preview-accent, #4a7bb5);
  border: 2px solid #d7e8ef;
}

.pixel-hero .sword {
  left: 30px;
  top: 18px;
  width: 4px;
  height: 36px;
  background: #d7e8ef;
  box-shadow: 0 26px 0 #6b4328;
}

.pixel-hero .bow {
  display: none;
  left: 29px;
  top: 17px;
  width: 14px;
  height: 38px;
  border: 3px solid #b97938;
  border-left: 0;
  border-radius: 0 16px 16px 0;
  box-shadow: inset -2px 0 #f4d27c;
}

.pixel-hero .bow::after {
  content: "";
  position: absolute;
  left: 1px;
  top: 3px;
  width: 1px;
  height: 28px;
  background: #d7eefc;
}

.pixel-hero .staff {
  display: none;
  left: 31px;
  top: 10px;
  width: 4px;
  height: 42px;
  background: #d7eefc;
  box-shadow: 0 30px 0 #6b4328;
}

.pixel-hero .staff::before {
  content: "S";
  position: absolute;
  left: -5px;
  top: -9px;
  width: 14px;
  height: 14px;
  background: #123c2f;
  border: 2px solid #f8df94;
  color: #6ee7b7;
  font: 700 12px Georgia, serif;
  text-align: center;
  box-shadow: 0 0 15px rgba(110, 231, 183, 0.7);
}

.character-card[data-weapon="bow"] .pixel-hero .sword,
.character-card[data-weapon="magicStaff"] .pixel-hero .sword {
  display: none;
}

.character-card[data-weapon="bow"] .pixel-hero .bow,
.character-card[data-weapon="magicStaff"] .pixel-hero .staff {
  display: block;
}

.pixel-hero .boots {
  left: 9px;
  top: 51px;
  width: 22px;
  height: 10px;
  background: #25231e;
}

.pixel-slime {
  right: 18px;
  top: 80px;
  width: 22px;
  height: 17px;
  background: #68459a;
  box-shadow: inset 5px -3px #3e2d67;
}

.pixel-rune {
  left: 14px;
  top: 18px;
  width: 28px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 2px solid var(--preview-accent, #7fa177);
  background: #123c2f;
  color: #28e6a0;
  font: 700 24px Georgia, serif;
  box-shadow: 0 0 16px rgba(40,230,160,0.34);
}

.entry-panel strong {
  display: block;
  margin: 5px 0 8px;
  overflow-wrap: anywhere;
}

.entry-panel p,
.site-cards p {
  color: var(--muted);
  line-height: 1.45;
}

.profile-form {
  display: grid;
  gap: 11px;
  margin-top: 14px;
}

.profile-form label {
  display: grid;
  gap: 6px;
  color: #f8df94;
  font-size: 13px;
}

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

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

.lore-board article {
  box-shadow: none;
}

.site-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: auto;
}

.site-cards article {
  border: 1px solid rgba(248, 223, 148, 0.18);
  border-radius: 8px;
  background: rgba(15, 19, 16, 0.78);
  padding: 16px;
}

.site-cards h2 {
  margin-top: 0;
}

.toast {
  position: absolute;
  left: 20px;
  bottom: 20px;
  max-width: min(620px, calc(100% - 40px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background: rgba(12, 15, 13, 0.88);
  color: #fff9e8;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.quickbar {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 8;
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid rgba(248, 223, 148, 0.28);
  border-radius: 8px;
  background: rgba(9, 12, 10, 0.58);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(4px);
}

.panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 12;
  width: min(390px, calc(100vw - 24px));
  height: 100vh;
  min-width: 0;
  overflow: auto;
  border: 0;
  border-left: 1px solid var(--edge);
  border-radius: 0;
  background: rgba(20, 25, 22, 0.96);
  padding: 16px;
  transform: translateX(100%);
  transition: transform 180ms ease;
  box-shadow: -24px 0 70px rgba(0, 0, 0, 0.45);
}

body.menu-open .panel {
  transform: translateX(0);
}

.menu-shade {
  position: fixed;
  inset: 0;
  z-index: 11;
  background: rgba(0, 0, 0, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

body.menu-open .menu-shade {
  opacity: 1;
  pointer-events: auto;
}

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

.kicker,
.label {
  margin: 0;
  color: var(--mint);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  margin-top: 18px;
  margin-bottom: 10px;
  font-size: 15px;
  color: #f8df94;
}

.icon-btn {
  width: 38px;
  padding: 0;
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
}

.wallet {
  margin: 16px 0;
  padding: 12px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--panel-2);
}

.wallet strong {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

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

.stats-grid > div,
.inventory span,
.quest-log li {
  border: 1px solid var(--edge);
  border-radius: 7px;
  background: #171c19;
}

.stats-grid > div {
  padding: 10px;
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stats-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.actions button {
  min-width: 0;
}

.quest-log {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.quest-log li {
  padding: 10px;
  color: #e9e4d5;
  font-size: 13px;
  line-height: 1.35;
}

.quest-log li.done {
  color: var(--muted);
  text-decoration: line-through;
}

.inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inventory span,
.mmo-status span {
  padding: 7px 9px;
  font-size: 13px;
}

.inventory span.equipped {
  border-color: var(--gold);
  background: #252514;
  color: #fff4c2;
}

.mmo-status {
  display: grid;
  gap: 8px;
}

.mmo-status span {
  display: block;
  border: 1px solid var(--edge);
  border-radius: 7px;
  background: #171c19;
  line-height: 1.3;
}

.controls p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

@media (max-width: 700px) {
  .toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }

  .panel {
    width: 100vw;
  }

  .site-overlay {
    padding: 14px;
  }

  .site-nav,
  .site-grid {
    display: block;
  }

  .site-nav div {
    margin-top: 12px;
  }

  .hero-copy h1 {
    font-size: 40px;
  }

  .entry-column {
    margin-top: 18px;
  }

  .character-card,
  .lore-board {
    grid-template-columns: 1fr;
  }

  .site-cards {
    grid-template-columns: 1fr;
  }
}
