:root {
  --bg: #050811;
  --panel: rgba(10, 16, 28, 0.9);
  --panel-2: rgba(14, 22, 38, 0.94);
  --panel-3: rgba(19, 28, 48, 0.9);
  --line: rgba(158, 194, 255, 0.14);
  --line-strong: rgba(232, 206, 142, 0.28);
  --text: #f4f7ff;
  --muted: #a2b4d2;
  --gold: #e8c87d;
  --mint: #7ce8ce;
  --rose: #ff8bc0;
  --violet: #b598ff;
  --ember: #ff9d78;
  --danger: #ff7f8f;
  --shadow: rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 18%, rgba(133, 169, 255, 0.18), transparent 22%),
    radial-gradient(circle at 82% 16%, rgba(255, 152, 110, 0.16), transparent 18%),
    radial-gradient(circle at 72% 84%, rgba(153, 117, 255, 0.16), transparent 24%),
    linear-gradient(180deg, #090f1d 0%, #04070f 100%);
  font-family: "Inter", "Segoe UI", sans-serif;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body::before {
  opacity: 0.22;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.14) 0 1px, transparent 1px),
    radial-gradient(circle at 75% 30%, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px),
    radial-gradient(circle at 40% 78%, rgba(255, 255, 255, 0.09) 0 1px, transparent 1px);
  background-size: 260px 260px, 340px 340px, 380px 380px;
}

body::after {
  opacity: 0.08;
  mix-blend-mode: soft-light;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 3px 3px;
}

a {
  color: inherit;
}

button,
a,
canvas {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1560px, calc(100% - 26px));
  margin: 16px auto 24px;
  padding: 18px;
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 22%),
    linear-gradient(180deg, rgba(9, 15, 27, 0.96), rgba(5, 10, 18, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 34px 100px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(18px);
}

.shell::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 22px;
  border: 1px solid rgba(232, 206, 142, 0.1);
  pointer-events: none;
}

.masthead {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 8px 10px 22px;
  border-bottom: 1px solid var(--line);
}

.kicker,
.eyebrow,
.card-eyebrow {
  font-family: "Rajdhani", sans-serif;
  font-size: 1rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mint);
}

h1,
h2,
h3,
h4 {
  font-family: "Cinzel", serif;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1.05;
  color: #fff6de;
  text-shadow: 0 0 28px rgba(232, 206, 142, 0.12);
}

.sub {
  margin: 12px 0 0;
  max-width: 72ch;
  color: var(--muted);
  line-height: 1.7;
}

.hud-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  max-width: 460px;
}

.hud-chip,
.tiny-chip {
  min-width: 96px;
  border-radius: 999px;
  padding: 10px 13px;
  text-align: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.hud-chip span,
.tiny-chip span {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud-chip strong,
.tiny-chip strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 0.97rem;
}

.ghost-link,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 15px;
  padding: 12px 16px;
  border: none;
  text-decoration: none;
  font-weight: 700;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease, opacity 0.16s ease, border-color 0.16s ease;
}

.ghost-link,
button:not(.btn-dark):not(.btn-danger) {
  color: #120f10;
  background: linear-gradient(135deg, #f1d78d 0%, #ffab84 56%, #b594ff 100%);
  box-shadow: 0 12px 28px rgba(232, 206, 142, 0.16);
}

.btn-dark {
  color: var(--text);
  background: linear-gradient(180deg, rgba(160, 187, 255, 0.12), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(160, 187, 255, 0.14);
  box-shadow: none;
}

.btn-danger {
  color: #fff1f2;
  background: linear-gradient(180deg, rgba(255, 136, 150, 0.26), rgba(98, 24, 34, 0.9));
  border: 1px solid rgba(255, 136, 150, 0.18);
  box-shadow: none;
}

.ghost-link:hover,
button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  filter: none;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(330px, 0.8fr);
  gap: 18px;
}

.panel {
  position: relative;
  border-radius: 26px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 22%),
    linear-gradient(180deg, rgba(10, 17, 28, 0.96), rgba(7, 12, 21, 0.98));
  border: 1px solid var(--line);
  box-shadow: 0 26px 56px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at top right, rgba(124, 232, 206, 0.09), transparent 30%);
}

.world-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.world-heading,
.controls-row,
.hero-summary,
.hero-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.section-copy,
.dialog-copy,
.control-note span,
.log-item span,
.inventory-card span,
.quest-item p,
.lore-note p {
  color: var(--muted);
  line-height: 1.65;
}

.section-copy,
.dialog-copy {
  margin: 8px 0 0;
}

.control-cluster,
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.world-stage {
  position: relative;
  padding: 12px;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(173, 202, 255, 0.05), transparent 24%),
    linear-gradient(180deg, #080d17, #05070c);
  border: 1px solid rgba(173, 202, 255, 0.11);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: #04070f;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
  image-rendering: pixelated;
  cursor: pointer;
}

.floating-card {
  position: absolute;
  z-index: 2;
  max-width: min(370px, calc(100% - 48px));
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(173, 202, 255, 0.16);
  background: rgba(4, 8, 16, 0.72);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(12px);
}

.floating-card strong {
  display: block;
  margin-bottom: 4px;
}

.location-card {
  left: 24px;
  top: 24px;
}

.action-card {
  right: 24px;
  bottom: 24px;
}

.hidden {
  display: none !important;
}

.control-note {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  max-width: 580px;
}

.control-note strong {
  color: #fff6de;
}

.sidebar {
  display: grid;
  gap: 18px;
  align-content: start;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, #88f0d0, #f1d58d);
  color: #111419;
  font-weight: 800;
}

.hero-avatar,
.portrait {
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.hero-avatar {
  width: 84px;
  height: 84px;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.95) 0 6%, transparent 7%),
    radial-gradient(circle at 50% 42%, var(--avatar-accent, rgba(255, 255, 255, 0.6)) 0 18%, transparent 19%),
    linear-gradient(180deg, var(--avatar-primary, #79d7ff), var(--avatar-secondary, #8f67ff));
}

.hero-card,
.inventory-card,
.log-item,
.quest-item,
.battle-card,
.class-card {
  position: relative;
  border-radius: 20px;
  padding: 14px;
  border: 1px solid rgba(173, 202, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 25%),
    rgba(255, 255, 255, 0.02);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.hero-card {
  display: grid;
  gap: 14px;
}

.hero-copy h3 {
  margin: 8px 0 6px;
}

.hero-copy p {
  margin: 0;
  color: var(--muted);
}

.stat-grid,
.inventory-grid,
.class-grid,
.battle-grid {
  display: grid;
  gap: 12px;
}

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

.inventory-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
}

.inventory-card strong,
.log-item strong,
.quest-item strong,
.battle-card h4 {
  display: block;
  margin-bottom: 6px;
}

.meter {
  display: grid;
  gap: 10px;
}

.meter.compact {
  margin-top: 14px;
}

.meter-row {
  display: grid;
  gap: 6px;
}

.meter-row strong {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.bar i {
  display: block;
  width: 50%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f0c86c, #ff8f74);
  box-shadow: 0 0 16px rgba(255, 143, 116, 0.28);
}

.bar.mana i {
  background: linear-gradient(90deg, #7de9cd, #7aaeff);
  box-shadow: 0 0 16px rgba(122, 174, 255, 0.28);
}

.bar.enemy i {
  background: linear-gradient(90deg, #ff7f8f, #ffb76e);
  box-shadow: 0 0 16px rgba(255, 127, 143, 0.28);
}

.quest-list,
.log-feed,
.legend {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.quest-item {
  display: grid;
  gap: 8px;
}

.quest-item.completed {
  border-color: rgba(124, 232, 206, 0.22);
  background:
    linear-gradient(180deg, rgba(124, 232, 206, 0.08), transparent 28%),
    rgba(255, 255, 255, 0.02);
}

.quest-item button {
  justify-self: flex-start;
  padding: 10px 12px;
  font-size: 0.86rem;
}

.quest-item button:disabled {
  opacity: 0.55;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 30;
  padding: 14px 18px;
  border-radius: 999px;
  background: rgba(4, 8, 16, 0.9);
  border: 1px solid rgba(173, 202, 255, 0.16);
  color: #fff2d7;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 7, 12, 0.76);
  backdrop-filter: blur(16px);
}

.modal {
  width: min(1160px, 100%);
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 16%),
    linear-gradient(180deg, rgba(10, 17, 28, 0.98), rgba(6, 10, 18, 0.99));
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.46);
  overflow: hidden;
}

.modal.small {
  max-width: 780px;
}

.modal.large {
  max-width: 1160px;
}

.modal-head {
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2,
.modal-head h3 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 2rem);
}

.modal-body {
  padding: 22px 24px 24px;
}

.intro-grid {
  display: grid;
  grid-template-columns: 1.12fr 0.88fr;
  gap: 18px;
}

.lore-note {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(173, 202, 255, 0.12);
  background:
    radial-gradient(circle at top right, rgba(232, 206, 142, 0.14), transparent 42%),
    rgba(255, 255, 255, 0.03);
}

.class-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.class-card {
  cursor: pointer;
  min-height: 250px;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.class-card:hover,
.class-card.selected {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.24);
}

.class-card.selected::after {
  content: "Chosen vessel";
  position: absolute;
  top: 14px;
  right: 14px;
  font-family: "Rajdhani", sans-serif;
  font-size: 0.92rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mint);
}

.class-card h3 {
  margin: 8px 0 10px;
  font-size: 1.16rem;
}

.class-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.class-stats span {
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.8rem;
}

.legend-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  margin-top: 5px;
  flex: none;
}

.legend-swatch.court {
  background: linear-gradient(135deg, #f2d48c, #ffad86);
}

.legend-swatch.sigil {
  background: linear-gradient(135deg, #7ce8ce, #7eb0ff);
}

.legend-swatch.danger {
  background: linear-gradient(135deg, #ff7f8f, #ffbe76);
}

.battle-modal {
  max-width: 1080px;
}

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

.battle-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 16px;
  align-items: center;
}

.enemy-side {
  background:
    linear-gradient(180deg, rgba(255, 127, 143, 0.08), transparent 26%),
    rgba(255, 255, 255, 0.02);
}

.portrait-frame {
  padding: 8px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.portrait {
  width: 100%;
  aspect-ratio: 1;
  background:
    radial-gradient(circle at 50% 24%, rgba(255, 255, 255, 0.96) 0 8%, transparent 9%),
    radial-gradient(circle at 50% 45%, var(--portrait-accent, rgba(255, 255, 255, 0.6)) 0 18%, transparent 19%),
    linear-gradient(180deg, var(--portrait-primary, #79d7ff), var(--portrait-secondary, #8f67ff));
}

.battle-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.battle-log {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.end-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

@media (max-width: 1240px) {
  .layout,
  .intro-grid {
    grid-template-columns: 1fr;
  }

  .hud-strip {
    max-width: none;
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .masthead,
  .world-heading,
  .controls-row,
  .hero-summary,
  .hero-meta-row {
    flex-direction: column;
    align-items: stretch;
  }

  .battle-grid,
  .class-grid,
  .inventory-grid,
  .battle-actions {
    grid-template-columns: 1fr;
  }

  .battle-card {
    grid-template-columns: 1fr;
  }

  .hero-avatar {
    align-self: flex-start;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100%, calc(100% - 12px));
    margin: 6px auto 14px;
    padding: 10px;
    border-radius: 20px;
  }

  .panel,
  .modal {
    border-radius: 20px;
  }

  .location-card,
  .action-card {
    left: 16px;
    right: 16px;
    max-width: none;
  }

  .action-card {
    bottom: 16px;
  }

  .location-card {
    top: 16px;
  }
}
