/* ==========================================================
SHELF SORT — stylesheet
Fluid-responsive: scales smoothly from ~280px to desktop.

FONTS: Loaded via Google Fonts CDN (requires internet connection).
  - Lilita One (headings/buttons)
  - Nunito (body text)
  - Noto Color Emoji (emoji fallback)
========================================================== */
@import url("https://fonts.googleapis.com/css2?family=Lilita+One&family=Nunito:wght@700;800;900&family=Noto+Color+Emoji&display=swap");

:root {
  --wood1: #c98d54;
  --wood2: #8a5527;
  --wood3: #6d3f1a;
  --text: #5a3a1e;
  --panel: #fff6e3;
  --gold: #ffd23f;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  overflow-x: hidden;
}
html {
  background: #3b2410;
}
body {
  margin: 0;
  background: #3b2410;
  font-family: "Nunito", "Noto Color Emoji", sans-serif;
  touch-action: manipulation;
  user-select: none;
}
#app {
  position: relative;
  width: min(480px, 100vw);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: radial-gradient(
    circle at 50% 0%,
    #ffefcf 0%,
    #f6d9a8 55%,
    #eec38a 100%
  );
}

/* ==========================================================
2) SCREENS
========================================================== */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.screen.active {
  display: flex;
  animation: scrIn 0.25s ease-out;
}
@keyframes scrIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.hidden {
  display: none !important;
}

/* ==========================================================
3) 3D BUTTONS
========================================================== */
.btn3d {
  font-family: "Lilita One";
  letter-spacing: 1px;
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 16px;
  padding: clamp(8px, 2.6vw, 13px) clamp(10px, 4vw, 22px);
  font-size: clamp(11px, 4vw, 17px);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  box-shadow:
    0 6px 0 var(--sh),
    0 10px 18px rgba(0, 0, 0, 0.25),
    inset 0 2px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.08s;
}
.btn3d:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--sh);
}
.btn-green {
  background: linear-gradient(#9be15d, #5cb531);
  --sh: #3f8f1d;
}
.btn-purple {
  background: linear-gradient(#9d84f5, #6a4dd0);
  --sh: #4a35a0;
}
.btn-orange {
  background: linear-gradient(#ffb347, #f58a23);
  --sh: #c05f10;
}
.btn-blue {
  background: linear-gradient(#6cc0f5, #3a8fd0);
  --sh: #22689c;
}
.btn-red {
  background: linear-gradient(#f58a6c, #e0564a);
  --sh: #a03020;
}
.btn-gold {
  background: linear-gradient(#ffe27a, #f5a623);
  --sh: #c77f16;
}
.btn-play {
  font-size: min(30px, 6vh);
  padding: min(15px, 2.4vh) min(70px, 20vw);
  animation: breathe 1.6s infinite;
  position: relative;
  overflow: hidden;
}
.btn-play::after {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  transform: skewX(-20deg);
  background: linear-gradient(
    120deg,
    transparent,
    rgba(255, 255, 255, 0.5),
    transparent
  );
  animation: playShine 2.8s ease-in-out infinite;
}
@keyframes playShine {
  0% {
    left: -60%;
  }
  60%,
  100% {
    left: 130%;
  }
}
.btn-play.small {
  font-size: 19px;
  padding: 11px 44px;
  animation: none;
}
.btn-play.small::after {
  display: none;
}
@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

/* ==========================================================
4) RIBBONS / CHIPS / ICON BUTTONS
========================================================== */
.ribbon {
  font-family: "Lilita One";
  background: linear-gradient(#9d84f5, #6a4dd0);
  padding: clamp(4px, 1.4vw, 8px) clamp(10px, 3.4vw, 22px);
  border-radius: 12px;
  color: #fff;
  box-shadow:
    0 4px 0 #4a35a0,
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
  letter-spacing: 1px;
  font-size: clamp(10px, 3.8vw, 15px);
}
.rb-red {
  background: linear-gradient(#f58a6c, #d04a3a);
  box-shadow:
    0 4px 0 #a03020,
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}
.rb-blue {
  background: linear-gradient(#6cc0f5, #3a8fd0);
  box-shadow:
    0 4px 0 #22689c,
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}
.rb-gold {
  background: linear-gradient(#ffe27a, #f5a623);
  box-shadow:
    0 4px 0 #c77f16,
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.chip {
  background: var(--panel);
  border-radius: 999px;
  padding: clamp(3px, 1vw, 5px) clamp(7px, 2.4vw, 11px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
  font-weight: 900;
  color: var(--text);
  font-size: clamp(9px, 3.2vw, 13px);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chip.warn {
  background: #ffd7d0;
  color: #a03020;
  animation: breathe 1s infinite;
}
.icon-btn {
  width: clamp(30px, 9.5vw, 42px);
  height: clamp(30px, 9.5vw, 42px);
  border-radius: 12px;
  background: var(--panel);
  border: none;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
  cursor: pointer;
  color: var(--text);
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn svg {
  width: clamp(15px, 5.4vw, 20px);
  height: clamp(15px, 5.4vw, 20px);
}
.icon-btn.back {
  font-size: clamp(22px, 7.6vw, 30px);
  font-weight: 900;
  line-height: 1;
}
#g-pause,
#g-sound {
  width: clamp(34px, 10.5vw, 46px);
  height: clamp(34px, 10.5vw, 46px);
}
#g-pause svg,
#g-sound svg {
  width: clamp(17px, 6vw, 26px);
  height: clamp(17px, 6vw, 26px);
}

/* Standard Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(6px, 2vw, 10px) clamp(4px, 1.6vw, 10px) 4px;
  gap: clamp(4px, 1.4vw, 8px);
  z-index: 20;
}
.tb-right {
  display: flex;
  gap: clamp(4px, 1.4vw, 8px);
}
.spacer {
  width: 42px;
}

/* ==========================================================
5) TOAST + PARTICLES
========================================================== */
#toast {
  position: absolute;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  transition: 0.25s;
  background: #5a3a1e;
  color: #fff;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 900;
  z-index: 80;
  pointer-events: none;
  white-space: nowrap;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%);
}
.part {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  z-index: 70;
  pointer-events: none;
  animation: fly 0.65s ease-out forwards;
}
@keyframes fly {
  to {
    transform: translate(var(--dx), var(--dy)) scale(0);
    opacity: 0;
  }
}
.floaty {
  position: absolute;
  transform: translate(-50%, 0);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  z-index: 71;
  pointer-events: none;
  animation: rise 0.9s ease-out forwards;
}
@keyframes rise {
  to {
    transform: translate(-50%, -46px);
    opacity: 0;
  }
}
.flyer {
  position: absolute;
  z-index: 75;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  pointer-events: none;
  box-shadow:
    0 10px 16px rgba(0, 0, 0, 0.4),
    0 0 0 2px rgba(255, 255, 255, 0.6);
  transform: scale(1.08);
}

/* ==========================================================
6) HOME / LOBBY — EMOJIS STATIC
========================================================== */
#scr-home {
  padding-bottom: 10px;
  overflow-y: auto;
}
.vsp {
  flex: 1 1 0;
  min-height: 6px;
}
.hud {
  display: flex;
  gap: clamp(4px, 1.6vw, 8px);
  justify-content: center;
  padding-top: clamp(6px, 1.4vh, 14px);
  align-items: center;
  flex-wrap: wrap;
}
.logo-wrap {
  margin: 0 auto;
  background: linear-gradient(#8a6cf0, #5b3fb0);
  border: 4px solid rgba(255, 255, 255, 0.35);
  border-radius: 24px;
  padding: clamp(8px, 1.6vh, 14px) clamp(16px, 6vw, 30px);
  transform: rotate(-2deg);
  width: fit-content;
  max-width: 92%;
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}
.logo {
  font-family: "Lilita One";
  line-height: 0.9;
  color: var(--gold);
  text-align: center;
  -webkit-text-stroke: 2px #7a4a1f;
  text-shadow:
    0 4px 0 #c26a1f,
    0 7px 12px rgba(0, 0, 0, 0.35);
  font-size: clamp(22px, min(11vw, 7.2vh), 50px);
}
.tag {
  color: #fff;
  text-align: center;
  font-weight: 900;
  letter-spacing: 2px;
  margin-top: 5px;
  font-size: clamp(7px, min(2.6vw, 1.5vh), 11px);
}
.home-shelves {
  margin: 0 clamp(12px, 5vw, 26px);
}
.dshelf {
  position: relative;
  display: flex;
  gap: clamp(8px, 3vw, 16px);
  justify-content: center;
  align-items: flex-end;
  padding: 0 12px clamp(7px, 1.2vh, 10px);
  margin-bottom: clamp(6px, 1.2vh, 10px);
  font-size: clamp(20px, min(9vw, 7vh), 44px);
}
.dshelf span {
  display: flex;
} /* Static */
.dshelf::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 11px;
  border-radius: 6px;
  background: linear-gradient(var(--wood1), var(--wood2));
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
#btn-play {
  display: block;
  margin: 0 auto;
}
.home-menu {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 12px;
  align-items: center;
}
.home-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.chap-bar {
  margin: 0 clamp(12px, 5vw, 22px);
  background: var(--wood3);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}
.chap-mid {
  flex: 1;
}
.chap-info {
  display: flex;
  justify-content: space-between;
  color: #ffe9c2;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.bar {
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 99px;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(#ffe27a, #f5a623);
  border-radius: 99px;
  transition: width 0.4s;
}
#chap-gift {
  border: none;
  font-size: 22px;
  cursor: pointer;
  background: none;
  filter: grayscale(1);
  transition: 0.2s;
}
#chap-gift.ready {
  filter: none;
  animation: breathe 1.2s infinite;
}

/* ==========================================================
7) LEVEL MAP — PLAIN BG, NO WALKER
========================================================== */
#map-scroll {
  flex: 1;
  overflow-y: auto;
  position: relative;
  background: radial-gradient(
    circle at 50% 0%,
    #ffefcf 0%,
    #f6d9a8 55%,
    #eec38a 100%
  );
}
#map-canvas {
  position: relative;
  width: 100%;
}
#map-canvas > svg {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
}
.sign {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  white-space: nowrap;
  background: linear-gradient(#a9713d, #8a5527);
  border: 3px solid #6d3f1a;
  border-radius: 10px;
  padding: 6px 16px;
  color: #ffe9c2;
  font-family: "Lilita One";
  letter-spacing: 1px;
  font-size: 12px;
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
.sign::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 16px;
  background: #6d3f1a;
  border-radius: 0 0 3px 3px;
}
.node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Lilita One";
  font-size: 20px;
  color: #fff;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.1s;
  border: 3px solid #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}
.node:active {
  transform: translate(-50%, -50%) scale(0.92);
}
.node.done {
  background: radial-gradient(
    circle at 35% 28%,
    #d2f7ae,
    #9be15d 45%,
    #57b22e 95%
  );
  box-shadow:
    0 5px 0 #3f8f1d,
    0 9px 12px rgba(0, 0, 0, 0.25),
    inset 0 -5px 8px rgba(0, 0, 0, 0.15);
}
.node.cur {
  background: radial-gradient(
    circle at 35% 28%,
    #fff0b8,
    #ffe27a 45%,
    #f5a623 95%
  );
  box-shadow:
    0 5px 0 #c77f16,
    0 9px 12px rgba(0, 0, 0, 0.25),
    inset 0 -5px 8px rgba(0, 0, 0, 0.15);
  width: 64px;
  height: 64px;
  font-size: 22px;
  animation: pulse 1.2s infinite;
}
.node.locked {
  background: radial-gradient(
    circle at 35% 28%,
    #dbe4ea,
    #aeb9c2 50%,
    #8b98a2 95%
  );
  border-color: #e6edf2;
  box-shadow:
    0 5px 0 #6e7a83,
    0 8px 10px rgba(0, 0, 0, 0.2);
}
.node.milestone {
  width: 66px;
  height: 66px;
  background: radial-gradient(
    circle at 35% 28%,
    #cfc0ff,
    #9d84f5 45%,
    #6a4dd0 95%
  );
  box-shadow:
    0 5px 0 #4a35a0,
    0 9px 14px rgba(0, 0, 0, 0.3),
    inset 0 -5px 8px rgba(0, 0, 0, 0.2);
}
.node.milestone.locked {
  background: radial-gradient(
    circle at 35% 28%,
    #dbe4ea,
    #aeb9c2 50%,
    #8b98a2 95%
  );
  box-shadow: 0 5px 0 #6e7a83;
}
@keyframes pulse {
  0% {
    box-shadow:
      0 5px 0 #c77f16,
      0 0 0 0 rgba(255, 210, 63, 0.75);
  }
  100% {
    box-shadow:
      0 5px 0 #c77f16,
      0 0 0 18px rgba(255, 210, 63, 0);
  }
}
.nst {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  margin-top: 4px;
  background: rgba(255, 246, 227, 0.9);
  border-radius: 999px;
  padding: 2px 7px;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
}
.diff-tabs {
  display: flex;
  gap: 8px;
  padding: 8px 10px 12px;
  background: linear-gradient(var(--wood2), var(--wood3));
}
.dtab {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 10px 4px;
  font-family: "Lilita One";
  font-size: clamp(10px, 3.4vw, 13px);
  letter-spacing: 1px;
  cursor: pointer;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}
.dtab.active {
  background: linear-gradient(#9be15d, #57b22e);
  box-shadow: 0 3px 0 #3f8f1d;
}
.dtab.locked {
  opacity: 0.55;
}

/* ==========================================================
8) GAME BOARD
========================================================== */
.stats-row {
  display: flex;
  justify-content: center;
  gap: clamp(4px, 1.6vw, 8px);
  padding: 2px;
  flex-wrap: wrap;
}
#goal {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(3px, 1.2vw, 5px);
  justify-content: center;
  padding: 2px 8px;
  min-height: 22px;
}
.gchip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 1px clamp(5px, 1.8vw, 8px);
  font-size: clamp(10px, 3.4vw, 14px);
  border: 2px solid rgba(0, 0, 0, 0.12);
}
.gchip b {
  font-size: 10px;
  color: var(--text);
}
#board {
  flex: 1;
  display: grid;
  gap: 12px;
  padding: 10px;
  align-content: center;
  justify-items: center;
  overflow: hidden;
}
.shelf {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  max-width: 170px;
  min-width: 0;
  min-height: calc(var(--ih, 52px) + 22px);
  background: linear-gradient(#e8cf9e, #d9b98c);
  border: 5px solid var(--wood2);
  border-radius: 10px;
  padding: 8px 6px 8px;
  box-shadow:
    inset 0 -6px 8px rgba(0, 0, 0, 0.18),
    inset 0 3px 4px rgba(255, 255, 255, 0.4),
    0 3px 6px rgba(0, 0, 0, 0.25);
}
.shelf .item + .item {
  margin-left: calc(var(--iw, 60px) * -0.42);
}
.slot {
  width: var(--iw, 60px);
  height: var(--ih, 52px);
  border: 2px dashed rgba(122, 74, 31, 0.35);
  border-radius: 10px;
}
.slot + .slot {
  margin-left: 4px;
}
.slot.broken {
  border: none;
  background: radial-gradient(
    circle at 50% 45%,
    #1d0f06 0%,
    #2a1709 60%,
    #3b2410 100%
  );
  box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.7);
  opacity: 0.95;
}
.item {
  position: relative;
  width: var(--iw, 60px);
  height: var(--ih, 52px);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  border: 2px solid rgba(0, 0, 0, 0.12);
  transition:
    transform 0.12s,
    opacity 0.15s;
  background: #fff;
  touch-action: none;
  box-shadow:
    0 3px 0 rgba(0, 0, 0, 0.18),
    inset 0 2px 0 rgba(255, 255, 255, 0.5);
}
.item:active {
  cursor: grabbing;
}
.item.popIn {
  animation: popIn 0.4s ease-out backwards;
}
@keyframes popIn {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.item.ghost {
  opacity: 0.25;
  filter: grayscale(0.7);
}
.item.bye {
  transform: scale(0) rotate(120deg);
  opacity: 0;
  transition: all 0.4s;
}
.item.hintGlow,
.shelf.hintGlow {
  box-shadow:
    0 0 0 4px var(--gold),
    0 0 18px var(--gold);
}
.shelf.badGlow {
  box-shadow:
    0 0 0 4px #e0564a,
    0 0 16px #e0564a;
}
.item.frozen::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 10px;
  border: 2px solid #bfe6f5;
  background: linear-gradient(
    160deg,
    rgba(215, 242, 255, 0.9),
    rgba(140, 200, 240, 0.85)
  );
}
.item .fsnow {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shelf.chained .item {
  filter: grayscale(0.5) brightness(0.85);
}
.shelf.chained::before,
.shelf.chained::after {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  height: 9px;
  z-index: 6;
  background: repeating-linear-gradient(
    90deg,
    #cfd8dc 0 12px,
    #90a4ae 12px 24px
  );
  border-radius: 5px;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.45);
}
.shelf.chained::before {
  top: 28%;
  transform: rotate(7deg);
}
.shelf.chained::after {
  top: 62%;
  transform: rotate(-7deg);
}
.chain-badge {
  position: absolute;
  top: -12px;
  right: -10px;
  z-index: 7;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(#fff6c9, #f5a623);
  border: 2px solid #c77f16;
  color: #7a4a1f;
  font-weight: 900;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  font-family: "Nunito";
}

/* ==========================================================
9) ACTION BAR
========================================================== */
.actions {
  display: flex;
  justify-content: center;
  gap: clamp(5px, 1.8vw, 10px);
  padding: 8px 6px 10px;
  flex-wrap: wrap;
}
.act {
  border: none;
  border-radius: 16px;
  padding: clamp(5px, 1.8vw, 8px) clamp(6px, 2.2vw, 12px);
  min-width: 0;
  flex: 1 1 auto;
  max-width: 90px;
  color: #fff;
  font-family: "Lilita One";
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 4px 0 var(--sh);
  font-size: clamp(13px, 4.8vw, 20px);
  position: relative;
  transition: transform 0.08s;
}
.act span {
  font-size: clamp(6px, 2.2vw, 9px);
  letter-spacing: 1px;
}
.act:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--sh);
}
.act .bdg {
  position: absolute;
  top: -7px;
  right: -5px;
  background: #e0564a;
  color: #fff;
  font-size: 10px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 0 #a03020;
  font-family: "Nunito";
  font-weight: 900;
}
.act.purple {
  background: #8a6cf0;
  --sh: #5b3fb0;
}
.act.blue {
  background: #4aa3e8;
  --sh: #2b7ab0;
}
.act.gold {
  background: #f5a623;
  --sh: #c77f16;
}
.act.green {
  background: #69c04a;
  --sh: #3f8f1d;
}

/* ==========================================================
10) DAILY CHALLENGE — CENTERED
========================================================== */
#scr-daily {
  align-items: center;
  justify-content: center;
  text-align: center;
}
#d-back {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
}
#scr-daily .topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  justify-content: center;
  padding-top: 20px;
  pointer-events: none;
}
#scr-daily .topbar > * {
  pointer-events: auto;
}
#scr-daily .spacer {
  display: none;
}

.d-timer {
  color: #a08363;
  font-weight: 900;
  font-size: 11px;
  text-align: center;
}
.daily-art {
  margin: 4px 0 0;
  animation: bob 2.4s ease-in-out infinite;
  font-size: 84px !important;
  line-height: 1;
}
.daily-text {
  text-align: center;
  font-weight: 800;
  color: var(--text);
  padding: 0 30px;
  margin: 5px 0;
}
.rewards {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 8px 0 12px;
}
#d-play {
  display: block;
  margin: 0 auto;
}
.streak {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 14px 10px;
  flex-wrap: wrap;
}
.day {
  width: 38px;
  height: 44px;
  border-radius: 10px;
  background: #e5d3b3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 14px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}
.day small {
  font-size: 7px;
  font-weight: 900;
  color: #a08363;
}
.day.done {
  background: linear-gradient(#9be15d, #57b22e);
  box-shadow: 0 2px 0 #3f8f1d;
}
.day.done small {
  color: #eaffea;
}
.day.today {
  outline: 3px solid var(--gold);
}

/* ==========================================================
11) HOW TO PLAY
========================================================== */
.how-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 18px;
}
.hstep {
  position: relative;
  display: flex;
  gap: 12px;
  padding-bottom: 16px;
}
.hstep::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 48px;
  bottom: 2px;
  width: 3px;
  background: repeating-linear-gradient(#d9b98c 0 6px, transparent 6px 12px);
}
.hstep:last-of-type::before {
  display: none;
}
.hnum {
  width: clamp(34px, 10vw, 46px);
  height: clamp(34px, 10vw, 46px);
  flex: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Lilita One";
  font-size: clamp(14px, 4.6vw, 20px);
  color: #fff;
  background: var(--c, #57b22e);
  z-index: 1;
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.18),
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}
.c-green {
  --c: #57b22e;
}
.c-blue {
  --c: #3a8fd0;
}
.c-orange {
  --c: #f58a23;
}
.c-red {
  --c: #e0564a;
}
.c-gray {
  --c: #90a4ae;
}
.c-cyan {
  --c: #6cc0f5;
}
.c-purple {
  --c: #6a4dd0;
}
.c-gold {
  --c: #f5a623;
}
.hcard2 {
  flex: 1;
  background: #fff;
  border-radius: 16px;
  padding: 11px 14px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  gap: 10px;
}
.hcard2 p {
  margin: 0;
  font-size: clamp(10px, 3.6vw, 12.5px);
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
}
.hcard2 p b {
  color: #6a4dd0;
}
.tip {
  display: flex;
  gap: 12px;
  align-items: center;
  background: linear-gradient(#fff6e3, #ffe9c2);
  border: 3px solid #e8b06a;
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
  margin-bottom: 14px;
}
.tip-bulb {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(#fff6c9, #ffd23f 60%, #f5a623);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 12px rgba(255, 210, 63, 0.7),
    0 3px 0 #c77f16;
}
.tip p {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.45;
}
.tip b {
  color: #c05f10;
}
#how-play {
  display: block;
  margin: 0 auto;
  font-size: 18px;
  padding: 12px 30px;
}

/* ==========================================================
12) SHOP — CENTERED CONTENT WITH SAFE TOP PADDING
========================================================== */
/* 1. Topbar stays at top */
#scr-shop .topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  /* Background gradient to hide content scrolling underneath */
  background: radial-gradient(
    circle at 50% 0%,
    #ffefcf 0%,
    #f6d9a8 55%,
    #eec38a 100%
  );
  padding-bottom: 8px;
}

/* 2. Shop Wrap centers content but respects header space */
#scr-shop .shop-wrap {
  flex: 1;
  overflow-y: auto;
  width: 100%;

  /* Flex centering */
  display: flex;
  flex-direction: column;
  justify-content: center; /* Vertically center */
  align-items: center; /* Horizontally center */

  /* CRITICAL: Padding top ensures content never hides behind header */
  /* Header is approx 60px tall. We add 70px to be safe. */
  padding: 70px 16px 20px 16px;
}

.shoptitle {
  font-family: "Lilita One";
  color: var(--text);
  letter-spacing: 1px;
  font-size: 15px;
  margin: 8px auto 10px;
  text-align: center;
  width: 100%;
}
.tgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(6px, 2vw, 12px);
  width: 100%;
}
.tcard {
  background: #fff;
  border-radius: 16px;
  padding: clamp(8px, 2.4vw, 12px) clamp(6px, 2vw, 10px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
  min-width: 0;
}
.tcard.sel {
  outline: 3px solid var(--gold);
  box-shadow:
    0 0 0 3px rgba(255, 210, 63, 0.35),
    0 3px 0 rgba(0, 0, 0, 0.12);
}
.tprev {
  display: flex;
  gap: clamp(3px, 1.2vw, 5px);
}
.tprev span {
  width: clamp(16px, 6.4vw, 34px);
  height: clamp(16px, 6.4vw, 34px);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    0 2px 0 rgba(0, 0, 0, 0.12);
}
.tname {
  font-family: "Lilita One";
  font-size: clamp(9px, 3vw, 12px);
  color: var(--text);
  letter-spacing: 1px;
}
.tbtn {
  border: none;
  border-radius: 12px;
  padding: 7px 14px;
  font-family: "Lilita One";
  font-size: clamp(10px, 3.2vw, 12px);
  color: #fff;
  cursor: pointer;
  background: linear-gradient(#9be15d, #5cb531);
  box-shadow: 0 3px 0 #3f8f1d;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tbtn.own {
  background: linear-gradient(#6cc0f5, #3a8fd0);
  box-shadow: 0 3px 0 #22689c;
}
.tbtn.cur {
  background: linear-gradient(#ffe27a, #f5a623);
  box-shadow: 0 3px 0 #c77f16;
  color: #7a4a1f;
}
.tbtn:active {
  transform: translateY(2px);
  box-shadow: none;
}
.ucard {
  background: #fff;
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  width: 100%;
}
.ucard .em {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}
.ucard .mid {
  flex: 1;
}
.ucard .mid h4 {
  margin: 0 0 2px;
  font-family: "Lilita One";
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.5px;
}
.ucard .mid p {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  color: #a08363;
}
.pips {
  display: flex;
  gap: 4px;
  margin-top: 5px;
}
.pips i {
  width: 14px;
  height: 8px;
  border-radius: 4px;
  background: #e5d3b3;
}
.pips i.on {
  background: linear-gradient(#ffe27a, #f5a623);
  box-shadow: 0 1px 0 #c77f16;
}

/* ==========================================================
13) OVERLAYS / MODALS
========================================================== */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(40, 20, 5, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay.show {
  display: flex;
}
.panel {
  position: relative;
  background: linear-gradient(#fffaf0, #ffe9c2);
  border-radius: 26px;
  padding: 44px 22px 20px;
  width: min(340px, 88%);
  text-align: center;
  border: 5px solid #e8b06a;
  box-shadow:
    0 14px 40px rgba(0, 0, 0, 0.45),
    inset 0 2px 0 #fff;
}
.overlay.show .panel {
  animation: panelIn 0.35s cubic-bezier(0.5, 1.6, 0.5, 1);
}
@keyframes panelIn {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.win-ribbon {
  position: absolute;
  top: -17px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 34px;
  white-space: nowrap;
  font-family: "Lilita One";
  color: #fff;
  letter-spacing: 1px;
  font-size: 18px;
  background: linear-gradient(#9d84f5, #6a4dd0);
  border-radius: 10px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  box-shadow:
    0 4px 0 #4a35a0,
    inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
.win-ribbon::before,
.win-ribbon::after {
  content: "";
  position: absolute;
  top: 7px;
  width: 24px;
  height: 100%;
  background: #5b3fb0;
  z-index: -1;
}
.win-ribbon::before {
  left: -15px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 35% 50%);
}
.win-ribbon::after {
  right: -15px;
  clip-path: polygon(0 0, 100% 0, 65% 50%, 100% 100%, 0 100%);
}
.pbtn {
  display: block;
  width: 82%;
  margin: 9px auto 0;
  font-size: 16px;
  padding: 12px 10px;
}
.pause-art {
  margin: 2px 0 8px;
  animation: bob 2s ease-in-out infinite;
}
.fail-text {
  font-weight: 800;
  color: var(--text);
}
.win-stars {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 12px;
}
.win-stars::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 190px;
  height: 190px;
  margin: -95px 0 0 -95px;
  background: repeating-conic-gradient(
    rgba(255, 210, 63, 0.28) 0 12deg,
    transparent 12deg 26deg
  );
  border-radius: 50%;
  animation: spin 9s linear infinite;
  filter: blur(1px);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.star {
  width: 66px;
  height: 66px;
  position: relative;
  z-index: 1;
  background: #e0d0b0;
  clip-path: polygon(
    50% 0%,
    63% 32%,
    98% 35%,
    71% 57%,
    81% 91%,
    50% 73%,
    19% 91%,
    29% 57%,
    2% 35%,
    37% 32%
  );
}
.star.on {
  background: linear-gradient(
    180deg,
    #fff6c9 0%,
    #ffd23f 35%,
    #f5a623 70%,
    #c77f16 100%
  );
  animation:
    starPop 0.5s cubic-bezier(0.5, 1.8, 0.5, 1),
    starGlow 1.6s ease-in-out 0.5s infinite;
}
.star.on::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent 32%,
    rgba(255, 255, 255, 0.95) 50%,
    transparent 68%
  );
  transform: translateX(-100%);
  animation: shine 1.8s ease-in-out 0.6s infinite;
}
@keyframes shine {
  0% {
    transform: translateX(-100%);
  }
  60%,
  100% {
    transform: translateX(100%);
  }
}
@keyframes starPop {
  from {
    transform: scale(0) rotate(-180deg);
  }
  to {
    transform: scale(1);
  }
}
@keyframes starGlow {
  0%,
  100% {
    filter: drop-shadow(0 0 4px rgba(255, 210, 63, 0.7));
  }
  50% {
    filter: drop-shadow(0 0 14px rgba(255, 210, 63, 1));
  }
}
.win-stats {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 16px;
  flex-wrap: wrap;
}
.wstat {
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
  min-width: 82px;
}
.wstat small {
  display: block;
  font-size: 9px;
  font-weight: 900;
  color: #a08363;
  letter-spacing: 1px;
}
.wstat b {
  font-size: 17px;
  color: var(--text);
}
#w-next {
  display: block;
  margin: 4px auto 10px;
  font-size: 20px;
  padding: 13px 40px;
}
#w-map {
  font-size: 14px;
  padding: 10px 22px;
}
.setrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 6px;
  font-weight: 900;
  color: var(--text);
}
.setrow.tight {
  margin: 16px 6px 4px;
}

/* ==========================================================
14) RESPONSIVE
========================================================== */
@media (max-height: 640px) {
  .vsp {
    min-height: 2px;
  }
  .logo {
    font-size: clamp(26px, 6vh, 40px);
  }
  .logo-wrap {
    padding: 6px 18px;
  }
  .dshelf {
    font-size: clamp(20px, 5vh, 30px);
    margin-bottom: 4px;
  }
  .home-menu {
    gap: 6px;
  }
  .chap-bar {
    margin-top: 4px;
  }
}
