/* Emberfall — dusk-festival chrome. Scoped to #app: a game must never style
   `body` or bare elements, because the hub's chrome may live in an adjacent
   document and leaking selectors is the classic way games break their host. */

:root {
  --ink: #f3ead9;
  --dim: #a99e8a;
  --accent: #ffb45e;
  --ember: #ff9a3d;
  --deep: #0b0d14;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--deep);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  color: var(--ink);
  font: 500 16px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
}

/* ------------------------------- HUD ------------------------------- */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#hud.hidden,
#touch.hidden,
.screen.hidden {
  display: none;
}

#hud-top {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 0 18px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(10, 11, 18, 0.45);
  border: 1px solid rgba(255, 180, 94, 0.14);
  border-radius: 12px;
  padding: 8px 14px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.stat .k {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--dim);
}

#objective-text {
  font-size: 14px;
  font-weight: 600;
  max-width: 46vw;
}

#resin-pips {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.12em;
  min-height: 18px;
}

/* the corner valley map */
#minimap {
  position: absolute;
  top: calc(max(14px, env(safe-area-inset-top)) + 56px);
  right: max(14px, env(safe-area-inset-right));
  width: 168px;
  height: 168px;
  pointer-events: none;
  opacity: 0.92;
}

@media (max-width: 760px) {
  #minimap {
    width: 118px;
    height: 118px;
    top: calc(max(10px, env(safe-area-inset-top)) + 50px);
  }
}

/* Interact prompt */
#prompt {
  position: absolute;
  left: 50%;
  bottom: 16%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 180, 94, 0.35);
  background: rgba(12, 10, 8, 0.6);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.18s;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

#prompt.on {
  opacity: 1;
}

#prompt kbd {
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 180, 94, 0.5);
  background: rgba(255, 154, 61, 0.16);
  color: var(--accent);
  font: 700 12px/1.3 inherit;
}

@media (pointer: coarse) {
  #prompt kbd { display: none; }
}

/* Beacon channel ring */
#channel {
  position: absolute;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  width: 190px;
  height: 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 180, 94, 0.3);
  background: rgba(10, 8, 6, 0.55);
  overflow: hidden;
}

#channel-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ember), #ffd27a);
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 26%;
  transform: translateX(-50%);
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 0.3s;
  text-align: center;
  max-width: 80vw;
}

#toast.on {
  opacity: 1;
}

#toast.whisper {
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-weight: 400;
  font-size: 19px;
  letter-spacing: 0.02em;
  color: #ffe2b0;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.85), 0 0 26px rgba(255, 170, 80, 0.35);
  bottom: 32%;
}

/* --------------------------- touch controls ------------------------ */

#touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#joy-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 55%;
  height: 62%;
  pointer-events: auto;
}

#joy {
  position: absolute;
  width: 118px;
  height: 118px;
  margin: -59px 0 0 -59px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 200, 130, 0.35);
  background: rgba(20, 16, 10, 0.25);
  pointer-events: none;
}

#joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd9a0, #e78a2e 70%);
  box-shadow: 0 2px 14px rgba(255, 154, 61, 0.45);
}

#btn-act {
  position: absolute;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(30px, calc(env(safe-area-inset-bottom) + 22px));
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 200, 130, 0.5);
  background: radial-gradient(circle at 35% 30%, rgba(255, 154, 61, 0.5), rgba(120, 60, 18, 0.5));
  color: #ffe3b8;
  font-size: 26px;
  pointer-events: auto;
  transition: transform 0.1s, box-shadow 0.2s;
}

#btn-act.pressed {
  transform: scale(0.92);
  box-shadow: 0 0 24px rgba(255, 154, 61, 0.5);
}

#btn-act.glow {
  box-shadow: 0 0 26px rgba(255, 170, 70, 0.65);
}

/* ------------------------------ screens ---------------------------- */

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 38%, rgba(22, 17, 10, 0.42) 0%, rgba(8, 9, 14, 0.8) 74%);
  text-align: center;
  padding: 24px;
  z-index: 5;
}

/* the title lets the attract-mode valley glow through */
#screen-title {
  background: radial-gradient(circle at 50% 42%, rgba(22, 17, 10, 0.3) 0%, rgba(8, 9, 14, 0.66) 76%);
}

#screen-pause {
  background: rgba(8, 9, 14, 0.82);
}

.screen.lore {
  background: radial-gradient(circle at 50% 30%, rgba(96, 56, 18, 0.5) 0%, rgba(11, 13, 20, 0.82) 70%);
}

.inner {
  max-width: 500px;
}

h1 {
  margin: 0;
  font-size: clamp(42px, 11vw, 76px);
  letter-spacing: 0.14em;
  font-weight: 800;
  color: var(--ink);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85), 0 2px 34px rgba(255, 154, 61, 0.45);
}

/* skip-intro hint */
#skip-hint {
  position: absolute;
  right: 18px;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 180, 94, 0.25);
  background: rgba(10, 10, 14, 0.55);
  color: var(--dim);
  font-size: 12px;
  z-index: 4;
}

#skip-hint.hidden {
  display: none;
}

/* on touch, the ember button owns the bottom-right — move the hint to center */
@media (pointer: coarse) {
  #skip-hint {
    right: 50%;
    transform: translateX(50%);
  }
}
html[data-touch='1'] #skip-hint {
  right: 50%;
  transform: translateX(50%);
}

/* the narrative line — the story told over the intro flight and the video */
#story-line {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translateX(-50%);
  width: min(82vw, 760px);
  text-align: center;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: clamp(20px, 3.4vw, 30px);
  line-height: 1.45;
  color: #ffe9c8;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.9), 0 0 34px rgba(255, 160, 70, 0.4);
  opacity: 0;
  transition: opacity 0.9s ease;
  pointer-events: none;
  z-index: 4;
}

#story-line.on {
  opacity: 1;
}

h2 {
  margin: 0 0 10px;
  font-size: 28px;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.tagline {
  color: var(--dim);
  margin: 10px 0 22px;
}

.howto {
  color: var(--dim);
  font-size: 13.5px;
  margin-bottom: 24px;
}

.credit {
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.06em;
  margin-top: 20px;
  opacity: 0.8;
}

.row {
  display: flex;
  gap: 12px;
  justify-content: center;
}

kbd {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid rgba(255, 180, 94, 0.25);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(26, 20, 12, 0.8);
  font: inherit;
  font-size: 12px;
  color: var(--ink);
}

.btn {
  appearance: none;
  border: 1px solid rgba(255, 180, 94, 0.4);
  border-radius: 12px;
  background: rgba(30, 22, 12, 0.85);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 13px 30px;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s, box-shadow 0.2s;
}

.btn:hover {
  background: rgba(48, 34, 18, 0.9);
  box-shadow: 0 0 20px rgba(255, 154, 61, 0.25);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: linear-gradient(180deg, #d97a2e, #a9531a);
  border-color: #ff9a3d;
  color: #fff4e4;
  box-shadow: 0 2px 22px rgba(255, 154, 61, 0.35);
}

.btn.primary:hover {
  background: linear-gradient(180deg, #e98c3f, #bb6122);
}

/* Lore card */
.lore-body {
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.65;
  margin: 6px 0 18px;
}

#lore-plinths {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 22px;
}

#lore-plinths span {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 180, 94, 0.3);
  background: rgba(30, 22, 12, 0.7);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--accent);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s, transform 0.5s;
}

#lore-plinths span.on {
  opacity: 1;
  transform: none;
}

/* ------------------------------------------------ mobile pass
   The touch patterns every game in the arcade ships: controls that work on a
   phone, copy that matches them, and a nudge to turn the device — no JS.
   (#app sets touch-action:none; src/input.js drives the joystick/look zones.) */
.howto-touch { display: none; }
@media (pointer: coarse) {
  .howto-desktop { display: none; }
  .howto-touch { display: block; }
}
html[data-touch='1'] .howto-desktop { display: none; }
html[data-touch='1'] .howto-touch { display: block; }

@media (orientation: portrait) and (hover: none) and (pointer: coarse) {
  #app::after {
    content: "↻  Best played in landscape";
    position: fixed;
    left: 50%;
    bottom: max(10px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 9999;
    padding: 0.42rem 0.9rem;
    border: 1px solid rgba(243, 237, 225, 0.18);
    border-radius: 999px;
    background: rgba(8, 10, 16, 0.82);
    color: #f3ede1;
    font: 600 0.72rem/1.2 system-ui, -apple-system, sans-serif;
    letter-spacing: 0.04em;
    white-space: nowrap;
    pointer-events: none;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }
}
