/* ============================================================
   GLOAM — playable prototype
   ============================================================ */

.logo { display: inline-flex; align-items: center; gap: 0.55em; }

.logo__word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.16em;
  color: var(--ink-100);
}

.play { padding-block: var(--s-5) var(--s-7); }

.stage {
  position: relative;
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  aspect-ratio: 16 / 10;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #0B0907;
  box-shadow: inset 0 0 0 1px var(--line-hair), var(--shadow-lift);
  touch-action: none;
}

@media (max-width: 820px) {
  /* Portrait, but never so short that the playable area is a letterbox.
     svh, not vh, so the iOS URL bar collapsing does not resize the stage
     mid-run and re-centre the camera under the player's thumb. */
  .stage {
    aspect-ratio: 3 / 4;
    min-height: min(66svh, 620px);
    border-radius: var(--r-md);
  }
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

#game:focus-visible { outline: 2px solid var(--ember); outline-offset: -2px; }

/* ============================================================
   HUD
   ============================================================ */

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--s-4);
  font-size: var(--fs-sm);
}

.hud__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.hud__zone {
  padding: var(--s-3) var(--s-4);
  min-width: 9rem;
}

.hud__zone-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--ink-100);
  margin-top: 2px;
}

.hud__gauges {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.gauge {
  padding: var(--s-3) var(--s-4);
  min-width: 7rem;
}

.gauge__big {
  margin-top: 2px;
  font-size: var(--fs-md);
  color: var(--ember);
}

.gauge__bar {
  position: relative;
  height: 6px;
  margin: var(--s-3) 0 var(--s-2);
  border-radius: var(--r-full);
  background: var(--soot-800);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--line-hair);
}

.gauge__bar span {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ember-dim), var(--ember));
  transform-origin: left;
  transition: transform 220ms linear, background-color var(--t-med) linear;
}

.gauge__val { font-size: var(--fs-xs); color: var(--ink-400); }

#gauge-torch.is-low .gauge__bar span {
  background: linear-gradient(90deg, #b8443a, var(--moss));
}

#gauge-torch.is-low {
  animation: torchpulse 1.1s ease-in-out infinite;
}

@keyframes torchpulse {
  50% { box-shadow: inset 0 0 0 1px rgba(134, 192, 81, 0.6), 0 0 26px -8px var(--moss-glow); }
}

/* ---- bottom ---- */
.hud__bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-3);
}

.hud__hint {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  color: var(--ink-100);
  animation: hintIn var(--t-med) var(--ease-out);
}

@keyframes hintIn {
  from { opacity: 0; transform: translateY(6px); }
}

.key {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding-inline: 6px;
  border-radius: var(--r-sm);
  background: var(--soot-600);
  box-shadow: inset 0 0 0 1px var(--line-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ember);
}

.hud__log {
  display: grid;
  gap: var(--s-2);
  justify-items: end;
  text-align: right;
  max-width: 22rem;
}

.hud__log p {
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  background: rgba(11, 9, 7, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: inset 0 0 0 1px var(--line-hair);
  font-size: var(--fs-xs);
  color: var(--ink-200);
  animation: logIn var(--t-med) var(--ease-out);
}

.hud__log p.is-gone { opacity: 0; transition: opacity var(--t-slow) linear; }

.hud__log b { color: var(--ember); font-weight: 600; }

@keyframes logIn {
  from { opacity: 0; transform: translateX(10px); }
}

/* ---- touch controls ---- */
.stick,
.stick__action { display: none; }

@media (pointer: coarse) {
  .stick {
    display: block;
    position: absolute;
    left: var(--s-5);
    bottom: var(--s-6);
    pointer-events: auto;
  }

  .stick__base {
    position: relative;
    width: 108px;
    height: 108px;
    border-radius: 50%;
    background: rgba(26, 23, 18, 0.5);
    box-shadow: inset 0 0 0 1px var(--line-soft);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

  .stick__knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 46px;
    height: 46px;
    margin: -23px 0 0 -23px;
    border-radius: 50%;
    background: rgba(255, 138, 61, 0.22);
    box-shadow: inset 0 0 0 1px var(--ember), 0 0 22px -6px var(--ember-glow);
  }

  .stick__action {
    display: grid;
    place-items: center;
    position: absolute;
    right: var(--s-5);
    bottom: var(--s-6);
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 138, 61, 0.16);
    box-shadow: inset 0 0 0 1px var(--ember);
    color: var(--ember);
    font-family: var(--font-mono);
    font-size: 1.1rem;
    pointer-events: auto;
  }

  .stick__action:active { background: rgba(255, 138, 61, 0.32); }
}

/* ============================================================
   Salvage scan minigame
   ============================================================ */

.scan {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--s-5);
  background: rgba(11, 9, 7, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5;
}

.scan[hidden] { display: none; }

.scan__box {
  width: min(30rem, 100%);
  padding: var(--s-6);
  text-align: center;
}

.scan__box h2 {
  font-size: var(--fs-lg);
  margin: var(--s-3) 0 var(--s-2);
}

.scan__box .label { justify-content: center; }

.scan__help {
  color: var(--ink-400);
  font-size: var(--fs-sm);
  margin-bottom: var(--s-6);
}

.scan__track {
  position: relative;
  height: 46px;
  border-radius: var(--r-md);
  background: var(--soot-800);
  box-shadow: inset 0 0 0 1px var(--line-hair);
  overflow: hidden;
}

/* tick marks so the sweep reads as an instrument */
.scan__track::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    90deg, var(--line-hair) 0 1px, transparent 1px 10%);
  opacity: 0.7;
}

.scan__band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255, 138, 61, 0.35), rgba(255, 138, 61, 0.14));
  box-shadow: inset 0 0 0 1px var(--ember), 0 0 26px -4px var(--ember-glow);
  transition: left 220ms var(--ease-out), width 220ms var(--ease-out);
}

.scan__needle {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--ink-100);
  box-shadow: 0 0 14px 2px rgba(246, 239, 228, 0.7);
}

.scan__pips {
  display: flex;
  justify-content: center;
  gap: var(--s-2);
  margin: var(--s-5) 0 var(--s-3);
}

.scan__pips span {
  width: 26px;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--soot-600);
  box-shadow: inset 0 0 0 1px var(--line-hair);
  transition: background-color var(--t-med) var(--ease-out);
}

.scan__pips span.is-hit {
  background: var(--ember);
  box-shadow: 0 0 14px var(--ember-glow);
}

.scan__pips span.is-miss {
  background: var(--moss);
  box-shadow: none;
}

.scan__result {
  min-height: 1.6em;
  font-size: var(--fs-sm);
  color: var(--ink-300);
  margin-bottom: var(--s-5);
}

.scan__cta {
  display: flex;
  gap: var(--s-3);
  justify-content: center;
  flex-wrap: wrap;
}

.scan__cta .key { margin-left: 0.4em; }

/* ============================================================
   Gate (start / pause)
   ============================================================ */

.gate {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--s-5);
  /* The box is taller than a portrait stage. Scroll it rather than
     centring it and clipping the title off the top and the wallet note
     off the bottom — which is exactly what happened at 375px. */
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Kept light enough that the stonework reads through it — the
     start screen should look like the place you are about to enter. */
  background:
    radial-gradient(80% 60% at 50% 40%, rgba(51, 41, 30, 0.4), transparent 70%),
    rgba(11, 9, 7, 0.62);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 6;
  transition: opacity var(--t-med) var(--ease-out);
}

.gate[hidden] { display: none; }

.gate__box {
  width: min(34rem, 100%);
  padding: var(--s-7) var(--s-6);
  text-align: center;
}

.gate__box .label { justify-content: center; }

.gate__title {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  margin: var(--s-3) 0 var(--s-4);
}

.gate__lede {
  color: var(--ink-300);
  font-size: var(--fs-sm);
  max-width: 26rem;
  margin-inline: auto;
}

.gate__keys {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--s-3);
  margin: var(--s-6) 0;
  text-align: left;
}

.gate__keys div {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--fs-xs);
  color: var(--ink-400);
}

.gate__account {
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line-hair);
  display: grid;
  justify-items: center;
  gap: var(--s-3);
}

.gate__account-note {
  max-width: 26rem;
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: var(--ink-500);
}

.gate__account-note b {
  color: var(--ember);
  font-family: var(--font-mono);
  font-weight: 400;
}

.gate__note {
  margin-top: var(--s-5);
  font-size: var(--fs-xs);
  color: var(--ink-500);
}

/* "local only" / "not saving" marker under the Tallow readout */
.gauge__sync {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.9;
}

@media (pointer: fine) {
  .gate__note { display: none; }
}

/* ============================================================
   Footer note
   ============================================================ */

.play__foot {
  max-width: 46rem;
  margin-top: var(--s-7);
  color: var(--ink-400);
  font-size: var(--fs-sm);
}

.play__foot p { margin-top: var(--s-3); }

.play__credit { color: var(--ink-500); font-size: var(--fs-xs); }

/* ============================================================
   Phones — the gate has to fit a portrait stage
   ============================================================ */

@media (max-width: 560px) {
  .gate { align-items: start; padding: var(--s-4) var(--s-3); }

  .gate__box {
    padding: var(--s-5) var(--s-4);
  }

  .gate__keys {
    grid-template-columns: 1fr 1fr;
    gap: var(--s-2) var(--s-3);
    margin: var(--s-5) 0 var(--s-4);
  }

  .gate__account {
    margin-top: var(--s-4);
    padding-top: var(--s-4);
  }

  .gate__lede { font-size: var(--fs-xs); }

  /* The HUD was eating half a portrait stage. One compact chip row, then
     three equal gauges — everything still legible, nothing over the
     middle of the floor where the delver actually is. */
  .hud { padding: var(--s-3); }

  .hud__top {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-2);
  }

  .hud__zone {
    padding: 6px 10px;
    min-width: 0;
    justify-self: start;
  }

  .hud__zone-name { font-size: var(--fs-base); margin-top: 0; }

  .hud__gauges {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s-2);
  }

  .gauge {
    padding: 6px 10px;
    min-width: 0;
  }

  .gauge__big { font-size: var(--fs-sm); }
  .gauge__bar { margin: 6px 0 4px; }
}

/* The log and the interact hint share the bottom edge with the thumbstick
   and the E button. Lift them clear rather than stacking them. */
@media (pointer: coarse) {
  .hud__bottom { padding-bottom: 112px; }
}
