@font-face {
  font-family: "Grapiso";
  src: url("assets/Grapiso.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Acumin";
  src: url("assets/Acumin Pro Condensed XTL.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --black: #111211;
  --black-deep: #080a09;
  --white: #f6f6f1;
  --mint: #c8e3cf;
  --sage: #a8b59a;
  --line: rgba(246, 246, 241, 0.2);
}

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

html,
body {
  width: 100%;
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--white);
  background:
    radial-gradient(
      circle at 76% 8%,
      rgba(200, 227, 207, 0.22) 0%,
      rgba(168, 181, 154, 0.11) 26%,
      transparent 52%
    ),
    radial-gradient(
      circle at 12% 94%,
      rgba(88, 103, 90, 0.2) 0%,
      transparent 45%
    ),
    linear-gradient(145deg, #0d100e 0%, #111512 45%, #070908 100%);
  font-family: "Acumin", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

a {
  text-decoration: none;
}

.game-page {
  position: relative;
  display: grid;
  width: 100vw;
  min-height: 100svh;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

.game-frame {
  container-type: inline-size;
  position: relative;
  width: min(390px, calc((100svh - 32px) * 9 / 16), calc(100vw - 32px));
  aspect-ratio: 9 / 16;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(
      circle at 93% -2%,
      rgba(236, 247, 238, 0.74) 0%,
      rgba(200, 227, 207, 0.5) 9%,
      rgba(168, 181, 154, 0.24) 25%,
      transparent 47%
    ),
    radial-gradient(
      circle at -10% 103%,
      rgba(168, 181, 154, 0.32) 0%,
      rgba(168, 181, 154, 0.1) 28%,
      transparent 50%
    ),
    var(--black);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.2);
}

.game-frame::after {
  position: absolute;
  z-index: 8;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  content: "";
  pointer-events: none;
}

.game-glow {
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  filter: blur(30px);
  opacity: 0.25;
  pointer-events: none;
}

.game-glow-top {
  top: -5%;
  right: -12%;
  width: 60%;
  aspect-ratio: 1;
  background: var(--mint);
}

.game-glow-bottom {
  bottom: -12%;
  left: -24%;
  width: 70%;
  aspect-ratio: 1;
  background: var(--sage);
}

.game-ui {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding:
    max(14px, env(safe-area-inset-top))
    5.2cqw
    max(10px, env(safe-area-inset-bottom));
}

.game-header {
  display: flex;
  min-height: 7cqw;
  align-items: center;
  justify-content: space-between;
}

.game-logo {
  width: 22cqw;
  max-width: 90px;
}

.game-logo img {
  display: block;
  width: 100%;
  filter: invert(1);
}

.game-exit {
  display: flex;
  align-items: center;
  gap: 1.8cqw;
  font-size: 3.2cqw;
  letter-spacing: 0.12em;
}

.game-meta {
  display: flex;
  align-items: center;
  gap: 1.6cqw;
  margin-top: 3.5cqw;
  color: rgba(246, 246, 241, 0.65);
  font-size: 2.65cqw;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.game-title {
  display: flex;
  flex-direction: column;
  margin-top: 3.4cqw;
  font-family: "Grapiso", Impact, sans-serif;
  font-size: 11.8cqw;
  font-weight: 400;
  line-height: 0.76;
  letter-spacing: -0.045em;
  text-transform: uppercase;
}

.game-title span:last-child {
  align-self: flex-end;
}

.game-hud {
  display: grid;
  grid-template-columns: 1.3fr 1.1fr 0.55fr 0.7fr;
  align-items: center;
  margin-top: 3.4cqw;
  color: var(--sage);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 2.8cqw;
  letter-spacing: 0.02em;
}

.game-hud span:nth-child(n + 2) {
  text-align: right;
}

.game-hud strong {
  color: var(--white);
  font-weight: 600;
}

.maze-wrap {
  position: relative;
  width: 96%;
  aspect-ratio: 1;
  align-self: center;
  flex: 0 0 auto;
  margin-top: 2.7cqw;
  overflow: hidden;
  border-top: 1px solid rgba(200, 227, 207, 0.16);
  border-bottom: 1px solid rgba(200, 227, 207, 0.12);
  background: rgba(5, 7, 6, 0.3);
  touch-action: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.game-overlay {
  position: absolute;
  display: flex;
  inset: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 8cqw;
  background: rgba(8, 10, 9, 0.88);
  backdrop-filter: blur(7px);
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.game-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.overlay-kicker {
  color: var(--sage);
  font-size: 2.8cqw;
  letter-spacing: 0.14em;
}

.game-overlay h2 {
  margin-top: 3.2cqw;
  font-family: "Grapiso", Impact, sans-serif;
  font-size: 9.6cqw;
  font-weight: 400;
  line-height: 0.8;
  letter-spacing: -0.04em;
}

.game-overlay p:not(.overlay-kicker) {
  margin-top: 4.4cqw;
  color: rgba(246, 246, 241, 0.72);
  font-size: 3.5cqw;
  line-height: 1.12;
}

.game-overlay button {
  min-width: 28cqw;
  margin-top: 5cqw;
  padding: 3.2cqw 5cqw 2.8cqw;
  cursor: pointer;
  background: var(--mint);
  color: var(--black);
  font-size: 3.4cqw;
  letter-spacing: 0.12em;
}

.game-controls {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: center;
  margin-top: 2.2cqw;
}

.control-copy {
  display: flex;
  justify-content: space-between;
  color: rgba(246, 246, 241, 0.46);
  font-size: 2.3cqw;
  letter-spacing: 0.12em;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 10.5cqw);
  grid-template-rows: repeat(2, 8.3cqw);
  gap: 0.9cqw;
}

.dpad-button,
.secondary-controls button {
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(200, 227, 207, 0.42);
  background: rgba(200, 227, 207, 0.08);
  color: var(--white);
  touch-action: manipulation;
}

.dpad-button {
  font-family: Arial, sans-serif;
  font-size: 5cqw;
  line-height: 1;
}

.dpad-button:active,
.dpad-button.is-active,
.secondary-controls button:active {
  background: var(--mint);
  color: var(--black);
}

.dpad-up {
  grid-column: 2;
  grid-row: 1;
}

.dpad-left {
  grid-column: 1;
  grid-row: 2;
}

.dpad-down {
  grid-column: 2;
  grid-row: 2;
}

.dpad-right {
  grid-column: 3;
  grid-row: 2;
}

.secondary-controls {
  display: flex;
  width: 27cqw;
  flex-direction: column;
  gap: 0.9cqw;
}

.secondary-controls button {
  min-height: 8.3cqw;
  padding: 0 2cqw;
  font-size: 2.8cqw;
  letter-spacing: 0.08em;
}

.game-footer {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 1.3cqw;
  border-top: 1px solid var(--line);
  color: rgba(246, 246, 241, 0.56);
  font-size: 2.65cqw;
  line-height: 1;
}

.game-status {
  display: flex;
  align-items: center;
  gap: 1.6cqw;
  letter-spacing: 0.1em;
}

.game-status i {
  width: 1.7cqw;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 12px rgba(200, 227, 207, 0.65);
}

.instagram-cta {
  position: relative;
  display: grid;
  min-height: 82svh;
  place-items: center;
  padding: clamp(72px, 9vw, 132px) clamp(24px, 6vw, 88px);
  overflow: hidden;
  background: var(--mint);
  color: var(--black);
}

.instagram-cta::after {
  position: absolute;
  right: -0.08em;
  bottom: -0.4em;
  color: rgba(17, 18, 17, 0.055);
  content: "@";
  font-family: "Grapiso", Impact, sans-serif;
  font-size: min(64vw, 820px);
  line-height: 1;
  pointer-events: none;
}

.instagram-cta__inner {
  position: relative;
  z-index: 1;
  width: min(100%, 1180px);
}

.instagram-cta__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(17, 18, 17, 0.28);
  font-size: clamp(12px, 1.15vw, 16px);
  letter-spacing: 0.12em;
}

.instagram-cta h2 {
  max-width: 1100px;
  margin-top: clamp(48px, 7vw, 92px);
  font-family: "Grapiso", Impact, sans-serif;
  font-size: clamp(64px, 10vw, 148px);
  font-weight: 400;
  line-height: 0.76;
  letter-spacing: -0.045em;
  text-transform: uppercase;
}

.instagram-cta__line {
  display: block;
}

.instagram-cta__line--bottom {
  margin-left: 0.42em;
  margin-top: 0.18em;
  font-size: 0.72em;
}

.instagram-cta__bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 48px;
  margin-top: clamp(54px, 8vw, 104px);
}

.instagram-cta__bottom p {
  max-width: 330px;
  font-size: clamp(18px, 1.65vw, 24px);
  line-height: 1.05;
}

.instagram-button {
  display: flex;
  width: min(100%, 430px);
  min-height: 72px;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  border: 1px solid var(--black);
  background: var(--black);
  color: var(--white);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(14px, 1.25vw, 18px);
  letter-spacing: 0.03em;
  transition: transform 180ms ease, background-color 180ms ease;
}

.instagram-button svg {
  width: 30px;
  flex: 0 0 auto;
}

.instagram-button__arrow {
  margin-left: auto;
  font-family: "Acumin", Arial, sans-serif;
  font-size: 24px;
}

.instagram-button:hover,
.instagram-button:focus-visible {
  background: #20251f;
  transform: translateY(-3px);
}

@media (max-width: 760px) {
  body {
    background: var(--black);
  }

  .game-page {
    min-height: 100dvh;
    padding: 0;
    background:
      radial-gradient(circle at 95% 0%, rgba(200, 227, 207, 0.2), transparent 42%),
      var(--black);
  }

  .game-frame {
    width: min(100vw, calc(100dvh * 9 / 16));
    max-width: none;
    box-shadow: none;
  }

  .game-frame::after {
    display: none;
  }

  .game-ui {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .instagram-cta {
    min-height: 100svh;
    padding: 72px 20px 38px;
  }

  .instagram-cta::after {
    right: -0.2em;
    bottom: -0.12em;
    font-size: 112vw;
  }

  .instagram-cta__meta span:last-child {
    display: none;
  }

  .instagram-cta h2 {
    margin-top: 64px;
    font-size: clamp(58px, 17.5vw, 84px);
  }

  .instagram-cta__line--bottom {
    margin-left: 0;
    font-size: 0.78em;
  }

  .instagram-cta__bottom {
    align-items: stretch;
    flex-direction: column;
    gap: 34px;
    margin-top: 62px;
  }

  .instagram-cta__bottom p {
    max-width: 270px;
  }

  .instagram-button {
    width: 100%;
    min-height: 68px;
  }
}

@media (max-height: 650px) and (orientation: landscape) {
  .game-frame {
    width: calc((100dvh - 12px) * 9 / 16);
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-overlay {
    transition: none;
  }
}
