@font-face {
  font-family: DessMain;
  src: url('../assets/fonts/main.ttf') format('truetype');
  font-display: swap;
}

:root {
  color-scheme: dark;
  background: #000;
  color: #fff;
  font: 1rem/1.5 DessMain, monospace;
  --accent: #ffe474;
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }
a:focus-visible, button:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.hub-page {
  min-height: 100svh;
  background: #000;
}

.hub {
  --frame-size: clamp(1rem, 4.2vw, 3.25rem);
  --jewel: url('pink-shop/spr_textbox_topleft.png');
  display: grid;
  grid-template-rows: minmax(14rem, 52svh) 1fr auto;
  min-height: 100svh;
  width: 100%;
  container-type: inline-size;
}
.back { color: #ccc; text-underline-offset: .25em; }
.back:hover { color: var(--accent); }
.shop-scene { position: relative; overflow: hidden; }
.shop-scene img { display: block; image-rendering: pixelated; }
.shop-background { width: 100%; height: 100%; }
.shop-sprite { position: absolute; }
.shop-sun { width: 14.6875%; height: 14.1667%; top: 60.8333%; left: 45.9375%; }
.shop-pink { width: 20.9375%; height: 78.3333%; top: 21.6667%; left: 12.65625%; }
.shop-pendant { width: 10.625%; height: 61.6667%; top: 0; left: 57.8125%; }
.shop-flowers { width: 21.875%; height: 82.5%; top: 0; left: 77.96875%; }
.shop-counter { width: 19.375%; height: 5.8333%; top: 70.8333%; left: 44.6875%; }

.shop-interface {
  display: grid;
  grid-template-columns: 1.48fr 1fr;
}

.shop-box {
  position: relative;
  min-width: 0;
  background: #000;
  padding: calc(var(--frame-size) * .9);
  font-size: clamp(.9rem, min(3.1cqw, 5svh), 3rem);
  line-height: 1.38;
}

.shop-dialogue {
  margin-right: calc(-.48 * var(--frame-size));
  padding-inline-start: clamp(1.85rem, 5.1vw, 6rem);
}
.shop-frame, .shop-frame i {
  position: absolute;
  inset: 0;
  pointer-events: none;
  image-rendering: pixelated;
}
.shop-frame { z-index: 1; }
.shop-frame i { background-size: 100% 100%; background-repeat: no-repeat; }
.shop-frame i:nth-child(-n+4) {
  width: var(--frame-size);
  height: var(--frame-size);
  background-image: var(--jewel);
}
.shop-frame i:nth-child(1) { inset: 0 auto auto 0; }
.shop-frame i:nth-child(2) { inset: 0 0 auto auto; transform: scaleX(-1); }
.shop-frame i:nth-child(3) { inset: auto auto 0 0; transform: scaleY(-1); }
.shop-frame i:nth-child(4) { inset: auto 0 0 auto; transform: scale(-1); }
.shop-frame i:nth-child(5), .shop-frame i:nth-child(6) {
  height: var(--frame-size);
  left: var(--frame-size);
  right: var(--frame-size);
  background-image: url('pink-shop/spr_textbox_top.png');
}
.shop-frame i:nth-child(5) { bottom: auto; }
.shop-frame i:nth-child(6) { top: auto; transform: scaleY(-1); }
.shop-frame i:nth-child(7), .shop-frame i:nth-child(8) {
  width: var(--frame-size);
  top: var(--frame-size);
  bottom: var(--frame-size);
  background-image: url('pink-shop/spr_textbox_left.png');
}
.shop-frame i:nth-child(7) { right: auto; }
.shop-frame i:nth-child(8) { left: auto; transform: scaleX(-1); }

.shop-dialogue p { margin: 0; }
.hub-menu { display: grid; align-content: start; gap: .45em; font-size: clamp(.9rem, 2.35cqw, 2.6rem); }
.hub-menu a {
  position: relative;
  display: block;
  width: fit-content;
  padding: .1em .25em .1em 1.35em;
  text-decoration: none;
  line-height: 1.25;
}
.hub-menu a[data-selected]::before, .hub-menu a:focus-visible::before {
  content: "";
  position: absolute;
  width: .8em;
  height: .8em;
  top: .35em;
  left: .12em;
  background: url('../assets/images/chapterselect/heart.png') center / contain no-repeat;
  image-rendering: pixelated;
}
.hub-menu a:focus-visible { outline: none; }
.shop-controls {
  padding: .32rem .85rem .5rem;
  font-size: clamp(.75rem, 2cqw, .95rem);
  color: #c9bccf;
}
.shop-volume { display: flex; align-items: center; gap: .5rem; }
.shop-volume input { width: clamp(4.5rem, 13vw, 10rem); margin: 0; accent-color: #ddd0ef; cursor: pointer; }
.shop-volume input:focus-visible { outline: 2px solid #ddd0ef; outline-offset: 3px; }

@media (max-width: 36rem) {
  .hub { grid-template-rows: minmax(12rem, 47svh) 1fr auto; }
  .shop-interface { grid-template-columns: 1.12fr 1fr; }
  .shop-box { padding: 1.05rem .7rem; }
  .shop-dialogue { padding-inline-start: clamp(1.15rem, 5vw, 2rem); }
}
.atlas {
  --frame-size: 32px;
  --jewel: url('pink-shop/spr_textbox_topleft.png');
  --panel-line: #61566f;
  max-width: 100rem;
  margin: 0 auto;
  padding: 1rem clamp(.75rem, 3vw, 2.75rem) 1.5rem;
}
.atlas-trail, .atlas-header { display: flex; align-items: center; gap: .5rem 1.25rem; }
.atlas-trail { color: #bcb4c7; }
.atlas-back { display: inline-flex; align-items: center; gap: .55rem; }
.atlas-back img, .worlds button::before { image-rendering: pixelated; }
.atlas-trail > span { border-left: 1px solid var(--panel-line); padding-left: 1.25rem; }
.atlas-header { flex-wrap: wrap; justify-content: space-between; padding: .7rem 0 1.1rem; }
.atlas-header h1 { margin: 0; font-size: clamp(1.85rem, 4vw, 3rem); line-height: 1.15; }
.atlas-header .map-status { margin: 0; color: #c7bdcf; }
.map-status[data-online="true"] { color: #a4e8a0; }
.atlas-layout { display: grid; grid-template-columns: minmax(12.5rem, 17rem) minmax(0, 1fr); gap: .9rem; align-items: start; }
.atlas-controls {
  --frame-size: 24px;
  position: relative;
  min-width: 0;
  padding: calc(var(--frame-size) * .55);
  background: #000;
}
.worlds { display: grid; }
.worlds button {
  position: relative;
  appearance: none;
  color: #fff;
  background: #000;
  border: 0;
  min-height: 2.6rem;
  min-width: 0;
  padding: .5rem .65rem .5rem 2rem;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.worlds button:focus-visible { outline: 1px solid #fff; outline-offset: -3px; }
.worlds [aria-pressed="true"]::before {
  content: "";
  position: absolute;
  top: 50%;
  left: .6rem;
  width: .85rem;
  height: .85rem;
  transform: translateY(-50%);
  background: url('../assets/images/chapterselect/heart.png') center / contain no-repeat;
}
.map-stage { min-width: 0; }
.map-shell { position: relative; padding: max(10px, calc(var(--frame-size) * .52)); background: #000; }
.map-viewport {
  position: relative;
  height: clamp(24rem, calc(100svh - 11rem), 66rem);
  overflow: hidden;
  background: #08070c;
  cursor: grab;
  touch-action: none;
}
.atlas[data-region="card-castle"] .map-viewport { height: clamp(35rem, 91svh, 74rem); }
.map-viewport:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.map-viewport[data-dragging] { cursor: grabbing; }
.world-layer { position: absolute; inset: 0 auto auto 0; transform-origin: top left; }
.map-room, .map-seam, .map-stitch { position: absolute; }
.map-stitch { background-repeat: no-repeat; image-rendering: pixelated; pointer-events: none; }
.map-seam {
  height: 16px;
  margin-top: -8px;
  background: #51436b;
  border-radius: 2px;
  transform-origin: left center;
  pointer-events: none;
}
.map-seam[data-region="field"] { background: #59358d; }
.map-seam[data-region="forest"] { background: #592143; }
.map-seam[data-region="card-castle"] { background: #4a4175; }
.map-seam-secondary { opacity: .57; }
.map-room { pointer-events: none; }
.map-room-art {
  position: absolute;
  display: block;
  image-rendering: pixelated;
  pointer-events: auto;
  user-select: none;
}
.map-icon {
  position: absolute;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%) scale(var(--marker-scale, 1));
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 1;
  filter: drop-shadow(0 0 2px #000) drop-shadow(0 0 1px #fff);
  transition: left 650ms linear, top 650ms linear;
}
.map-progress { display: block; width: calc(100% - 1rem); margin: .65rem .5rem 0; accent-color: var(--accent); cursor: ew-resize; }
.map-progress[hidden] { display: none; }
.atlas[data-world="dark"] { --accent: #e2b9ff; }

@media (max-width: 52rem) {
  .atlas-layout { grid-template-columns: minmax(0, 1fr); gap: .65rem; }
  .worlds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-viewport { height: clamp(23rem, calc(100svh - 14rem), 55rem); }
}
@media (max-width: 34rem) {
  .atlas { --frame-size: 24px; }
  .atlas-header { gap: .3rem .7rem; }
}
@media (prefers-reduced-motion: reduce) {
  .map-icon { transition: none; }
}
