:root {
  --game-black: #030302;
  --game-tan: #d8bd8a;
  --game-gold: #ffe3a6;
  --game-paper: #efe3ca;
}

.page-thinking-game {
  background: var(--game-black);
  overflow: hidden;
}

.thinking-game-shell {
  position: relative;
  height: calc(100svh - 70px);
  min-height: 520px;
  overflow: hidden;
  isolation: isolate;
  background: var(--game-black);
}

.thinking-game-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  background: var(--game-black);
  cursor: default;
}

.thinking-game-shell::before,
.thinking-game-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.thinking-game-shell::before {
  background:
    radial-gradient(circle at 50% 46%, rgba(216, 189, 138, .07), transparent 34%),
    linear-gradient(90deg, rgba(3, 3, 2, .58), transparent 28%, transparent 72%, rgba(3, 3, 2, .48));
}

.thinking-game-shell::after {
  background:
    linear-gradient(rgba(216, 189, 138, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(216, 189, 138, .018) 1px, transparent 1px);
  background-size: 74px 74px;
  opacity: .46;
}

.game-entry,
.game-hud,
.game-crosshair,
.game-instructions,
.game-proximity,
.game-repo-cta,
.game-mobile-controls,
.game-inspector,
.game-fallback {
  position: absolute;
  z-index: 5;
}

.game-entry {
  left: clamp(1rem, 5vw, 4rem);
  top: 50%;
  width: min(680px, calc(100% - 2rem));
  transform: translateY(-50%);
  padding: clamp(1.4rem, 3vw, 2.2rem);
  border-left: 1px solid rgba(216, 189, 138, .44);
  background: linear-gradient(90deg, rgba(3, 3, 2, .92), rgba(3, 3, 2, .58), transparent);
  transition: opacity .2s ease, visibility .2s ease;
}

.thinking-game-shell.is-started .game-entry {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.game-kicker {
  margin: 0 0 .75rem;
  color: var(--game-gold);
  font-family: "Space Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .72rem;
  text-transform: uppercase;
}

.game-entry h1 {
  max-width: 10ch;
  margin-bottom: 1rem;
  color: var(--cream);
  font-size: clamp(3rem, 7vw, 7rem);
  line-height: .9;
}

.game-entry p:not(.game-kicker):not(.game-control-note) {
  max-width: 48rem;
  color: rgba(239, 227, 202, .82);
  font-size: clamp(1.05rem, 1.45vw, 1.25rem);
  line-height: 1.55;
}

.game-entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem;
  margin-top: 1.2rem;
}

.game-control-note {
  max-width: 42rem;
  margin: 1rem 0 0;
  color: rgba(239, 227, 202, .62);
  font-family: "Space Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .72rem;
  line-height: 1.5;
}

.game-instructions {
  left: 50%;
  bottom: 2rem;
  width: min(560px, calc(100% - 2rem));
  transform: translateX(-50%);
  padding: .9rem 1rem;
  border: 1px solid rgba(216, 189, 138, .34);
  background: rgba(3, 3, 2, .82);
  text-align: center;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .46);
  pointer-events: none;
  transition: opacity .35s ease, visibility .35s ease, transform .35s ease;
}

.game-instructions p {
  margin: 0;
  color: rgba(239, 227, 202, .84);
}

.game-instructions p:not(.game-kicker) {
  font-size: clamp(.95rem, 1.15vw, 1.08rem);
  line-height: 1.45;
}

.game-instructions b {
  color: var(--game-gold);
}

.thinking-game-shell.has-dismissed-instructions .game-instructions {
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, .75rem);
}

.game-hud {
  left: max(1rem, calc((100vw - var(--max)) / 2));
  right: max(1rem, calc((100vw - var(--max)) / 2));
  top: 1rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  color: rgba(239, 227, 202, .72);
  font-family: "Space Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .68rem;
  text-transform: uppercase;
}

.game-hud-line {
  height: 1px;
  background: linear-gradient(90deg, rgba(216, 189, 138, .56), rgba(216, 189, 138, .08));
}

.game-crosshair {
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  display: none;
  place-items: center;
  opacity: .72;
  pointer-events: none;
}

.game-proximity {
  left: 50%;
  top: 51%;
  width: min(940px, calc(100% - 2rem));
  transform: translate(-50%, -50%) scale(.96);
  padding: clamp(1.2rem, 3.4vw, 2.6rem);
  border: 1px solid rgba(216, 189, 138, .34);
  background:
    radial-gradient(circle at 50% 0%, rgba(216, 189, 138, .12), transparent 46%),
    rgba(3, 3, 2, .76);
  text-align: center;
  box-shadow: 0 28px 100px rgba(0, 0, 0, .64);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .22s ease, visibility .22s ease, transform .22s ease;
}

.game-proximity.is-open {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.game-proximity h2 {
  max-width: 12ch;
  margin: 0 auto 1rem;
  color: var(--cream);
  font-size: clamp(3.1rem, 7vw, 7.6rem);
  line-height: .88;
}

.game-proximity p:not(.game-kicker) {
  max-width: 760px;
  margin: 0 auto;
  color: rgba(239, 227, 202, .88);
  font-size: clamp(1.15rem, 1.7vw, 1.55rem);
  line-height: 1.48;
}

.game-repo-cta {
  top: 4.25rem;
  right: clamp(1rem, 3vw, 2.5rem);
  display: inline-grid;
  place-items: center;
  min-height: 46px;
  padding: .75rem 1rem;
  border: 1px solid rgba(255, 227, 166, .54);
  background: rgba(3, 3, 2, .84);
  color: var(--game-gold);
  font-size: .78rem;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s ease, visibility .2s ease;
}

.game-repo-cta.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.game-crosshair span,
.game-crosshair::before,
.game-crosshair::after {
  position: absolute;
  content: "";
  background: rgba(255, 227, 166, .74);
}

.game-crosshair span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(216, 189, 138, .62);
}

.game-crosshair::before {
  width: 34px;
  height: 1px;
}

.game-crosshair::after {
  width: 1px;
  height: 34px;
}

.game-inspector {
  right: clamp(1rem, 3vw, 2.5rem);
  top: clamp(1rem, 7vw, 4rem);
  width: min(430px, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  overflow: auto;
  padding: 1.1rem;
  border: 1px solid rgba(216, 189, 138, .34);
  background: rgba(4, 3, 2, .92);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .66);
  transform: translateX(calc(100% + 3rem));
  transition: transform .22s var(--ease);
}

.game-inspector.is-open {
  transform: translateX(0);
}

.game-inspector h2 {
  max-width: 11ch;
  margin-bottom: .8rem;
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.game-inspector p:not(.game-kicker) {
  color: rgba(239, 227, 202, .82);
  line-height: 1.55;
}

.game-inspector-close {
  float: right;
  min-height: 38px;
  padding: .45rem .65rem;
  border: 1px solid rgba(216, 189, 138, .32);
  background: transparent;
  color: var(--game-paper);
  font-size: .72rem;
  font-weight: 800;
  cursor: pointer;
}

.game-mobile-controls {
  display: none;
}

.game-fallback {
  inset: 1rem;
  display: grid;
  place-content: center;
  gap: 1rem;
  padding: 2rem;
  background: rgba(3, 3, 2, .94);
  text-align: center;
}

.game-fallback[hidden] {
  display: none;
}

@media (max-width: 820px), (pointer: coarse) {
  .page-thinking-game {
    overflow: auto;
  }

  .thinking-game-shell {
    min-height: calc(100svh - 70px);
  }

  .thinking-game-shell::before {
    background:
      radial-gradient(circle at 54% 44%, rgba(216, 189, 138, .07), transparent 34%),
      linear-gradient(90deg, rgba(3, 3, 2, .72), transparent 62%, rgba(3, 3, 2, .42));
  }

  .game-entry {
    left: 1rem;
    right: 1rem;
    top: auto;
    bottom: 5.5rem;
    width: auto;
    transform: none;
    padding: 1rem;
  }

  .game-entry h1 {
    font-size: clamp(2.45rem, 12vw, 3.65rem);
  }

  .game-entry-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .game-entry-actions .btn {
    width: 100%;
  }

  .game-control-note,
  .game-crosshair,
  .game-instructions,
  .game-proximity,
  .game-repo-cta {
    display: none;
  }

  .game-hud {
    grid-template-columns: 1fr;
    gap: .35rem;
    top: .85rem;
  }

  .game-hud-line {
    display: none;
  }

  .game-mobile-controls {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: .55rem;
    align-items: center;
  }

  .game-mobile-controls button,
  .game-mobile-controls span {
    min-height: 44px;
    display: grid;
    place-items: center;
    padding: .55rem .7rem;
    border: 1px solid rgba(216, 189, 138, .34);
    background: rgba(3, 3, 2, .72);
    color: var(--game-paper);
    font: 800 .72rem/1 "Space Grotesk", sans-serif;
  }

  .game-mobile-controls .primary {
    grid-column: 1 / -1;
    color: #181009;
    border-color: var(--game-gold);
    background: var(--game-tan);
  }

  .game-inspector {
    left: 1rem;
    right: 1rem;
    top: auto;
    bottom: 1rem;
    width: auto;
    max-height: min(72svh, 560px);
    transform: translateY(calc(100% + 2rem));
  }

  .game-inspector.is-open {
    transform: translateY(0);
  }
}
