:root {
  --room-aspect: 965 / 1630;
  --parchment: #f1e5cf;
  --parchment-deep: #dbc7a5;
  --cyan: #79e8ff;
  --cyan-white: #edfdff;
  --stage-width: min(
    calc(100vw - 16px),
    calc((100dvh - 120px) * 965 / 1630),
    480px
  );
}

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

body {
  min-height: 100dvh;
  overflow: hidden;
  background: #08070b;
}

.wallpaper {
  inset: -44px;
  opacity: 0.48;
  background:
    linear-gradient(rgb(5 4 8 / 42%), rgb(5 4 8 / 82%)),
    url("./assets/hotel-room-v2.webp") center 48% / cover no-repeat;
  filter: blur(26px) saturate(0.72);
  mask-image: none;
  transform: scale(1.08);
}

.intro,
.side-note,
footer {
  display: none;
}

.site-shell {
  width: 100%;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
}

.game-frame {
  position: relative;
  width: min(100%, 510px);
  min-height: 100dvh;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  color: #161019;
  background:
    linear-gradient(90deg, rgb(89 56 31 / 8%), transparent 9%, transparent 91%, rgb(89 56 31 / 8%)),
    var(--parchment);
  box-shadow:
    0 30px 100px rgb(0 0 0 / 78%),
    inset 0 0 0 1px rgb(65 39 20 / 30%);
}

.game-frame::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  opacity: 0.17;
  background-image:
    radial-gradient(circle at 16% 19%, #8f6a3e 0 0.5px, transparent 0.7px),
    radial-gradient(circle at 72% 61%, #8f6a3e 0 0.45px, transparent 0.65px);
  background-size: 10px 13px, 14px 17px;
  mix-blend-mode: multiply;
}

.game-header {
  position: absolute;
  z-index: 24;
  top: 14px;
  left: 50%;
  width: calc(100% - 28px);
  min-height: 0;
  margin: 0;
  display: block;
  transform: translateX(-50%);
  pointer-events: none;
}

.status-pills {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-pill {
  min-width: 76px;
  height: 38px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 999px;
  color: #f7f5ef;
  background: rgb(6 7 12 / 86%);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 10%),
    0 3px 0 rgb(0 0 0 / 48%),
    0 8px 18px rgb(0 0 0 / 35%);
  backdrop-filter: blur(8px);
}

.status-pill strong {
  font-family: "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.025em;
}

.mini-ghost {
  position: relative;
  width: 20px;
  height: 23px;
  flex: 0 0 auto;
  clip-path: polygon(50% 0, 72% 6%, 90% 22%, 100% 46%, 100% 100%, 75% 79%, 55% 100%, 35% 80%, 10% 100%, 0 46%, 10% 22%, 28% 6%);
  background:
    radial-gradient(circle at 35% 43%, #20334e 0 8%, transparent 9%),
    radial-gradient(circle at 65% 43%, #20334e 0 8%, transparent 9%),
    linear-gradient(#f4feff, #90dcf6);
  filter: drop-shadow(0 0 6px rgb(121 232 255 / 86%));
}

.light-pill {
  min-width: 76px;
  color: #fff3be;
  border-color: rgb(255 221 118 / 24%);
}

.light-pill.is-dark {
  color: #e3d5ff;
  border-color: rgb(167 123 255 / 28%);
  background: rgb(10 8 25 / 88%);
}

.mini-bulb {
  position: relative;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 2px solid #fff3b2;
  border-radius: 50%;
  background: #ffd84e;
  box-shadow: 0 0 9px #ffc43d, 0 0 16px rgb(255 196 61 / 60%);
}

.mini-bulb::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 13px;
  width: 7px;
  height: 6px;
  border-radius: 1px 1px 4px 4px;
  background: #c9982d;
  box-shadow: inset 0 -2px 0 #79561d;
  transform: translateX(-50%);
}

.light-pill.is-dark .mini-bulb {
  border-color: #cdbdff;
  background: #6c57a5;
  box-shadow: 0 0 8px rgb(176 139 255 / 55%);
}

.board-wrap {
  position: relative;
  z-index: 2;
  width: var(--stage-width);
  aspect-ratio: var(--room-aspect);
  flex: 0 0 auto;
  margin: 0;
  padding: 5px;
  isolation: isolate;
  overflow: hidden;
  border: 2px solid #07070b;
  border-radius: 23px;
  background: #07070b;
  box-shadow:
    inset 0 0 0 2px #3a2a21,
    0 2px 0 #8e704b,
    0 8px 20px rgb(25 12 7 / 42%);
}

.board-wrap::before {
  content: "";
  position: absolute;
  z-index: 10;
  inset: 3px;
  pointer-events: none;
  border: 1px solid rgb(208 170 106 / 25%);
  border-radius: 17px;
  box-shadow: inset 0 0 0 2px rgb(0 0 0 / 52%);
}

.board {
  --cols: 5;
  --rows: 6;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  display: block;
  overflow: hidden;
  border-radius: 17px;
  background: #13101b url("./assets/hotel-room-v2.webp") center / 100% 100% no-repeat;
  box-shadow: none;
  filter: none;
  transition: none;
}

.board::before,
.board::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.board::before {
  z-index: 2;
  opacity: 0.34;
  background:
    radial-gradient(circle at 17% 27%, rgb(255 191 76 / 34%), transparent 10%),
    radial-gradient(circle at 87% 55%, rgb(255 191 76 / 30%), transparent 11%),
    radial-gradient(circle at 13% 50%, rgb(255 191 76 / 24%), transparent 9%),
    linear-gradient(rgb(255 213 134 / 3%), rgb(255 169 61 / 2%));
  mix-blend-mode: screen;
  transition: opacity 360ms ease, background 360ms ease;
}

.board::after {
  z-index: 7;
  opacity: 1;
  background:
    linear-gradient(180deg, rgb(1 2 10 / 12%), transparent 20%, transparent 76%, rgb(1 1 6 / 17%)),
    radial-gradient(ellipse at center, transparent 54%, rgb(0 0 5 / 30%) 100%);
  mix-blend-mode: normal;
}

.board.light-off {
  background: #0e1020 url("./assets/hotel-room-v2.webp") center / 100% 100% no-repeat;
  filter: none;
  box-shadow: none;
}

.board.light-off::before {
  opacity: 1;
  background:
    radial-gradient(circle at 50% 54%, rgb(63 47 112 / 12%), transparent 46%),
    linear-gradient(rgb(12 10 42 / 46%), rgb(7 8 31 / 54%));
  mix-blend-mode: normal;
}

.playfield {
  position: absolute;
  z-index: 4;
  left: 8.5%;
  right: 8.5%;
  top: 19%;
  bottom: 10.5%;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  overflow: visible;
  pointer-events: none;
}

.floor-tile {
  position: relative;
  z-index: 0;
  min-width: 0;
  border: 0;
  background: transparent;
  pointer-events: none;
}

.floor-tile.alt,
.floor-tile::before {
  border: 0;
  background: transparent;
}

.floor-tile.path-preview::after {
  content: "";
  position: absolute;
  inset: 38%;
  min-width: 5px;
  min-height: 5px;
  border: 1px solid #e8fdff;
  border-radius: 50%;
  background: #8cedff;
  box-shadow: 0 0 7px 2px rgb(106 226 255 / 72%);
  animation: path-fade 650ms ease both;
}

.exit-label {
  display: none;
}

.edge-portal {
  --impact: 50%;
  position: absolute;
  z-index: 13;
  display: block;
  opacity: 0.42;
  pointer-events: none;
  filter: drop-shadow(0 0 3px rgb(94 222 255 / 34%));
  transition: opacity 160ms ease, filter 160ms ease;
  animation: portal-breathe 5.4s ease-in-out infinite;
}

.portal-north,
.portal-south {
  left: 7%;
  right: 7%;
  height: 18px;
}

.portal-north {
  top: 3px;
  animation-delay: -4.1s;
}

.portal-south {
  bottom: 3px;
  animation-delay: -1.4s;
}

.portal-east,
.portal-west {
  top: 7%;
  bottom: 7%;
  width: 18px;
}

.portal-east {
  right: 3px;
  animation-delay: -2.7s;
}

.portal-west {
  left: 3px;
}

.portal-frame,
.portal-core,
.portal-rune {
  position: absolute;
  display: block;
  pointer-events: none;
}

.portal-north .portal-frame,
.portal-south .portal-frame {
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgb(102 220 255 / 18%) 16%, rgb(206 249 255 / 58%) 50%, rgb(102 220 255 / 18%) 84%, transparent);
  box-shadow: 0 0 5px rgb(83 211 255 / 35%);
  transform: translateY(-50%);
}

.portal-east .portal-frame,
.portal-west .portal-frame {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, transparent, rgb(102 220 255 / 18%) 16%, rgb(206 249 255 / 58%) 50%, rgb(102 220 255 / 18%) 84%, transparent);
  box-shadow: 0 0 5px rgb(83 211 255 / 35%);
  transform: translateX(-50%);
}

.portal-north .portal-core,
.portal-south .portal-core {
  left: var(--impact);
  top: 50%;
  width: clamp(38px, 15%, 64px);
  height: 13px;
  border: 1px solid rgb(202 246 255 / 42%);
  border-radius: 50%;
  opacity: 0;
  background: radial-gradient(ellipse, rgb(224 253 255 / 96%), rgb(66 206 255 / 45%) 35%, transparent 72%);
  box-shadow: 0 0 8px rgb(96 224 255 / 65%);
  transform: translate(-50%, -50%) scaleX(0.3);
}

.portal-east .portal-core,
.portal-west .portal-core {
  left: 50%;
  top: var(--impact);
  width: 13px;
  height: clamp(38px, 15%, 64px);
  border: 1px solid rgb(202 246 255 / 42%);
  border-radius: 50%;
  opacity: 0;
  background: radial-gradient(ellipse, rgb(224 253 255 / 96%), rgb(66 206 255 / 45%) 35%, transparent 72%);
  box-shadow: 0 0 8px rgb(96 224 255 / 65%);
  transform: translate(-50%, -50%) scaleY(0.3);
}

.portal-north .portal-rune,
.portal-south .portal-rune {
  left: var(--impact);
  top: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
}

.portal-east .portal-rune,
.portal-west .portal-rune {
  left: 50%;
  top: var(--impact);
  transform: translate(-50%, -50%) rotate(45deg);
}

.portal-rune {
  width: 8px;
  height: 8px;
  opacity: 0.88;
  border: 1px solid #dffcff;
  border-radius: 2px;
  box-shadow: 0 0 4px #fff, 0 0 9px #50d9ff;
}

.portal-opening .edge-portal:not(.is-active) {
  opacity: 0.14;
  animation: none;
}

.edge-portal.is-active {
  z-index: 15;
  opacity: 1;
  filter: drop-shadow(0 0 6px #b9f6ff) drop-shadow(0 0 14px rgb(63 207 255 / 86%));
  animation: portal-receive 620ms ease-out both;
}

.edge-portal.is-active .portal-frame {
  background: #dffcff;
  box-shadow: 0 0 5px #fff, 0 0 12px #58ddff, 0 0 24px rgb(62 177 255 / 70%);
}

.portal-north.is-active .portal-core,
.portal-south.is-active .portal-core {
  animation: portal-core-open-x 620ms cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.portal-east.is-active .portal-core,
.portal-west.is-active .portal-core {
  animation: portal-core-open-y 620ms cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.edge-portal.is-active .portal-rune {
  animation: portal-rune-flash 620ms ease-out both;
}

.board-vignette {
  position: absolute;
  z-index: 9;
  inset: 5px;
  border-radius: 17px;
  pointer-events: none;
  box-shadow:
    inset 0 0 38px rgb(0 0 4 / 35%),
    inset 0 0 0 1px rgb(255 227 176 / 9%);
}

.ghost {
  position: relative;
  z-index: 6;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  place-self: stretch;
  overflow: visible;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}

.ghost::after {
  content: "";
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 65%;
  width: 60%;
  height: 19%;
  border-radius: 50%;
  background: rgb(80 214 255 / 30%);
  filter: blur(8px);
  transform: translate(-50%, -50%);
}

.ghost-art {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 53%;
  width: min(88%, 68px);
  height: auto;
  overflow: visible;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 7px rgb(117 227 255 / 78%)) drop-shadow(0 8px 6px rgb(0 0 0 / 46%));
  animation: premium-ghost-float 2.25s ease-in-out infinite;
  transition: filter 150ms ease;
}

.ghost:nth-child(3n) .ghost-art {
  animation-delay: -0.72s;
}

.ghost-body {
  stroke: #e7fbff;
  stroke-width: 2.4;
  stroke-linejoin: round;
}

.ghost-highlight {
  fill: none;
  stroke: rgb(255 255 255 / 68%);
  stroke-width: 3;
  stroke-linecap: round;
}

.ghost-eye,
.ghost-mouth {
  fill: #263451;
}

.ghost-eye-glint {
  fill: #f8ffff;
}

.ghost-shadow {
  fill: rgb(5 8 19 / 50%);
  filter: blur(2px);
}

.ghost-glow {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 57%;
  width: 88%;
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0.42;
  background: #74dfff;
  filter: blur(11px);
  transform: translate(-50%, -50%);
  mix-blend-mode: screen;
}

.direction-arrow {
  position: absolute;
  z-index: 5;
  width: min(70%, 50px);
  height: auto;
  overflow: visible;
  filter:
    drop-shadow(0 0 3px #e8ffff)
    drop-shadow(0 0 7px rgb(64 213 255 / 95%))
    drop-shadow(0 3px 2px rgb(4 15 28 / 82%));
  animation: premium-arrow-pulse 1.65s ease-in-out infinite;
  pointer-events: none;
}

.arrow-under {
  fill: #f3feff;
  stroke: #172a42;
  stroke-width: 10;
  stroke-linejoin: round;
  paint-order: stroke fill;
}

.arrow-core {
  fill: #f7ffff;
  stroke: #6fe8ff;
  stroke-width: 4.2;
  stroke-linejoin: round;
}

.ghost[data-dir="N"] .direction-arrow {
  left: 50%;
  top: -9%;
  transform: translate(-50%, -50%);
}

.ghost[data-dir="S"] .direction-arrow {
  left: 50%;
  bottom: -9%;
  transform: translate(-50%, 50%) rotate(180deg);
}

.ghost[data-dir="E"] .direction-arrow {
  right: -13%;
  top: 50%;
  transform: translate(50%, -50%) rotate(90deg);
}

.ghost[data-dir="W"] .direction-arrow {
  left: -13%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
}

.lantern-mark {
  position: absolute;
  z-index: 7;
  right: 5%;
  top: 8%;
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  border: 2px solid #fff6c7;
  border-radius: 50%;
  color: #6d3b08;
  background: #ffd857;
  box-shadow: 0 0 5px #fff0a8, 0 0 13px #ffb62f, 0 2px 4px rgb(0 0 0 / 62%);
  font-size: 0.66rem;
  font-weight: 1000;
}

.board.dense .ghost-art {
  width: min(80%, 53px);
}

.board.dense .direction-arrow {
  width: min(62%, 38px);
}

.board.dense .lantern-mark {
  right: 1%;
  width: 17px;
  height: 17px;
  font-size: 0.55rem;
}

.ghost:hover .ghost-art,
.ghost:focus-visible .ghost-art {
  filter: drop-shadow(0 0 11px rgb(172 246 255 / 100%)) drop-shadow(0 9px 7px rgb(0 0 0 / 48%));
}

.ghost:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: -5px;
  border-radius: 22px;
}

.ghost.hinting .ghost-art,
.ghost.hinting .direction-arrow {
  animation: premium-hint 700ms ease-in-out 3;
}

.ghost.blocked {
  animation: ghost-shake 330ms ease;
}

.ghost.blocked .ghost-art {
  filter: drop-shadow(0 0 12px #ff607f) drop-shadow(0 8px 6px rgb(0 0 0 / 45%));
}

.ghost.blocker .ghost-art {
  animation: blocker-pulse 420ms ease 2;
}

.ghost.leaving.dir-N,
.ghost.leaving.dir-E,
.ghost.leaving.dir-S,
.ghost.leaving.dir-W {
  z-index: 12;
  pointer-events: none;
  transform-origin: center;
  will-change: transform, opacity, filter;
  animation: ghost-to-portal 620ms cubic-bezier(0.34, 0.03, 0.64, 1) forwards;
}

.ghost.leaving .ghost-art {
  animation: spirit-phase-out 620ms ease-in forwards;
}

.ghost.leaving .direction-arrow {
  animation: portal-arrow-out 220ms ease-out forwards;
}

.ghost.leaving .ghost-glow {
  animation: portal-trail-out 620ms ease-in forwards;
}

.ghost.leaving .lantern-mark {
  animation: portal-arrow-out 260ms ease-out forwards;
}

.barrier {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  border: 1px solid rgb(11 8 16 / 88%);
  border-radius: 999px;
  opacity: 0.2;
  background-clip: padding-box;
  filter: none;
  transition: opacity 300ms ease, box-shadow 300ms ease;
}

.barrier.vertical {
  width: 7px !important;
  transform: translateX(-50%);
}

.barrier.horizontal {
  height: 7px !important;
  transform: translateY(-50%);
}

.barrier.vertical.light {
  background: repeating-linear-gradient(0deg, #fff4b4 0 7px, #b87618 7px 11px);
}

.barrier.horizontal.light {
  background: repeating-linear-gradient(90deg, #fff4b4 0 7px, #b87618 7px 11px);
}

.barrier.vertical.dark {
  background: repeating-linear-gradient(0deg, #eadcff 0 7px, #733bb3 7px 11px);
}

.barrier.horizontal.dark {
  background: repeating-linear-gradient(90deg, #eadcff 0 7px, #733bb3 7px 11px);
}

.barrier.active {
  opacity: 1;
}

.barrier.light.active {
  box-shadow: 0 0 4px #fff7c5, 0 0 10px 3px rgb(255 183 49 / 86%);
}

.barrier.dark.active {
  box-shadow: 0 0 4px #f0e5ff, 0 0 10px 3px rgb(148 78 255 / 88%);
}

.coach {
  position: absolute;
  z-index: 14;
  left: 50%;
  bottom: 18px;
  width: min(calc(100% - 38px), 350px);
  min-height: 42px;
  margin: 0;
  padding: 7px 11px;
  display: grid;
  grid-template-columns: 25px 1fr;
  align-items: center;
  gap: 8px;
  border: 1px solid rgb(149 235 255 / 30%);
  border-radius: 14px;
  color: #e8f9fb;
  background: rgb(6 9 16 / 78%);
  box-shadow: 0 6px 18px rgb(0 0 0 / 45%), inset 0 1px 0 rgb(255 255 255 / 8%);
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
}

.coach-spark {
  width: 25px;
  height: 25px;
  border-radius: 8px;
  color: #dffbff;
  background: rgb(93 219 255 / 18%);
  font-size: 0.76rem;
}

.coach p {
  color: inherit;
  font-size: clamp(0.64rem, 2.3vw, 0.72rem);
  line-height: 1.25;
}

.coach.blocked-message {
  border-color: rgb(255 102 133 / 45%);
  color: #fff0f3;
  background: rgb(34 7 17 / 82%);
}

.game-identity {
  position: relative;
  z-index: 2;
  width: var(--stage-width);
  min-height: 59px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 4px 5px 1px;
}

.game-wordmark {
  color: #1d1718;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(1.55rem, 7vw, 2.25rem);
  line-height: 1;
  letter-spacing: 0.035em;
  text-shadow: 0 1px 0 #fff8e8;
}

.room-button {
  min-width: 0;
  max-width: 185px;
  padding: 4px 2px 4px 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 7px;
  border-left: 1px solid rgb(54 35 26 / 22%);
  color: #2d2221;
  text-align: right;
  background: transparent;
}

.room-number {
  color: #7b4d2f;
  font-size: 0.57rem;
  letter-spacing: 0.13em;
}

.room-button strong {
  max-width: 15ch;
  color: #261a1b;
  font-family: "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif;
  font-size: 0.72rem;
}

.room-button:hover strong {
  color: #4d2765;
}

.controls {
  position: relative;
  z-index: 2;
  width: var(--stage-width);
  min-height: 43px;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.control-button {
  min-height: 42px;
  padding: 4px 5px;
  flex-direction: row;
  gap: 5px;
  border: 1px solid rgb(43 28 25 / 17%);
  border-radius: 11px;
  color: #4d3c38;
  background: rgb(255 250 239 / 54%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 60%);
}

.control-button > span:first-child {
  color: #37272a;
  font-size: 0.98rem;
}

.control-button > span:last-child {
  color: inherit;
  font-size: 0.6rem;
}

.control-button:hover:not(:disabled) {
  border-color: rgb(72 40 80 / 30%);
  color: #42254f;
  background: #fff9eb;
}

.hint-button {
  border-color: rgb(40 125 145 / 25%);
  background: rgb(211 246 246 / 62%);
}

.hint-button > span:first-child {
  color: #167d96;
}

.completion-panel {
  z-index: 30;
  inset: 5px;
  border-radius: 17px;
  color: var(--cream);
  background:
    radial-gradient(circle at 50% 32%, rgb(115 229 255 / 23%), transparent 37%),
    rgb(11 8 18 / 91%);
}

.room-dialog {
  color: var(--cream);
}

@keyframes premium-ghost-float {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  50% {
    transform: translate(-50%, calc(-50% - 4px));
  }
}

@keyframes premium-arrow-pulse {
  0%,
  100% {
    opacity: 0.88;
    filter: drop-shadow(0 0 3px #e8ffff) drop-shadow(0 0 7px rgb(64 213 255 / 90%)) drop-shadow(0 3px 2px rgb(4 15 28 / 82%));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 4px #fff) drop-shadow(0 0 11px rgb(64 213 255 / 100%)) drop-shadow(0 3px 2px rgb(4 15 28 / 82%));
  }
}

@keyframes premium-hint {
  0%,
  100% {
    filter: drop-shadow(0 0 8px rgb(117 227 255 / 78%));
  }
  50% {
    filter: drop-shadow(0 0 16px #fff) drop-shadow(0 0 22px #59dcff);
  }
}

@keyframes portal-breathe {
  0%,
  72%,
  100% {
    opacity: 0.44;
  }
  82% {
    opacity: 0.68;
  }
}

@keyframes portal-receive {
  0% {
    opacity: 0.42;
  }
  38%,
  82% {
    opacity: 1;
  }
  100% {
    opacity: 0.78;
  }
}

@keyframes portal-core-open-x {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scaleX(0.18);
  }
  48% {
    opacity: 0.58;
    transform: translate(-50%, -50%) scaleX(0.72);
  }
  76% {
    opacity: 1;
    transform: translate(-50%, -50%) scaleX(1.2);
  }
  100% {
    opacity: 0.36;
    transform: translate(-50%, -50%) scaleX(0.76);
  }
}

@keyframes portal-core-open-y {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scaleY(0.18);
  }
  48% {
    opacity: 0.58;
    transform: translate(-50%, -50%) scaleY(0.72);
  }
  76% {
    opacity: 1;
    transform: translate(-50%, -50%) scaleY(1.2);
  }
  100% {
    opacity: 0.36;
    transform: translate(-50%, -50%) scaleY(0.76);
  }
}

@keyframes portal-rune-flash {
  0%,
  34% {
    opacity: 0;
    filter: blur(2px);
  }
  66%,
  82% {
    opacity: 1;
    filter: blur(0);
  }
  100% {
    opacity: 0;
    filter: blur(3px);
  }
}

@keyframes ghost-to-portal {
  0% {
    opacity: 1;
    filter: none;
    transform: translate3d(0, 0, 0) scale(1);
  }
  68% {
    opacity: 1;
    filter: brightness(1.18);
    transform: translate3d(var(--exit-x), var(--exit-y), 0) scale(0.72);
  }
  86% {
    opacity: 0.64;
    filter: blur(1px) brightness(1.9);
    transform: translate3d(var(--exit-x), var(--exit-y), 0) scale(0.36);
  }
  100% {
    opacity: 0;
    filter: blur(5px) brightness(2.8);
    transform: translate3d(var(--exit-x), var(--exit-y), 0) scale(0.06);
  }
}

@keyframes spirit-phase-out {
  0%,
  58% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  84% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(0.82);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.25);
  }
}

@keyframes portal-arrow-out {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    filter: blur(4px) brightness(1.8);
  }
}

@keyframes portal-trail-out {
  0% {
    opacity: 0.42;
    transform: translate(-50%, -50%) scale(1);
  }
  72% {
    opacity: 0.72;
    transform: translate(-50%, -50%) scale(1.45);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.15);
  }
}

@media (min-width: 511px) {
  .game-frame {
    min-height: min(100dvh, 900px);
    border-right: 1px solid rgb(255 239 209 / 14%);
    border-left: 1px solid rgb(255 239 209 / 14%);
  }
}

@media (max-height: 650px) {
  :root {
    --stage-width: min(
      calc(100vw - 16px),
      calc((100dvh - 84px) * 965 / 1630),
      480px
    );
  }

  .game-frame {
    justify-content: center;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .game-header {
    top: 11px;
  }

  .status-pill {
    min-width: 68px;
    height: 33px;
    padding: 0 10px;
  }

  .game-identity {
    min-height: 39px;
    padding-top: 2px;
  }

  .game-wordmark {
    font-size: 1.45rem;
  }

  .room-number {
    display: none;
  }

  .room-button strong {
    font-size: 0.66rem;
  }

  .controls {
    min-height: 37px;
  }

  .control-button {
    min-height: 36px;
  }

  .coach {
    bottom: 12px;
    min-height: 37px;
    padding-block: 5px;
  }
}

@media (max-width: 350px) {
  .game-identity {
    gap: 8px;
  }

  .game-wordmark {
    font-size: 1.35rem;
  }

  .room-button {
    max-width: 135px;
  }

  .control-button {
    gap: 2px;
  }

  .control-button > span:last-child {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ghost-art,
  .direction-arrow {
    animation: none !important;
  }
}
