/*
 * game.css — the page around the canvas.
 *
 * The game itself is drawn; this is only the frame it sits in and the few
 * pieces of furniture that have to be real DOM so that a keyboard and a screen
 * reader can reach them. The palette is the homepage's, so arriving here reads
 * as going further in rather than going somewhere else.
 */

:root {
  --bg: #07060b;
  --ink: #f2efe8;
  --dim: #6b6678;
  --line: #23212c;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', 'Palatino Linotype', serif;
  -webkit-font-smoothing: antialiased;
  /* Arrow keys and Space are the game's; the page must not also scroll. */
  overflow: hidden;
  overscroll-behavior: none;
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

/* ── Furniture ─────────────────────────────────────────────────────────── */

#hud {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.6rem;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.9rem 1.4rem 1.1rem;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  color: var(--dim);
  pointer-events: none;
}

#controls {
  max-width: 86ch;
  line-height: 1.8;
}

#exits {
  display: flex;
  gap: 1.2rem;
  align-items: baseline;
  pointer-events: auto;
}

#exits a,
#exits button {
  font: inherit;
  letter-spacing: inherit;
  color: var(--dim);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.15rem 0.1rem;
  cursor: pointer;
  text-decoration: none;
  transition: color 160ms ease, border-color 160ms ease;
}

#exits a:hover,
#exits button:hover,
#exits a:focus-visible,
#exits button:focus-visible {
  color: var(--ink);
  border-color: var(--ink);
}

/* Never rely on the browser's default ring alone against a black canvas. */
#exits a:focus-visible,
#exits button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

#exits button[aria-pressed='true'] {
  color: var(--ink);
  border-color: var(--ink);
}

/* Pressed state must be readable without colour: the label says so too. */
#exits button[aria-pressed='true']::after {
  content: ' · on';
}

#paused {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  font-size: 1.1rem;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--ink);
  background: rgba(7, 6, 11, 0.72);
  pointer-events: none;
}

#paused[hidden] {
  display: none;
}

#admin-menu {
  width: min(38rem, calc(100vw - 2rem));
  margin-top: 1.8rem;
  padding: 1.2rem 1.3rem 1.3rem;
  border: 1px solid var(--line);
  background: rgba(7, 6, 11, 0.94);
  pointer-events: auto;
}

#admin-menu[hidden] {
  display: none;
}

#admin-menu > p {
  margin-bottom: 1rem;
  font-size: 0.68rem;
  letter-spacing: 0.3em;
  color: var(--dim);
}

#admin-levels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

#admin-levels button {
  min-width: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  color: var(--dim);
  background: transparent;
  font: 0.72rem/1.35 Georgia, 'Times New Roman', serif;
  letter-spacing: 0.12em;
  text-align: left;
  text-transform: none;
  cursor: pointer;
}

#admin-levels button:hover,
#admin-levels button:focus-visible {
  color: var(--ink);
  border-color: var(--ink);
  outline: none;
}

@media (max-width: 520px) {
  #admin-levels {
    grid-template-columns: 1fr;
  }
}

#noscript {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
  line-height: 1.8;
  max-width: 46ch;
  margin: 0 auto;
}

#noscript a {
  color: var(--ink);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  #hud {
    font-size: 0.66rem;
    padding: 0.7rem 0.9rem 0.9rem;
  }
}

/* ── Touch controls ────────────────────────────────────────────────────── */
/*
 * Shown only on coarse pointers (touchscreens), never on a mouse — a
 * keyboard player should never see buttons meant for someone without one.
 * The keyboard hint text in #controls is hidden alongside it: the full
 * prose description on the canvas already covers every control for anyone
 * using assistive tech, and the shorthand bar exists for keyboard players.
 */
#touch {
  display: none;
}

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

  #touch {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    touch-action: none;
  }

  .tc-row {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 0.9rem;
  }

  .tc-row[hidden] {
    display: none;
  }

  /* #hud's exit links sit in the same bottom-left corner of the viewport;
     .tc-main must clear its full height (padding + text, which can wrap
     to two lines on a narrow phone) or the restart button sits on top of
     the Sound/Pause links and steals their taps. */
  .tc-main {
    bottom: 4rem;
  }

  .tc-help {
    top: 1rem;
    justify-content: flex-end;
    gap: 0.5rem;
    pointer-events: none;
  }

  .tc-help .tc-btn {
    pointer-events: auto;
  }

  .tc-upper {
    bottom: 8.7rem;
  }

  .tc-cluster {
    display: flex;
    gap: 0.6rem;
    pointer-events: auto;
  }

  .tc-cluster-mid {
    align-self: center;
    gap: 0.5rem;
  }

  .tc-forms {
    bottom: 13.4rem;
    justify-content: center;
    gap: 0.5rem;
  }

  .tc-btn {
    width: 3.4rem;
    height: 3.4rem;
    display: grid;
    place-content: center;
    font: inherit;
    font-size: 1.3rem;
    line-height: 1;
    color: var(--ink);
    background: rgba(242, 239, 232, 0.06);
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
    transition: background 100ms ease, border-color 100ms ease;
  }

  .tc-btn.active {
    background: rgba(242, 239, 232, 0.18);
    border-color: var(--ink);
  }

  .tc-btn.tc-small {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1rem;
    opacity: 0.85;
  }

  .tc-btn[hidden] {
    display: none;
  }
}

@media (pointer: coarse) and (prefers-reduced-motion: reduce) {
  .tc-btn {
    transition: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  #exits a,
  #exits button {
    transition: none;
  }
}
