/* =========================================================
   Wrong world — srpsoftware.com
   Palette: dusk over a floating island
   ========================================================= */

:root {
  --void:      #1B1033;
  --void-deep: #120A24;
  --magenta:   #E0568A;
  --amber:     #F2A65A;
  --grass:     #6A9E3F;
  --violet:    #A45CFF;
  --bone:      #F4EDE4;
  --bone-dim:  #B9AEC4;

  --panel:     rgba(23, 13, 44, 0.88);
  --edge-lit:  rgba(244, 237, 228, 0.30);
  --edge-dark: rgba(0, 0, 0, 0.55);

  --display: "Silkscreen", "Courier New", monospace;
  --body:    "Pixelify Sans", "Trebuchet MS", sans-serif;
  --util:    "Space Mono", ui-monospace, monospace;

  --step: 8px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--void-deep);
  color: var(--bone);
  font-family: var(--body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  /* Pixelify Sans ships a broken fi/fl ligature — keep glyphs literal */
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0, "dlig" 0, "calt" 0;
}

body { touch-action: none; }

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Full-screen veils ---------- */

.veil {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center start;
  padding: clamp(20px, 6vw, 88px);
  z-index: 20;
  /* barely there — the island stays the hero */
  background:
    linear-gradient(100deg, rgba(18, 10, 36, 0.62) 0%, rgba(18, 10, 36, 0.28) 46%, rgba(18, 10, 36, 0) 72%),
    radial-gradient(140% 110% at 50% 45%, rgba(18, 10, 36, 0) 40%, rgba(18, 10, 36, 0.55));
  transition: opacity 500ms ease, visibility 500ms;
}

.veil[hidden] { display: none; }

.veil.gone {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ---------- Loader ---------- */

#loader {
  background: var(--void-deep);
  place-items: center;
  z-index: 60;
}

.loader-inner { text-align: center; width: min(320px, 80vw); }

.loader-label {
  font-family: var(--util);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin: 0 0 14px;
}

.loader-bar {
  height: 14px;
  background: #0B0618;
  box-shadow:
    inset 2px 2px 0 var(--edge-dark),
    inset -2px -2px 0 rgba(255, 255, 255, 0.06);
}

.loader-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(90deg, var(--grass) 0 6px, #7CB44A 6px 12px);
  transition: width 220ms ease;
}

/* ---------- Cards ---------- */

.card {
  width: min(560px, 100%);
  padding: clamp(24px, 3.4vw, 40px);
  background: var(--panel);
  backdrop-filter: blur(3px);
  box-shadow:
    inset 3px 3px 0 var(--edge-lit),
    inset -3px -3px 0 var(--edge-dark),
    0 30px 90px rgba(0, 0, 0, 0.55);
  animation: card-in 620ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.eyebrow {
  font-family: var(--util);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--magenta);
  margin: 0 0 18px;
}

.eyebrow::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 10px;
  background: var(--magenta);
  vertical-align: 1px;
  animation: blink 1.6s steps(1) infinite;
}

@keyframes blink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: 0.15; } }

h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(28px, 5.4vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
  text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
}

h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(22px, 4.4vw, 40px);
  line-height: 1.12;
  margin: 0 0 16px;
  color: var(--magenta);
  text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
}

.lede {
  font-size: clamp(16px, 2.1vw, 20px);
  line-height: 1.6;
  color: var(--bone-dim);
  margin: 0 0 28px;
  max-width: 46ch;
}

.lede b { color: var(--bone); }

/* ---------- Buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 22px;
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-block;
  padding: 17px 22px;
  /* Silkscreen for controls: Pixelify's G and fi are ambiguous at this size */
  font-family: var(--display);
  font-size: 14px;
  line-height: 1;
  color: var(--bone);
  text-decoration: none;
  background: #2E1C55;
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, 0.18),
    inset -3px -3px 0 rgba(0, 0, 0, 0.5);
  transition: transform 90ms ease, background-color 160ms ease;
}

.btn:hover { background: #3B2470; }
.btn:active { transform: translateY(3px); box-shadow: inset 3px 3px 0 rgba(0, 0, 0, 0.4); }

.btn-go {
  background: var(--grass);
  color: #12210A;
  font-weight: 600;
}

.btn-go:hover { background: #7EBC49; }

.btn:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.fineprint {
  font-family: var(--util);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(185, 174, 196, 0.7);
  margin: 0;
}

/* ---------- Death screen ---------- */

.died {
  place-items: center;
  background:
    radial-gradient(120% 100% at 50% 45%, rgba(120, 16, 36, 0.42), rgba(52, 6, 18, 0.78));
}
.card-died { box-shadow: inset 3px 3px 0 rgba(255, 130, 150, 0.25), inset -3px -3px 0 var(--edge-dark); }

/* ---------- Music toggle ---------- */

.music {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 40; /* above the title card, so it stays reachable */
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  cursor: pointer;
  color: var(--bone);
  background: rgba(10, 5, 22, 0.6);
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.16),
    inset -2px -2px 0 rgba(0, 0, 0, 0.5);
  transition: background-color 160ms ease, transform 90ms ease;
}

.music[hidden] { display: none; }
.music:hover { background: rgba(46, 28, 85, 0.8); }
.music:active { transform: translateY(2px); }

.music:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.music svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.music[aria-pressed="true"] .cross { display: none; }
.music[aria-pressed="false"] .waves { display: none; }
.music[aria-pressed="false"] { color: var(--bone-dim); }

/* ---------- F3 debug overlay ---------- */

.debug {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 15;
  padding: 10px 14px 12px;
  margin: 0;
  font-family: var(--util);
  font-size: 12px;
  line-height: 1.55;
  color: var(--bone);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.85);
  pointer-events: none;
  background: linear-gradient(105deg, rgba(10, 5, 22, 0.5), rgba(10, 5, 22, 0));
  transition: opacity 200ms ease;
}

.debug p { margin: 0; white-space: nowrap; }
.debug .dim { color: rgba(185, 174, 196, 0.75); }
.debug .warn { color: var(--magenta); }
.debug .good { color: #8BE04E; }
.debug .tiny { font-size: 10px; opacity: 0.5; margin-top: 6px; }
.debug.off { opacity: 0; }

/* ---------- In-world HUD ---------- */

.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.hud[hidden] { display: none; }

.crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  opacity: 0.85;
  mix-blend-mode: difference;
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background: #fff;
}

.crosshair::before { left: 9px; top: 0; width: 2px; height: 20px; }
.crosshair::after { top: 9px; left: 0; height: 2px; width: 20px; }

.prompt {
  position: absolute;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%);
  margin: 0;
  padding: 9px 16px;
  max-width: 84vw;
  text-align: center;
  font-size: 17px;
  color: var(--bone);
  background: rgba(10, 5, 22, 0.72);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.8);
  opacity: 0;
  transition: opacity 260ms ease;
}

.prompt.show { opacity: 1; }

.hotbar {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(10, 5, 22, 0.6);
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.14),
    inset -2px -2px 0 rgba(0, 0, 0, 0.5);
}

.slot {
  width: 76px;
  height: 62px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  background: rgba(46, 28, 85, 0.55);
  box-shadow:
    inset 2px 2px 0 rgba(0, 0, 0, 0.45),
    inset -2px -2px 0 rgba(255, 255, 255, 0.12);
}

.slot .key {
  font-family: var(--util);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--bone);
}

.slot .cap {
  font-size: 12px;
  color: rgba(185, 174, 196, 0.85);
}

/* ---------- Portal wipe ---------- */

.wipe {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: radial-gradient(60% 60% at 50% 50%, #C77DFF, #4B1E86 55%, #120A24);
  opacity: 0;
  visibility: hidden;
  transition: opacity 900ms ease, visibility 900ms;
}

.wipe.on { opacity: 1; visibility: visible; }

.wipe p {
  font-family: var(--display);
  font-size: clamp(15px, 3vw, 26px);
  color: #fff;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .debug { font-size: 10.5px; padding: 8px 10px 10px; }
  .slot { width: 58px; height: 54px; }
  .slot .key { font-size: 8.5px; }
  .slot .cap { font-size: 10px; }
  .prompt { bottom: 96px; font-size: 15px; }
  .actions .btn { flex: 1 1 100%; text-align: center; }
}

@media (max-height: 520px) {
  .hotbar { display: none; }
  .prompt { bottom: 26px; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
