:root {
  color-scheme: dark;
  --ink: #f6ecd5;
  --muted: #b5b4b7;
  --gold: #d9b86c;
  --gold-bright: #f4d58d;
  --night: #030711;
  --panel: rgba(7, 12, 23, 0.88);
  --edge: rgba(220, 191, 123, 0.34);
}

* { box-sizing: border-box; }

html,
body,
#shell,
#gameScene {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--night);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#gameScene { position: fixed; inset: 0; }

.screen {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 70% 22%, rgba(74, 94, 130, 0.2), transparent 34%),
    linear-gradient(120deg, rgba(3, 6, 14, 0.5), rgba(3, 5, 12, 0.92));
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease;
}

.screen.visible { opacity: 1; pointer-events: auto; }

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.11;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
}

.menu-card {
  position: relative;
  width: min(650px, 100%);
  padding: clamp(30px, 6vw, 70px);
  border: 1px solid var(--edge);
  background:
    linear-gradient(145deg, rgba(13, 22, 37, 0.95), rgba(5, 9, 17, 0.96)),
    var(--panel);
  box-shadow: 0 42px 120px rgba(0, 0, 0, 0.64), inset 0 1px rgba(255,255,255,.05);
  clip-path: polygon(0 18px, 18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%);
}

.menu-card::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(217, 184, 108, 0.11);
  pointer-events: none;
}

.menu-card.compact { width: min(520px, 100%); padding: 48px; }

.eyebrow {
  margin: 0 0 14px;
  color: var(--gold);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .28em;
}

h1,
h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -.045em;
  text-wrap: balance;
}

h1 { font-size: clamp(3rem, 9vw, 6.4rem); line-height: .82; }
h1 span { color: var(--gold-bright); }
h2 { font-size: clamp(2.2rem, 6vw, 4rem); line-height: .95; }

.intro,
.menu-card.compact p {
  max-width: 48ch;
  margin: 28px 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.menu-actions { display: grid; gap: 10px; margin-top: 34px; }

button {
  min-height: 52px;
  padding: 0 24px;
  border: 1px solid rgba(217,184,108,.28);
  color: var(--ink);
  background: rgba(255,255,255,.035);
  font: 800 .82rem/1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .18em;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  border-color: var(--gold-bright);
  background: rgba(217,184,108,.1);
  outline: none;
}

button.primary {
  color: #18150e;
  border-color: var(--gold-bright);
  background: linear-gradient(135deg, #f0d38e, #b98c3d);
}

.controls-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-top: 28px;
  color: #8f939d;
  font-size: .78rem;
}

.controls-preview b,
.desktop-help b {
  color: var(--gold-bright);
  font-weight: 800;
}

.support-note { margin: 16px 0 0; color: #747984; font-size: .76rem; }

label { display: flex; justify-content: space-between; gap: 18px; margin: 30px 0 12px; color: #d8d5ce; }

input[type="range"] { width: 100%; accent-color: var(--gold); }

.toggle-row {
  align-items: center;
  margin: 28px 0;
  padding: 18px 0;
  border-block: 1px solid rgba(255,255,255,.08);
}

.toggle-row input { width: 22px; height: 22px; accent-color: var(--gold); }

.victory { text-align: center; }
.key-mark { color: var(--gold-bright); font: 400 5rem/1 Georgia, serif; filter: drop-shadow(0 0 18px rgba(240, 201, 111, .48)); }

.hud {
  position: fixed;
  z-index: 20;
  inset: 22px 22px auto 22px;
  display: none;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  pointer-events: none;
}

.hud.visible { display: grid; }

.objective,
.tool-status {
  width: fit-content;
  max-width: min(520px, 70vw);
  padding: 13px 16px;
  border-left: 2px solid var(--gold);
  background: rgba(4, 9, 17, .78);
  box-shadow: 0 12px 38px rgba(0,0,0,.3);
  backdrop-filter: blur(10px);
}

.tool-status { justify-self: end; text-align: right; }
.objective small,
.tool-status small { display: block; margin-bottom: 5px; color: var(--gold); font-size: .64rem; font-weight: 900; letter-spacing: .2em; }
.objective strong,
.tool-status strong { font-size: .86rem; font-weight: 700; }

.message {
  grid-column: 1 / -1;
  justify-self: center;
  align-self: start;
  min-height: 44px;
  max-width: min(700px, 88vw);
  margin-top: 2vh;
  padding: 12px 18px;
  border: 1px solid rgba(217,184,108,.2);
  color: #f6e9c8;
  background: rgba(4, 9, 17, .84);
  font-size: .9rem;
  text-align: center;
  opacity: 0;
  transform: translateY(-6px);
  transition: 180ms ease;
}

.message.show { opacity: 1; transform: none; }

.desktop-help {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 9px 14px;
  border: 1px solid rgba(255,255,255,.08);
  color: #a2a5aa;
  background: rgba(3,7,13,.72);
  font-size: .72rem;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

#crosshair {
  position: fixed;
  z-index: 18;
  left: 50%;
  top: 50%;
  display: none;
  width: 12px;
  height: 12px;
  margin: -6px;
  border: 1px solid rgba(246,236,213,.72);
  border-radius: 50%;
  pointer-events: none;
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(246,236,213,.7);
  transform: translate(-50%,-50%);
}

#crosshair::before { width: 18px; height: 1px; }
#crosshair::after { width: 1px; height: 18px; }
#crosshair.visible { display: block; }

#loadingBadge {
  position: fixed;
  z-index: 80;
  right: 18px;
  bottom: 18px;
  padding: 10px 13px;
  color: #d4c69f;
  background: rgba(4,8,15,.84);
  border: 1px solid rgba(217,184,108,.2);
  font-size: .67rem;
  font-weight: 800;
  letter-spacing: .14em;
  transition: opacity 260ms ease;
}

#loadingBadge.hidden { opacity: 0; pointer-events: none; }

.a-enter-vr { display: none !important; }

@media (max-width: 650px) {
  .screen { padding: 12px; }
  .menu-card,
  .menu-card.compact { padding: 34px 26px; }
  .hud { inset: 10px 10px auto; grid-template-columns: 1fr; }
  .tool-status { justify-self: start; text-align: left; }
  .desktop-help { display: none; }
  .controls-preview { font-size: .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
