:root {
  --ink: #1a140e;
  --cream: #f7f1df;
  --shadow: rgba(8, 12, 8, 0.45);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: transparent;
  color: var(--cream);
  font-family: Nunito, system-ui, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button {
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
}

.sq-studio {
  position: relative;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--cream);
  font-weight: 800;
  background: transparent;
  padding: 0.25rem 0.45rem;
  margin: 0 0 0.45rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.75);
}
body.is-playing .sq-studio { display: none !important; }

#sq-open {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: start center;
  align-content: start;
  padding: 1rem 0.75rem 0.85rem;
  overflow-y: auto;
  background:
    linear-gradient(rgba(12, 22, 16, 0.35), rgba(12, 22, 16, 0.55)),
    url("../assets/bg/mountain.png") center / cover no-repeat;
}
#sq-open[hidden], #game-wrap[hidden], #overlay[hidden] { display: none !important; }

.sq-howto {
  width: min(640px, 100%);
  padding: 1.8rem 2rem 2.05rem;
  background: transparent url("../assets/ui/wood_panel.png") center / 100% 100% no-repeat;
  filter: brightness(0.8) contrast(1.1);
  border-radius: 0;
  box-shadow: 0 10px 28px var(--shadow);
  color: #fff6e4;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8), 0 0 10px rgba(0,0,0,0.35);
}
.sq-howto > * { filter: none; }
.sq-howto .eyebrow,
.sq-howto h1,
.sq-howto p,
.sq-howto .btn-play { filter: brightness(1.22); }
.eyebrow {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 800;
  color: #ffe7a8;
}
.sq-howto h1 {
  margin: 0 0 0.55rem;
  font-family: Fredoka, sans-serif;
  font-size: 2.5rem;
  color: #fff8e6;
}
.sq-howto p { margin: 0 0 0.65rem; line-height: 1.45; font-size: 1.2rem; }
.hint { font-size: 1.08rem; color: #ffe9b8; }

.btn-play {
  display: block;
  width: min(320px, 82%);
  height: 84px;
  margin: 0.85rem auto 0;
  border: none;
  background: transparent url("../assets/ui/wood_bar.png") center / 100% 100% no-repeat;
  color: #fff6e4;
  font-family: Fredoka, sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 3px rgba(0,0,0,0.85);
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.45)) brightness(0.92);
}
.btn-play:disabled { opacity: 0.55; cursor: wait; filter: grayscale(0.35); color: transparent; }
.btn-play:not(:disabled) { color: #fff6e4; }
.btn-play:active:not(:disabled) { transform: translateY(2px); }

#game-wrap {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #16241c;
}

/* The game is built for a landscape 16:9 camera, so #game-stage is kept
   at that ratio and centered - letterboxed (not stretched/cropped) on
   any screen that isn't exactly 16:9, instead of distorting the canvas
   to fill a mismatched container. */
#game-stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: calc(100vh * 16 / 9);
  max-height: calc(100vw * 9 / 16);
  aspect-ratio: 16 / 9;
}

#rotate-notice {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding: 1.5rem;
  text-align: center;
  background: #16241c;
  color: #fff6e4;
}
#rotate-notice p { max-width: 20rem; font-size: 1.1rem; font-weight: 700; margin: 0; }
@media (orientation: portrait) {
  #game-stage { display: none; }
  #rotate-notice { display: flex; }
}

/* The canvas fills the game stage and the wooden banner sits on top of
   it (not in a row above it), so anything the wood art doesn't fully
   cover shows the game's own sky behind it instead of a blank gap. */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 1.1rem;
  min-height: 4.4rem;
  background: transparent url("../assets/ui/wood_bar.png") center / 100% 100% no-repeat;
  filter: brightness(0.82) contrast(1.1);
  box-shadow: 0 4px 14px var(--shadow);
}
#hud > * { filter: brightness(1.22); }

.hud-left {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}
.hud-label {
  display: inline-flex;
  align-items: center;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff6e4;
  text-shadow: 0 1px 2px rgba(0,0,0,0.85);
  white-space: nowrap;
}
.hud-coin-icon { width: 1.3rem; height: 1.3rem; vertical-align: -0.3rem; }
.hud-gold { margin-left: 0.35rem; }

.hud-hearts {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
  background: none;
  margin-right: 0.6rem;
}
.hud-heart {
  position: relative;
  width: 1.45rem;
  height: 1.3rem;
  background: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.65));
}
.hud-heart svg { position: absolute; inset: 0; width: 100%; height: 100%; background: none; overflow: visible; }
.hud-heart .heart-empty path { fill: rgba(20, 12, 6, 0.45); stroke: rgba(0,0,0,0.5); stroke-width: 3; }
.hud-heart .heart-fill path { fill: #e3483f; stroke: rgba(0,0,0,0.5); stroke-width: 3; }

#game {
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: block;
  background: #203528;
  touch-action: none;
}
#overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(8, 14, 10, 0.28);
}
.overlay-panel {
  width: min(420px, 100%);
  padding: 1.25rem 1.3rem 1.35rem;
  background: transparent url("../assets/ui/stone_panel.png") center / 100% 100% no-repeat;
  border-radius: 0;
  box-shadow: 0 12px 32px var(--shadow);
  text-align: center;
  color: #fff6e4;
  text-shadow: 0 1px 2px rgba(0,0,0,0.75);
  filter: brightness(0.88) contrast(1.05);
}
.overlay-panel > * { filter: brightness(1.18); }
.overlay-panel h2 {
  margin: 0.35rem 0 0.4rem;
  font-family: Fredoka, sans-serif;
  color: #fff8e6;
}
.overlay-panel p { margin: 0 0 0.75rem; }
.btn-next {
  display: inline-block;
  min-width: 180px;
  height: 56px;
  padding: 0 1.4rem;
  border: none;
  background: transparent url("../assets/ui/wood_bar.png") center / 100% 100% no-repeat;
  color: #fff6e4;
  font-weight: 800;
  line-height: 56px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.75);
  filter: brightness(0.9);
}
.btn-next:active { transform: translateY(2px); }
