@font-face {
  font-family: "AriPixel";
  src: url("../assets/fonts/ari.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #11110f;
  --surface: #1a1916;
  --surface-2: #22201c;
  --surface-3: #2b2822;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f7f2e9;
  --muted: #a9a297;
  --accent: #f3b95f;
  --accent-strong: #ffd485;
  --visited-light: #9ecb9b;
  --visited-dark: #5c936b;
  --light-tile: #d9c39d;
  --dark-tile: #876247;
  --move-indicator: rgba(255, 255, 255, .92);
  --danger: #ef6d62;
  --success: #8bd09b;
  --cell-size: 72px;
  --piece-size: 76%;
  --rows: 8;
  --cols: 8;
  font-family: "AriPixel", monospace;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(180deg, #0d0d0c, #171612 65%, #0e0e0d);
  background-size: 10px 10px, 10px 10px, auto;
  image-rendering: pixelated;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:not(:disabled),
a[href],
[role="button"]:not([aria-disabled="true"]) {
  cursor: pointer;
}
button:disabled {
  cursor: default;
}
a { color: inherit; text-decoration: none; }
img,
svg {
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.eyebrow {
  display: block;
  margin: 0 0 7px;
  color: var(--accent);
  font-size: .82rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 rgba(0,0,0,.35);
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(1.9rem, 4vw, 3.4rem);
  line-height: 1;
  letter-spacing: .03em;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 rgba(0,0,0,.34);
}
h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.button,
.icon-button {
  border: 0;
  cursor: pointer;
}

.button {
  min-height: 44px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface-3);
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
  box-shadow: inset -2px -2px 0 rgba(0,0,0,.28), inset 2px 2px 0 rgba(255,255,255,.03);
  transition: transform .14s ease, border-color .14s ease, background .14s ease, opacity .14s ease;
}
.button:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.button:active { transform: translateY(1px); box-shadow: inset 2px 2px 0 rgba(0,0,0,.24), inset -2px -2px 0 rgba(255,255,255,.02); }
.button.primary { background: var(--accent); color: #20180d; border-color: transparent; }
.button.primary:hover { background: var(--accent-strong); }
.button.secondary { background: #2c2924; }
.button.ghost { background: transparent; }
.button.full { width: 100%; }
.button:disabled { opacity: .38; cursor: default; transform: none; }

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255,255,255,.05);
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: inset -2px -2px 0 rgba(0,0,0,.28), inset 2px 2px 0 rgba(255,255,255,.03);
  transition: transform .14s ease, background .14s ease, border-color .14s ease;
}
.icon-button:hover { transform: translateY(-1px); background: rgba(255,255,255,.09); border-color: var(--line-strong); }
.icon-button:active { transform: translateY(1px); }
.icon-button.small { width: 34px; height: 34px; font-size: 1rem; }
.icon-button:disabled { opacity: .3; cursor: default; transform: none; }
.ui-icon {
  --icon-mirror: 1;
  width: 20px;
  height: 20px;
  display: block;
  fill: currentColor;
  flex: 0 0 auto;
  transform: scaleX(var(--icon-mirror));
  transform-origin: 50% 50%;
  transform-box: fill-box;
  transition:
    transform .26s cubic-bezier(.18, 1.18, .28, 1),
    filter .22s ease;
  will-change: transform, filter;
}
.mirror-x { --icon-mirror: -1; }
.icon-button.small .ui-icon { width: 14px; height: 14px; }

:is(.icon-button, .hint-button, .screen-button, .button):hover:not(:disabled) .ui-icon {
  transform: scaleX(var(--icon-mirror)) scale(1.14);
  animation: none;
  filter: drop-shadow(2px 2px 0 rgba(0,0,0,.28));
}

:is(.icon-button, .hint-button, .screen-button, .button):active:not(:disabled) .ui-icon {
  transform: scaleX(var(--icon-mirror)) scale(.86);
  animation: none;
}

:is(.icon-button, .hint-button, .screen-button, .button).is-icon-pressing:not(:disabled) .ui-icon {
  transform: scaleX(var(--icon-mirror)) scale(.86);
  animation: none;
}

:is(.icon-button, .hint-button, .screen-button, .button).is-icon-release-pop:not(:disabled) .ui-icon {
  animation: uiIconReleasePop .34s cubic-bezier(.16, 1.25, .24, 1) both;
}

/* Shared board */
.board-stage {
  position: relative;
  min-width: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0;
  background:
    linear-gradient(rgba(255,255,255,.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.028) 1px, transparent 1px),
    rgba(18, 17, 15, .88);
  background-size: 14px 14px;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.3);
}

.board-frame {
  position: relative;
  width: calc(var(--cell-size) * var(--cols));
  height: calc(var(--cell-size) * var(--rows));
  user-select: none;
  touch-action: none;
  filter: drop-shadow(6px 6px 0 rgba(0,0,0,.32));
  transition: opacity .2s ease;
}
.board-frame.is-loading { opacity: 0; pointer-events: none; }

.board-grid,
.piece-layer {
  position: absolute;
  inset: 0;
}
.board-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell-size));
  grid-template-rows: repeat(var(--rows), var(--cell-size));
}
.piece-layer { pointer-events: none; }

.tile {
  position: relative;
  --capture-base: var(--light-tile);
  --capture-flash: #8f211c;
  width: var(--cell-size);
  height: var(--cell-size);
  padding: max(2px, calc(var(--cell-size) * .035));
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  outline: none;
}
.tile::before {
  content: "";
  position: absolute;
  inset: max(2px, calc(var(--cell-size) * .035));
  border-radius: 0;
  background: var(--light-tile);
  box-shadow:
    inset 2px 2px 0 rgba(255,255,255,.08),
    inset -3px -3px 0 rgba(66,42,24,.18),
    2px 2px 0 rgba(0,0,0,.14);
  transition: background .22s ease, filter .16s ease, opacity .16s ease, transform .16s ease;
}
.tile.dark { --capture-base: var(--dark-tile); }
.tile.visited { --capture-base: var(--visited-light); }
.tile.dark.visited { --capture-base: var(--visited-dark); }
.tile.dark::before { background: var(--dark-tile); }
.tile.visited::before { background: var(--visited-light); }
.tile.dark.visited::before { background: var(--visited-dark); }
.tile.morph-tile::before {
  background: #7d41bb;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.12),
    inset 0 -3px 0 rgba(64, 26, 104, .24),
    0 4px 7px rgba(0,0,0,.16);
}
.tile.morph-tile { --capture-base: #7d41bb; }
.tile.dark.morph-tile::before { background: #65339a; }
.tile.dark.morph-tile { --capture-base: #65339a; }
.tile.morph-tile.visited::before { background: #9057cc; }
.tile.morph-tile.visited { --capture-base: #9057cc; }
.tile.dark.morph-tile.visited::before { background: #7840b3; }
.tile.dark.morph-tile.visited { --capture-base: #7840b3; }
.tile.portal-tile::before {
  opacity: 0;
  box-shadow: none;
}
.tile.portal-tile.portal-violet {
  --portal-c1: #5c0d8b;
  --portal-c2: #6a149d;
  --portal-c3: #781caf;
  --portal-c4: #8623c1;
}
.tile.portal-tile.portal-cyan {
  --portal-c1: #0d5c8b;
  --portal-c2: #14739d;
  --portal-c3: #1c8daf;
  --portal-c4: #23a6c1;
}
.tile.portal-tile.portal-gold {
  --portal-c1: #8b5b0d;
  --portal-c2: #9d6d14;
  --portal-c3: #af821c;
  --portal-c4: #c19723;
}
.tile.break-tile::before {
  background-image:
    linear-gradient(135deg, rgba(255,255,255,.08) 0 10%, transparent 10% 100%),
    linear-gradient(45deg, transparent 0 42%, rgba(37,31,24,.24) 42% 47%, transparent 47% 100%);
}
.tile.broken-spent {
  cursor: default;
  pointer-events: none;
}
.tile.broken-spent::before {
  opacity: .12;
  filter: saturate(.45) brightness(.72);
  background-image:
    linear-gradient(135deg, transparent 0 17%, rgba(21, 17, 13, .5) 17% 23%, transparent 23% 100%),
    linear-gradient(45deg, transparent 0 48%, rgba(255, 255, 255, .08) 48% 53%, transparent 53% 100%);
}
.tile.broken-spent::after {
  content: "";
  position: absolute;
  inset: 22%;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(135deg, transparent 0 40%, rgba(0, 0, 0, .34) 40% 47%, transparent 47% 100%),
    linear-gradient(45deg, transparent 0 55%, rgba(0, 0, 0, .28) 55% 62%, transparent 62% 100%);
  opacity: .55;
}
.tile:not(.inactive):hover::before { filter: brightness(1.08); transform: translateY(-1px); }
.tile:focus-visible::before { box-shadow: inset 0 0 0 3px var(--accent), 0 4px 8px rgba(0,0,0,.2); }

.tile.inactive {
  cursor: default;
  pointer-events: none;
}
.tile.inactive::before { opacity: 0; }

.tile .move-dot,
.tile .capture-ring,
.tile .hint-path-mark,
.tile .tutorial-path-mark,
.tile .start-mark,
.tile .portal-mark,
.tile .break-mark {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  will-change: transform, opacity;
}
.tile .move-dot {
  inset: 10%;
  background:
    linear-gradient(to right, var(--move-indicator) 0 max(2px, calc(var(--cell-size) * .07 - 1px)), transparent max(2px, calc(var(--cell-size) * .07 - 1px)) 100%) top left / 28% 28% no-repeat,
    linear-gradient(to bottom, var(--move-indicator) 0 max(2px, calc(var(--cell-size) * .07 - 1px)), transparent max(2px, calc(var(--cell-size) * .07 - 1px)) 100%) top left / 28% 28% no-repeat,
    linear-gradient(to left, var(--move-indicator) 0 max(2px, calc(var(--cell-size) * .07 - 1px)), transparent max(2px, calc(var(--cell-size) * .07 - 1px)) 100%) top right / 28% 28% no-repeat,
    linear-gradient(to bottom, var(--move-indicator) 0 max(2px, calc(var(--cell-size) * .07 - 1px)), transparent max(2px, calc(var(--cell-size) * .07 - 1px)) 100%) top right / 28% 28% no-repeat,
    linear-gradient(to right, var(--move-indicator) 0 max(2px, calc(var(--cell-size) * .07 - 1px)), transparent max(2px, calc(var(--cell-size) * .07 - 1px)) 100%) bottom left / 28% 28% no-repeat,
    linear-gradient(to top, var(--move-indicator) 0 max(2px, calc(var(--cell-size) * .07 - 1px)), transparent max(2px, calc(var(--cell-size) * .07 - 1px)) 100%) bottom left / 28% 28% no-repeat,
    linear-gradient(to left, var(--move-indicator) 0 max(2px, calc(var(--cell-size) * .07 - 1px)), transparent max(2px, calc(var(--cell-size) * .07 - 1px)) 100%) bottom right / 28% 28% no-repeat,
    linear-gradient(to top, var(--move-indicator) 0 max(2px, calc(var(--cell-size) * .07 - 1px)), transparent max(2px, calc(var(--cell-size) * .07 - 1px)) 100%) bottom right / 28% 28% no-repeat;
}
.tile .capture-ring {
  inset: 10%;
  background:
    linear-gradient(to right, rgba(255, 255, 255, .95) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) top left / 28% 28% no-repeat,
    linear-gradient(to bottom, rgba(255, 255, 255, .95) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) top left / 28% 28% no-repeat,

    linear-gradient(to left, rgba(255, 255, 255, .95) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) top right / 28% 28% no-repeat,
    linear-gradient(to bottom, rgba(255, 255, 255, .95) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) top right / 28% 28% no-repeat,

    linear-gradient(to right, rgba(255, 255, 255, .95) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) bottom left / 28% 28% no-repeat,
    linear-gradient(to top, rgba(255, 255, 255, .95) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) bottom left / 28% 28% no-repeat,

    linear-gradient(to left, rgba(255, 255, 255, .95) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) bottom right / 28% 28% no-repeat,
    linear-gradient(to top, rgba(255, 255, 255, .95) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) bottom right / 28% 28% no-repeat;
}
.tile .hint-path-mark {
  --guide-mark-color: rgba(126, 58, 191, .98);
  inset: 10%;
  background:
    linear-gradient(to right, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) top left / 28% 28% no-repeat,
    linear-gradient(to bottom, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) top left / 28% 28% no-repeat,
    linear-gradient(to left, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) top right / 28% 28% no-repeat,
    linear-gradient(to bottom, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) top right / 28% 28% no-repeat,
    linear-gradient(to right, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) bottom left / 28% 28% no-repeat,
    linear-gradient(to top, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) bottom left / 28% 28% no-repeat,
    linear-gradient(to left, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) bottom right / 28% 28% no-repeat,
    linear-gradient(to top, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) bottom right / 28% 28% no-repeat;
}
.tile .tutorial-path-mark {
  --guide-mark-color: rgba(126, 58, 191, .98);
  inset: 10%;
  background:
    linear-gradient(to right, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) top left / 28% 28% no-repeat,
    linear-gradient(to bottom, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) top left / 28% 28% no-repeat,
    linear-gradient(to left, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) top right / 28% 28% no-repeat,
    linear-gradient(to bottom, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) top right / 28% 28% no-repeat,
    linear-gradient(to right, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) bottom left / 28% 28% no-repeat,
    linear-gradient(to top, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) bottom left / 28% 28% no-repeat,
    linear-gradient(to left, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) bottom right / 28% 28% no-repeat,
    linear-gradient(to top, var(--guide-mark-color) 0 max(2px, calc(var(--cell-size) * .07)), transparent max(2px, calc(var(--cell-size) * .07)) 100%) bottom right / 28% 28% no-repeat;
}
.tutorial-hand-overlay {
  position: absolute;
  z-index: 60;
  width: clamp(42px, calc(var(--cell-size) * .9), 86px);
  height: clamp(42px, calc(var(--cell-size) * .9), 86px);
  pointer-events: none;
  transform: translate(-18%, -10%);
  animation: tutorialHandFloat 1s cubic-bezier(.22,.9,.34,1) infinite;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.28));
}
.tutorial-hand-overlay svg {
  width: 100%;
  height: 100%;
  display: block;
}
.tile.capture-target::before {
  background: var(--capture-base);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.12),
    inset 0 -3px 0 rgba(64, 10, 10, .22),
    0 4px 7px rgba(0,0,0,.16);
  animation: captureTilePulse .82s ease-in-out infinite;
}
.tile.dark.capture-target::before {
  background: var(--capture-base);
}
.tile .start-mark {
  inset: 12%;
  border: max(2px, calc(var(--cell-size) * .035)) solid rgba(255, 227, 144, .78);
  border-radius: 0;
}
.tile .portal-mark {
  inset: max(2px, calc(var(--cell-size) * .035));
  border: solid max(3px, calc(var(--cell-size) * .12)) var(--portal-c1, #5c0d8b);
  background: var(--portal-c2, #6a149d);
  animation: portalColors 2s linear infinite;
}
.tile .portal-mark::before,
.tile .portal-mark::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.tile .portal-mark::before {
  width: 62%;
  height: 62%;
  background: var(--portal-c3, #781caf);
  animation: portalBeforeColors 2s linear infinite;
}
.tile .portal-mark::after {
  width: 24%;
  height: 24%;
  background: var(--portal-c4, #8623c1);
  animation: portalAfterColors 2s linear infinite;
}
.tile .break-mark {
  inset: 28%;
  background:
    linear-gradient(135deg, transparent 0 22%, rgba(66, 48, 33, .68) 22% 28%, transparent 28% 100%),
    linear-gradient(35deg, transparent 0 38%, rgba(66, 48, 33, .62) 38% 45%, transparent 45% 100%),
    linear-gradient(160deg, transparent 0 54%, rgba(255,255,255,.12) 54% 59%, transparent 59% 100%);
  opacity: .78;
}
.tile .move-dot,
.tile .capture-ring,
.tile .hint-path-mark,
.tile .tutorial-path-mark {
  opacity: .88;
  animation: moveIndicatorBreath 2.15s ease-in-out infinite;
}
.tile.is-last::after {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 0;
  background: rgba(255, 226, 132, .18);
  pointer-events: none;
}

.piece {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cell-size);
  height: var(--cell-size);
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
  cursor: pointer;
  z-index: 10;
  display: grid;
  place-items: center;
  will-change: left, top, opacity;
}
.piece.black-piece { cursor: default; z-index: 8; pointer-events: none; }
@keyframes captureTilePulse {
  0%, 100% { background: var(--capture-base); }
  50% { background: var(--capture-flash); }
}
@keyframes moveIndicatorBreath {
  0%, 100% { transform: scale(.985); }
  50% { transform: scale(1.02); }
}
@keyframes tutorialHandFloat {
  0%, 100% { transform: translate(-18%, -10%) rotate(-8deg) scale(1); }
  25% { transform: translate(-14%, -19%) rotate(-3deg) scale(1.08); }
  55% { transform: translate(-10%, -5%) rotate(2deg) scale(.96); }
  75% { transform: translate(-16%, -14%) rotate(-1deg) scale(1.04); }
}
@keyframes portalColors {
  0%, 100% {
    border-color: var(--portal-c1, #5c0d8b);
    background: var(--portal-c2, #6a149d);
  }
  25% {
    border-color: var(--portal-c2, #6a149d);
    background: var(--portal-c3, #781caf);
  }
  50% {
    border-color: var(--portal-c3, #781caf);
    background: var(--portal-c4, #8623c1);
  }
  75% {
    border-color: var(--portal-c4, #8623c1);
    background: var(--portal-c1, #5c0d8b);
  }
}
@keyframes portalBeforeColors {
  0%, 100% { background: var(--portal-c3, #781caf); }
  25% { background: var(--portal-c4, #8623c1); }
  50% { background: var(--portal-c1, #5c0d8b); }
  75% { background: var(--portal-c2, #6a149d); }
}
@keyframes portalAfterColors {
  0%, 100% { background: var(--portal-c4, #8623c1); }
  25% { background: var(--portal-c1, #5c0d8b); }
  50% { background: var(--portal-c2, #6a149d); }
  75% { background: var(--portal-c3, #781caf); }
}
.piece-sprite {
  display: block;
  width: var(--piece-size);
  height: var(--piece-size);
  object-fit: contain;
  object-position: center;
  image-rendering: pixelated;
  pointer-events: none;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
}

.loading-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 13px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 750;
  letter-spacing: .03em;
}
.loading-state p { margin: 0; }
.loading-mark {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255,255,255,.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes uiIconHoverBounce {
  from { transform: scaleX(var(--icon-mirror)) scale(1); }
  to { transform: scaleX(var(--icon-mirror)) scale(1.14); }
}

@keyframes uiIconReleasePop {
  0% { transform: scaleX(var(--icon-mirror)) scale(.86); }
  45% { transform: scaleX(var(--icon-mirror)) scale(1.16); }
  100% { transform: scaleX(var(--icon-mirror)) scale(1); }
}

/* Game */
.game-page { overflow-x: hidden; }
.game-shell {
  width: min(900px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
}
.game-hud,
.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.level-copy h1 { font-size: clamp(1.7rem, 5vw, 3rem); }
.hud-actions { display: flex; align-items: center; gap: 9px; }
.progress-chip {
  min-height: 42px;
  min-width: 82px;
  padding: 7px 12px;
  display: grid;
  place-content: center;
  justify-items: center;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255,255,255,.045);
  box-shadow: inset -2px -2px 0 rgba(0,0,0,.25), inset 2px 2px 0 rgba(255,255,255,.03);
  line-height: 1;
}
.progress-chip span { font-size: .9rem; font-weight: 900; }
.progress-chip small { margin-top: 4px; color: var(--muted); font-size: .58rem; text-transform: uppercase; letter-spacing: .12em; }
.game-stage { min-height: min(72vh, 720px); padding: 20px; }
.game-footer { color: var(--muted); font-size: .8rem; }
.game-footer p { margin: 0; }
.game-footer span { white-space: nowrap; color: var(--text); font-weight: 800; }
.music-button { width: 42px; height: 42px; flex: 0 0 auto; }
.music-button .music-icon { width: 22px; height: 22px; }
.music-button[aria-pressed="true"] { opacity: .55; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 25px;
  z-index: 90;
  transform: translate(-50%, 20px);
  padding: 11px 15px;
  border: 1px solid rgba(239,109,98,.42);
  border-radius: 0;
  background: rgba(39, 24, 22, .95);
  color: #ffc0ba;
  box-shadow: 0 14px 30px rgba(0,0,0,.3);
  opacity: 0;
  pointer-events: none;
  font-size: .82rem;
  font-weight: 800;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(5,5,4,.72);
  backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.modal.open { visibility: visible; pointer-events: auto; }
.modal-card {
  width: min(460px, 100%);
  padding: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: #1d1b18;
  box-shadow: 8px 8px 0 rgba(0,0,0,.32);
}
.modal-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: center; gap: 9px; margin-top: 20px; }
.modal-actions.wrap { flex-wrap: wrap; justify-content: flex-start; }
.complete-card { text-align: center; }
.complete-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 17px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--success);
  color: #142016;
  font-size: 2rem;
  font-weight: 1000;
}
.complete-card p:not(.eyebrow) { margin: 12px 0 0; color: var(--muted); }
.json-card { width: min(760px, 100%); }
.json-card textarea {
  width: 100%;
  height: min(54vh, 430px);
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  background: #11100e;
  color: #e7dfd4;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  tab-size: 2;
}
.json-card textarea:focus { border-color: rgba(243,185,95,.5); }
.json-message { min-height: 18px; margin: 8px 0 0; color: var(--muted); font-size: .73rem; }
.json-message.error { color: #ffada6; }
.json-message.success { color: #a8dfb4; }

.particle {
  position: fixed;
  z-index: 130;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--accent);
  pointer-events: none;
}

@media (max-width: 700px) {
  .game-shell { padding: 14px; }
  .game-hud { align-items: center; }
  .game-footer { align-items: flex-start; }
  .game-footer p { max-width: 70%; }
  .game-stage { min-height: calc(100vh - 190px); padding: 10px; border-radius: 0; }
  .modal-card { padding: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
