:root {
  --gold: #ffd36b;
  --gold2: #c98a24;
  --ink: #2a1408;
  --cream: #fff6e0;
  --ice: #cfe3ff;
  --u: clamp(9px, 0.7vw + 5px, 15px);
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #120a0e;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
#c {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}
button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- the curtain and the opening card ---------- */
#curtain {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 60%, #1d2a4a 0%, #0b0f1e 72%);
  z-index: 10;
  transition: opacity 1.1s ease;
  padding: 16px;
}
#curtain.gone {
  opacity: 0;
  pointer-events: none;
}
.curtainIn {
  text-align: center;
  color: var(--cream);
  max-width: 34em;
  font: 500 calc(var(--u) * 1.15) / 1.45 'Chakra Petch', sans-serif;
}
.curtainIn .flake {
  font-size: calc(var(--u) * 3.4);
  color: var(--ice);
  text-shadow: 0 0 20px rgba(180, 210, 255, 0.6);
  animation: spin 9s linear infinite;
  display: inline-block;
}
.curtainIn .ttl {
  font: 600 calc(var(--u) * 4.2) / 1.1 Fraunces, Georgia, serif;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-shadow: 0 2px 0 #6b3d0c, 0 0 30px rgba(255, 200, 90, 0.35);
}
.curtainIn .sub {
  opacity: 0.8;
  margin-top: calc(var(--u) * 0.4);
}
.curtainIn .bar {
  width: calc(var(--u) * 16);
  height: 6px;
  border-radius: 3px;
  margin: calc(var(--u) * 1.2) auto 0;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.curtainIn .bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold2), var(--gold));
  transition: width 0.25s;
}
#start {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.6s, transform 0.6s;
  margin-top: calc(var(--u) * 1.2);
}
#start.in {
  opacity: 1;
  transform: none;
}
#start p {
  margin: 0.5em 0;
  opacity: 0.9;
}
#start .lead {
  font: 500 calc(var(--u) * 1.6) / 1.3 Caveat, cursive;
  color: var(--ice);
  opacity: 1;
}
#start .ask {
  margin-top: 1.1em;
  font: 600 calc(var(--u) * 1.3) Fraunces, Georgia, serif;
  color: var(--gold);
}
#start .btns {
  display: flex;
  gap: 0.7em;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0.8em 0;
}
#start .note {
  font-size: 0.8em;
  opacity: 0.6;
}
.spotBtn {
  border: 0;
  cursor: pointer;
  padding: 0.75em 1.4em;
  border-radius: 999px;
  font: 600 calc(var(--u) * 1.1) 'Chakra Petch', sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #ffe9a8, var(--gold) 45%, var(--gold2));
  box-shadow: 0 2px 0 #7a4a10, 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.spotBtn:active {
  transform: translateY(1px);
}
.spotBtn.ghost {
  color: var(--cream);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1.5px rgba(255, 211, 107, 0.55);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- the in-game UI ---------- */
#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  color: var(--cream);
  font: 500 calc(var(--u) * 1) 'Chakra Petch', sans-serif;
}
#ui button {
  pointer-events: auto;
  cursor: pointer;
}
.brand {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  top: max(10px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 0.6em;
  min-height: 44px;
  border: 0;
  background: rgba(18, 10, 14, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 0 16px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 211, 107, 0.3);
  font-size: 15px;
}
.brand .bt {
  font: 600 19px Fraunces, Georgia, serif;
  color: var(--gold);
}
.brand .bc {
  opacity: 0.95;
  font-weight: 600;
}
.brand .bc i {
  font-style: normal;
  color: var(--gold);
}
.brand.ping {
  animation: ping 1.2s ease;
}
.brand.all {
  box-shadow: inset 0 0 0 1.5px var(--gold), 0 0 18px rgba(255, 211, 107, 0.5);
}
@keyframes ping {
  30% {
    transform: scale(1.12);
    box-shadow: inset 0 0 0 2px var(--gold), 0 0 30px rgba(255, 211, 107, 0.8);
  }
}
.bar {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  top: max(10px, env(safe-area-inset-top));
  display: flex;
  gap: 8px;
}
.tb {
  position: relative;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 44px;
  min-width: 44px;
  padding: 0 14px 0 11px;
  border-radius: 999px;
  background: rgba(18, 10, 14, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  color: var(--cream);
  font-size: 14.5px;
  font-weight: 600;
  transition: background 0.2s, transform 0.12s;
}
.tb:hover {
  background: rgba(40, 20, 26, 0.66);
}
.tb:active {
  transform: scale(0.95);
}
.tb svg {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  position: relative;
  z-index: 1;
}
.tb span:not(.lvl) {
  position: relative;
  z-index: 1;
}
.tb.on {
  color: var(--ink);
  background: linear-gradient(180deg, #ffe9a8, var(--gold) 50%, var(--gold2));
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
.tb.off {
  opacity: 0.7;
}
.tb .lvl {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 70%);
  opacity: 0;
  transition: transform 0.08s;
}
.tb.on .lvl {
  opacity: 1;
}
.tb.breath {
  box-shadow: 0 0 16px rgba(207, 227, 255, 0.9), 0 2px 10px rgba(0, 0, 0, 0.3);
}
/* a medium window: icons only, still big */
@media (max-width: 1100px) {
  .tb span:not(.lvl) {
    display: none;
  }
  .tb {
    width: 48px;
    height: 48px;
    padding: 0;
  }
  .tb svg {
    width: 26px;
    height: 26px;
  }
  .tb .lvl {
    left: 50%;
  }
}
/* short screens (a phone on its side) */
@media (max-height: 500px) {
  .brand .bt {
    display: none;
  }
  .hint {
    bottom: max(74px, calc(env(safe-area-inset-bottom) + 66px)) !important;
  }
}
/* a phone held upright: the toolbar sits along the bottom, under your thumb, and the kit's home buttons take the top left */
@media (max-width: 700px) and (orientation: portrait) {
  .brand {
    min-height: 34px;
    padding: 0 12px;
  }
  .brand .bt {
    display: none;
  }
  .bar {
    top: auto;
    right: 50%;
    transform: translateX(50%);
    bottom: max(14px, env(safe-area-inset-bottom));
    gap: 6px;
    padding: 6px;
    border-radius: 999px;
    background: rgba(18, 10, 14, 0.38);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
  .tb {
    background: rgba(255, 246, 224, 0.08);
  }
  .hint {
    bottom: max(86px, calc(env(safe-area-inset-bottom) + 76px)) !important;
  }
  .toast {
    top: max(104px, calc(env(safe-area-inset-top) + 98px)) !important;
  }
}

.hint {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translate(-50%, 8px);
  max-width: calc(100% - 32px);
  text-align: center;
  font: 600 calc(var(--u) * 1.75) / 1.15 Caveat, cursive;
  color: var(--cream);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8), 0 0 14px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.6s, transform 0.6s;
}
.hint.show {
  opacity: 0.95;
  transform: translate(-50%, 0);
}
.toast {
  position: absolute;
  left: 50%;
  top: max(64px, calc(env(safe-area-inset-top) + 54px));
  transform: translate(-50%, -10px) scale(0.96);
  text-align: center;
  padding: 0.55em 1.4em 0.65em;
  border-radius: 16px;
  font: 600 calc(var(--u) * 1.4) Fraunces, Georgia, serif;
  color: var(--gold);
  background: rgba(18, 10, 14, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px rgba(255, 211, 107, 0.4), 0 8px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.5s, transform 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
  white-space: nowrap;
}
.toast small {
  display: block;
  font: 500 calc(var(--u) * 0.85) 'Chakra Petch', sans-serif;
  color: var(--cream);
  opacity: 0.75;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.toast.big {
  font-size: calc(var(--u) * 1.8);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

/* ---------- the Book of Window Wonders ---------- */
.book {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  display: grid;
  place-items: center;
  background: rgba(8, 6, 14, 0.55);
  opacity: 0;
  transition: opacity 0.25s;
  padding: 16px;
}
.book.in {
  opacity: 1;
}
.book .page {
  position: relative;
  width: min(760px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 1.4em 1.4em 1.1em;
  border-radius: 18px;
  color: var(--ink);
  background: radial-gradient(ellipse at 50% 0%, #fffaf0, #f3e2bd);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), inset 0 0 0 2px rgba(201, 138, 36, 0.5), inset 0 0 0 7px #f8ecd0, inset 0 0 0 8px rgba(201, 138, 36, 0.35);
  touch-action: pan-y;
}
.book .close {
  position: absolute;
  right: 0.5em;
  top: 0.3em;
  border: 0;
  background: none;
  font-size: 1.9em;
  color: #8a5a1c;
}
.book .bh {
  font: 600 calc(var(--u) * 1.9) Fraunces, Georgia, serif;
  text-align: center;
  color: #6b3d0c;
}
.book .bs {
  text-align: center;
  opacity: 0.7;
  margin-bottom: 0.9em;
}
.book .cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5em, 1fr));
  gap: 0.6em;
}
.book .card {
  border-radius: 12px;
  padding: 0.6em 0.7em 0.7em;
  background: rgba(107, 61, 12, 0.07);
  box-shadow: inset 0 0 0 1px rgba(107, 61, 12, 0.18);
  min-height: 5.2em;
}
.book .card .num {
  font: 600 0.8em 'Russo One', sans-serif;
  opacity: 0.45;
}
.book .card .nm {
  font: 600 calc(var(--u) * 1.15) Fraunces, Georgia, serif;
}
.book .card .ht {
  font: 600 calc(var(--u) * 1.3) / 1.1 Caveat, cursive;
  opacity: 0.65;
}
.book .card.got {
  background: linear-gradient(180deg, #2a3a6a, #172246);
  color: var(--cream);
  box-shadow: inset 0 0 0 1.5px var(--gold), 0 3px 10px rgba(0, 0, 0, 0.25);
}
.book .card.got .nm {
  color: var(--gold);
}
.book .card.bonus.got {
  background: linear-gradient(180deg, #4a6aa8, #22386a);
}
.book .bf {
  margin-top: 1em;
  text-align: center;
  font: 600 calc(var(--u) * 1.3) Caveat, cursive;
  opacity: 0.7;
}
