:root {
  color-scheme: light;
  --ink: #43384e;
  --plum: #78609b;
  --paper: #fcf5e7;
  --muted: #766e7a;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
body {
  background: #e9e7da;
  color: var(--ink);
  font-family: ui-rounded, 'Avenir Next', Avenir, 'Trebuchet MS', sans-serif;
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}
button {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border: 0;
  color: inherit;
}
button:focus-visible {
  outline: 4px solid #8060a5;
  outline-offset: 5px;
}
button:active {
  transform: scale(0.96);
}
[hidden] {
  display: none !important;
}
#frame {
  position: relative;
  width: min(100vw, 150vh);
  width: min(100%, 150dvh);
  height: auto;
  max-height: 100%;
  aspect-ratio: 3/2;
  overflow: hidden;
  background: #f0e8d7;
  box-shadow: 0 8px 80px #6c685329;
  isolation: isolate;
}
#world,
#hotspots,
#hud,
#welcome,
#transition {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#world,
#hotspots {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#world {
  display: block;
}
#hotspots {
  z-index: 2;
}
#hotspots button {
  position: absolute;
  background: transparent;
  border: 0;
  opacity: 0;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}
#hotspots button:focus-visible {
  opacity: 1;
  background: #fff4;
  border-radius: 35%;
}
#hud {
  z-index: 3;
  pointer-events: none;
}
#hud button {
  pointer-events: auto;
}
#hud.celebrating button {
  pointer-events: none;
}
.round {
  position: absolute;
  top: 3%;
  width: clamp(44px, 5.5vw, 64px);
  height: clamp(44px, 5.5vw, 64px);
  display: grid;
  place-items: center;
  background: #fff8e8e6;
  border: 1px solid #fff9;
  border-radius: 50%;
  box-shadow: 0 3px 10px #49374216;
}
.round svg {
  width: 27px;
  height: 27px;
}
.top-left {
  left: 2.3%;
}
.explore-reset {
  left: 9%;
}
.top-right {
  right: 2.3%;
}
#collection {
  position: absolute;
  left: 50%;
  top: 3%;
  transform: translateX(-50%);
  width: clamp(180px, 48%, 430px);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 32px;
  background: #fff8e8e8;
  box-shadow: 0 3px 10px #49374216;
}
#piece-slots {
  display: flex;
  flex: 1;
  min-width: 0;
}
#piece-slots canvas {
  width: 16.666%;
  height: auto;
  aspect-ratio: 1;
}
#piece-slots canvas.collected {
  animation: piece-reveal 0.5s ease-out;
}
#piece-count {
  font-size: clamp(13px, 1.8vw, 22px);
  color: #746080;
  white-space: nowrap;
}
#collection.complete {
  box-shadow:
    0 0 0 2px #b798ce80,
    0 3px 10px #49374216;
}
.restart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.restart svg {
  width: 32px;
  height: 32px;
  flex: none;
}
@keyframes piece-reveal {
  from {
    transform: scale(0.65);
  }
  60% {
    transform: scale(1.13);
  }
  to {
    transform: scale(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  #piece-slots canvas.collected {
    animation: none;
  }
}
#cats {
  position: absolute;
  left: 3%;
  bottom: 2.5%;
  display: flex;
  gap: 10px;
}
.portrait {
  position: relative;
  width: clamp(64px, 8.4vw, 110px);
  height: clamp(69px, 9vw, 118px);
  background: #faf1e0d9;
  border: 3px solid transparent;
  border-radius: 45% 45% 35% 35%;
  box-shadow: 0 3px 14px #3b2a2c1a;
  padding: 0 0 5px;
}
.portrait[aria-pressed='true'] {
  border-color: #8d73b0;
  background: #fff8e9;
  box-shadow: 0 0 0 4px #fffa;
}
.portrait[aria-pressed='true']:after {
  content: '◆';
  position: absolute;
  top: -15px;
  left: calc(50% - 6px);
  font-size: 13px;
  color: #795a9d;
}
.portrait canvas {
  width: 100%;
  height: 82%;
  object-fit: contain;
  pointer-events: none;
}
.portrait span {
  display: block;
  font-size: clamp(11px, 1.3vw, 15px);
  line-height: 1;
}
#welcome {
  z-index: 5;
  background: linear-gradient(90deg, #fbf1dfef 0%, #fbf1dfdb 31%, #fbf1df12 64%);
}
.intro {
  position: absolute;
  left: 7%;
  top: 11%;
  width: 49%;
}
.eyebrow {
  font-size: clamp(9px, 1vw, 12px);
  letter-spacing: 0.19em;
  font-weight: 700;
  color: #84737f;
  margin: 0 0 18px;
}
h1 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(45px, 7.6vw, 98px);
  line-height: 0.95;
  letter-spacing: -0.055em;
  font-weight: 400;
  margin: 0;
  color: #493e50;
}
h1 i {
  font-size: 0.52em;
  font-weight: 400;
  color: #9275a2;
}
h1 span {
  display: block;
  font-size: clamp(17px, 2.3vw, 30px);
  letter-spacing: -0.015em;
  line-height: 1.35;
  margin-top: 23px;
  color: #775981;
}
.intro-copy {
  font-size: clamp(13px, 1.55vw, 20px);
  line-height: 1.65;
  color: #746570;
  margin: 20px 0 22px;
}
#play {
  display: flex;
  align-items: center;
  gap: 18px;
  border-radius: 50px;
  background: #8262a1;
  color: #fff9ef;
  padding: 17px 28px;
  font-size: clamp(16px, 1.7vw, 22px);
  box-shadow:
    0 6px 0 #63457c,
    0 12px 28px #7758842b;
  min-height: 54px;
}
#play:disabled {
  opacity: 0.6;
  cursor: wait;
}
.small-note {
  font-size: clamp(10px, 1.1vw, 14px);
  color: #8b7b82;
  margin-top: 22px;
}
.cover-caption {
  position: absolute;
  bottom: 13%;
  left: 59%;
  width: 32%;
  text-align: center;
  color: #fff9e9;
  text-shadow: 0 2px 6px #342d37;
  font:
    italic clamp(18px, 2.4vw, 30px) Georgia,
    serif;
}
.cover-caption span {
  margin: 0 24px;
  font-size: 0.7em;
}
#transition {
  background: #faf2e0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s;
}
#transition.on {
  opacity: 1;
}
dialog {
  border: 1px solid #fffc;
  border-radius: 28px;
  background: #fff8eb;
  color: var(--ink);
  padding: 38px;
  width: min(680px, 92vw);
  max-height: 88dvh;
  box-shadow: 0 20px 90px #32283e33;
}
dialog::backdrop {
  background: #3d30475e;
  backdrop-filter: blur(4px);
}
dialog h2 {
  font-family: Georgia, serif;
  font-weight: 400;
  font-size: 30px;
  margin: 0 0 24px;
}
.finale-content {
  text-align: center;
}
.finale-stars {
  display: block;
  color: #a884bf;
  font-size: 34px;
  letter-spacing: 12px;
}
.finale-content h2 {
  margin: 10px 0;
  font-size: clamp(32px, 5vw, 48px);
}
.finale-content p,
#explore-reset-dialog p {
  line-height: 1.5;
}
.finale-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-top: 24px;
}
.close {
  position: absolute;
  right: 12px;
  top: 12px;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  background: #ece2d7;
  font-size: 29px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 18px 0;
}
.toggle,
.primary {
  background: #8262a1;
  color: #fff;
  padding: 13px 18px;
  border-radius: 22px;
  min-height: 48px;
}
.toggle[aria-pressed='false'] {
  background: #e7ded7;
  color: #67596b;
}
.help {
  line-height: 1.65;
  font-size: 14px;
  color: #7d717c;
}
.text-button {
  min-height: 48px;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
  color: #7b5c8a;
  padding: 10px 0;
}
.dialog-note {
  text-align: center;
  color: #8f7d88;
  font:
    italic 16px Georgia,
    serif;
}
#map-places {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.map-place {
  padding: 0;
  overflow: hidden;
  border-radius: 15px;
  background: #f0e4d4;
  position: relative;
  min-height: 100px;
}
.map-place .thumb {
  display: block;
  aspect-ratio: 1.5;
  background-image: url('assets/worlds.webp?v=20260928b');
  background-size: 200% 300%;
  border-radius: 15px;
}
.map-place.current {
  outline: 3px solid #9676b2;
  outline-offset: 3px;
}
.map-place:disabled {
  opacity: 0.45;
  cursor: default;
}
.map-place .found {
  position: absolute;
  right: 8px;
  top: 8px;
  border-radius: 50%;
  background: #fff9eb;
  padding: 4px;
  color: #69577b;
}
#orientation {
  display: none;
  /* Absolute positioning avoids a WebKit fixed-layer viewport loop on rotation. */
  position: absolute;
  left: 0;
  right: 0;
  justify-content: center;
  padding: 0 12px;
  bottom: max(10px, env(safe-area-inset-bottom));
  align-items: center;
  gap: 12px;
  color: #786783;
  pointer-events: none;
  font-size: 14px;
  text-align: center;
}
#orientation span {
  font-size: 36px;
}
#orientation p {
  margin: 0;
}
@media (orientation: portrait) {
  #orientation {
    display: flex;
  }
  #frame {
    width: 100%;
  }
  dialog {
    padding: 30px 22px;
  }
  #map-places {
    gap: 10px;
  }
  .intro {
    top: 8%;
  }
  .intro-copy {
    margin: 12px 0;
  }
  h1 span {
    margin-top: 12px;
  }
  #play {
    padding: 12px 22px;
  }
  .small-note {
    margin-top: 15px;
  }
}
@media (max-width: 600px) and (orientation: portrait) {
  .intro {
    left: 6%;
    width: 58%;
  }
  .intro .eyebrow,
  .intro-copy,
  .small-note,
  .cover-caption {
    display: none;
  }
  h1 {
    font-size: clamp(34px, 9.5vw, 54px);
  }
  h1 span {
    margin-top: 8px;
    font-size: clamp(14px, 3.8vw, 20px);
    line-height: 1.25;
  }
  #play {
    margin-top: 14px;
    min-height: 48px;
    padding: 10px 18px;
    gap: 10px;
    font-size: 16px;
  }
}
@media (max-height: 550px) and (orientation: landscape) {
  #frame {
    width: 150vh;
    width: 150dvh;
  }
  .intro {
    top: 8%;
  }
  h1 {
    font-size: 12vh;
  }
  h1 span {
    font-size: 3.5vh;
    margin-top: 10px;
  }
  .intro-copy {
    font-size: 3vh;
    margin: 10px 0;
  }
  #play {
    font-size: 3vh;
    padding: 10px 22px;
  }
  .small-note {
    margin-top: 15px;
  }
  .eyebrow {
    margin-bottom: 10px;
  }
  .portrait {
    width: 64px;
    height: 69px;
  }
}
@media (max-width: 600px) and (orientation: portrait),
  (max-width: 950px) and (max-height: 550px) and (orientation: landscape) {
  #cats {
    gap: 6px;
  }
  .portrait {
    width: 50px;
    height: 54px;
  }
  .portrait span {
    font-size: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* The pieces themselves live on the touch surface below the compact tally. */
#collection {
  width: auto;
  min-width: 72px;
  justify-content: center;
}
#piece-slots {
  display: none;
}

#collection {
  top: 12.5%;
  left: auto;
  right: 25%;
  transform: none;
  min-width: 40px;
  padding: 2px 8px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#welcome {
  display: grid;
  place-items: center;
  background: #fbf1df36;
}
#play {
  width: clamp(82px, 12vw, 138px);
  height: clamp(82px, 12vw, 138px);
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #8262a1;
  box-shadow: 0 7px 0 #63457c, 0 14px 35px #45325066;
}
#play svg {
  width: 48%;
  height: 48%;
  margin-left: 6%;
  fill: currentColor;
}
#play:disabled {
  opacity: 0.6;
}

#settings {
  width: min(390px, 90vw);
  padding: 58px 32px 28px;
}
.setting-row {
  margin: 10px 0;
  padding: 8px 0;
}
.setting-icon {
  width: 46px;
  height: 46px;
  fill: none;
  stroke: #705781;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.toggle {
  position: relative;
  width: 78px;
  height: 48px;
  padding: 0;
  border-radius: 26px;
  background: #8262a1;
}
.toggle-mark {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fffaf0;
  box-shadow: 0 2px 5px #33263b33;
  transition: left 0.2s, right 0.2s;
}
.toggle[aria-pressed='false'] .toggle-mark {
  right: 36px;
}
.settings-actions {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #ded1d9;
}
.icon-button {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #eee3d8;
  color: #715985;
  text-decoration: none;
}
.icon-button svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#reset-confirm {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 14px;
  padding: 15px 0 0;
  border-top: 1px solid #ded1d9;
}
#reset-yes {
  background: #8262a1;
  color: #fff;
}
#reset-no {
  font-size: 34px;
  line-height: 1;
}
#map-dialog {
  padding-top: 64px;
}
