/* Full-screen mobile shell; desktop gets the same viewport-sized layout. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  overscroll-behavior: none; /* only works from the root: kills pull-to-refresh */
  touch-action: manipulation; /* no double-tap or pinch zoom anywhere */
}

body {
  margin: 0;
  height: 100vh;
  height: 100dvh; /* 100vh alone hides the bottom behind the mobile address bar */
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #070512;
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

input, textarea, [contenteditable] {
  user-select: text;
  -webkit-user-select: text;
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* taps and drags feed the game, never scroll the page */
}

/* Overlays routed by GAME.setScreen(); only tappables catch taps — text and
   wrappers let them through to the canvas. */
.screen {
  position: absolute;
  inset: 0;
  display: grid;
  text-align: center;
  padding: 2rem;
  gap: 0.75rem;
}
.screen, .screen * { pointer-events: none; }
.screen :is(button, a, input, [data-action]) { pointer-events: auto; }
.screen[hidden] { display: none; } /* display: grid above would defeat [hidden] */

button {
  font: inherit;
  font-size: 1.15rem;
  min-height: 48px;
  padding: 0.7rem 2.4rem;
  border: 0;
  border-radius: 999px;
  background: #7c6cff;
  color: #fff;
  cursor: pointer;
  justify-self: center;
}
button:active { transform: scale(0.96); }

h1 { margin: 0; font-size: 2.4rem; }
#tagline { margin: 0 0 1rem; color: #8f8ba8; max-width: 20rem; }
#resume-note { margin: 0; color: #8f8ba8; font-size: 0.95rem; }

/* ---- Start screen ---- */
.screen[data-screen="start"] {
  place-content: center;
  align-content: center;
}
.start-wrap {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
}
.logo-slime {
  font-size: 4.5rem;
  filter: drop-shadow(0 0 18px rgba(124,108,255,0.6));
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.04); }
}
#title {
  background: linear-gradient(90deg, #7c6cff, #3fd6a0, #ffcf4d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---- Play screen: HUD on top, ingredient bar at the bottom ---- */
.screen[data-screen="play"] {
  grid-template-rows: auto 1fr auto;
  align-content: stretch;
  justify-items: stretch;
  padding: 0;
}
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem calc(env(safe-area-inset-top) + 0.4rem);
  /* push it below the notch */
  margin-top: env(safe-area-inset-top);
  font-size: 0.95rem;
}
#slime-name {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
}
#drop-count {
  color: #b9b4d6;
  font-variant-numeric: tabular-nums;
}
#empty-hint {
  align-self: end;
  justify-self: center;
  color: #8f8ba8;
  font-size: 1rem;
  margin-bottom: 0.4rem;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* Ingredient bar — pill cards in a scrollable row */
.lab-bar {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem calc(env(safe-area-inset-bottom) + 0.55rem);
  background: linear-gradient(180deg, rgba(13,10,31,0) 0%, rgba(13,10,31,0.85) 40%, rgba(7,5,18,0.96) 100%);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.lab-bar::-webkit-scrollbar { display: none; }

.ing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  min-width: 62px;
  min-height: 0;
  height: 52px;
  padding: 0.25rem 0.45rem;
  border-radius: 14px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.10);
  color: #fff;
  font-size: 0.78rem;
  flex: 0 0 auto;
  transition: transform 0.08s ease, background 0.15s ease;
}
.ing .ing-emoji {
  font-size: 1.3rem;
  line-height: 1;
}
.ing .ing-label {
  font-size: 0.68rem;
  color: #c9c4e0;
}
.ing:active {
  transform: scale(0.9);
  background: rgba(124,108,255,0.28);
}
.ing.clear {
  background: rgba(255,93,115,0.14);
  border-color: rgba(255,93,115,0.30);
}
.ing.clear .ing-label { color: #ff9aa8; }
.ing.clear:active { background: rgba(255,93,115,0.34); }

/* ---- Trophy shelf (start screen) ---- */
.trophies {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.6rem;
  width: 100%;
  max-width: 24rem;
}
.trophy {
  flex: 1;
  display: grid;
  gap: 0.2rem;
  justify-items: center;
  padding: 0.6rem 0.5rem;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}
.trophy-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8f8ba8;
}
#best-name {
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.1;
  word-break: break-word;
}
#disc-count {
  font-weight: 700;
  font-size: 0.95rem;
  color: #ffcf4d;
}
.trophy-sub {
  font-size: 0.68rem;
  color: #8f8ba8;
}
.trophy-sub b { color: #c9c4e0; }
