/* baseline reset (auto-injected) */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh; }
img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; }
ul, ol { list-style: none; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }

:root {
  --color-primary: #0fa84f;
  --color-accent: #ffcc29;
  --color-bg: #04543a;
  --color-surface: #ffffff;
  --color-text: #ffffff;
  --color-text-muted: #d7f2c8;
  --radius-lg: 2rem;
  --radius-md: 1.2rem;
  --space-sm: 0.8rem;
  --space-md: 1.6rem;
  --space-lg: 2.8rem;
  --shadow-card: 0 20px 60px rgba(0,0,0,0.35);
}

html, body {
  min-height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'Poppins', 'Segoe UI', sans-serif;
  overflow-x: hidden;
}

.stage {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  overflow: hidden;
}

.carnival-bg {
  position: fixed;
  inset: 0;
  background-image: url("../images/brazil-carnival-bg.webp");
  background-size: cover;
  background-position: center;
  z-index: -1;
  pointer-events: none;
}

.game {
  align-items: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-height: 100dvh;
  justify-content: center;
  padding: var(--space-lg) var(--space-md);
  position: relative;
  width: 100%;
  z-index: 1;
  text-align: center;
  transition: filter 0.3s ease;
  overflow: hidden;
}

.game::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(4,84,58,0.1), rgba(4,84,58,0.6) 75%);
  z-index: -1;
  pointer-events: none;
}

@media screen and (orientation: landscape) and (max-height: 550px) {
  .game { flex-direction: row; gap: var(--space-lg); }
}

.game__banner {
  background: linear-gradient(120deg, var(--color-accent), #ffe27a);
  color: #1c3a1f;
  font-weight: 800;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  padding: 0.6rem 1.6rem;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.game__header { max-width: 42rem; display: flex; flex-direction: column; gap: 0.6rem; }

.game__header__h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  text-wrap: balance;
  color: var(--color-text);
}

.game__header__h3 {
  font-size: clamp(1rem, 2.6vw, 1.4rem);
  color: var(--color-text-muted);
  font-weight: 600;
}

.game__header__text {
  color: var(--color-text);
  text-transform: initial;
  font-size: clamp(1rem, 2.6vw, 1.3rem);
}

.game__main {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(60vw, 26rem);
  height: min(60vw, 26rem);
}

.game__main__image {
  transform: rotate(0);
  transition: transform 0.4s ease;
  max-height: 100%;
  max-width: 100%;
  user-select: none;
  pointer-events: none;
  filter: drop-shadow(0 20px 30px rgba(0,0,0,0.35));
}

.game__main__image-rotate-1 { transform: rotate(8deg) scale(1.03); }
.game__main__image-rotate-2 { transform: rotate(-8deg) scale(1.03); }

.game__main__image-hand {
  bottom: 4rem;
  height: 6rem;
  position: absolute;
  right: 2rem;
  width: 6rem;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,0.3));
}

.game__main__image-hand-animation-pulse {
  animation: handPulse 1.2s ease-in-out infinite;
}

@keyframes handPulse {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.08); }
}

.game__main__bonus-container {
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
  z-index: 1;
  pointer-events: none;
}

.game__main__bonus-value {
  animation: fadeOut 1.4s forwards;
  color: var(--color-accent);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 800;
  opacity: 1;
  position: absolute;
  text-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

@keyframes fadeOut {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-30px); }
}

@keyframes treasureGlow {
  0%, 100% { filter: drop-shadow(0 20px 30px rgba(0,0,0,0.35)) drop-shadow(0 0 25px rgba(255, 204, 41, 0.6)) drop-shadow(0 0 50px rgba(255, 204, 41, 0.3)); }
  50% { filter: drop-shadow(0 20px 30px rgba(0,0,0,0.35)) drop-shadow(0 0 35px rgba(255, 204, 41, 0.8)) drop-shadow(0 0 70px rgba(255, 204, 41, 0.5)); }
}

.game__footer { width: min(100%, 28rem); }

.game__progress {
  align-items: center;
  background-color: rgba(4, 84, 58, 0.75);
  border: 2px solid var(--color-accent);
  border-radius: 1.6rem;
  color: var(--color-text);
  display: flex;
  height: 4.4rem;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.game__progress__bar {
  bottom: 0;
  background-color: var(--color-accent);
  left: 0;
  position: absolute;
  top: 0;
  transition: width 1s linear;
  width: 0;
  z-index: 0;
}

.game__progress__text { position: relative; z-index: 1; font-weight: 700; display: flex; align-items: center; gap: 0.3rem; }

.game__progress__value { font-weight: 800; color: var(--color-accent); }

.game-final-screen {
  align-items: center;
  background-image: linear-gradient(rgba(4,84,58,0.55), rgba(4,84,58,0.55)), url("../images/brazil-carnival-bg.webp");
  background-size: cover;
  background-position: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  justify-content: center;
  padding: var(--space-lg) var(--space-md);
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  overflow: hidden;
  text-align: center;
}

@media screen and (orientation: landscape) and (max-height: 550px) {
  .game-final-screen { flex-direction: row; }
}

.game-final-screen .game__header { max-width: 36rem; }
.game-final-screen .game__header__h3 { color: rgba(255,255,255,0.85); }

.game-final-screen .game__main { position: relative; }

.game-final-screen .game__main::before,
.game-final-screen .game__main::after {
  content: "";
  position: absolute;
  width: 1.2rem;
  height: 1.2rem;
  background-image: url(../images/star-four-pointed.webp);
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
  user-select: none;
  animation: sparkleFloat 2.5s ease-in-out infinite;
}

.game-final-screen .game__main::before {
  top: -15%;
  left: 5%;
  animation-delay: 0s;
}

.game-final-screen .game__main::after {
  bottom: -10%;
  right: 8%;
  animation-delay: 0.5s;
}

@keyframes sparkleFloat {
  0%, 100% { opacity: 0.7; transform: translateY(0) scale(1); }
  50% { opacity: 1; transform: translateY(-8px) scale(1.15); }
}

.game-final-screen .game__main__image {
  transform: scale(1.3);
  filter: drop-shadow(0 20px 30px rgba(0,0,0,0.35)) drop-shadow(0 0 25px rgba(255, 204, 41, 0.6)) drop-shadow(0 0 50px rgba(255, 204, 41, 0.3));
  animation: treasureGlow 2s ease-in-out infinite;
}

.game__button {
  background: linear-gradient(120deg, var(--color-primary), #0c8a41);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  cursor: pointer;
  display: block;
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-weight: 800;
  line-height: 1.4;
  padding: 1rem 1.6rem;
  text-transform: uppercase;
  width: 100%;
  min-height: 44px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.game__button:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(0,0,0,0.4); }
.game__button:active { transform: translateY(0); box-shadow: 0 8px 20px rgba(0,0,0,0.3); }
.game__button:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }

.blur { filter: blur(8px); }

.hidden { display: none !important; }

.visible {
  animation: makeVisible 1s ease forwards;
  display: flex;
  opacity: 0;
}

@keyframes makeVisible {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.modal {
  align-items: center;
  backdrop-filter: blur(4px);
  background: rgba(4, 84, 58, 0.35);
  display: flex;
  justify-content: center;
  padding: 1.2rem;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
}

.modal__window {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  max-width: 26rem;
  width: 100%;
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  color: #123a24;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  border: 4px solid var(--color-accent);
}

.modal__window__title {
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  font-weight: 800;
  color: #0c6b3d;
}

.modal__window__text {
  font-size: clamp(0.95rem, 2.6vw, 1.1rem);
  color: #2a5c3d;
  font-weight: 500;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.modal__window__button {
  background: linear-gradient(120deg, var(--color-accent), #ffe27a);
  border-radius: 0.8rem;
  color: #123a24;
  display: block;
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-weight: 800;
  line-height: 3.2rem;
  padding: 0.4rem 0.8rem;
  text-transform: uppercase;
  min-height: 44px;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 24px rgba(0,0,0,0.25);
}

.modal__window__button:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(0,0,0,0.3); }
.modal__window__button:active { transform: translateY(0); }
.modal__window__button:focus-visible { outline: 3px solid var(--color-primary); outline-offset: 3px; }

@media (min-width: 1024px) {
  .game__header__h1 { font-size: clamp(2.4rem, 3.6vw, 3.4rem); }
  .modal__window { max-width: 30rem; padding: 3.2rem 2.4rem; }
  .game__main { width: min(30vw, 30rem); height: min(30vw, 30rem); }
}

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

html[dir=rtl] .game__banner { direction: rtl; }

html,
body {
  scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 0;
  height: 0;
}
