*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #2a1a0e;
  font-family: "Nunito", system-ui, sans-serif;
  color: #fff;
  touch-action: manipulation;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.game-wrapper {
  position: relative;
  width: 100%;
  max-width: min(480px, 100vw);
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: rgba(44, 28, 14, 0.95);
  border-bottom: 2px solid rgba(255, 220, 160, 0.15);
}

.brand-mark {
  font-family: "Fredoka One", cursive;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: #ffd166;
}

.mute-btn {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.mute-btn[aria-pressed="true"] {
  opacity: 0.7;
}

.game-ui {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: rgba(60, 40, 20, 0.92);
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.hud-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
}

.hud-value {
  font-family: "Fredoka One", cursive;
  font-size: 1.35rem;
  line-height: 1;
  color: #ffe08a;
}

.hud-lives {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  justify-content: flex-end;
  min-width: 4.5rem;
}

.hud-lives img {
  width: 1.5rem;
  height: 1.5rem;
  object-fit: contain;
}

#gameCanvas {
  display: block;
  width: 100%;
  max-width: 100%;
  flex: 0 0 auto;
  height: auto;
  aspect-ratio: 480 / 600;
  max-height: calc(100dvh - 7.5rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  touch-action: none;
  cursor: crosshair;
  background: #5c3d1e;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  background: rgba(20, 12, 6, 0.88);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.overlay-brand {
  margin: 0;
  font-family: "Fredoka One", cursive;
  font-size: 0.9rem;
  color: #ffd166;
  letter-spacing: 0.06em;
}

.overlay h1,
.overlay h2 {
  margin: 0;
  font-family: "Fredoka One", cursive;
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  color: #fff;
}

.overlay-desc,
.overlay-hint {
  margin: 0;
  max-width: 22rem;
  font-size: 0.95rem;
  line-height: 1.45;
  opacity: 0.9;
}

.btn-start {
  margin-top: 0.5rem;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 2rem;
  font-family: "Fredoka One", cursive;
  font-size: 1.1rem;
  color: #2a1a0e;
  background: linear-gradient(180deg, #ffd166 0%, #f4a261 100%);
  box-shadow: 0 4px 0 #b5651d;
  cursor: pointer;
}

.btn-start:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #b5651d;
}

@media (max-width: 520px) {
  .desktop-hint {
    display: none;
  }
}

@media (min-width: 521px) {
  .mobile-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-start:active {
    transform: none;
  }
}
