:root {
  color-scheme: dark;
  --field: #13052f;
  --field-deep: #08021c;
  --rail: #2d1764;
  --rail-lit: #51309a;
  --amber: #ffc247;
  --cyan: #28e2ff;
  --coral: #ff5576;
  --ink: #fff9ff;
  --muted: #b8abd6;
  --line: rgb(239 228 255 / 16%);
  --glass: rgb(12 4 40 / 76%);
  --cell-gap: 3px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, rgb(120 53 220 / 35%), transparent 31rem),
    radial-gradient(circle at 87% 73%, rgb(24 128 190 / 25%), transparent 34rem),
    linear-gradient(145deg, var(--field), var(--field-deep));
}

body::before {
  position: fixed;
  inset: 0;
  content: "";
  pointer-events: none;
  background-image:
    linear-gradient(90deg, rgb(255 255 255 / 2.5%) 1px, transparent 1px),
    linear-gradient(rgb(255 255 255 / 2.5%) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, #000, transparent 82%);
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  position: relative;
  width: min(1320px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: 12px clamp(12px, 2.1vw, 28px);
}

.playfield {
  min-width: 0;
  min-height: calc(100svh - 24px);
  display: grid;
  grid-template-rows: auto auto minmax(380px, 1fr) auto auto;
  border: 1px solid rgb(255 255 255 / 15%);
  border-radius: 22px 5px 22px 5px;
  overflow: hidden;
  background: rgb(8 2 28 / 42%);
  box-shadow: 0 28px 90px rgb(2 0 12 / 40%);
}

.board-cap,
.turn-strip,
.board-edge,
.board-foot {
  position: relative;
  z-index: 20;
}

.board-cap {
  min-width: 0;
  min-height: 62px;
  padding: 9px 12px 8px 15px;
  display: grid;
  grid-template-columns: minmax(250px, 1fr) auto auto;
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
  border-bottom: 1px solid var(--line);
  background: rgb(17 6 51 / 84%);
}

.day-mark,
.puzzle-mark,
.turn-strip,
.plane-label,
.maze-legend,
.depth-note,
.route-line,
.action-copy,
.edge-button,
.lock-button,
.move-button small,
.board-foot,
.win-kicker {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.day-mark {
  margin: 0 0 2px;
  color: var(--cyan);
  font-size: 0.56rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2.25vw, 2rem);
  font-weight: 790;
  line-height: 1;
  letter-spacing: -0.045em;
}

h1 span {
  color: var(--coral);
  font-weight: 510;
}

.puzzle-mark {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.57rem;
  white-space: nowrap;
}

.puzzle-mark > span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgb(40 226 255 / 48%);
  border-radius: 50%;
  color: var(--cyan);
}

.puzzle-mark strong {
  color: var(--ink);
  font-weight: 600;
}

.edge-button,
.lock-button,
.file-link {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(255 255 255 / 23%);
  border-radius: 999px;
  color: var(--muted);
  background: rgb(15 5 47 / 76%);
  font-size: 0.56rem;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.edge-button:hover,
.edge-button:focus-visible,
.lock-button:hover:not(:disabled),
.lock-button:focus-visible:not(:disabled),
.file-link:hover,
.file-link:focus-visible {
  border-color: var(--cyan);
  color: var(--ink);
  outline: none;
  background: rgb(40 226 255 / 10%);
}

.edge-button:active,
.lock-button:active:not(:disabled),
.file-link:active {
  transform: translateY(1px);
}

.edge-button--quiet {
  border-color: rgb(255 255 255 / 14%);
}

.turn-strip {
  min-width: 0;
  min-height: 38px;
  padding: 0 15px;
  display: grid;
  grid-template-columns: auto auto auto minmax(140px, 1fr);
  align-items: center;
  gap: clamp(12px, 2.6vw, 34px);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: rgb(12 4 42 / 72%);
  font-size: 0.57rem;
}

.turn-strip p {
  min-width: 0;
  margin: 0;
  white-space: nowrap;
}

.turn-strip strong {
  margin-left: 0.38rem;
  color: var(--ink);
  font-size: 0.69rem;
}

.gate-readout {
  justify-self: end;
  overflow: hidden;
  color: var(--coral);
  text-overflow: ellipsis;
}

.maze-stage {
  position: relative;
  min-width: 0;
  min-height: 380px;
  overflow: hidden;
  isolation: isolate;
  contain: layout paint;
  background:
    linear-gradient(90deg, rgb(255 255 255 / 3.5%) 1px, transparent 1px),
    linear-gradient(rgb(255 255 255 / 3.5%) 1px, transparent 1px),
    radial-gradient(ellipse at center, rgb(84 35 161 / 20%), transparent 68%),
    rgb(8 2 30 / 52%);
  background-size: 38px 38px, 38px 38px, auto, auto;
}

.maze-stage:focus {
  outline: none;
}

.maze-stage:focus-visible {
  box-shadow: inset 0 0 0 2px var(--cyan);
}

.maze-stage::before,
.exit-tear {
  position: absolute;
  z-index: 0;
  content: "";
  pointer-events: none;
  opacity: 0;
  transition: opacity 700ms ease;
}

.maze-stage::before {
  inset: 10% 12%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgb(128 103 255 / 27%), transparent 68%);
  filter: blur(12px);
}

.exit-tear {
  top: 12%;
  right: 1.5%;
  width: 8%;
  height: 66%;
  background: linear-gradient(90deg, transparent, #fff 43% 48%, var(--coral) 49% 52%, transparent 55%);
  filter: drop-shadow(0 0 18px var(--coral));
  clip-path: polygon(48% 0, 68% 18%, 51% 32%, 76% 48%, 43% 65%, 61% 82%, 35% 100%, 0 100%, 17% 79%, 4% 64%, 24% 46%, 7% 29%, 27% 12%, 15% 0);
}

.maze-stage.is-aligned::before,
.maze-stage.is-exit-ready .exit-tear {
  opacity: 1;
}

.timeline-stack {
  position: absolute;
  z-index: 2;
  inset: 0;
  perspective: 1100px;
  transform-style: preserve-3d;
}

.timeline-plane {
  --route-color: var(--ink);
  position: absolute;
  top: 8px;
  left: 50%;
  width: clamp(420px, 42vw, 590px);
  min-width: 0;
  transform-origin: 50% 0;
  opacity: 0.48;
  filter: saturate(0.75);
  transition:
    transform 680ms cubic-bezier(0.2, 0.78, 0.2, 1),
    opacity 420ms ease,
    filter 420ms ease;
}

.plane--amber {
  --route-color: var(--amber);
  z-index: 1;
  transform: translate3d(-72%, 0, -80px) rotateX(43deg) rotateZ(-2.2deg) scale(0.78);
}

.plane--cyan {
  --route-color: var(--cyan);
  z-index: 2;
  transform: translate3d(-52%, 45px, -6px) rotateX(43deg) rotateZ(-2.2deg) scale(0.89);
}

.plane--coral {
  --route-color: var(--coral);
  z-index: 3;
  transform: translate3d(-32%, 96px, 70px) rotateX(43deg) rotateZ(-2.2deg);
}

.timeline-plane.is-active {
  opacity: 1;
  filter: saturate(1.15) brightness(1.05);
}

.timeline-plane.is-authored:not(.is-active) {
  opacity: 0.72;
  filter: saturate(1);
}

.plane-label {
  height: 20px;
  margin: 0;
  display: flex;
  align-items: start;
  gap: 7px;
  color: var(--route-color);
  font-size: 0.54rem;
}

.plane-label b {
  font-weight: 900;
}

.plane-label span {
  margin-left: auto;
  opacity: 0.72;
}

.maze-grid {
  width: 100%;
  aspect-ratio: 9 / 7;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(7, minmax(0, 1fr));
  gap: var(--cell-gap);
  padding: var(--cell-gap);
  border: 1px solid color-mix(in srgb, var(--route-color) 38%, transparent);
  border-radius: 8px;
  background: rgb(9 3 35 / 87%);
  box-shadow: 0 19px 50px rgb(2 0 18 / 45%);
  transition: background 600ms ease, border-color 600ms ease, box-shadow 600ms ease;
}

.maze-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 2px;
  background: rgb(54 30 116 / 26%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 4%);
  transition: background 350ms ease, box-shadow 350ms ease, opacity 350ms ease;
}

.maze-cell.is-wall {
  background: linear-gradient(135deg, var(--rail-lit), var(--rail) 62%);
  box-shadow:
    inset 1px 1px 0 rgb(255 255 255 / 13%),
    0 2px 0 rgb(3 0 20 / 78%);
}

.cell-label,
.feature,
.trail-mark,
.turn-bead,
.actor {
  position: absolute;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.cell-label {
  z-index: 3;
  color: rgb(255 255 255 / 82%);
  font: 900 clamp(0.48rem, 0.85vw, 0.68rem) "SFMono-Regular", Consolas, monospace;
}

.cell-label--start {
  left: 12%;
  bottom: 8%;
  color: var(--muted);
}

.feature {
  z-index: 2;
  inset: 17%;
}

.feature--plate {
  border: 2px solid rgb(255 255 255 / 40%);
  border-radius: 50%;
  background: rgb(9 3 35 / 68%);
  box-shadow: inset 0 0 0 4px rgb(255 255 255 / 5%);
}

.feature--plate-b {
  inset: 20%;
  border-radius: 3px;
  transform: rotate(45deg);
}

.feature--plate > span {
  color: var(--ink);
  font: 900 clamp(0.48rem, 0.85vw, 0.7rem) "SFMono-Regular", Consolas, monospace;
}

.feature--plate-b > span {
  transform: rotate(-45deg);
}

.maze-cell.is-held .feature--plate-a {
  border-color: var(--amber);
  background: rgb(255 194 71 / 27%);
  box-shadow: 0 0 20px rgb(255 194 71 / 72%);
}

.maze-cell.is-held .feature--plate-b {
  border-color: var(--cyan);
  background: rgb(40 226 255 / 24%);
  box-shadow: 0 0 20px rgb(40 226 255 / 72%);
}

.maze-stage.is-confirming .maze-cell.is-held .feature--plate-a,
.maze-stage.is-confirming .maze-cell.is-held .feature--plate-b {
  border-width: 3px;
  filter: brightness(1.32) saturate(1.25);
  animation: plate-confirm 460ms ease-out both;
}

.feature--gate {
  z-index: 4;
  inset: 4% 29%;
  border: 1px solid rgb(255 255 255 / 30%);
  border-radius: 2px;
  background: linear-gradient(90deg, var(--rail), var(--rail-lit), var(--rail));
  box-shadow: 0 0 0 2px rgb(6 1 25 / 78%), 0 0 12px rgb(255 85 118 / 38%);
  transition: inset 450ms ease, opacity 450ms ease, box-shadow 450ms ease;
}

.feature--gate > span {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: var(--rail);
  font: 900 0.62rem "SFMono-Regular", Consolas, monospace;
}

.maze-cell.is-open .feature--gate {
  inset: 4% 45%;
  opacity: 0.34;
  box-shadow: 0 0 16px var(--route-color);
}

.feature--exit {
  inset: 8%;
  border: 2px solid rgb(255 85 118 / 60%);
  border-radius: 2px;
  background: repeating-linear-gradient(135deg, rgb(255 85 118 / 16%) 0 4px, transparent 4px 8px);
}

.feature--exit > span {
  color: var(--coral);
  font: 900 clamp(0.48rem, 0.85vw, 0.72rem) "SFMono-Regular", Consolas, monospace;
}

.maze-cell.is-exit-open .feature--exit {
  border-color: #fff;
  background: #fff;
  box-shadow: 0 0 10px #fff, 0 0 30px var(--coral), 0 0 48px var(--cyan);
  animation: exit-tear 900ms ease-in-out infinite alternate;
}

.maze-cell.is-exit-open .feature--exit > span {
  color: var(--field-deep);
}

.trail-mark {
  z-index: 1;
  width: 70%;
  height: 28%;
  border-radius: 999px;
  background: color-mix(in srgb, var(--route-color) 74%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--route-color) 58%, transparent);
  opacity: 0.66;
  transform: rotate(-8deg);
  animation: route-arrives 250ms ease-out both;
}

.maze-stage.is-confirming .trail-mark {
  height: 36%;
  opacity: 0.94;
  filter: saturate(1.3) brightness(1.22);
  box-shadow:
    0 0 8px color-mix(in srgb, var(--route-color) 88%, transparent),
    0 0 18px color-mix(in srgb, var(--route-color) 62%, transparent);
  animation: route-confirms 460ms ease-out both;
}

.turn-bead {
  z-index: 5;
  top: 5%;
  right: 5%;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--route-color);
  background: rgb(7 2 28 / 88%);
  font: 800 clamp(0.35rem, 0.62vw, 0.5rem) "SFMono-Regular", Consolas, monospace;
}

.actor {
  z-index: 8;
  width: 57%;
  aspect-ratio: 1;
  color: var(--field-deep);
  background: var(--route-color);
  box-shadow: 0 0 9px var(--route-color), 0 0 22px var(--route-color);
  font: 950 clamp(0.52rem, 0.9vw, 0.76rem) "SFMono-Regular", Consolas, monospace;
  animation: actor-breathe 1.5s ease-in-out infinite;
}

.actor--amber {
  border: 2px solid #fff5d1;
  border-radius: 50%;
}

.actor--cyan {
  width: 48%;
  border: 2px solid #e3fbff;
  border-radius: 3px;
  transform: rotate(45deg);
}

.actor--cyan > span {
  transform: rotate(-45deg);
}

.actor--coral {
  border: 2px solid #ffe7ec;
  clip-path: polygon(50% 0, 93% 24%, 93% 76%, 50% 100%, 7% 76%, 7% 24%);
}

.maze-legend {
  position: absolute;
  z-index: 8;
  left: 13px;
  bottom: 13px;
  color: rgb(255 255 255 / 57%);
  font-size: 0.5rem;
  line-height: 1.55;
}

.maze-legend p {
  margin: 0;
}

.maze-legend b {
  width: 1.1rem;
  display: inline-block;
  color: var(--ink);
}

.depth-note {
  position: absolute;
  z-index: 7;
  right: 13px;
  bottom: 12px;
  margin: 0;
  color: rgb(255 255 255 / 40%);
  font-size: 0.48rem;
}

.maze-stage.is-aligned .timeline-plane {
  top: 12px;
  left: 50%;
  width: clamp(500px, 52vw, 650px);
  opacity: 1;
  filter: saturate(1.2) brightness(1.06);
  transform: translate3d(-50%, 16px, 0) rotateX(7deg) rotateZ(0) scale(0.96);
}

.maze-stage.is-aligned .plane--amber {
  z-index: 1;
}

.maze-stage.is-aligned .plane--cyan {
  z-index: 2;
}

.maze-stage.is-aligned .plane--coral {
  z-index: 3;
}

.maze-stage.is-aligned .plane--cyan .maze-grid,
.maze-stage.is-aligned .plane--coral .maze-grid {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.maze-stage.is-aligned .plane--cyan .maze-cell,
.maze-stage.is-aligned .plane--coral .maze-cell {
  background: transparent;
  box-shadow: none;
}

.maze-stage.is-aligned .plane--cyan .maze-cell.is-wall,
.maze-stage.is-aligned .plane--coral .maze-cell.is-wall,
.maze-stage.is-aligned .plane--cyan .cell-label,
.maze-stage.is-aligned .plane--coral .cell-label,
.maze-stage.is-aligned .plane--cyan .feature,
.maze-stage.is-aligned .plane--coral .feature {
  opacity: 0;
}

.maze-stage.is-aligned .plane-label {
  opacity: 0;
}

.maze-stage.is-aligned .plane--amber .trail-mark {
  transform: translateY(-24%) rotate(-7deg);
}

.maze-stage.is-aligned .plane--cyan .trail-mark {
  transform: rotate(0);
}

.maze-stage.is-aligned .plane--coral .trail-mark {
  transform: translateY(24%) rotate(7deg);
}

.maze-stage.is-aligned .plane--amber .turn-bead {
  top: 4%;
  right: auto;
  left: 4%;
}

.maze-stage.is-aligned .plane--cyan .turn-bead {
  top: 4%;
  right: 4%;
}

.maze-stage.is-aligned .plane--coral .turn-bead {
  top: auto;
  right: 4%;
  bottom: 4%;
}

.win-edge {
  position: absolute;
  z-index: 30;
  right: 12px;
  bottom: 10px;
  left: auto;
  max-width: min(520px, calc(100% - 24px));
  min-height: 64px;
  padding: 8px 9px 8px 13px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid rgb(255 255 255 / 25%);
  border-radius: 16px 3px 16px 3px;
  background: rgb(8 2 29 / 88%);
  box-shadow: 0 10px 40px rgb(0 0 0 / 42%);
  animation: win-edge-in 360ms ease-out both;
}

.win-edge[hidden] {
  display: none;
}

.win-kicker {
  margin: 0 0 3px;
  color: var(--cyan);
  font-size: 0.47rem;
}

.win-edge h2 {
  margin: 0;
  font-size: clamp(0.92rem, 1.6vw, 1.2rem);
  line-height: 1;
  letter-spacing: -0.025em;
}

.win-actions {
  display: flex;
  gap: 6px;
}

.board-edge {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(390px, 0.92fr) minmax(480px, 1.08fr);
  border-top: 1px solid var(--line);
  background: rgb(14 5 43 / 88%);
}

.route-bank {
  min-width: 0;
  padding: 8px 11px;
  display: grid;
  gap: 4px;
  border-right: 1px solid var(--line);
}

.route-line {
  --route-color: var(--muted);
  min-width: 0;
  min-height: 26px;
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  color: var(--route-color);
  font-size: 0.5rem;
}

.route-line--amber { --route-color: var(--amber); }
.route-line--cyan { --route-color: var(--cyan); }
.route-line--coral { --route-color: var(--coral); }

.route-line p {
  min-width: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
}

.route-line p b {
  grid-row: 1 / span 2;
  font-size: 0.68rem;
}

.route-line p span {
  color: var(--ink);
}

.route-line p em {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.42rem;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-line ol {
  min-width: 0;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow: hidden;
  list-style: none;
}

.route-line li {
  min-width: 16px;
  max-width: 24px;
  height: 21px;
  flex: 1 1 21px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--route-color) 42%, transparent);
  border-radius: 999px;
  color: var(--route-color);
  background: color-mix(in srgb, var(--route-color) 7%, transparent);
  font-size: 0.47rem;
}

.action-edge {
  min-width: 0;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: minmax(145px, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.action-copy {
  min-width: 0;
  color: var(--muted);
  font-size: 0.49rem;
  line-height: 1.42;
}

.action-copy p {
  margin: 0;
}

#run-objective {
  margin-top: 5px;
  color: var(--ink);
}

.announcer {
  min-height: 1.42em;
  margin-top: 5px !important;
  color: var(--cyan);
}

.control-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
}

.direction-pad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  grid-template-areas:
    ". north ."
    "west wait east"
    ". south .";
  gap: 3px;
}

.move-button {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  border: 1px solid rgb(40 226 255 / 37%);
  border-radius: 10px;
  color: var(--cyan);
  background: linear-gradient(145deg, rgb(62 31 130 / 87%), rgb(20 7 58 / 94%));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 11%), 0 4px 13px rgb(2 0 19 / 34%);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 120ms ease, transform 120ms ease, background 120ms ease;
}

.move-button > span {
  align-self: end;
  font-size: 1.05rem;
  line-height: 1;
}

.move-button small {
  align-self: start;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.43rem;
}

.move-button--north { grid-area: north; }
.move-button--west { grid-area: west; }
.move-button--wait { grid-area: wait; border-color: rgb(255 85 118 / 50%); color: var(--coral); }
.move-button--east { grid-area: east; }
.move-button--south { grid-area: south; }

.move-button:hover,
.move-button:focus-visible {
  border-color: currentColor;
  outline: none;
  transform: translateY(-1px);
}

.move-button:active,
.move-button.is-pressed {
  transform: translateY(1px) scale(0.96);
  background: rgb(40 226 255 / 16%);
}

.route-controls {
  width: 102px;
  display: grid;
  gap: 3px;
}

.route-controls .edge-button,
.route-controls .lock-button {
  width: 100%;
  height: 44px;
  min-height: 44px;
  padding: 4px 7px;
  border-radius: 8px;
  font-size: 0.48rem;
}

.lock-button {
  border-color: var(--coral);
  color: var(--ink);
  background: rgb(255 85 118 / 14%);
}

button:disabled {
  border-color: rgb(255 255 255 / 10%);
  color: rgb(184 171 214 / 38%);
  background: rgb(255 255 255 / 2%);
  cursor: not-allowed;
}

.board-foot {
  min-width: 0;
  min-height: 45px;
  padding: 0 8px 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  color: rgb(255 255 255 / 42%);
  background: rgb(9 3 31 / 91%);
  font-size: 0.46rem;
}

.board-foot p {
  margin: 0;
}

.file-link {
  min-height: 36px;
  padding: 4px 11px;
  font-size: 0.45rem;
}

.noscript-fallback {
  position: fixed;
  z-index: 100;
  inset: 18px;
  padding: clamp(24px, 6vw, 70px);
  display: grid;
  place-content: center;
  border: 2px solid var(--coral);
  border-radius: 22px;
  color: var(--ink);
  background: var(--field-deep);
  text-align: center;
}

.noscript-fallback h2 {
  margin: 0 0 12px;
  font-size: clamp(1.5rem, 5vw, 3.2rem);
}

.noscript-fallback p {
  max-width: 42rem;
  margin: 6px auto;
  color: var(--muted);
}

@keyframes actor-breathe {
  50% { filter: brightness(1.28); }
}

@keyframes route-arrives {
  from { opacity: 0; transform: rotate(-8deg) scaleX(0.25); }
}

@keyframes route-confirms {
  from { opacity: 0.66; filter: saturate(1) brightness(1); }
}

@keyframes plate-confirm {
  from { filter: brightness(1) saturate(1); }
}

@keyframes exit-tear {
  to { transform: scaleX(0.58) scaleY(1.13); }
}

@keyframes win-edge-in {
  from { opacity: 0; transform: translateY(9px); }
}

@media (max-width: 900px) {
  .board-edge {
    grid-template-columns: minmax(310px, 0.8fr) minmax(430px, 1.2fr);
  }

  .action-edge {
    gap: 6px;
  }

  .route-bank {
    padding-inline: 7px;
  }

  .route-line {
    grid-template-columns: 94px minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  :root {
    --cell-gap: 2px;
  }

  body::before {
    background-size: 30px 30px;
  }

  .game-shell {
    min-height: 100svh;
    padding: 6px;
  }

  .playfield {
    width: 100%;
    height: calc(100svh - 12px);
    min-height: 760px;
    grid-template-rows: 53px 34px minmax(300px, 1fr) 224px 44px;
    border-radius: 16px 4px 16px 4px;
  }

  .board-cap {
    min-height: 53px;
    padding: 5px 5px 5px 9px;
    grid-template-columns: minmax(145px, 1fr) auto 82px;
    gap: 5px;
  }

  .day-mark {
    font-size: 0.43rem;
  }

  h1 {
    font-size: 1.06rem;
  }

  h1 span {
    display: block;
  }

  .puzzle-mark {
    gap: 4px;
    font-size: 0.44rem;
  }

  .puzzle-mark > span {
    width: 25px;
    height: 25px;
  }

  .puzzle-mark strong {
    display: none;
  }

  .reset-all-button {
    width: 82px;
    min-height: 44px;
    padding: 4px 7px;
    font-size: 0.45rem;
  }

  .turn-strip {
    min-height: 34px;
    padding: 0 8px;
    grid-template-columns: auto auto auto 1fr;
    gap: 7px;
    font-size: 0.44rem;
  }

  .turn-strip p > span {
    display: none;
  }

  .turn-strip strong {
    margin: 0;
    font-size: 0.51rem;
  }

  .gate-readout {
    font-size: 0.41rem;
  }

  .maze-stage {
    min-height: 300px;
    background-size: 28px 28px, 28px 28px, auto, auto;
  }

  .timeline-plane {
    top: 15px;
    width: min(88vw, 350px);
  }

  .plane--amber {
    opacity: 0.37;
    transform: translate3d(-55%, 0, 0) scale(0.91);
  }

  .plane--cyan {
    opacity: 0.52;
    transform: translate3d(-50%, 14px, 0) scale(0.95);
  }

  .plane--coral {
    opacity: 0.7;
    transform: translate3d(-45%, 29px, 0);
  }

  .timeline-plane.is-active,
  .timeline-plane.is-authored:not(.is-active) {
    opacity: 0.94;
  }

  .plane-label {
    height: 17px;
    font-size: 0.44rem;
  }

  .turn-bead {
    min-width: 14px;
    height: 14px;
    font-size: 0.36rem;
  }

  .maze-legend {
    left: 7px;
    bottom: 6px;
    font-size: 0.4rem;
  }

  .depth-note {
    right: 7px;
    bottom: 6px;
    font-size: 0.4rem;
  }

  .maze-stage.is-aligned .timeline-plane {
    top: 12px;
    width: min(91vw, 356px);
    transform: translate3d(-50%, 12px, 0) rotateX(3deg) rotateZ(0) scale(0.98);
  }

  .exit-tear {
    top: 7%;
    height: 59%;
  }

  .win-edge {
    right: 6px;
    bottom: 6px;
    left: 6px;
    max-width: none;
    min-height: 62px;
    padding: 6px 7px 6px 10px;
    justify-content: space-between;
    gap: 7px;
  }

  .win-kicker {
    font-size: 0.39rem;
  }

  .win-edge h2 {
    font-size: 0.83rem;
  }

  .win-actions {
    flex: 0 0 174px;
  }

  .win-actions .edge-button {
    min-width: 82px;
    min-height: 44px;
    padding: 4px 6px;
    font-size: 0.42rem;
  }

  .board-edge {
    min-height: 224px;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 70px 154px;
  }

  .route-bank {
    padding: 3px 5px;
    gap: 1px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .route-line {
    min-height: 20px;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 3px;
    font-size: 0.42rem;
  }

  .route-line p {
    grid-template-columns: 18px 1fr;
  }

  .route-line p b {
    font-size: 0.56rem;
  }

  .route-line p em {
    font-size: 0.36rem;
  }

  .route-line ol {
    gap: 1px;
  }

  .route-line li {
    min-width: 13px;
    height: 17px;
    font-size: 0.39rem;
  }

  .action-edge {
    min-height: 154px;
    padding: 3px 5px;
    grid-template-columns: minmax(82px, 1fr) auto;
    gap: 4px;
  }

  .action-copy {
    font-size: 0.4rem;
    line-height: 1.35;
  }

  #run-objective,
  .announcer {
    margin-top: 4px !important;
  }

  .control-cluster {
    gap: 4px;
  }

  .direction-pad {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    gap: 3px;
  }

  .route-controls {
    width: 86px;
    gap: 3px;
  }

  .route-controls .edge-button,
  .route-controls .lock-button {
    padding: 3px 4px;
    font-size: 0.41rem;
  }

  .board-foot {
    min-height: 44px;
    padding: 0 4px;
    justify-content: flex-end;
  }

  .board-foot p {
    display: none;
  }

  .file-link {
    width: 100%;
    min-height: 44px;
    padding: 4px 8px;
    border-color: transparent;
    border-radius: 8px;
    font-size: 0.42rem;
  }

  body.has-won .playfield {
    height: auto;
    min-height: 0;
    grid-template-rows: 53px 34px auto 224px 44px;
  }

  .maze-stage.is-confirming {
    min-height: 0;
    display: grid;
    grid-template-rows: 294px auto;
  }

  .maze-stage.is-confirming .timeline-stack {
    position: relative;
    inset: auto;
    grid-row: 1;
    height: 294px;
  }

  .maze-stage.is-confirming .timeline-plane {
    top: 0;
    width: min(calc(100% - 38px), 326px);
  }

  .maze-stage.is-confirming:not(.is-aligned) .plane--amber {
    transform: translate3d(-55%, 0, 0) scale(0.91);
  }

  .maze-stage.is-confirming:not(.is-aligned) .plane--cyan {
    transform: translate3d(-50%, 10px, 0) scale(0.95);
  }

  .maze-stage.is-confirming:not(.is-aligned) .plane--coral {
    transform: translate3d(-45%, 20px, 0);
  }

  .maze-stage.is-aligned .timeline-plane {
    top: 0;
    width: min(calc(100% - 38px), 326px);
    transform: translate3d(-50%, 5px, 0) rotateX(0) rotateZ(0);
  }

  .maze-stage.is-confirming .maze-legend,
  .maze-stage.is-confirming .depth-note {
    display: none;
  }

  .maze-stage.is-exit-ready .exit-tear {
    top: 26px;
    right: 8px;
    width: 22px;
    height: 232px;
    background: linear-gradient(90deg, transparent, #fff 42% 50%, var(--coral) 51% 58%, transparent 60%);
  }

  .maze-stage.is-aligned .trail-mark {
    width: 82%;
    height: 42%;
    opacity: 0.96;
  }

  .maze-stage.is-aligned .turn-bead {
    min-width: 20px;
    height: 20px;
    padding: 0 3px;
    border-width: 2px;
    color: var(--route-color);
    background: var(--field-deep);
    box-shadow: 0 0 0 1px rgb(255 255 255 / 20%), 0 0 8px var(--route-color);
    font-size: 0.48rem;
  }

  .maze-stage.is-aligned .actor {
    width: 62%;
  }

  .maze-stage.is-aligned .actor--cyan {
    width: 54%;
  }

  .maze-stage.is-confirming .win-edge {
    position: relative;
    right: auto;
    bottom: auto;
    left: auto;
    grid-row: 2;
    width: auto;
    max-width: none;
    min-height: 70px;
    margin: 0 6px 6px;
  }
}

@media (max-width: 370px), (max-height: 780px) and (max-width: 720px) {
  .playfield {
    height: auto;
    min-height: 760px;
  }

  .action-copy p:first-child {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
