html, body {
  margin: 0;
  padding: 0;
  background: #1a1f12;
  min-height: 100%;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  touch-action: manipulation;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
}

#page-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

#game-wrap {
  position: relative;
  width: 960px;
  height: 600px;
  max-width: 100vw;
  max-height: 100dvh;
  aspect-ratio: 960 / 600;
  margin: 0 auto;
  background: #000;
}

@media (max-width: 980px) {
  #game-wrap {
    width: 100vw;
    height: calc(100vw * 600 / 960);
  }
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  cursor: pointer;
}

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #2b2116;
  color: #f0dfc0;
  gap: 14px;
}

.loading-label {
  font-size: 20px;
  letter-spacing: 2px;
}

.loading-bar {
  width: 280px;
  height: 18px;
  border: 3px solid #f0dfc0;
  border-radius: 6px;
  overflow: hidden;
  background: #1a1310;
}

#loading-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(#e2b23c, #b97c1f);
  transition: width 0.15s ease-out;
}

#loading.hidden {
  display: none;
}

/* On-screen move/jump controls. Sit in normal document flow below the
   canvas (not overlaid on top of it, so they never cover letters or the
   HUD) and only appear on touch devices - a mouse/keyboard user never
   sees them. */
#touch-controls {
  display: none;
  width: min(960px, 100vw);
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  box-sizing: border-box;
}

@media (hover: none) and (pointer: coarse) {
  #touch-controls {
    display: flex;
  }
}

.touch-dpad {
  display: flex;
  gap: 14px;
}

.touch-btn {
  width: 15vmin;
  height: 15vmin;
  min-width: 54px;
  min-height: 54px;
  max-width: 72px;
  max-height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(240, 223, 192, 0.6);
  background: rgba(35, 38, 25, 0.85);
  color: #f0dfc0;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.touch-btn:active {
  background: rgba(232, 178, 60, 0.7);
}

/* Snack Quests title / opening overlay. Same shell as Spelling, Lantern Bearer,
   and the other storefront games: art first, then a how-to card and Play. */
#sq-open {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#sq-open.is-off { display: none !important; }
#sq-open .sq-stage {
  position: relative;
  width: min(100%, 1400px);
  max-height: 100%;
  max-height: 100dvh;
}
#sq-open .sq-art {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100dvh;
  object-fit: contain;
}
#sq-open .sq-play {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.55));
  transition: transform 0.1s ease;
}
#sq-open .sq-play:active { transform: translateX(-50%) scale(0.94); }
#sq-open .sq-play img {
  display: block;
  width: clamp(88px, 20vw, 150px);
  height: auto;
  pointer-events: none;
}

#sq-open .sq-studio {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: #fff6eb;
  background: rgba(26, 18, 12, 0.78);
  border: 2px solid #e8a838;
  padding: 4px 8px 4px 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
#sq-open .sq-studio svg {
  display: block;
  width: 22px;
  height: 22px;
  flex: none;
}
