:root {
  --ink: #3b2a1a;
  --ink-soft: #7a6450;
  --card: #fffaf0;
  --accent: #f29e4c;
  --accent-dark: #c9742a;
  --leaf: #6fae4a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #bfe3f0;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  user-select: none;
}

#game { display: block; width: 100vw; height: 100vh; }

.hidden { display: none !important; }

/* HUD */
#hud {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  gap: 10px;
  pointer-events: none;
}
.hud-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 6px 10px;
  background: rgba(255, 250, 240, 0.88);
  border-radius: 999px;
  font-weight: 900;
  font-size: 20px;
  box-shadow: 0 3px 0 rgba(59, 42, 26, 0.18);
}
.hud-item .icon { font-size: 22px; }
.hud-item.bump { animation: bump 0.25s ease-out; }
#hud-crates { margin-left: auto; }
.hud-btn {
  pointer-events: auto;
  border: 0;
  background: rgba(255, 250, 240, 0.88);
  border-radius: 999px;
  width: 42px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(59, 42, 26, 0.18);
}
@keyframes bump { 40% { transform: scale(1.18); } }

/* Toast */
#toast {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translate(-50%, 0);
  padding: 10px 22px;
  background: rgba(255, 250, 240, 0.92);
  border-radius: 14px;
  font-weight: 800;
  font-size: 22px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 4px 0 rgba(59, 42, 26, 0.18);
  text-align: center;
  max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, -8px); }

#fade {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s;
}
#fade.on { opacity: 1; }
/* cartoon iris wipe: black everywhere except a circle at (--ix, --iy) of radius --ir */
#fade.iris {
  opacity: 1;
  transition: none;
  -webkit-mask-image: radial-gradient(circle at var(--ix) var(--iy), transparent var(--ir), #000 calc(var(--ir) + 1.5px));
  mask-image: radial-gradient(circle at var(--ix) var(--iy), transparent var(--ir), #000 calc(var(--ir) + 1.5px));
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(40, 60, 30, 0.25);
}
/* keep the celebrating boar visible above the results */
#complete { align-items: flex-end; padding-bottom: 5vh; background: transparent; }
.card {
  background: var(--card);
  border-radius: 24px;
  padding: 28px 34px;
  text-align: center;
  box-shadow: 0 8px 0 rgba(59, 42, 26, 0.2);
  max-width: 420px;
  width: 100%;
}
h1 { margin: 0 0 4px; font-size: 44px; font-weight: 900; }
h2 { margin: 0 0 14px; font-size: 30px; font-weight: 900; }
.sub { margin: 0 0 18px; color: var(--ink-soft); font-weight: 700; }
.sub.small { margin: 14px 0 0; font-size: 14px; }
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: #e9dcc6;
  font-size: 12px;
  vertical-align: 2px;
}
.btn {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--accent-dark);
  transition: transform 0.08s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--accent-dark); }
.btn.ghost { background: #e9dcc6; color: var(--ink); box-shadow: 0 5px 0 #c9b89c; }

.controls {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.9;
}
kbd {
  display: inline-block;
  padding: 0 7px;
  border-radius: 6px;
  background: #efe3cf;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 2px 0 #cdb99a;
}
.stats { list-style: none; margin: 0; padding: 0; font-size: 20px; font-weight: 800; line-height: 1.8; }
.stats b { margin-left: 8px; }
.gem { font-weight: 800; color: var(--ink-soft); min-height: 1.4em; }
.gem.got { color: #3b8fd1; }

@media (max-width: 480px) {
  h1 { font-size: 34px; }
  .card { padding: 22px 18px; }
  .hud-item { font-size: 16px; padding: 4px 10px 4px 8px; }
}

/* ---- title menu (Nickelodeon-style splash) ---- */
.splash {
  flex-direction: column;
  background: radial-gradient(circle at 50% 45%, #ffcf7a 0%, #9142dc 45%, #6a25b0 100%);
}
.splash img { width: min(720px, 92vw); height: auto; animation: pulse 2.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.035); } }

.splash-ui {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 5vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.splash-ui > * { pointer-events: auto; }
.splash-ui.busy > * { pointer-events: none; opacity: 0; transition: opacity 0.3s; }
.chip.sleepy { background: rgba(200, 210, 255, 0.85); color: #26285f; box-shadow: 0 4px 0 #26285f; }
.btn-big {
  font-family: 'Luckiest Guy', 'Nunito', sans-serif;
  font-size: clamp(34px, 6vw, 56px);
  letter-spacing: 2px;
  color: #fff;
  background: #ff7a0f;
  border: 6px solid #fff;
  border-radius: 999px;
  padding: 14px 64px 8px;
  cursor: pointer;
  text-shadow: 0 4px 0 #4b1e7a;
  box-shadow: 0 8px 0 #4b1e7a, 0 14px 30px rgba(40, 0, 70, 0.45);
  animation: wobble 2.6s ease-in-out infinite;
}
.btn-big:hover { background: #ff8f2e; }
.btn-big:active { transform: translateY(5px); box-shadow: 0 3px 0 #4b1e7a; }
@keyframes wobble { 0%, 100% { transform: rotate(-2deg) scale(1); } 50% { transform: rotate(2deg) scale(1.05); } }
.press {
  margin: 0;
  font-family: 'Luckiest Guy', 'Nunito', sans-serif;
  font-size: 20px;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 3px 0 #4b1e7a;
  animation: blink 1.6s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: 0.55; } }
.menu-row { display: flex; gap: 10px; }
.chip {
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.92);
  color: #4b1e7a;
  font: 800 16px 'Nunito', sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 0 #4b1e7a;
}

/* ---- pause: frosted edges, the napping boar stays clear in the middle ---- */
#pause { position: fixed; inset: 0; pointer-events: none; }
#pause .frost {
  position: absolute;
  inset: 0;
  background: rgba(225, 238, 255, 0.22);
  -webkit-backdrop-filter: blur(10px) saturate(1.35);
  backdrop-filter: blur(10px) saturate(1.35);
  -webkit-mask-image: radial-gradient(ellipse 34% 40% at 50% 52%, transparent 45%, black 100%);
  mask-image: radial-gradient(ellipse 34% 40% at 50% 52%, transparent 45%, black 100%);
  animation: frost-in 0.6s ease-out;
}
@keyframes frost-in { from { opacity: 0; } }
.pause-top { position: absolute; top: 72px; left: 0; right: 0; text-align: center; }
.pause-title {
  margin: 0;
  font-family: 'Luckiest Guy', 'Nunito', sans-serif;
  font-size: clamp(40px, 7vw, 64px);
  font-weight: normal;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 5px 0 #4b1e7a;
  animation: float 3s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-6px); } }
.pause-bottom {
  position: absolute;
  bottom: 5vh;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}
.btn-big.small { font-size: clamp(26px, 4.5vw, 40px); padding: 10px 48px 4px; }

/* ---- level complete: the boar (and Mama) stay visible above the card ---- */
#complete { position: fixed; inset: 0; pointer-events: none; }
.complete-card {
  position: absolute;
  left: 50%;
  bottom: 3vh;
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px));
  padding: 16px 22px 14px;
  border-radius: 24px;
  background: rgba(255, 250, 240, 0.9);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 0 rgba(75, 30, 122, 0.35);
  text-align: center;
  pointer-events: auto;
  animation: card-up 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes card-up { from { transform: translate(-50%, 40px); opacity: 0; } }
.complete-card .stats { font-size: 19px; line-height: 1.7; }
.complete-card .prev { font-size: 14px; color: var(--ink-soft); line-height: 1; margin-bottom: 4px; }
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 10px 0;
  border-radius: 999px;
  background: #ff7a0f;
  color: #fff;
  font: normal 15px 'Luckiest Guy', sans-serif;
  letter-spacing: 1px;
  transform: rotate(-4deg);
  animation: bump 0.6s ease-out 0.3s;
}
.gem { margin: 6px 0; }
.missed { list-style: none; margin: 0 0 8px; padding: 0; font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.missed li::before { content: '📦 '; }
.tagline {
  margin: 0;
  font: 800 16px 'Nunito', sans-serif;
  color: #fff;
  text-shadow: 0 2px 0 #4b1e7a;
}

/* ---- controls strip: shown while idle, fades away while you play ---- */
.controls-hint {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  max-width: calc(100vw - 32px);
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.82);
  box-shadow: 0 3px 0 rgba(59, 42, 26, 0.18);
  color: var(--ink-soft);
  font: 800 14px 'Nunito', sans-serif;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s;
}
.controls-hint.show { opacity: 1; }
