/* Page look for the retro game. Kept in its own file (not inside index.html)
   so strict security headers can later block styles written into the page. */

html, body {
  margin: 0;
  height: 100%;
  background: #14110f;
  color: #d9cbb4;
  font-family: system-ui, sans-serif;
}

main {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.5rem;
  box-sizing: border-box;
}

/* ---------- meters and language switch ---------- */
.topbar {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  width: min(96vw, calc(75vh * 16 / 9));
}
.meters {
  flex: 1;
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
}
#lang { display: flex; gap: 0.25rem; }
#lang button {
  min-width: 44px;
  min-height: 32px;
  font: inherit;
  font-size: 0.8rem;
  color: #d9cbb4;
  background: transparent;
  border: 2px solid #3a302a;
  border-radius: 6px;
  cursor: pointer;
}
#lang button[aria-pressed="true"] { background: #b8572f; border-color: #b8572f; color: #fff; }
.meters label { flex: 1; display: flex; flex-direction: column; }
.meters meter { width: 100%; }

/* ---------- the game screen ---------- */
.stage {
  position: relative;                 /* the story window is placed on top of the canvas */
  width: min(96vw, calc(75vh * 16 / 9));
}

/* The game draws on a tiny 320 x 180 canvas; the browser enlarges it.
   "pixelated" keeps the pixels sharp instead of blurring them. */
#screen {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  border: 4px solid #3a302a;
  box-sizing: border-box;
  background: #000;
  touch-action: none;
}

/* ---------- intro card ---------- */
#intro-card {
  position: absolute;
  top: 4%;
  left: 4%;
  max-width: 62%;
  padding: 0.6rem 2.2rem 0.6rem 0.9rem;
  background: rgba(20, 17, 15, 0.86);
  color: #f3efe6;
  border-left: 4px solid #b8572f;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.4;
  pointer-events: auto;
}
#intro-card[hidden] { display: none; }
#i-place { display: block; font-size: 1rem; margin-bottom: 0.25rem; }
#i-text { margin: 0 0 0.35rem; }
#i-task { margin: 0; font-style: italic; color: #e9c9a8; }
#intro-close {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 32px;
  height: 32px;
  font-size: 0.9rem;
  color: #f3efe6;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
#intro-close:hover, #intro-close:focus-visible { background: #3a302a; }

/* ---------- story window ---------- */
#dialog {
  position: absolute;
  inset: 6%;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  background: #fffdf8;
  color: #2b2a28;
  border: 4px solid #2c2420;
  border-radius: 6px;
  box-shadow: 0 0 0 4px #b8572f;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.5;
}
#dialog[hidden] { display: none; }

#d-step {
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b665d;
}
#d-step:empty { display: none; }

#d-title { margin: 0.2rem 0 0.6rem; font-size: 1.3rem; }
#d-text { white-space: pre-line; margin: 0 0 0.75rem; }

#d-result {
  white-space: pre-line;
  font-style: italic;
  background: #fbeee2;
  border-left: 4px solid #b8572f;
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
}
#d-result:empty { display: none; }

#d-choices button {
  display: block;
  width: 100%;
  min-height: 44px;                  /* big enough for a finger */
  margin: 0.45rem 0;
  padding: 0.6rem 0.9rem;
  font: inherit;
  text-align: left;
  color: #fff;
  background: #b8572f;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
#d-choices button:hover,
#d-choices button:focus-visible { background: #8f3f1f; outline: 2px solid #2c2420; }

/* ---------- touch buttons: hidden on computers ---------- */
#touch { display: none; }

@media (hover: none) and (pointer: coarse) {
  #touch {
    display: flex;
    gap: 0.75rem;
    width: min(96vw, calc(75vh * 16 / 9));
    justify-content: space-between;
  }
  #touch button {
    width: 64px;
    height: 64px;
    font-size: 1.6rem;
    color: #f3efe6;
    background: #3a302a;
    border: 3px solid #b8572f;
    border-radius: 12px;
    touch-action: none;              /* no zooming or scrolling while pressing */
    user-select: none;
    -webkit-user-select: none;
  }
  #touch button:active { background: #b8572f; }
  #hint { display: none; }           /* keyboard hints make no sense on a phone */
}

#hint {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.8;
  text-align: center;
}

/* Small screens: the game picture is too small to hold the story text,
   so the story window covers the whole screen instead. */
@media (max-width: 700px) {
  /* on phones the intro card sits under the game picture, so it hides nothing */
  #intro-card {
    position: relative;              /* in the page flow, but still holds its ✕ button */
    top: auto;
    left: auto;
    max-width: none;
    margin-top: 0.5rem;
  }
  #dialog {
    position: fixed;
    inset: 0.5rem;
    z-index: 10;
  }
}

/* the "fictional story" note at the bottom: small, but always visible (also on phones) */
#note {
  font-size: 0.75rem;
  opacity: 0.6;
  text-align: center;
  max-width: 40rem;
}
