* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
}

html {
  font-size: 10px;
  line-height: 1.5;
}

@media screen and (max-width: 400px), (max-height: 400px) {
  html {
    font-size: calc(5px + 1vmin);
  }
}
body {
  color: #000;
  display: flex;
  font-family: ui-sans-serif, system-ui, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
  text-align: center;
}

a {
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h3 {
  font-weight: 700;
}

h1 {
  font-size: 3.6rem;
  line-height: 4rem;
}

h3 {
  font-size: 2.4rem;
  line-height: 3.2rem;
}

img {
  display: block;
}

p {
  font-size: 2rem;
  line-height: 2.8rem;
}

.background,
.background__stars {
  height: 100%;
  width: 100%;
}

.background {
  background-image: linear-gradient(to bottom, #01364a, #108e7a);
  display: flex;
  justify-content: space-between;
  overflow: hidden;
  padding-top: 7rem;
  position: absolute;
  z-index: 0;
}

.background__left,
.background__right {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.background__left__bottom,
.background__right__bottom {
  position: relative;
}

.background__right__top {
  margin-top: 50%;
}

.background__cloud {
  display: block;
}

.background__cloud-left-1 {
  height: 8.4rem;
  width: 9.3rem;
}

.background__cloud-left-2 {
  height: 11.7rem;
  width: 14.6rem;
}

.background__cloud-left-3,
.background__cloud-left-4 {
  bottom: 0;
  position: absolute;
}

.background__cloud-left-3 {
  height: 14.5rem;
  width: 16.9rem;
}

.background__cloud-left-4 {
  height: 14.2rem;
  width: 13.1rem;
}

.background__cloud-right-1 {
  height: 11.5rem;
  width: 11.4rem;
}

.background__cloud-right-2,
.background__cloud-right-3 {
  bottom: 0;
  right: 0;
  position: absolute;
}

.background__cloud-right-2 {
  height: 14.5rem;
  width: 20.5rem;
}

.background__cloud-right-3 {
  height: 8.7rem;
  width: 17.3rem;
}

.background__stars {
  bottom: 0;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.background__star {
  position: absolute;
}

.background__star-1 {
  height: 2.4rem;
  left: 2rem;
  top: 32%;
  width: 2.4rem;
}

.background__star-2 {
  bottom: 32%;
  height: 3.2rem;
  left: 4rem;
  width: 3.2rem;
}

.background__star-3 {
  height: 3.2rem;
  opacity: 0.75;
  right: 3rem;
  top: 8%;
  width: 3.2rem;
}

.background__star-4 {
  height: 1.6rem;
  opacity: 0.3;
  right: 6rem;
  top: 50%;
  width: 1.6rem;
}

.background__star-5 {
  height: 2.4rem;
  right: -1rem;
  top: 63%;
  width: 2.4rem;
}

.background__star-6 {
  bottom: 10%;
  height: 2.6rem;
  right: 40%;
  width: 2.6rem;
}

.modal {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: center;
  padding: 1.2rem;
  position: absolute;
  width: 100%;
  z-index: 3;
}

.modal__window {
  background-color: #fff;
  border-radius: 1.6rem;
  max-width: 38.4rem;
  padding: 2rem;
}

.modal__window__title {
  margin-bottom: 1.2rem;
}

.modal__window__text {
  color: rgb(122, 122, 122);
  font-size: 2rem;
  font-weight: 700;
  line-height: 2.8rem;
  margin-bottom: 3.2rem;
}

.modal__window__button {
  background-color: rgb(24, 139, 120);
  border-radius: 0.8rem;
  color: #fff;
  display: block;
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 3.2rem;
  padding: 0.8rem;
  text-transform: uppercase;
}

.game {
  align-items: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: center;
  padding: 2.8rem;
  position: relative;
  width: 100%;
  z-index: 1;
}

@media screen and (orientation: landscape) and (max-height: 550px) {
  .game {
    flex-direction: row;
  }
}
.game__header {
  max-width: 55rem;
  text-transform: uppercase;
}

.game__header__h1 {
  color: #fff;
}

.game__header__h1 b {
  color: rgb(253, 196, 82);
}

.game__header__h3 {
  color: rgb(212, 212, 216);
  font-weight: 700;
}

.game__header__text {
  color: #fff;
  text-transform: initial;
}

.game__main {
  max-height: 35.7rem;
  max-width: 35.7rem;
  position: relative;
}

.game__main__image {
  transform: rotate(0);
  transition: transform 1s;
  max-height: 100%;
  max-width: 100%;
}

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

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

.game__main__image-hand {
  bottom: 5.5rem;
  height: 8rem;
  position: absolute;
  right: 7rem;
  width: 8rem;
}

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

@keyframes handPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
}
.game__main__bonus-container {
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 100%;
  z-index: 1;
}

.game__main__bonus-value {
  animation: fadeOut 3s forwards;
  color: #fff;
  font-size: 2.4rem;
  font-weight: 700;
  opacity: 1;
  position: absolute;
}

@keyframes fadeOut {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
.game__footer {
  bottom: 2.8rem;
  left: 2.8rem;
  position: absolute;
  right: 2.8rem;
}

.game__progress {
  align-items: center;
  background-color: rgb(10, 96, 76);
  border-radius: 1.6rem;
  color: #fff;
  display: flex;
  height: 5.6rem;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.game__progress__bar {
  bottom: 0;
  background-color: rgb(254, 189, 42);
  left: 0;
  position: absolute;
  top: 0;
  transition: width 1s linear;
  width: 0;
  z-index: 0;
}

.game__progress__text {
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 2.8rem;
  position: relative;
  z-index: 1;
}

.game-final-screen {
  align-items: center;
  background-image: linear-gradient(to bottom, #ffbd39, #ffe1a5);
  bottom: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: center;
  left: 0;
  padding: 2.8rem;
  position: absolute;
  right: 0;
  top: 0;
  width: 100%;
  z-index: 2;
  overflow: hidden;
}

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

.game-final-screen .game__header__h3 {
  color: rgba(88, 59, 0, 0.5019607843);
}

.game-final-screen .game__main__image {
  transform: scale(1.45);
}

.game__button {
  background-color: rgb(88, 59, 0);
  border-radius: 0.8rem;
  color: rgb(253, 196, 82);
  display: block;
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 3.2rem;
  padding: 1.2rem;
  text-transform: uppercase;
  width: 100%;
  margin: auto;
  max-width: 42rem;
}

.color-yellow {
  color: rgb(253, 196, 82);
}

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

.hidden {
  display: none;
}

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

@keyframes makeVisible {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
html[dir=rtl] .background__cloud {
  transform: scaleX(-1);
}
/* ===== Customized: chọn ngày/tháng/năm sinh ===== */
.step {
  justify-content: flex-start;
  overflow-y: auto;
  padding: 3.2rem 1.6rem 2.4rem;
  gap: 2.4rem;
  cursor: default;
}

@media screen and (orientation: landscape) and (max-height: 550px) {
  .step {
    flex-direction: column;
  }
}
.step__header {
  margin-top: auto;
}

.step__header .game__header__h3 {
  margin-top: 0.8rem;
  text-transform: none;
}

.chest-grid {
  display: grid;
  gap: 1.2rem;
  margin-bottom: auto;
  width: 100%;
}

.chest-grid--month {
  grid-template-columns: repeat(4, 1fr);
  max-width: 52rem;
}

.chest-grid--day {
  grid-template-columns: repeat(7, 1fr);
  gap: 0.8rem;
  max-width: 64rem;
}

.chest {
  align-items: center;
  background: none;
  border: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font-family: inherit;
  padding: 0;
  position: relative;
  transition: transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.chest:hover,
.chest:focus-visible {
  transform: scale(1.08);
  outline: none;
}

.chest:active {
  transform: scale(0.95);
}

.chest img {
  filter: drop-shadow(0 0.4rem 0.6rem rgba(0, 0, 0, 0.35));
  width: 100%;
}

.chest__num {
  background-image: linear-gradient(to bottom, #ff4d5e, #c8102e);
  border: 0.25rem solid #fff;
  border-radius: 99rem;
  box-shadow: 0 0.3rem 0.8rem rgba(0, 0, 0, 0.45), 0 0 0 0.15rem rgba(200, 16, 46, 0.6);
  color: #fff;
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1;
  margin-top: -1.4rem;
  min-width: 4rem;
  padding: 0.6rem 0.9rem;
  position: relative;
  text-shadow: 0 0.1rem 0.2rem rgba(0, 0, 0, 0.5);
}

.chest-grid--day .chest__num {
  border-width: 0.2rem;
  font-size: 1.7rem;
  margin-top: -1rem;
  min-width: 3rem;
  padding: 0.4rem 0.5rem;
}

.chest--picked {
  animation: chestPicked 0.45s ease;
}

@keyframes chestPicked {
  0%, 100% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-10deg) scale(1.15); }
  75% { transform: rotate(10deg) scale(1.15); }
}

.year-form {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  margin-bottom: auto;
  max-width: 42rem;
  width: 100%;
}

.year-form__chest {
  filter: drop-shadow(0 0.6rem 1rem rgba(0, 0, 0, 0.35));
  width: 16rem;
}

.year-form__input {
  background-color: #fff;
  border: 0.3rem solid rgb(253, 196, 82);
  border-radius: 1.2rem;
  color: rgb(88, 59, 0);
  font-family: inherit;
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: 0.4rem;
  padding: 1rem;
  text-align: center;
  width: 100%;
}

.year-form__input:focus {
  outline: 0.3rem solid rgba(253, 196, 82, 0.5);
  outline-offset: 0.2rem;
}

.year-form__error {
  color: #ffd2d2;
  font-size: 1.6rem;
  font-weight: 700;
}

.year-form__error.visible {
  display: block;
}

.year-form__button {
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

/* Màn cuối: rương mở phát sáng */
.game-final-screen .game__header__text {
  color: rgb(88, 59, 0);
  font-weight: 700;
}

/* customized */
.game-final-screen .game__header .game__header__h3 { font-size: 2rem; line-height: 2.6rem; margin-top: 0.4rem; }

.final__birthday {
  font-size: 2.2rem;
  margin-top: 0.6rem;
}

.final__treasure {
  align-items: center;
  display: flex;
  justify-content: center;
  margin: 1rem 0 8rem;
  overflow: visible;
}

.final__rays {
  animation: raysSpin 14s linear infinite;
  aspect-ratio: 1;
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.75) 0deg 8deg, rgba(255, 255, 255, 0) 8deg 22deg);
  border-radius: 50%;
  left: 50%;
  -webkit-mask-image: radial-gradient(circle, #000 15%, transparent 68%);
  mask-image: radial-gradient(circle, #000 15%, transparent 68%);
  position: absolute;
  top: 50%;
  translate: -50% -50%;
  width: 190%;
  z-index: 0;
}

.final__glow {
  animation: glowPulse 2.2s ease-in-out infinite;
  aspect-ratio: 1;
  background: radial-gradient(circle, #fffbe0 0%, rgba(255, 236, 140, 0.9) 25%, rgba(255, 200, 60, 0) 65%);
  border-radius: 50%;
  left: 50%;
  position: absolute;
  top: 42%;
  translate: -50% -50%;
  width: 120%;
  z-index: 0;
}

.game-final-screen .final__chest {
  animation: chestFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 0 2.4rem rgba(255, 245, 180, 0.95));
  position: relative;
  z-index: 1;
}

.final__sparkle {
  animation: sparkle 1.8s ease-in-out infinite;
  background: radial-gradient(circle, #fff 0%, #fff6b0 35%, transparent 70%);
  border-radius: 50%;
  height: 2.4rem;
  position: absolute;
  width: 2.4rem;
  z-index: 2;
}

.final__sparkle::before,
.final__sparkle::after {
  background: #fff;
  border-radius: 1rem;
  content: "";
  left: 50%;
  position: absolute;
  top: 50%;
  translate: -50% -50%;
}

.final__sparkle::before { height: 300%; width: 0.25rem; }
.final__sparkle::after { height: 0.25rem; width: 300%; }

.final__sparkle--1 { left: 12%; top: 18%; }
.final__sparkle--2 { animation-delay: 0.5s; right: 10%; top: 28%; }
.final__sparkle--3 { animation-delay: 1s; left: 22%; top: 55%; }
.final__sparkle--4 { animation-delay: 1.4s; right: 24%; top: 8%; }

@keyframes raysSpin {
  to { rotate: 360deg; }
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.75; scale: 0.92; }
  50% { opacity: 1; scale: 1.08; }
}

@keyframes chestFloat {
  0%, 100% { transform: scale(1.2) translateY(0); }
  50% { transform: scale(1.2) translateY(-0.6rem); }
}

@keyframes sparkle {
  0%, 100% { opacity: 0; scale: 0.3; }
  50% { opacity: 1; scale: 1; }
}

.game-final-screen .game__button {
  animation: buttonPulse 1.6s ease-in-out infinite;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

@keyframes buttonPulse {
  0%, 100% { scale: 1; }
  50% { scale: 1.04; }
}

@media screen and (max-width: 480px) and (min-height: 600px) {
  .chest-grid--day {
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem 1.2rem;
  }
}

/* Nền màu cờ theo quốc gia (biến --flag-bg do flag-theme.js đặt) */
.background {
  background: var(--flag-bg, linear-gradient(to bottom, #01364a, #108e7a));
}

html[data-country] .step .game__header__h1,
html[data-country] .step .game__header__h3 {
  text-shadow: 0 0.2rem 0.6rem rgba(0, 0, 0, 0.75), 0 0 0.2rem rgba(0, 0, 0, 0.6);
}

html[data-country] .step .game__header__h3 {
  color: #fff;
}

html[data-country] .year-form__error {
  background-color: rgba(0, 0, 0, 0.55);
  border-radius: 0.6rem;
  color: #ffe0e0;
  padding: 0.2rem 0.8rem;
}

/* Bản cố định quốc gia: luôn hiển thị trái-sang-phải dù trình duyệt dùng ngôn ngữ RTL */
html[dir=rtl] .step,
html[dir=rtl] .modal,
html[dir=rtl] .game-final-screen {
  direction: ltr;
}
