@font-face {
  font-family: "Barlow Condensed";
  src: url(../assets/arcade/barlow-condensed-1.ttf) format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

.number-campaign {
  --cream: #fff0d8;
  --lavender: #d6cde8;
  --display: "Barlow Condensed", "Inter", sans-serif;
  --rainbow: linear-gradient(112deg, #fff0a7 3%, #ffc5a1 29%, #f5b7ef 51%, #bdc1ff 72%, #a2f2d7 100%);
  --well: #131321;
  font-family: "Inter", sans-serif;
  color: var(--cream);
  scroll-margin-top: 12px;
}
.number-campaign *, .number-campaign *::before, .number-campaign *::after { box-sizing: border-box; }
.number-campaign [hidden] { display: none !important; }
.number-campaign ::selection { color: #20152f; background: #f9cafa; }
.number-campaign button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.number-campaign button:disabled { cursor: default; }
.number-campaign :focus-visible { outline: 3px solid #ffe19c; outline-offset: 4px; }
.number-campaign [tabindex="-1"]:focus { outline: none; }
.number-campaign :is(h1, h2, h3, p) { margin: 0; }

.number-home, .number-play {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  align-items: center;
  gap: clamp(24px, 5vw, 80px);
  padding: clamp(24px, 4vw, 58px);
  border: 1px solid #453658;
  border-radius: 26px;
  background:
    radial-gradient(ellipse at 78% 43%, #512c5d88, transparent 53%),
    radial-gradient(ellipse at 32% 0, #392a5182, transparent 66%),
    linear-gradient(153deg, #201b35, #181526 76%);
}
.number-home { min-height: clamp(390px, 42vw, 565px); overflow: hidden; isolation: isolate; }
#home-title {
  font: 700 clamp(3rem, 6vw, 6rem)/.86 var(--display);
  letter-spacing: -.022em;
  text-shadow: 0 3px #a46568, 0 5px #74495e, 0 9px 18px #120c22aa;
}
#home-title > span { display: block; color: #ffe1ad; }
#home-title > span + span { color: #ffbedb; }
#home-title small {
  display: block;
  margin-top: .36em;
  color: #bdf3e3;
  font-size: .47em;
  line-height: 1.12;
  letter-spacing: 0;
  text-shadow: 0 2px #547678, 0 5px 12px #130e26b8;
}
.number-intro p, .play-rules {
  max-width: 35ch;
  margin-top: 20px !important;
  color: var(--lavender);
  font-size: clamp(.89rem, 1.18vw, 1.05rem);
  line-height: 1.6;
}
.home-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 20px; }
.home-progress {
  width: min(100%, 326px);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .77rem;
  font-weight: 650;
  color: var(--lavender);
  white-space: nowrap;
}
.home-progress progress {
  appearance: none;
  flex: 1;
  min-width: 0;
  height: 7px;
  border: 0;
  border-radius: 99px;
  overflow: hidden;
  background: #100e1b;
}
.home-progress progress::-webkit-progress-bar { background: #100e1b; }
.home-progress progress::-webkit-progress-value { background: var(--rainbow); }
.home-progress progress::-moz-progress-bar { background: var(--rainbow); }

.number-button {
  --tone: #d3bdff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 9px 15px 12px;
  border: 1px solid #ffffff40;
  border-radius: 11px;
  color: #241732;
  background: linear-gradient(155deg, color-mix(in srgb, var(--tone) 58%, #fff6eb), var(--tone) 76%);
  box-shadow: inset 0 1px #ffffffa8, inset 0 -4px color-mix(in srgb, var(--tone) 56%, #34234d), 0 5px 10px #120e2590;
  font: 750 .88rem/1.15 "Inter", sans-serif;
  white-space: nowrap;
  transition: transform 140ms ease, filter 140ms ease;
}
.number-button:hover:enabled { filter: brightness(1.075); transform: translateY(-2px); }
.number-button:active:enabled { transform: translateY(2px); }
.number-button.rainbow { background: var(--rainbow); box-shadow: inset 0 1px #fffbc9, inset 0 -4px #74436b75, 0 6px 14px #190e2d90; }
.number-button.primary { min-height: 54px; padding-inline: 18px; font-size: .94rem; }
.number-button.violet { --tone: #ceb5ff; }
.number-button.sky { --tone: #9bdefa; }
.number-button.gold { --tone: #ffdc87; }
.number-button.rose { --tone: #ffaecb; }
.number-button.quiet {
  color: #f5e8ff;
  border-color: #6e5a7d;
  background: #342746;
  box-shadow: inset 0 -3px #221931, 0 3px 8px #100d1d66;
}
.number-button:disabled {
  color: #c0b5d1;
  border-color: #4a405a;
  background: #30283e;
  box-shadow: inset 0 -3px #211b2c;
}
.play-icon {
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-right: 0;
  border-left: 8px solid currentColor;
}
.chevron { width: 7px; height: 7px; border: solid currentColor; border-width: 0 0 2px 2px; }
.chevron.left { transform: rotate(45deg); }
.check { width: 12px; height: 7px; border: solid currentColor; border-width: 0 0 2px 2px; transform: rotate(-45deg); }
.lock { position: relative; width: 11px; height: 9px; margin-top: 4px; border: 1.5px solid currentColor; border-radius: 2px; }
.lock::before { content: ""; position: absolute; top: -6px; left: 1px; width: 6px; height: 6px; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 5px 5px 0 0; }

.number-preview {
  width: min(100%, 392px);
  align-self: center;
  justify-self: center;
  padding: 7% 6%;
}
.preview-board {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10%;
  background: linear-gradient(135deg, #49406b, #242039);
  box-shadow: 0 9px #342645, 0 15px #241833, 0 22px 24px #110e25a8, -12px 28px 50px #100d22a6, inset 0 1px #fff3;
  outline: 1px solid #7b6196;
  transform: perspective(800px) rotateX(27deg) rotateZ(-13deg);
}
.preview-cells, .preview-route { position: absolute; inset: 6%; }
.preview-cells { display: grid; grid-template: repeat(4, minmax(0, 1fr)) / repeat(4, minmax(0, 1fr)); gap: 3%; }
.preview-cells i {
  border-radius: 13%;
  background: linear-gradient(155deg, #484164, #322b4e 85%);
  box-shadow: inset 0 1px #fff2, inset 0 -3px #261f3b;
}
.preview-route :is(i,b) {
  position: absolute;
  top: calc(var(--y) * 25%);
  left: calc(var(--x) * 25%);
}
.preview-route i {
  width: 5%;
  height: 30%;
  background: var(--tone);
  border-radius: 99px;
  transform: translate(-50%, -8.333%);
  box-shadow: inset 1px 1px #fff9, 0 3px 4px #1a122c99;
}
.preview-route i.horizontal { width: 30%; height: 5%; transform: translate(-8.333%, -50%); }
.preview-route b {
  z-index: 1;
  display: grid;
  place-items: center;
  width: 21%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 15%;
  background: linear-gradient(145deg, color-mix(in srgb, var(--tone) 61%, #fff4db), var(--tone));
  color: #281933;
  box-shadow: inset 0 1px #fff9, inset 0 -4px color-mix(in srgb, var(--tone) 62%, #332145), 0 5px 6px #110b25a6;
  font: 700 clamp(1.3rem, 3.2vw, 2.75rem)/1 var(--display);
}

.number-map {
  padding: clamp(18px, 3.8vw, 52px);
  border: 1px solid #413353;
  border-radius: 22px;
  background: linear-gradient(150deg, #2e2543, #1a1629 82%);
}
.map-top { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.screen-title { color: #fff0d8; font: 700 clamp(2.8rem, 5.6vw, 5rem)/.94 var(--display); letter-spacing: -.02em; }
.map-top .screen-title, .play-info .screen-title { margin-top: 16px; }
.map-count, .map-chapter p, .map-help, .play-detail { color: var(--lavender); font-size: .86rem; line-height: 1.48; }
.map-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.chapter-strip {
  display: grid;
  grid-template-columns: repeat(10, minmax(44px, 1fr));
  gap: 7px;
  padding: 6px 2px 10px;
  margin: 18px -2px 4px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #8d76ad #221b31;
}
.chapter-button { padding-inline: 2px; }
.chapter-button:not([aria-pressed="true"]) {
  background: #332743;
  border-color: #5f4c71;
  box-shadow: inset 0 -3px #251d31;
  color: #e4d8f0;
}
.map-panel { margin-top: 10px; padding: clamp(12px, 2.1vw, 25px); border-radius: 15px; background: #13101e; border: 1px solid #493953; }
.map-chapter { display: flex; align-items: baseline; flex-wrap: wrap; justify-content: space-between; gap: 5px 14px; }
.map-chapter h3 { color: #fff0d8; font: 700 1.8rem/1 var(--display); }
.level-grid { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 8px; margin-top: 18px; }
.level-button {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 58px;
  padding: 7px 1px 10px;
  font: 700 clamp(1.12rem, 2.6vw, 1.75rem)/1 var(--display);
  font-variant-numeric: tabular-nums;
}
.level-button[aria-current="step"] { background: var(--rainbow); border-color: #fff8c7; }
.level-button .play-icon { border-width: 4px 0 4px 7px; }
.map-panel .map-help { margin-top: 14px; }

.number-play {
  grid-template-columns: minmax(175px, 1fr) minmax(0, 540px);
  gap: clamp(22px, 4vw, 62px);
  padding: clamp(16px, 3vw, 44px);
}
.play-info .play-detail { margin-top: 9px; }
.play-info .number-button.violet { margin-top: 18px; }
.number-board-panel { width: 100%; }
.board-shell {
  padding: clamp(5px, 1vw, 11px);
  background: var(--well);
  border-radius: 14px;
  box-shadow: inset 0 3px 10px #080916c0, 0 1px #ffffff2a;
}
.board {
  --size: 4;
  --gap: clamp(2px, .55vw, 7px);
  position: relative;
  aspect-ratio: 1;
  touch-action: none;
  user-select: none;
  isolation: isolate;
  container-type: inline-size;
}
.board:is([data-size="8"], [data-size="9"], [data-size="10"]) { --gap: clamp(2px, .36vw, 5px); }
.tiles { position: absolute; inset: 0; display: grid; gap: var(--gap); grid-template: repeat(var(--size), minmax(0, 1fr)) / repeat(var(--size), minmax(0, 1fr)); }
.tile {
  --base: #28243c;
  --top: #38314d;
  --face: #2d273f;
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: clamp(4px, .65vw, 8px);
  background: linear-gradient(155deg, var(--top), var(--face) 68%);
  box-shadow: inset 0 1px #ffffff19, inset 0 -3px var(--base);
  color: #21182c;
  touch-action: none !important;
}
.tile.visited:not(.numbered) {
  --base: color-mix(in srgb, var(--tone) 23%, #22223a);
  --top: color-mix(in srgb, var(--tone) 37%, #292940);
  --face: color-mix(in srgb, var(--tone) 24%, #22223a);
}
.tile.numbered {
  --base: color-mix(in srgb, var(--tone) 61%, #21152b);
  --top: color-mix(in srgb, var(--tone) 66%, #fffbdf);
  --face: var(--tone);
  z-index: 1;
  box-shadow: inset 0 1px #fff9, inset 0 -3px var(--base), 0 2px 5px #08081c55;
}
.tile.numbered span { padding-bottom: 2px; font: 700 clamp(.9rem, calc(62cqw / var(--size)), 2.85rem)/1 var(--display); }
.tile.head { outline: 2px solid #fff3; outline-offset: -3px; }
.tile.start-ready { outline: 2px solid #f5ffcf; outline-offset: -3px; }
.tile:focus-visible { outline: 3px solid #fff0a8; outline-offset: -3px; z-index: 2; }
@media (hover: hover) { .tile:hover { filter: brightness(1.12); } }
#trail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.readout, .game-footer { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.readout { margin-top: 12px; }
.progress { flex: 1; height: 7px; border-radius: 99px; background: var(--well); overflow: hidden; }
.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--rainbow);
  transform: scaleX(var(--coverage, 0));
  transform-origin: left;
  transition: transform 150ms ease-out;
}
#coverage { font-size: .78rem; color: var(--lavender); font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.game-footer { min-height: 46px; margin-top: 9px; }
#status { color: #f2e5fb; font-size: .85rem; line-height: 1.4; }
.number-tools { display: flex; gap: 6px; margin-left: auto; flex: 0 0 auto; }
.number-tools .number-button { padding-inline: 10px; font-size: .77rem; min-height: 44px; }

.number-win {
  position: fixed;
  width: min(440px, calc(100vw - 28px));
  max-height: calc(100dvh - 32px);
  padding: 22px clamp(17px, 5vw, 33px) 27px;
  border: 1px solid #a983b7;
  border-radius: 25px;
  color: var(--cream);
  background: radial-gradient(ellipse at 50% 10%, #734384, transparent 58%), linear-gradient(155deg, #362540, #211830 80%);
  text-align: center;
  box-shadow: inset 0 2px #fff5, inset 0 -7px #190e28, 0 22px 70px #0b0818d9;
  animation: win-arrive 420ms cubic-bezier(.22, 1, .36, 1) both;
}
.number-win::backdrop { background: #110d1bd7; }
.win-art { position: relative; height: 112px; display: grid; place-items: center; perspective: 500px; }
.win-medal {
  display: grid;
  width: 76px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  color: #542853;
  background: var(--rainbow);
  box-shadow: inset 0 0 0 4px #fff4ce85, inset 0 1px 6px #fff, 0 6px #aa676d, 0 12px 22px #1c102fa8;
  transform: rotateX(17deg) rotateZ(-14deg);
  animation: medal-arrive 570ms .09s cubic-bezier(.22, 1, .36, 1) backwards;
}
.win-medal .check { width: 35px; height: 20px; border-width: 0 0 6px 6px; transform: translateY(-4px) rotate(-33deg); }
.win-spark { --spark: #aaf3dd; position: absolute; width: 11px; height: 11px; border-radius: 3px; background: var(--spark); transform: rotate(45deg); box-shadow: inset 0 1px #fff8, 0 3px 6px #21152d; animation: spark-arrive 510ms .2s ease-out backwards; }
.win-spark:nth-child(1) { left: 23%; top: 28%; }
.win-spark:nth-child(2) { --spark: #f8c8ff; right: 24%; top: 23%; width: 7px; height: 7px; animation-delay: .33s; }
.win-spark:nth-child(3) { --spark: #ffe09a; right: 17%; top: 63%; animation-delay: .29s; }
.win-spark:nth-child(4) { --spark: #c6bbff; left: 19%; top: 69%; width: 6px; height: 6px; animation-delay: .4s; }
.number-win h2 { color: #ffe0a5; font: 700 clamp(2.75rem, 9vw, 4rem)/.96 var(--display); letter-spacing: -.018em; text-shadow: 0 3px #a76363, 0 5px #5f3757, 0 9px 17px #170c268a; }
.number-win p { color: #f1e4fb; line-height: 1.5; font-size: .94rem; margin-top: 13px; }
.win-actions { display: grid; gap: 9px; max-width: 275px; margin: 20px auto 0; }
.win-actions > div { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
@keyframes win-arrive { from { opacity: 0; transform: translateY(18px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes medal-arrive { from { opacity: 0; transform: translateY(-20px) rotateX(50deg) rotateZ(-49deg) scale(.65); } }
@keyframes spark-arrive { from { opacity: 0; transform: scale(.2) rotate(80deg); } }

.puzzle-guide { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 40px; margin-top: 22px; padding: 24px; }
.puzzle-guide :is(h2,h3) { margin-top: 0; }
.puzzle-guide a { text-underline-offset: .2em; }

@media (max-width: 1100px) {
  .level-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 740px) {
  .number-home { gap: 16px; padding: 24px; }
  .home-actions { gap: 8px; }
  .number-play { gap: 14px; }
}
@media (max-width: 590px) {
  .number-home, .number-play { grid-template-columns: minmax(0, 1fr); border-radius: 18px; }
  .number-home { display: flex; flex-direction: column; padding: 24px 16px 18px; gap: 15px; }
  .number-intro { width: 100%; }
  #home-title { font-size: clamp(3.15rem, 13vw, 4.4rem); }
  .number-preview { width: min(74%, 260px); padding: 5% 7% 9%; }
  .preview-route b { font-size: 1.58rem; }
  .chapter-strip { grid-template-columns: repeat(5, minmax(44px, 1fr)); margin-top: 10px; }
  .chapter-button { min-height: 44px; }
  .number-play { padding: 9px; }
  .board-shell { padding: 4px; }
  .play-info { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
  .play-info .back-button { order: 0; margin-right: auto; }
  .play-info .number-button.violet { order: 1; margin-top: 0; }
  .play-info .screen-title { order: 2; margin-top: 4px; flex-basis: 100%; font-size: 2.52rem; }
  .play-info .play-detail { order: 3; margin-top: 0; }
  .play-info .play-rules { display: none; }
  .game-footer { flex-wrap: wrap; }
  #status { flex: 1 0 105px; font-size: .77rem; }
  .puzzle-guide { grid-template-columns: 1fr; gap: 8px; padding: 16px; }
}
@media (max-width: 370px) {
  .number-tools { width: 100%; }
  .number-tools .number-button { flex: 1; }
  .number-button { padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .number-campaign *, .number-campaign *::before, .number-campaign *::after { animation: none !important; transition: none !important; }
}
