/* ---------- About: the handheld. A 3D console on the left that leans after the cursor; Stac plays on its screen. ---------- */
.hh__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(28px, 5vw, 72px);
}

.hh__stage {
  position: relative;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  outline: none;
}

.hh__stage:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 6px;
  border-radius: 24px;
}

.hh__gl {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.6s var(--ease);
}

/* The rendered still: shown before the 3D arrives, and kept on devices that can't draw it */
.hh__still {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  height: 75%;
  aspect-ratio: 640 / 800;
  transform: translate(-50%, -52%) perspective(900px) rotateX(var(--still-rx, 0deg)) rotateY(var(--still-ry, 0deg));
  transform-style: preserve-3d;
  transition: opacity 0.6s var(--ease);
}

/* Thickness for the still: darker copies of its outline stacked behind it, so its sides show as it turns */
.hh__depth {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  pointer-events: none;
}

.hh__depth img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: translateZ(calc(var(--z) * -1px));
  filter: brightness(var(--b)) saturate(0.85);
}

.hh__still > img,
.hh__screen {
  transform: translateZ(0.5px);
}

.hh__still img {
  display: block;
  width: 100%;
  height: 100%;
}

.hh__screen {
  position: absolute;
  left: 15.03%;
  top: 12.86%;
  width: 69.94%;
  height: 38.57%;
  overflow: hidden;
  border-radius: 2%;
}

.hh__screen canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hh__stage.is-3d .hh__gl { opacity: 1; }
.hh__stage.is-3d .hh__still { opacity: 0; }

/* A soft shadow on the page that slides as the console leans */
.hh__shadow {
  position: absolute;
  left: 50%;
  bottom: 9%;
  width: 46%;
  height: 7%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(20, 33, 61, 0.28), rgba(20, 33, 61, 0));
  transform: translate(calc(-50% + var(--tilt-x, 0px) * -1), var(--tilt-y, 0px));
  filter: blur(6px);
}

.hh__hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.hh__hint b {
  color: var(--ink);
  font-weight: 600;
}

@media (max-width: 899px) {
  .hh__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .hh__stage { max-width: 440px; }
}

.hh__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hh__full {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hh__full svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Full screen: the game drawn large over a dimmed page ---------- */
html.hh-full-open,
html.hh-full-open body {
  overflow: hidden;
}

.hh-full {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 12px;
  background: rgba(8, 13, 30, 0.86);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  opacity: 0;
  transition: opacity 0.35s var(--ease);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.hh-full.is-open { opacity: 1; }

.hh-full__frame {
  overflow: hidden;
  border-radius: 18px;
  box-shadow: 0 0 0 1px rgba(244, 237, 224, 0.12), 0 40px 90px -20px rgba(0, 0, 0, 0.7);
  transform: scale(0.96);
  transition: transform 0.5s var(--ease);
}

.hh-full.is-open .hh-full__frame { transform: none; }

.hh-full__frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hh-full__close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(244, 237, 224, 0.14);
  color: #f4ede0;
  cursor: pointer;
}

.hh-full__close:hover { background: rgba(244, 237, 224, 0.24); }

.hh-full__close svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.hh-full__close:focus-visible {
  outline: 2px solid #f4ede0;
  outline-offset: 3px;
}

.hh-full__hint {
  margin: 0;
  color: rgba(244, 237, 224, 0.7);
  font-size: 14px;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .hh-full,
  .hh-full__frame { transition: none; }
}

/* ---------- Play full screen: a navy button that stands apart ---------- */
.ed-btn-pair .ed-btn.hh__full {
  color: #f4ede0;
  background: #14213d;
}

.ed-btn-pair:hover .ed-btn.hh__full,
.ed-btn-pair .ed-btn.hh__full:focus-visible {
  background: #294073;
}

/* On stacked layouts the same button sits above the console and fades in as the game comes into view */
.hh__full-top {
  display: none;
}

@media (max-width: 899px) {
  .hh__full-pair { display: none; }

  .hh__full-top {
    display: inline-flex;
    align-items: center;
    justify-self: center;
    gap: 8px;
    height: 44px;
    margin: 0 0 4px;
    padding: 0 20px;
    border: 0;
    border-radius: 999px;
    color: #f4ede0;
    background: #14213d;
    box-shadow: 0 12px 26px -12px rgba(20, 33, 61, 0.55);
    font: 600 16px/1 var(--sans);
    letter-spacing: -0.02em;
    cursor: pointer;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s var(--ease), transform 0.7s var(--ease), background 0.2s ease;
  }

  .hh__full-top svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .hh__full-top:active { background: #294073; }

  .hh__full-top:focus-visible {
    outline: 2px solid #14213d;
    outline-offset: 3px;
  }

  #play.is-in .hh__full-top {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hh__full-top { transform: none; transition: opacity 0.2s linear; }
}
