:root {
  --gold: #d8b673;
  --gold-dim: rgba(216, 182, 115, 0.28);
  --ink: #05070d;
  --paper: #ece6d8;
  --muted: #9a9488;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }

/* ---------- capas decorativas ---------- */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background:
    radial-gradient(ellipse at 50% 46%, rgba(0,0,0,0) 38%, rgba(0,0,0,0.45) 78%, rgba(0,0,0,0.82) 100%),
    linear-gradient(to bottom, rgba(3,4,8,0.55) 0%, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 70%, rgba(2,3,6,0.75) 100%);
}

#grain {
  position: fixed; inset: -50%; pointer-events: none; z-index: 6; opacity: 0.055;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='240' height='240' filter='url(%23n)' opacity='0.9'/></svg>");
  mix-blend-mode: overlay;
  animation: grain 900ms steps(3) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-2%, 1.5%); }
  66% { transform: translate(1.5%, -1%); }
  100% { transform: translate(0, 0); }
}

/* ---------- arranque ---------- */
#boot {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 40%, #101728 0%, #05070d 62%, #020308 100%);
  transition: opacity 1.1s var(--ease), visibility 1.1s;
}
#boot.gone { opacity: 0; visibility: hidden; pointer-events: none; }

.boot-inner { text-align: center; padding: 24px; }

.crest {
  position: relative; width: 74px; height: 74px; margin: 0 auto 26px;
  color: var(--gold); display: grid; place-items: center;
}
.crest svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.crest span {
  font-family: "Cinzel", Georgia, serif; font-size: 30px; font-weight: 600;
  letter-spacing: 0.02em; transform: translateY(1px);
  text-shadow: 0 0 22px rgba(216, 182, 115, 0.55);
}

#boot h1 {
  margin: 0; font-family: "Cinzel", Georgia, serif; font-weight: 400;
  font-size: clamp(30px, 6.5vw, 54px); letter-spacing: 0.34em; text-indent: 0.34em;
  color: #f2ecdd;
}
#boot .sub {
  margin: 12px 0 30px; font-size: 10.5px; letter-spacing: 0.42em;
  text-transform: uppercase; color: var(--gold); opacity: 0.85;
}
#boot .bar {
  width: 190px; height: 1px; margin: 0 auto 18px; background: rgba(216,182,115,0.18);
  overflow: hidden;
}
#boot .bar i {
  display: block; height: 100%; width: 30%;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  animation: sweep 1.6s linear infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
#boot-msg {
  margin: 0; font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--muted); min-height: 14px;
}
#boot-msg.err { color: #e08a6a; letter-spacing: 0.06em; text-transform: none; font-size: 13px; line-height: 1.5; }

/* ---------- HUD ---------- */
#ui {
  position: fixed; inset: 0; z-index: 10; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: clamp(18px, 3.2vw, 40px);
  transition: opacity 0.8s var(--ease);
}

#ui header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand .mark {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--gold-dim); color: var(--gold);
  font-family: "Cinzel", Georgia, serif; font-size: 15px;
  transform: rotate(45deg);
}
.brand .mark::after { content: ""; }
.brand .mark { position: relative; }
.brand .mark > * { transform: rotate(-45deg); }
.brand .bt { display: flex; flex-direction: column; gap: 4px; }
.brand strong {
  font-family: "Cinzel", Georgia, serif; font-weight: 600; font-size: 15px;
  letter-spacing: 0.26em; text-transform: uppercase; color: #f1ead9;
}
.brand em {
  font-style: normal; font-size: 9px; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--muted);
}
.meta {
  display: flex; align-items: center; gap: 12px; font-size: 10px;
  letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted);
  padding-top: 6px;
}
#clock { color: var(--gold); font-variant-numeric: tabular-nums; }
.dot {
  width: 3px; height: 3px; border-radius: 50%; background: var(--gold-dim);
  display: inline-block; flex: none;
}

.quote { margin: 0; max-width: 330px; }
.quote p {
  margin: 0; font-family: "Cinzel", Georgia, serif; font-size: 13.5px;
  line-height: 1.7; color: #f0e9d8; opacity: 1; letter-spacing: 0.02em;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.85);
}
.quote cite {
  display: block; margin-top: 10px; font-style: normal; font-size: 9px;
  letter-spacing: 0.28em; text-transform: uppercase; color: var(--gold); opacity: 0.9;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.8);
}

/* ---------- botones ---------- */
.tools {
  display: flex; gap: 9px; align-self: flex-end; pointer-events: auto; flex-wrap: wrap;
  justify-content: flex-end;
}
.tools button {
  appearance: none; cursor: pointer; position: relative;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 11px 16px 11px 18px; border-radius: 999px;
  border: 1px solid rgba(216, 182, 115, 0.22);
  background: rgba(9, 12, 19, 0.58);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  color: #e9e2d1; font-family: inherit; font-size: 10.5px; font-weight: 400;
  letter-spacing: 0.2em; text-transform: uppercase;
  transition: border-color 0.35s var(--ease), background 0.35s var(--ease),
              color 0.35s var(--ease), transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.tools button i {
  font-style: normal; font-size: 8.5px; letter-spacing: 0.1em;
  color: var(--muted); border: 1px solid rgba(216,182,115,0.2);
  border-radius: 4px; padding: 2px 4px; line-height: 1; opacity: 0.7;
}
.tools button:hover {
  border-color: rgba(216, 182, 115, 0.62);
  background: rgba(26, 22, 14, 0.72);
  transform: translateY(-1px);
  box-shadow: 0 8px 30px rgba(216, 168, 74, 0.12);
}
.tools button:active { transform: translateY(0); }
.tools button.on {
  border-color: rgba(216, 182, 115, 0.9);
  background: rgba(216, 168, 74, 0.16);
  color: #fff3d8;
  box-shadow: 0 0 26px rgba(216, 168, 74, 0.22), inset 0 0 18px rgba(216, 168, 74, 0.08);
}
.tools button:focus-visible { outline: 1px solid var(--gold); outline-offset: 3px; }

.hint {
  margin: 0; padding-top: 18px; text-align: center;
  font-size: 9px; letter-spacing: 0.26em; text-transform: uppercase;
  color: rgba(200, 194, 180, 0.5);
  display: flex; align-items: center; justify-content: center; gap: 12px;
  transition: opacity 1s var(--ease);
}
.hint.faded { opacity: 0; }

/* ---------- modo cine ---------- */
#bars { position: fixed; inset: 0; z-index: 8; pointer-events: none; }
#bars i {
  position: absolute; left: 0; right: 0; height: 0; background: #000;
  transition: height 1.1s var(--ease);
}
#bars i:first-child { top: 0; }
#bars i:last-child { bottom: 0; }
body.cinema #bars i { height: 7vh; }
body.cinema header, body.cinema .quote, body.cinema .hint { opacity: 0; transition: opacity 0.8s var(--ease); }
body.cinema .tools { opacity: 0.18; transition: opacity 0.8s var(--ease); }
body.cinema .tools:hover { opacity: 1; }
body.cinema #btn-flight { border-color: rgba(216, 182, 115, 0.55); }

#debug {
  position: fixed; left: 10px; bottom: 8px; z-index: 30; pointer-events: none;
  font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: rgba(180, 230, 180, 0.55); white-space: pre; display: none;
}
body.debug #debug { display: block; }

.only-sm { display: none; }

/* ---------- adaptación ---------- */
@media (max-width: 760px) {
    .hide-sm { display: none !important; }
  .only-sm { display: inline !important; }
  #ui { padding: 16px; }
  .quote { max-width: 240px; }
  .quote p { font-size: 11.5px; line-height: 1.6; }
  .brand em { display: none; }
  .tools button { padding: 12px 16px; font-size: 9.5px; letter-spacing: 0.16em; }
  .tools button i { display: none; }
  .hint { font-size: 8px; letter-spacing: 0.18em; gap: 8px; }
  #boot h1 { letter-spacing: 0.26em; }
}
@media (max-height: 520px) {
  .quote { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #grain { animation: none; }
}
