:root {
  color-scheme: light;
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --pink: #ff71ce;
  --yellow: #dfff00;
  --cyan: #00ffff;
  --purple: #7c3aed;
  --orange: #ff7a00;
  --lavender: #e7d5ff;
  --ink: #3b176d;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: var(--purple);
}

body {
  display: grid;
  place-items: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  background-image: linear-gradient(45deg, var(--pink) 25%, transparent 25%), linear-gradient(-45deg, var(--cyan) 25%, transparent 25%);
  background-size: 42px 42px;
}

button { font: inherit; }

.game-shell {
  position: relative;
  width: min(100vw, 540px);
  height: 100dvh;
  min-height: 540px;
  overflow: hidden;
  isolation: isolate;
  background: var(--cyan);
  touch-action: none;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.game-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: .12;
  background-image: radial-gradient(circle, var(--yellow) 0 2px, transparent 2.5px);
  background-size: 24px 24px;
}

.topbar {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(18px, env(safe-area-inset-top)) 18px 10px;
  color: var(--ink);
  pointer-events: none;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 9px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(var(--pink) 0 33%, var(--yellow) 33% 66%, var(--cyan) 66%);
  box-shadow: 3px 3px 0 var(--purple);
}

.brand h1 {
  margin: 0;
  color: var(--purple);
  font-family: Georgia, serif;
  font-size: clamp(20px, 5.5vw, 28px);
  line-height: .95;
  letter-spacing: -.055em;
  text-shadow: 2px 2px 0 var(--yellow);
}

.brand p {
  margin: 5px 0 0;
  color: var(--purple);
  font-size: 12px;
  font-weight: 900;
}

.top-actions { display: flex; gap: 8px; pointer-events: auto; }

.icon-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 3px solid var(--purple);
  border-radius: 18px;
  color: var(--purple);
  background: var(--yellow);
  box-shadow: 0 5px 0 var(--pink);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}

.icon-button:nth-child(2) { background: var(--pink); box-shadow-color: var(--cyan); }
.icon-button:active { transform: translateY(4px) rotate(3deg); box-shadow: 0 1px 0 var(--cyan); }
.icon-button svg { width: 22px; height: 22px; fill: currentColor; }
.sound-off { display: none; }
.icon-button[aria-pressed="false"] .sound-on { display: none; }
.icon-button[aria-pressed="false"] .sound-off { display: block; }

.stats {
  position: absolute;
  z-index: 10;
  top: max(82px, calc(env(safe-area-inset-top) + 63px));
  left: 18px;
  display: flex;
  gap: 9px;
  pointer-events: none;
}

.stats div {
  min-width: 72px;
  padding: 8px 11px;
  border: 3px solid var(--purple);
  border-radius: 18px;
  color: var(--ink);
  background: var(--pink);
  box-shadow: 4px 4px 0 var(--yellow);
}

.stats div:nth-child(2) { background: var(--cyan); transform: rotate(2deg); box-shadow-color: var(--pink); }
.stats span { display: block; font-family: "Courier New", monospace; font-size: 18px; font-weight: 900; line-height: 1; }
.stats small { display: block; margin-top: 3px; color: var(--purple); font-size: 10px; font-weight: 900; }

.hint {
  position: absolute;
  z-index: 11;
  left: 50%;
  top: 48%;
  width: 224px;
  padding: 15px 16px;
  transform: translate(-50%, -50%) rotate(-2deg);
  border: 4px solid var(--purple);
  border-radius: 26px;
  color: var(--ink);
  background-color: var(--yellow);
  background-image: radial-gradient(circle, var(--pink) 0 2px, transparent 2.5px);
  background-size: 19px 19px;
  box-shadow: 8px 8px 0 var(--pink), -5px -5px 0 var(--cyan);
  text-align: center;
  pointer-events: none;
  transition: opacity .45s ease, transform .45s ease;
}

.hint.hidden { opacity: 0; transform: translate(-50%, -46%) scale(.9); }
.hint p { margin: 7px 0 0; font-size: 14px; font-weight: 900; line-height: 1.35; text-shadow: 1px 1px 0 var(--pink); }

.finger {
  display: block;
  width: 18px;
  height: 27px;
  margin: auto;
  border: 4px solid var(--purple);
  border-radius: 11px 11px 8px 8px;
  background: var(--cyan);
  animation: scratch 1.35s ease-in-out infinite;
}

@keyframes scratch {
  0%, 100% { transform: translateX(-30px) rotate(-14deg); }
  50% { transform: translateX(30px) rotate(14deg); }
}

.toolbar {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(92%, 410px);
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.toolbar-actions { display: flex; align-items: stretch; gap: 9px; }

.bomb-button,
.scene-button {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 3px solid var(--purple);
  border-radius: 24px;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  pointer-events: auto;
  transition: transform .2s ease, box-shadow .2s ease;
}

.bomb-button { flex: 1.1; background: var(--yellow); box-shadow: 0 7px 0 var(--pink); }
.scene-button { flex: 1; background: var(--cyan); box-shadow: 0 7px 0 var(--purple); }
.scene-button svg { width: 25px; height: 25px; fill: var(--purple); }
.bomb-button:active, .scene-button:active { transform: translateY(5px) rotate(-2deg); box-shadow: 0 2px 0 var(--pink); }
.toolbar p { display: inline-block; margin: 12px 0 0; padding: 4px 10px; border-radius: 12px; color: var(--purple); background: var(--pink); font-family: "Courier New", monospace; font-size: 11px; font-weight: 900; }

.mini-bomb {
  position: relative;
  width: 28px;
  height: 28px;
  border: 3px solid var(--purple);
  border-radius: 50%;
  background: var(--pink);
  box-shadow: inset -6px -7px 0 var(--orange), inset 5px 5px 0 var(--cyan);
}

.mini-bomb::before {
  content: "";
  position: absolute;
  width: 5px;
  height: 10px;
  top: -9px;
  left: 18px;
  border: 3px solid var(--purple);
  border-left: 0;
  border-bottom: 0;
  border-radius: 0 8px 0 0;
}

.mini-bomb i {
  position: absolute;
  width: 7px;
  height: 7px;
  top: -11px;
  right: -6px;
  border-radius: 50%;
  background: var(--yellow);
}

.flash {
  position: absolute;
  z-index: 30;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: conic-gradient(from 45deg, var(--pink), var(--yellow), var(--cyan), var(--purple), var(--pink));
}

.flash.fire { animation: flash .38s ease-out; }
@keyframes flash { 0% { opacity: .86; } 100% { opacity: 0; } }

.game-shell.shake { animation: shake .4s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake {
  0%, 100% { transform: translate(0); }
  18% { transform: translate(-7px, 4px) rotate(-.35deg); }
  36% { transform: translate(7px, -4px) rotate(.3deg); }
  54% { transform: translate(-4px, -2px); }
  72% { transform: translate(3px, 3px); }
}

@media (min-width: 600px) {
  .game-shell { height: min(94dvh, 900px); border: 5px solid var(--yellow); border-radius: 32px; box-shadow: 16px 16px 0 var(--pink), -16px -16px 0 var(--cyan); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* HUD, campo e controles ocupam faixas próprias: nenhuma camada cobre o jogo. */
.game-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.game-shell::after { display: none; }

.game-hud {
  position: relative;
  z-index: 10;
  padding: max(12px, env(safe-area-inset-top)) 16px 10px;
  border-bottom: 5px solid var(--purple);
  background-color: var(--pink);
  background-image: radial-gradient(circle, var(--yellow) 0 2px, transparent 2.5px);
  background-size: 22px 22px;
}

.topbar {
  position: static;
  padding: 0;
}

.stats {
  position: static;
  margin-top: 10px;
}

.stats div { padding: 6px 10px; }

.playfield {
  position: relative;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  background: var(--cyan);
  touch-action: none;
}

.playfield::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: .1;
  background-image: radial-gradient(circle, var(--yellow) 0 2px, transparent 2.5px);
  background-size: 24px 24px;
}

.hint { top: 50%; }

.toolbar {
  position: relative;
  z-index: 12;
  left: auto;
  bottom: auto;
  width: 100%;
  padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  transform: none;
  border-top: 5px solid var(--purple);
  background-color: var(--orange);
  background-image: repeating-linear-gradient(135deg, transparent 0 12px, rgba(255,113,206,.55) 12px 18px);
}

.toolbar p { margin-top: 8px; }

.playfield.shake { animation: shake .4s cubic-bezier(.36,.07,.19,.97); }
