/* 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; }

/* ─── Design tokens ─────────────────────────────────────────── */
:root {
  --color-primary:    #0038A8;
  --color-accent:     #FCD116;
  --color-bg:         #0038A8;
  --color-surface:    #FFFFFF;
  --color-text:       #FFFFFF;
  --color-muted:      #CE1126;
  --color-gold-dark:  #c9a000;
  --color-blue-deep:  #002880;
  --color-red-dark:   #a00d1e;

  --radius-sm:  0.6rem;
  --radius-md:  1.2rem;
  --radius-lg:  2rem;
  --radius-pill: 9999px;

  --shadow-glow-gold: 0 0 24px 4px rgba(252,209,22,0.55);
  --shadow-glow-blue: 0 0 32px 8px rgba(0,56,168,0.4);
  --shadow-card:      0 8px 40px rgba(0,0,0,0.3);

  --font-display: 'Segoe UI', system-ui, sans-serif;
}

/* ─── Base ───────────────────────────────────────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-display);
  background: var(--color-bg);
  color: var(--color-text);
}

/* ─── Background section ─────────────────────────────────────── */
.background {
  background-image: url("../images/hero-bg.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  height: 100%;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
  width: 100%;
  z-index: 0;
}

.background__left,
.background__right {
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  position: absolute;
  top: 0;
  width: 20%;
}

.background__left  { left: 0; }
.background__right { right: 0; }

.background__left__top,
.background__right__top {
  align-items: flex-start;
  display: flex;
  padding-top: 1rem;
}

.background__left__bottom,
.background__right__bottom {
  align-items: flex-end;
  display: flex;
  padding-bottom: 1rem;
}

.background__cloud {
  max-width: 100%;
  opacity: 0.35;
  pointer-events: none;
  user-select: none;
}

.background__stars {
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.background__star {
  opacity: 0.7;
  pointer-events: none;
  position: absolute;
  user-select: none;
  animation: starPulse 3s ease-in-out infinite;
}

.background__star-1  { top: 8%;  left: 14%; width: 28px; animation-delay: 0s; }
.background__star-2  { top: 18%; right: 12%; width: 22px; animation-delay: 0.6s; }
.background__star-3  { top: 55%; left: 8%;  width: 18px; animation-delay: 1.1s; }
.background__star-4  { top: 72%; right: 9%; width: 24px; animation-delay: 0.3s; }
.background__star-5  { top: 38%; left: 22%; width: 16px; animation-delay: 1.7s; }
.background__star-6  { top: 28%; right: 22%; width: 20px; animation-delay: 0.9s; }

@keyframes starPulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%       { opacity: 1;    transform: scale(1.25); }
}

/* ─── Game screen ────────────────────────────────────────────── */
.game {
  align-items: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: center;
  padding: 2.4rem 2rem;
  position: relative;
  width: 100%;
  z-index: 1;
  gap: 1rem;
}

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

.game__header {
  text-align: center;
  z-index: 2;
  pointer-events: none;
  user-select: none;
}

.game__header__h1 {
  color: var(--color-accent);
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 20px rgba(252,209,22,0.4);
  text-wrap: balance;
  margin-bottom: 0.4rem;
}

.game__header__h3 {
  color: var(--color-surface);
  font-size: clamp(1rem, 2.5vw, 1.5rem);
  font-weight: 600;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
  text-wrap: balance;
}

.game__header__text {
  color: var(--color-text);
  font-size: clamp(0.9rem, 2.2vw, 1.3rem);
  font-weight: 500;
  text-shadow: 0 1px 5px rgba(0,0,0,0.5);
  text-transform: initial;
  text-wrap: pretty;
}

/* ─── Game main (chest / giftbox area) ──────────────────────── */
.game__main {
  align-items: center;
  display: flex;
  flex: 1;
  justify-content: center;
  max-height: 50vh;
  position: relative;
  width: 100%;
  z-index: 2;
}

.game__main__image {
  filter: drop-shadow(0 8px 32px rgba(252,209,22,0.5)) drop-shadow(0 2px 8px rgba(0,0,0,0.35));
  max-height: 100%;
  max-width: min(340px, 80vw);
  pointer-events: none;
  transform: rotate(0deg);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
}

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

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

.game__main__image-hand {
  bottom: 2rem;
  height: 7rem;
  pointer-events: none;
  position: absolute;
  right: calc(50% - 8rem);
  user-select: none;
  width: 7rem;
  z-index: 3;
}

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

.game__main__bonus-value {
  animation: fadeOut 3s forwards;
  color: var(--color-accent);
  font-size: 2rem;
  font-weight: 900;
  opacity: 1;
  pointer-events: none;
  position: absolute;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 16px rgba(252,209,22,0.6);
  user-select: none;
}

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

/* ─── Game footer ────────────────────────────────────────────── */
.game__footer {
  width: 100%;
  max-width: 480px;
  z-index: 2;
  pointer-events: none;
}

/* ─── Progress bar ───────────────────────────────────────────── */
.game__progress {
  align-items: center;
  background: rgba(0,20,80,0.55);
  backdrop-filter: blur(6px);
  border: 1.5px solid rgba(252,209,22,0.35);
  border-radius: var(--radius-pill);
  color: var(--color-surface);
  display: flex;
  height: 4.8rem;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
  position: relative;
  width: 100%;
}

.game__progress__bar {
  background: linear-gradient(90deg, var(--color-accent) 0%, #ffe569 100%);
  border-radius: var(--radius-pill);
  bottom: 0;
  box-shadow: 0 0 16px rgba(252,209,22,0.6);
  left: 0;
  position: absolute;
  top: 0;
  transition: width 1s linear;
  width: 0;
  z-index: 0;
}

.game__progress__text {
  align-items: center;
  color: var(--color-surface);
  display: flex;
  font-size: 1.4rem;
  font-weight: 700;
  position: relative;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  z-index: 1;
}

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

.game__progress__value-header {
  /* shown as h3 in header; styled via game__header__h3 */
}

/* ─── Pulse animation on hand cue ───────────────────────────── */
.game__main__image-hand-animation-pulse {
  animation: handPulse 1s ease-in-out infinite;
}

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

/* ─── Game final screen ──────────────────────────────────────── */
.game-final-screen {
  align-items: center;
  background-image: url("../images/final-screen-bg.webp");
  background-size: cover;
  background-position: center;
  bottom: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  height: 100%;
  justify-content: center;
  left: 0;
  overflow: hidden;
  padding: 2.8rem 2rem;
  position: absolute;
  right: 0;
  top: 0;
  width: 100%;
  z-index: 2;
}

.game-final-screen::before {
  background: rgba(0,20,80,0.22);
  content: '';
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 0;
}

.game-final-screen > * {
  position: relative;
  z-index: 1;
}

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

.game-final-screen .game__header {
  max-width: 40rem;
}

.game-final-screen .game__header__h1 {
  color: var(--color-accent);
  font-size: clamp(2rem, 5vw, 3.2rem);
  text-shadow: 0 2px 10px rgba(0,0,0,0.4), 0 0 24px rgba(252,209,22,0.5);
}

.game-final-screen .game__header__text {
  color: var(--color-surface);
  font-size: clamp(1rem, 2.4vw, 1.4rem);
  font-weight: 700;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
}

.game-final-screen .game__header__h3 {
  color: rgba(255,255,255,0.75);
  font-size: clamp(0.85rem, 2vw, 1.2rem);
}

.game-final-screen .game__main {
  max-height: 42vh;
}

.game-final-screen .game__main__image {
  filter: drop-shadow(0 8px 40px rgba(252,209,22,0.7)) drop-shadow(0 2px 10px rgba(0,0,0,0.4));
  max-width: min(300px, 72vw);
  transform: scale(1);
  animation: giftReveal 0.6s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

@keyframes giftReveal {
  0%   { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1.1); opacity: 1; }
}

/* ─── CTA button on final screen ─────────────────────────────── */
.game__button {
  background: linear-gradient(135deg, var(--color-accent) 0%, #ffe042 50%, var(--color-accent) 100%);
  border: none;
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 20px rgba(252,209,22,0.6), 0 2px 8px rgba(0,0,0,0.3);
  color: var(--color-primary);
  cursor: pointer;
  display: block;
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  min-height: 56px;
  padding: 1rem 2.4rem;
  position: relative;
  text-transform: uppercase;
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
  width: 100%;
  z-index: 1;
}

.game__button:hover {
  box-shadow: 0 6px 28px rgba(252,209,22,0.8), 0 2px 10px rgba(0,0,0,0.35);
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.game__button:active {
  box-shadow: 0 2px 10px rgba(252,209,22,0.5);
  transform: translateY(1px);
}

.game__button:focus-visible {
  outline: 3px solid var(--color-muted);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .game__button,
  .game__main__image,
  .background__star,
  .game__main__image-hand-animation-pulse,
  .game__main__bonus-value {
    animation: none;
    transition: none;
  }
}

/* ─── Modal ─────────────────────────────────────────────────── */
.modal {
  align-items: center;
  background: rgba(0,16,70,0.72);
  backdrop-filter: blur(4px);
  display: flex;
  height: 100%;
  justify-content: center;
  inset: 0;
  padding: 1.6rem;
  position: fixed;
  width: 100%;
  z-index: 10;
}

.modal__window {
  background: linear-gradient(155deg, #0042c9 0%, #002880 60%, #001a60 100%);
  border: 2px solid rgba(252,209,22,0.5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card), 0 0 60px rgba(252,209,22,0.25);
  max-width: 400px;
  padding: 2.4rem 2rem;
  text-align: center;
  width: 100%;
}

.modal__window__icon {
  font-size: 3.2rem;
  line-height: 1;
  margin-bottom: 0.8rem;
  pointer-events: none;
  user-select: none;
}

.modal__window__title {
  color: var(--color-accent);
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 900;
  letter-spacing: 0.01em;
  margin-bottom: 0.8rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
  text-wrap: balance;
}

.modal__window__text {
  color: rgba(255,255,255,0.9);
  font-size: clamp(0.95rem, 2.2vw, 1.2rem);
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 1.6rem;
  text-wrap: pretty;
}

.modal__window__button {
  background: linear-gradient(135deg, var(--color-muted) 0%, #f0152a 50%, var(--color-muted) 100%);
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 16px rgba(206,17,38,0.55), 0 2px 8px rgba(0,0,0,0.3);
  color: var(--color-surface);
  display: block;
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  min-height: 52px;
  padding: 0.9rem 2rem;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
  width: 100%;
}

.modal__window__button:hover {
  box-shadow: 0 6px 24px rgba(206,17,38,0.7);
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.modal__window__button:active {
  box-shadow: 0 2px 8px rgba(206,17,38,0.4);
  transform: translateY(1px);
}

.modal__window__button:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

/* ─── JS-toggled utility classes ─────────────────────────────── */
.hidden {
  display: none !important;
}

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

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

.blur {
  filter: blur(8px);
  pointer-events: none;
}

/* ─── RTL support ────────────────────────────────────────────── */
html[dir=rtl] .background__cloud {
  transform: scaleX(-1);
}

html,
body {
  scrollbar-width: none;
}

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