/* ============================================================
   style.css, the console shell around the screen
   ============================================================
   Everything inside the canvas is drawn in four shades by the game itself.
   This file only styles the housing: the bezel, the pad, and the page it all
   sits on. The two colour systems meet at --shell and --screen-bg, which
   main.js sets from the active palette so the housing follows the screen.
   ============================================================ */

:root {
  --shell: #2b2b2b;
  --screen-bg: #f7f7ef;
  --page: #14140f;
  --case: #d8d5cc;
  --case-dark: #a9a69c;
  --ink: #2a2a26;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--page);
  color: var(--case);
  font-family: "Segoe UI", system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  /* The pad is meant to be thumbed, so nothing here should also pan or
     zoom the page under the finger. */
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* --- Gate ------------------------------------------------------------
   The shared-password overlay. See js/gate.js: it is a speed bump, not
   security. Styled to match the console so the first thing a visitor sees
   still looks like the thing they came for. */

.gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page);
  padding: 24px;
  z-index: 10;
}

.gate[hidden] {
  display: none;
}

.gate__card {
  background: var(--case);
  border-radius: 14px 14px 46px 14px;
  padding: 28px 26px 24px;
  box-shadow:
    0 1px 0 #ffffff inset,
    0 -3px 0 var(--case-dark) inset,
    0 18px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(300px, 100%);
}

.gate__title {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--ink);
  text-align: center;
}

.gate__label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6d6a63;
}

.gate__input {
  font: inherit;
  font-size: 15px;
  padding: 9px 11px;
  border: 1.5px solid var(--case-dark);
  border-radius: 8px;
  background: #f4f2ec;
  color: var(--ink);
  width: 100%;
}

.gate__input:focus {
  outline: 2px solid #8c2f4a;
  outline-offset: 1px;
}

.gate__button {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: #8c2f4a;
  color: #ffe9f0;
  cursor: pointer;
  box-shadow: 0 3px 0 #5e1e31;
}

.gate__button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #5e1e31;
}

.gate__error {
  margin: 0;
  font-size: 11px;
  color: #8c2f4a;
  text-align: center;
}

.gate__error[hidden] {
  display: none;
}

@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.gate--wrong .gate__card {
  animation: gate-shake 320ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .gate--wrong .gate__card {
    animation: none;
  }
}

.console[hidden] {
  display: none;
}

.console {
  background: var(--case);
  border-radius: 14px 14px 46px 14px;
  padding: 18px 20px 20px;
  box-shadow:
    0 1px 0 #ffffff inset,
    0 -3px 0 var(--case-dark) inset,
    0 18px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 100%;
}

.console__bezel {
  background: var(--shell);
  border-radius: 10px 10px 26px 10px;
  padding: 18px 22px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4) inset;
  display: flex;
  transition: background 180ms ease;
}

#screen {
  display: block;
  background: var(--screen-bg);
  /* The whole point of the art style: never let the browser smooth the
     upscale, or every hand-placed pixel turns to mush. */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transition: background 180ms ease;
}

.console__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 0 4px;
}

.console__title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--ink);
}

.console__palette {
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--case-dark);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  min-width: 74px;
}

.console__palette:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* --- Controls ------------------------------------------------------- */

.pad {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 24px;
  padding: 4px 4px 0;
}

/* 46px, not the 34px this started at. The pad is the ONLY control on a phone,
   and 34px is well under the ~44px a thumb can hit reliably, so mis-steps were
   guaranteed on exactly the device the pad exists for. */
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 46px);
  grid-template-rows: repeat(3, 46px);
}

.dpad__btn,
.dpad__hub {
  background: #3a3a38;
  border: none;
  padding: 0;
}

.dpad__hub {
  grid-area: 2 / 2;
}

.dpad__btn {
  cursor: pointer;
  position: relative;
}

.dpad__btn::after {
  content: "";
  position: absolute;
  inset: 34%;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 1px;
}

.dpad__btn--up {
  grid-area: 1 / 2;
  border-radius: 6px 6px 0 0;
}

.dpad__btn--left {
  grid-area: 2 / 1;
  border-radius: 6px 0 0 6px;
}

.dpad__btn--right {
  grid-area: 2 / 3;
  border-radius: 0 6px 6px 0;
}

.dpad__btn--down {
  grid-area: 3 / 2;
  border-radius: 0 0 6px 6px;
}

.dpad__btn.is-pressed {
  background: #222220;
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  /* Tilted the way the originals were, which also happens to sit better
     under a thumb than a flat row. */
  transform: rotate(-18deg);
}

/* none, not the body's `manipulation`: on the controls themselves the browser
   must never interpret a press as the start of a pan or zoom, because doing so
   cancels the pointer stream mid-gesture and the press is simply lost. */
.dpad__btn,
.actions__btn {
  touch-action: none;
}

.actions__btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: #8c2f4a;
  color: #ffe9f0;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 3px 0 #5e1e31;
}

.actions__btn.is-pressed {
  transform: translateY(3px);
  box-shadow: 0 0 0 #5e1e31;
}

/* --- Footnotes ------------------------------------------------------ */

/* One instruction per row. As a single wrapping paragraph the break landed
   wherever the width happened to put it, splitting "Enter or Space to talk."
   across two lines mid-phrase. Discrete rows always break where meaning does. */
.hint,
.version {
  margin: 0;
  color: #6d6a63;
  font-size: 11px;
  text-align: center;
  line-height: 1.5;
  max-width: 42ch;
}

.hint__line {
  margin: 0;
}

.hint__note {
  color: #8d8a82;
  font-style: italic;
}

.version {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: #8d8a82;
}

/* On a phone the housing is decoration the screen cannot afford, so the
   bezel tightens and the pad gets the room instead. */
@media (max-width: 560px) {
  body {
    padding: 8px;
    align-items: flex-start;
  }

  .console {
    padding: 12px 12px 16px;
    border-radius: 12px;
    width: 100%;
  }

  .console__bezel {
    padding: 10px;
    width: 100%;
    justify-content: center;
  }

  /* The keyboard rows are noise on a phone, but the laptop note is exactly the
     thing a phone player benefits from knowing, so it stays. */
  .hint__line {
    display: none;
  }

  .hint__note {
    display: block;
  }
}
