:root {
  --bg-stone: #12161c;
  --surface: rgba(18, 23, 30, 0.84);
  --surface-solid: #171d26;
  --surface-hover: rgba(29, 37, 48, 0.92);
  --border: rgba(212, 184, 128, 0.24);
  --border-strong: rgba(212, 184, 128, 0.48);
  --text: #f0ece1;
  --text-muted: #b5b0a2;
  --gold: #d9b15f;
  --gold-bright: #f0cb78;
  --crimson: #c44536;
  --emerald: #3a9c6d;
  --sky: #5fa8d3;
  --font-display: 'Cinzel', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-stone);
  color: var(--text);
  font-family: var(--font-sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
}

#vignette-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  transition: box-shadow 0.14s ease-out;
}

/* Boot Overlay */
.overlay-center {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 16, 22, 0.88);
  backdrop-filter: blur(8px);
}

.boot-panel {
  width: min(440px, 90vw);
  padding: 36px 32px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
}

.brand-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 10px;
}

.boot-title {
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 0.14em;
  margin-bottom: 12px;
}

.boot-status {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.boot-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

#boot-bar-fill {
  width: 32%;
  height: 100%;
  background: var(--gold);
  transition: width 0.3s ease;
}

/* Portal Website Overlay */
.portal {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  background: linear-gradient(180deg, rgba(13, 17, 23, 0.72) 0%, rgba(13, 17, 23, 0.56) 38%, rgba(13, 17, 23, 0.92) 78%, #10141a 100%);
}

.topbar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.studio-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.16em;
  color: var(--gold-bright);
}

.domain-sep { color: rgba(255, 255, 255, 0.28); }
.domain-label { font-size: 0.85rem; color: var(--text-muted); }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.topbar-nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s;
}

.topbar-nav a:hover { color: var(--gold-bright); }

.portal-content {
  max-width: 1180px;
  margin: 0 auto;
  padding: 44px 28px 64px;
}

.hero {
  max-width: 720px;
  padding: 36px 0 56px;
}

.hero-eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 14px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.06;
  color: #faf6eb;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
  margin-bottom: 18px;
}

.hero-lead {
  font-size: 1.05rem;
  line-height: 1.65;
  color: #e0dbd0;
  margin-bottom: 28px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 26px;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

/* Buttons */
button, .btn-outline {
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: var(--gold);
  color: #14120e;
  border: 1px solid var(--gold-bright);
  padding: 12px 24px;
}
.btn-primary:hover { background: var(--gold-bright); transform: translateY(-1px); }

.btn-secondary {
  background: rgba(27, 36, 48, 0.88);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 12px 22px;
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--gold); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(240, 236, 225, 0.28);
  padding: 10px 18px;
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold-bright); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 8px 14px;
}
.btn-ghost:hover { color: var(--text); }

/* Sections & Realm Cards */
.panel-section {
  margin-top: 36px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  backdrop-filter: blur(10px);
}

.section-header {
  margin-bottom: 22px;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.section-header p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.realm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.realm-card {
  text-align: left;
  padding: 18px 20px;
  background: rgba(15, 20, 27, 0.82);
  border: 1px solid var(--border);
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
}

.realm-card:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--gold);
  transform: translateY(-2px);
}

.realm-card:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.realm-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-transform: uppercase;
}

.realm-card-title {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 700;
}

.realm-card-sub {
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.realm-card-meta {
  margin-top: auto;
  padding-top: 6px;
  font-size: 0.78rem;
  color: var(--emerald);
}

/* Controls Grid */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(12, 16, 22, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  font-size: 0.85rem;
}

.control-item kbd {
  min-width: 92px;
  text-align: center;
  padding: 4px 8px;
  background: rgba(217, 177, 95, 0.14);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--gold-bright);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.78rem;
}

.portal-footer {
  margin-top: 44px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* In-Game HUD */
.hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  user-select: none;
}

#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(240, 203, 120, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.7);
}

.hud-top {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, 72vw);
  padding: 10px 16px;
  background: rgba(14, 18, 24, 0.78);
  border: 1px solid var(--border);
  border-radius: 5px;
  text-align: center;
}

.hud-realm-line {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
  margin-bottom: 6px;
}

.eq-bar-wrap {
  position: relative;
  height: 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.eq-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.18s;
}

.eq-bar-goal {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ffffff;
  left: 55%;
}

.eq-label { font-size: 0.76rem; color: var(--text-muted); }

.hud-radar-wrap {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 4px;
  background: rgba(14, 18, 24, 0.82);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
}

#radar-canvas { display: block; border-radius: 50%; }

.hud-vitals {
  position: fixed;
  bottom: 18px;
  left: 18px;
  width: 270px;
  padding: 12px 14px;
  background: rgba(14, 18, 24, 0.80);
  border: 1px solid var(--border);
  border-radius: 5px;
}

.vital-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.vital-tag { width: 24px; font-size: 0.74rem; font-weight: 700; color: var(--gold); }
.vital-bar { flex: 1; height: 9px; background: rgba(255, 255, 255, 0.12); border-radius: 3px; overflow: hidden; }
.fill-hp { height: 100%; width: 100%; background: var(--crimson); transition: width 0.1s; }
.fill-mp { height: 100%; width: 100%; background: var(--sky); transition: width 0.1s; }
.vital-val { width: 34px; text-align: right; font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.castle-info { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.hud-spells {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
}

.spell-slot {
  min-width: 148px;
  padding: 10px 14px;
  background: rgba(14, 18, 24, 0.84);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.slot-key { font-size: 0.68rem; letter-spacing: 0.12em; color: var(--gold); font-weight: 700; }
.slot-name { font-family: var(--font-display); font-size: 0.92rem; }
.slot-cd { font-size: 0.74rem; color: var(--crimson); min-height: 15px; }

.hud-hints {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(14, 18, 24, 0.72);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.toast-container {
  position: fixed;
  top: 106px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.toast-msg {
  padding: 7px 14px;
  background: rgba(18, 23, 30, 0.88);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.84rem;
  color: var(--text);
}

.lock-banner {
  position: fixed;
  top: 58%;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: rgba(18, 23, 30, 0.92);
  border: 1px solid var(--gold);
  border-radius: 4px;
  font-size: 0.88rem;
  color: var(--gold-bright);
}

/* Achievement Banner */
.achievement-banner {
  position: fixed;
  top: 22px;
  left: 22px;
  z-index: 60;
  padding: 14px 18px;
  background: rgba(24, 21, 14, 0.95);
  border: 1px solid var(--gold-bright);
  border-radius: 5px;
  min-width: 260px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}
.ach-kicker { font-size: 0.68rem; letter-spacing: 0.16em; color: var(--gold-bright); font-weight: 700; margin-bottom: 4px; }
.ach-title { font-family: var(--font-display); font-size: 1rem; margin-bottom: 2px; }
.ach-desc { font-size: 0.8rem; color: var(--text-muted); }

/* Modals & Spell Wheel */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 13, 18, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  width: min(420px, 92vw);
  padding: 28px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  text-align: center;
}

.modal-card h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.modal-desc { font-size: 0.92rem; color: var(--text-muted); margin-bottom: 20px; }

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.settings-card { text-align: left; }
.setting-row { margin-bottom: 14px; }
.setting-row label { display: block; font-size: 0.86rem; margin-bottom: 6px; color: var(--text); }
.setting-row input[type="range"] { width: 100%; accent-color: var(--gold); }
.setting-checks { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; font-size: 0.88rem; }
.setting-checks label { display: flex; align-items: center; gap: 8px; cursor: pointer; }

.wheel-panel {
  width: min(760px, 94vw);
  padding: 24px;
  background: rgba(17, 22, 29, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  text-align: center;
}

.wheel-panel h3 { font-family: var(--font-display); font-size: 1.25rem; margin-bottom: 6px; }
.wheel-sub { font-size: 0.84rem; color: var(--text-muted); margin-bottom: 16px; }

.wheel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.wheel-btn {
  padding: 10px 12px;
  background: rgba(24, 31, 40, 0.9);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
}
.wheel-btn:hover:not(:disabled) { border-color: var(--gold); background: var(--surface-hover); }
.wheel-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.wheel-btn .w-name { font-family: var(--font-display); font-size: 0.88rem; color: var(--gold-bright); }
.wheel-btn .w-meta { font-size: 0.72rem; color: var(--text-muted); }

@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .hud-hints { display: none; }
  .hud-vitals { width: 210px; }
}
