:root {
  --sky: #3d9be9;
  --sky-2: #7ec8ff;
  --grass: #5aad32;
  --grass-dark: #3f8a22;
  --dirt: #8b5a2b;
  --wood: #c4a574;
  --ink: #1a1208;
  --gold: #ffd24a;
  --panel: #f4f7ef;
  --font-pixel: "Press Start 2P", monospace;
  --font-body: "VT323", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0d1b2a;
  font-family: var(--font-body);
  color: var(--ink);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  background: linear-gradient(180deg, var(--sky) 0%, var(--sky-2) 55%, #b8e8ff 55%, #b8e8ff 62%, var(--grass) 62%);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background: transparent;
}

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 12px max(20px, env(safe-area-inset-bottom));
  background: rgba(10, 25, 40, 0.55);
  backdrop-filter: blur(2px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.panel {
  width: min(100%, 440px);
  margin: 0 auto 24px;
  background: var(--panel);
  border: 5px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 18px 16px 16px;
  text-align: center;
  flex-shrink: 0;
}

.win-panel {
  position: relative;
  overflow: visible;
  max-width: min(100%, 440px);
}

.prize-hero {
  position: relative;
  margin: 0 0 14px;
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: radial-gradient(circle at 50% 40%, #fff7b0 0%, #ffe27a 35%, #7ec8ff 70%, #3d9be9 100%);
  border: 4px solid var(--ink);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35), 4px 4px 0 var(--ink);
  overflow: visible;
}

.prize-sun {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 10px;
  background: radial-gradient(circle at 35% 30%, #fffce8, #ffd24a 48%, #f0a202 78%);
  border: 4px solid var(--ink);
  box-shadow:
    0 0 0 5px rgba(255, 210, 74, 0.35),
    0 0 16px 4px rgba(255, 230, 120, 0.7),
    3px 3px 0 var(--ink);
  animation: sun-pop 0.9s cubic-bezier(0.2, 1.4, 0.4, 1) both, sun-pulse 2.2s ease-in-out 0.9s infinite;
  z-index: 1;
}

.prize-sun-core {
  position: absolute;
  inset: 12px;
  background: #fff7b0;
  border: 2px solid rgba(26, 18, 8, 0.2);
}

.prize-percent {
  position: relative;
  z-index: 2;
  margin: 0;
  text-align: center;
  width: 100%;
  animation: prize-bounce 0.85s cubic-bezier(0.2, 1.5, 0.4, 1) 0.15s both;
}

.prize-number {
  display: block;
  font-family: var(--font-pixel);
  font-size: clamp(2rem, 12vw, 2.8rem);
  line-height: 1.05;
  padding: 4px 0;
  color: #fff8dc;
  text-shadow:
    3px 3px 0 #1a1208,
    -2px 0 0 #1a1208,
    2px 0 0 #1a1208,
    0 0 14px rgba(255, 210, 74, 1);
  animation: percent-shine 1.8s ease-in-out infinite;
}

.prize-label {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 8px;
  font-family: var(--font-pixel);
  font-size: 0.48rem;
  letter-spacing: 0.04em;
  color: #1a1208;
  background: #ffd24a;
  border: 3px solid #1a1208;
  box-shadow: 3px 3px 0 #1a1208;
}

.prize-won {
  position: relative;
  z-index: 2;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-pixel);
  font-size: clamp(0.4rem, 2.2vw, 0.5rem);
  line-height: 1.45;
  color: #153d12;
  background: rgba(244, 247, 239, 0.92);
  border: 3px solid #1a1208;
  padding: 8px 8px;
  box-shadow: 3px 3px 0 #1a1208;
}

.win-panel h2 {
  font-size: clamp(0.52rem, 2.6vw, 0.7rem);
  line-height: 1.5;
  margin-bottom: 10px;
}

.win-panel .lead {
  font-size: clamp(1.05rem, 4.2vw, 1.2rem);
  margin-bottom: 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.win-panel .brand-break {
  display: block;
  margin-top: 4px;
  margin-bottom: 4px;
  color: #1a5c12;
  font-weight: 700;
}

.win-panel .btn-cta {
  min-height: 56px;
  margin-bottom: 8px;
}

body.showing-win .game-top-title {
  display: none;
}

@media (max-height: 720px) {
  .prize-hero {
    padding: 12px 8px 10px;
    margin-bottom: 10px;
    gap: 6px;
  }
  .prize-sun {
    width: 48px;
    height: 48px;
  }
  .prize-sun-core {
    inset: 10px;
  }
  .prize-number {
    font-size: clamp(1.7rem, 10vw, 2.2rem);
  }
  .win-panel {
    padding: 14px 12px 12px;
  }
  .win-stats {
    margin-bottom: 8px;
    padding: 6px 8px;
    font-size: 0.42rem;
  }
}

.brand {
  margin: 0 0 10px;
  font-family: var(--font-pixel);
  font-size: clamp(0.72rem, 3.5vw, 0.9rem);
  color: #c99700;
  letter-spacing: 0.04em;
  text-shadow: 2px 2px 0 #1a1208;
}

.game-top-title {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  z-index: 13;
  margin: 0;
  text-align: center;
  font-family: var(--font-pixel);
  font-size: clamp(0.55rem, 3vw, 0.72rem);
  line-height: 1.4;
  color: #ffd24a;
  text-shadow: 2px 2px 0 #1a1208, -1px 0 0 #1a1208, 1px 0 0 #1a1208;
  pointer-events: none;
}

h1, h2 {
  margin: 0 0 14px;
  font-family: var(--font-pixel);
  font-size: clamp(0.78rem, 3.6vw, 1rem);
  line-height: 1.55;
  color: #153d12;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.45);
}

.lead {
  margin: 0 0 18px;
  font-size: 1.28rem;
  line-height: 1.35;
}

.lead strong {
  color: #1a5c12;
  font-weight: 700;
}

.help {
  margin-top: 14px;
  font-size: 1.12rem;
  line-height: 1.35;
  opacity: 0.92;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border: 2px solid #1b1b1b;
  border-radius: 0;
  font-family: var(--font-pixel);
  font-size: 0.58rem;
  line-height: 1.4;
  text-decoration: none;
  color: #373737;
  cursor: pointer;
  background: #c6c6c6;
  box-shadow:
    inset 2px 2px 0 #ffffff,
    inset -2px -2px 0 #555555,
    0 0 0 1px #000;
  transition: filter 0.08s ease, transform 0.08s ease;
  image-rendering: pixelated;
}

.btn:active {
  transform: translate(1px, 1px);
  box-shadow:
    inset 2px 2px 0 #555555,
    inset -2px -2px 0 #ffffff,
    0 0 0 1px #000;
  filter: brightness(0.92);
}

.btn-primary {
  background: #c6c6c6;
  color: #373737;
}

.btn-primary:hover,
.btn:hover {
  filter: brightness(1.06);
}

.btn-cta {
  background: linear-gradient(180deg, #d8d8d8, #bdbdbd);
  font-size: clamp(0.48rem, 2.8vw, 0.56rem);
  min-height: 64px;
  margin-bottom: 12px;
  color: #1a1a1a;
}

.btn-secondary {
  background: #bdbdbd;
  margin-top: 10px;
}

.btn-artur {
  background: #5aad32;
  color: #fff8dc;
  margin-top: 10px;
  font-size: clamp(0.42rem, 2.4vw, 0.5rem);
  min-height: 48px;
  text-shadow: 2px 2px 0 #1a1208;
  box-shadow:
    inset 2px 2px 0 #9be37a,
    inset -2px -2px 0 #2f6b18,
    0 0 0 1px #000;
}

.legal {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.35;
  opacity: 0.88;
}

.win-panel {
  position: relative;
  overflow: hidden;
}

.win-panel::before {
  display: none;
}

.confetti {
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 2;
}

.confetti i {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 8px;
  background: #ffd24a;
  animation: confetti-fall 1.4s linear forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(460px) rotate(400deg);
    opacity: 0;
  }
}

.prize-hero {
  position: relative;
  margin: 0 0 18px;
  padding: 18px 10px 12px;
  min-height: 168px;
  display: grid;
  place-items: center;
  gap: 6px;
  background: radial-gradient(circle at 50% 40%, #fff7b0 0%, #ffe27a 35%, #7ec8ff 70%, #3d9be9 100%);
  border: 4px solid var(--ink);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35), 4px 4px 0 var(--ink);
  overflow: hidden;
}

.prize-rays {
  position: absolute;
  inset: -40%;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255, 255, 255, 0.35) 0deg 12deg,
    rgba(255, 210, 74, 0.08) 12deg 24deg
  );
  animation: rays-spin 10s linear infinite;
  opacity: 0.85;
}

.prize-sun {
  position: absolute;
  width: 96px;
  height: 96px;
  border-radius: 10px;
  background: radial-gradient(circle at 35% 30%, #fffce8, #ffd24a 48%, #f0a202 78%);
  border: 4px solid var(--ink);
  box-shadow:
    0 0 0 8px rgba(255, 210, 74, 0.35),
    0 0 28px 8px rgba(255, 230, 120, 0.75),
    4px 4px 0 var(--ink);
  animation: sun-pop 0.9s cubic-bezier(0.2, 1.4, 0.4, 1) both, sun-pulse 2.2s ease-in-out 0.9s infinite;
  z-index: 1;
  top: 18px;
}

.prize-sun-core {
  position: absolute;
  inset: 18px;
  background: #fff7b0;
  border: 2px solid rgba(26, 18, 8, 0.2);
}

.prize-percent {
  position: relative;
  z-index: 2;
  margin-top: 78px;
  text-align: center;
  animation: prize-bounce 0.85s cubic-bezier(0.2, 1.5, 0.4, 1) 0.15s both;
}

.prize-number {
  display: block;
  font-family: var(--font-pixel);
  font-size: clamp(2.4rem, 14vw, 3.4rem);
  line-height: 1;
  color: #fff8dc;
  text-shadow:
    4px 4px 0 #1a1208,
    -2px 0 0 #1a1208,
    2px 0 0 #1a1208,
    0 0 18px rgba(255, 210, 74, 1);
  animation: percent-shine 1.8s ease-in-out infinite;
}

.prize-label {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 10px;
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  color: #1a1208;
  background: #ffd24a;
  border: 3px solid #1a1208;
  box-shadow: 3px 3px 0 #1a1208;
}

.prize-won {
  position: relative;
  z-index: 2;
  margin: 8px 0 0;
  font-family: var(--font-pixel);
  font-size: clamp(0.48rem, 2.8vw, 0.58rem);
  line-height: 1.45;
  color: #153d12;
  background: rgba(244, 247, 239, 0.92);
  border: 3px solid #1a1208;
  padding: 8px 10px;
  box-shadow: 3px 3px 0 #1a1208;
}

.win-panel h2 {
  font-size: clamp(0.58rem, 2.9vw, 0.76rem);
  line-height: 1.55;
}

@keyframes rays-spin {
  to { transform: rotate(360deg); }
}

@keyframes sun-pop {
  from { transform: scale(0.2) translateY(30px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes sun-pulse {
  0%, 100% {
    filter: brightness(1);
    box-shadow:
      0 0 0 8px rgba(255, 210, 74, 0.35),
      0 0 28px 8px rgba(255, 230, 120, 0.75),
      4px 4px 0 var(--ink);
  }
  50% {
    filter: brightness(1.15);
    box-shadow:
      0 0 0 14px rgba(255, 210, 74, 0.45),
      0 0 42px 14px rgba(255, 230, 120, 0.9),
      4px 4px 0 var(--ink);
  }
}

@keyframes prize-bounce {
  from { transform: scale(0.4) translateY(24px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes percent-shine {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
}

/* legado (mantido se usado em outro lugar) */
.sun-wrap {
  height: 90px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sun {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: radial-gradient(circle at 35% 35%, #fff7b0, #ffd24a 45%, #f0a202 80%);
  border: 4px solid var(--ink);
  box-shadow: 0 0 0 6px rgba(255, 210, 74, 0.35), 4px 4px 0 var(--ink);
}

#hud {
  position: absolute;
  top: max(40px, calc(env(safe-area-inset-top) + 32px));
  left: 10px;
  right: 10px;
  z-index: 12;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
  pointer-events: none;
}

.hud-chip {
  pointer-events: none;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  min-height: 42px;
  background: rgba(244, 247, 239, 0.94);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 0 10px;
  font-family: var(--font-pixel);
  font-size: 0.42rem;
  line-height: 1.2;
  max-width: min(72vw, 340px);
}

#hud-lives {
  color: #8b1e1e;
  background: #ffe8e8;
}

#hud-coins {
  color: #7a5200;
  background: #fff3c4;
}

.hud-progress {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 118px;
  max-width: min(92vw, 420px);
  padding-top: 6px;
  padding-bottom: 6px;
}

.hud-bar {
  display: block;
  height: 6px;
  background: #d7d2c4;
  border: 2px solid #1a1208;
}

.hud-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5aad32, #ffd24a);
  transition: width 0.25s ease;
}

.hud-progress.is-level-up {
  animation: hud-level-flash 0.9s ease;
  background: #fff3c4;
  color: #7a5200;
}

@keyframes hud-level-flash {
  0%, 100% { transform: scale(1); box-shadow: 3px 3px 0 var(--ink); }
  40% { transform: scale(1.06); box-shadow: 0 0 0 3px #ffd24a, 3px 3px 0 var(--ink); }
}

.level-banner {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -50%);
  z-index: 20;
  width: min(92vw, 420px);
  text-align: center;
  pointer-events: none;
  padding: 16px 18px 14px;
  background: linear-gradient(180deg, rgba(18, 42, 78, 0.94), rgba(12, 28, 52, 0.96));
  border: 4px solid #ffd24a;
  box-shadow: 0 0 0 3px #1a1208, 6px 6px 0 #1a1208;
  color: #fff8dc;
}

.level-banner.is-show {
  animation: level-banner-in 2.8s ease forwards;
}

.level-banner-kicker {
  margin: 0 0 8px;
  font-family: var(--font-pixel);
  font-size: clamp(0.48rem, 2.4vw, 0.62rem);
  letter-spacing: 0.06em;
  color: #ffd24a;
}

.level-banner-title {
  margin: 0 0 10px;
  font-family: var(--font-pixel);
  font-size: clamp(0.72rem, 3.6vw, 1rem);
  line-height: 1.35;
  color: #fff;
  text-shadow: 3px 3px 0 #1a1208;
}

.level-banner-next {
  margin: 0;
  font-family: var(--font-ui, "VT323", monospace);
  font-size: clamp(1.05rem, 4.2vw, 1.35rem);
  line-height: 1.25;
  color: #9fd6ff;
}

@keyframes level-banner-in {
  0% { opacity: 0; transform: translate(-50%, -42%) scale(0.86); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  22% { transform: translate(-50%, -50%) scale(1); }
  78% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(0.96); }
}

body.is-mobile .level-banner {
  top: 18%;
  padding: 12px 14px 10px;
}

.win-stats {
  margin: 0 0 12px;
  font-family: var(--font-pixel);
  font-size: 0.48rem;
  line-height: 1.45;
  color: #7a5200;
  background: #fff3c4;
  border: 3px solid #1a1208;
  padding: 8px 10px;
}

.hud-mute {
  pointer-events: auto;
  margin-left: auto;
  align-self: stretch;
  border: 3px solid var(--ink);
  background: #fff;
  box-shadow: 3px 3px 0 var(--ink);
  min-width: 42px;
  min-height: 42px;
  height: auto;
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.touch {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 15;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 14px;
  gap: 12px;
  pointer-events: none;
}

body.is-mobile .touch:not(.hidden) {
  display: flex !important;
}

.touch-left,
.touch-right {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.touch-right {
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.mc-pad {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  width: auto;
  min-width: 148px;
  min-height: 84px;
  border-radius: 14px;
  background: rgba(120, 120, 120, 0.38);
  border: 2px solid rgba(40, 40, 40, 0.45);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.touch-btn.mc-ctrl {
  width: 64px;
  height: 64px;
  border: 2px solid rgba(35, 35, 35, 0.55);
  border-radius: 12px;
  background: rgba(150, 150, 150, 0.48);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18);
  font-size: 1.1rem;
  font-family: var(--font-pixel);
  color: rgba(20, 20, 20, 0.88);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  backdrop-filter: blur(1px);
}

.mc-pad .mc-ctrl {
  width: 58px;
  height: 58px;
  background: rgba(170, 170, 170, 0.28);
  border-color: rgba(50, 50, 50, 0.35);
  box-shadow: none;
}

.mc-ico {
  width: 28px;
  height: 28px;
  display: block;
  color: rgba(18, 18, 18, 0.92);
}

.mc-ico-jump {
  width: 30px;
  height: 30px;
}

.mc-ico-act {
  width: 26px;
  height: 26px;
}

.touch-cap {
  font-size: 0.34rem;
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: rgba(20, 20, 20, 0.9);
  text-transform: uppercase;
}

.touch-jump {
  width: 70px !important;
  height: 70px !important;
}

.touch-act {
  width: 78px !important;
  height: 78px !important;
  padding: 4px !important;
}

.touch-btn.mc-ctrl:active,
.touch-btn.mc-ctrl.is-held {
  transform: scale(0.96);
  background: rgba(210, 210, 210, 0.62);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.touch-btn.is-flash {
  animation: touch-flash 0.7s ease-in-out infinite;
}

@keyframes touch-flash {
  0%, 100% { filter: brightness(1); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2); }
  50% { filter: brightness(1.2); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85); }
}

@media (min-width: 900px) {
  body:not(.is-mobile) .touch {
    display: none !important;
  }
}

body.is-mobile #help-desktop { display: none; }
body:not(.is-mobile) #help-mobile { display: none; }

body.is-mobile #hud {
  top: max(34px, calc(env(safe-area-inset-top) + 26px));
  gap: 6px;
}

body.is-mobile .hud-chip {
  min-height: 36px;
  font-size: 0.36rem;
  padding: 0 8px;
}

body.is-mobile .game-top-title {
  font-size: 0.5rem;
}

/* Tela de prêmio: evita corte no topo e compacta no celular */
#screen-win.screen,
#screen-over.screen,
#screen-menu.screen {
  align-items: flex-start !important;
  justify-content: center !important;
  padding-top: max(16px, env(safe-area-inset-top)) !important;
  overflow-y: auto !important;
}

#screen-win .win-panel {
  overflow: visible !important;
  margin-top: 0 !important;
}

#screen-win .prize-hero {
  min-height: 0 !important;
  margin-bottom: 12px !important;
  padding: 14px 10px 12px !important;
  overflow: visible !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}

#screen-win .prize-sun {
  position: relative !important;
  width: 52px !important;
  height: 52px !important;
  top: auto !important;
}

#screen-win .prize-sun-core {
  inset: 11px !important;
}

#screen-win .prize-percent {
  margin-top: 0 !important;
  width: 100% !important;
}

#screen-win .prize-number {
  font-size: clamp(1.9rem, 11vw, 2.6rem) !important;
  line-height: 1.1 !important;
  padding: 6px 4px !important;
}

body.showing-win .game-top-title {
  display: none !important;
}

@media (max-height: 700px) {
  #screen-win .prize-sun {
    width: 44px !important;
    height: 44px !important;
  }
  #screen-win .prize-number {
    font-size: clamp(1.6rem, 9vw, 2.1rem) !important;
  }
  #screen-win .lead {
    font-size: 1.05rem !important;
    margin-bottom: 10px !important;
  }
  #screen-win h2 {
    font-size: 0.52rem !important;
    margin-bottom: 8px !important;
  }
}
