:root {
  --black: #100b0b;
  --white: #ffffff;
  --orange: #f59b14;
  --grey: #7d7d7d;
  --purple: #9a86ff;
  --skin: #ba7f6d;
  --red: #ff0000;
  color-scheme: dark;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', Arial;
}

body {
  background: var(--black);
  color: var(--white);
  display: flex;
  align-items: stretch;
}

.app {
  max-width: 420px;
  margin: auto;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  margin-top: 10%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
}

.coins {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 700;
}

.coin-badge {
  background: var(--orange);
  color: var(--black);
  padding: 6px 10px;
  border-radius: 20px;
}

.play-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* place the doodle area lower on the screen so its top sits ~20% from the top */
  justify-content: flex-start;
  padding-top: 20vh;
  padding: 8px 8px 8px 8px;
}

/* make the doodle card responsive so the stacked figure can grow to fill more of the screen */
.doodle {
  width: 92%;
  max-width: 420px;
  height: auto;
  border-radius: 16px;
  background: var(--purple);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 16px;
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.06);
}

/* Flexible background layer for the doodle card. Uses a CSS variable
   `--doodle-bg` so you can override it with an image or gradient. The
   pseudo-element covers the full card and scales via background-size: cover. */
.doodle {
  position: relative;
  overflow: hidden;
}
.doodle::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  /* Default background: subtle radial gradient. Override with --doodle-bg. */
  background: var(
    --doodle-bg,
    radial-gradient(1200px 600px at 10% 20%, rgba(154, 134, 255, 0.18), transparent 30%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0))
  );
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  border-radius: inherit;
  pointer-events: none;
}

/* Ensure doodle content sits above the background layer */
.doodle > * {
  position: relative;
  z-index: 1;
}

/* Use the provided graveyard image as the doodle background. Keep this
   relative path so it works when served from the project root. If you
   deploy the app from a subfolder, adjust the path accordingly. */
.doodle {
  /* No hard-coded image path here. The JS `render()` sets `--doodle-bg` to a
     fully-resolved URL at runtime (using document.baseURI) so backgrounds
     work both locally and when deployed under subpaths. */
  /* provide a sensible fallback color so the card isn't empty while JS runs */
  --doodle-bg: radial-gradient(1200px 600px at 10% 20%, rgba(154, 134, 255, 0.18), transparent 30%);
}

/* face used as an overlayed image inside the stacked figure; size is controlled by .stack */
.face {
  display: block;
  transition: transform 0.12s;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.face.smile {
  transform: translateY(-4px);
}

.face.surprised {
  transform: scale(0.98);
}

.drum-piece {
  margin-top: 14px;
  width: 200px;
  height: 120px;
  background: var(--orange);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey);
}

/* stacked figure images — ensure images fill the stack and overlay exactly */
.stack {
  position: relative;
  z-index: 1;
  width: 86%;
  max-width: 380px;
  margin: 8px auto;
  aspect-ratio: 1/1;
}

.stack img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* ensure the face image is on top */
#face {
  z-index: 40;
}

#armLeftImg {
  z-index: 29;
}

#armLeftCymbalImg {
  z-index: 27;
}

#armLeftTomImg {
  z-index: 28;
}

#armRightImg {
  z-index: 26;
}

#armRightTomImg {
  z-index: 25;
}

#armRightSnareImg {
  z-index: 30;
}

#bodyImg {
  z-index: 10;
}

#drumTapImg {
  z-index: 41;
}

/* When the cursed drum skin is active, ensure the tap overlay sits above all UI */
#drumTapImg.tap--cursed {
  z-index: 99999 !important;
}

#drumImg {
  z-index: 40;
}

/* cymbal should sit above the character */
#cymbalImg {
  z-index: 59;
}

#cymbalTapImg {
  z-index: 60;
}

#tomImg {
  z-index: 50;
}

#tomTapImg {
  z-index: 51;
}

#snareImg {
  z-index: 52;
}

#snareTapImg {
  z-index: 53;
}

.bottom {
  /* reduce vertical padding so buttons sit slightly higher on the screen */
  padding: 8px 14px;
  display: flex;
  justify-content: center;
  /* keep the bottom controls in normal flow, below the play-area */
  position: static;
  margin-top: 8px;
  z-index: 200;
}

.play-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}

.play-btn {
  background: var(--orange);
  border: 0;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--orange);
  font-weight: 700;
}

/* small icon buttons shown for owned instruments */
.small-play-btn {
  background: var(--orange);
  border: 0;
  padding: 6px;
  border-radius: 10px;
  color: var(--white);
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.small-play-btn img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: block;
}

button {
  background: var(--orange);
  border: 0;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--black);
  font-weight: 700;
}

.shop-btn {
  background: var(--orange);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--black);
}

/* modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
  z-index: 10000;
}

.modal.open {
  display: flex;
}

.modal-card {
  width: 92%;
  max-width: 420px;
  background: #0c0c10;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  /* Limit modal height so it doesn't overflow the viewport; allow internal scrolling */
  max-height: 70vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
}

.item.owned {
  opacity: 0.4;
}

.items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.small {
  font-size: 12px;
  color: var(--white);
}

.update-banner {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 12px;
  background: var(--black);
  padding: 8px 12px;
  border-radius: 10px;
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 9999;
}

.update-banner button {
  background: var(--orange);
  color: var(--black);
  border: 0;
  padding: 6px 8px;
  border-radius: 6px;
}

.idle-hint {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translate(-50%, -50%);
  width: 80vw; /* <- 80% of the viewport width */
  max-width: 420px; /* <- optional cap to keep it from getting too wide on large screens */
  box-sizing: border-box; /* include padding in the width calculation */
  background: rgba(0, 0, 0, 0.6);
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--white);
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.25s cubic-bezier(0.2, 0.9, 0.2, 1);
  z-index: 2000;
  text-align: center; /* nicer for wider blocks */
  word-wrap: break-word; /* avoid overflow from long words */
}

.idle-hint.show {
  opacity: 1;
  transform: translate(-50%, -60%);
}

/* Small completion indicator shown in the shop modal */
.shop-completion {
  margin-top: 8px;
  margin-bottom: 6px;
  color: var(--grey);
  font-size: 13px;
  font-weight: 700;
}
