html,
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  width: 100vw;
  overflow-x: hidden;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #000;
  overflow-x: hidden;
  overflow-y: auto;
}

img {
  max-width: 100%;
  height: auto;
  image-rendering: auto;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: block;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  will-change: auto;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.bg-image {
  width: 40%;
  min-width: 40%;
  height: auto;
  max-height: 100vh;
  object-fit: contain;
  object-position: center;
  display: block;
  image-rendering: auto;
  backface-visibility: hidden;
}

.bg-image-bottom {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 0);
  width: 90%;
  max-width: 530px;
  height: auto;
  object-fit: cover;
  pointer-events: none;
}

@media (max-width: 1280px) {
  .bg-image-bottom {
    width: 95%;
    max-width: 780px;
  }
}

@media (max-width: 1024px) {
  .bg-image-bottom {
    width: 105%;
    max-width: none;
  }
}

@media (max-width: 768px) {
  .bg-image-bottom {
    width: 115%;
  }
}

@media (max-width: 540px) {
  .bg-image-bottom {
    width: 130%;
  }
}

.logo-container {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 30%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.logo {
  width: auto;
  min-width: 0;
  height: auto;
  object-fit: contain;
  object-position: center;
  image-rendering: auto;
  backface-visibility: hidden;
  display: block;
}
.logo:first-child {
  width: 50%;
}
.logo:nth-child(2),
.logo:nth-child(3) {
  width: 90%;
}
.logo:nth-child(3) {
  margin-top: -35px;
}
.scratch-text-container {
  position: absolute;
  top: 29%;
  left: 35%;
  transform: translate(-75%, -50%);
  z-index: 10;
  pointer-events: none;
  width: 50%;
  max-width: 50%;
}
.scratch-text {
  margin: 0;
  padding: 0;
  color: #14495e;
  font-size: 25px;
  font-weight: bold;
  font-family: Arial, sans-serif;
  white-space: nowrap;
  text-shadow:
    -1px -1px 0 #fff,
    1px -1px 0 #fff,
    -1px 1px 0 #fff,
    1px 1px 0 #fff,
    0 0 3px rgba(255, 255, 255, 0.8),
    0 2px 4px rgba(0, 0, 0, 0.3);
  text-align: right;
  letter-spacing: 1px;
}
.grid-wrapper {
  position: absolute;
  top: 53%;
  left: 50%;
  transform: translate(-50%, -50%);
  /* slightly narrower wrapper so tiles have more horizontal room */
  width: 26%;
  max-width: calc(46% - 40px);
  pointer-events: none;
}
.grid-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  object-fit: fill;
  z-index: 1;
  pointer-events: none;
}

.dragon-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.dragon-overlay.show {
  opacity: 1;
  visibility: visible;
}

.dragon-overlay img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: cover;
  display: block;
}

.grid-container {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  /* larger gap and padding to give the rectangular tiles breathing room */
  gap: 18px;
  padding: 22px;
  box-sizing: border-box;
  pointer-events: auto;
  z-index: 2;
  background: none;
  width: 100%;
}

.scratch-text-overlay {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 100%;
  height: auto;
  z-index: 4;
  pointer-events: none;
  image-rendering: auto;
  backface-visibility: hidden;
}

.layer-container {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 20px;
  width: 50%;
  max-width: 600px;
  pointer-events: none;
  z-index: 5;
}

.layer-left,
.layer-right {
  width: auto;
  min-width: 0;
  height: auto;
  max-width: 180px;
  min-width: 150px;
  max-height: 300px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  image-rendering: auto;
  backface-visibility: hidden;
}

.grid-item {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 2.2 / 1;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  cursor: pointer;
  /* inner spacing so artwork doesn't touch corners */
  box-sizing: border-box;
}
.grid-item.revealed {
  cursor: pointer;
}

.grid-item img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s ease;
  image-rendering: auto;
  backface-visibility: hidden;
}

.scratch-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.pop-out-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
  pointer-events: none;
}

.pop-out-backdrop.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.pop-out-tryagain {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
  pointer-events: none;
}

.pop-out-tryagain.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.pop-out-tryagain img {
  max-width: 350px;
  min-width: 250px;
  width: auto;
  height: auto;
  display: block;
  image-rendering: auto;
  backface-visibility: hidden;
}

.tryagain-button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.2s ease;
  margin-top: -10px;
}

.tryagain-button:active {
  transform: scale(0.95);
}

.tryagain-button img {
  max-width: 220px;
  min-width: 150px;
  width: auto;
  height: auto;
  display: block;
  image-rendering: auto;
  backface-visibility: hidden;
}

.pop-out-win {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
  pointer-events: none;
}

.pop-out-win.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.pop-out-win img {
  max-width: 400px;
  min-width: 300px;
  width: auto;
  height: auto;
  display: block;
  image-rendering: auto;
  backface-visibility: hidden;
}

.pop-out-win .money-amount {
  max-width: 120px;
  min-width: 80px;
  width: auto;
}

.pop-out-win .win-prize {
  max-width: 320px;
  min-width: 240px;
  width: auto;
}

.btn-win {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  margin-top: -10px;
}

.ps-link,
.tg-link {
  display: inline-block;
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.2s ease;
  pointer-events: auto;
  position: relative;
  z-index: 1001;
}

.btn-win img {
  max-width: 180px;
  min-width: 150px;
  width: auto;
  height: auto;
  display: block;
  cursor: pointer;
  transition: transform 0.2s ease;
  image-rendering: auto;
  backface-visibility: hidden;
}

.btn-win img:active {
  transform: scale(0.95);
}

/* Small mobile devices */
@media (max-width: 360px) {
  .logo-container {
    top: 5px;
    padding: 2px;
  }

  .logo {
    max-width: 75%;
  }

  .grid-wrapper {
    width: 95%;
    max-width: calc(100% - 10px);
    left: 50%;
    transform: translate(-50%, -50%);
    top: 55%;
  }

  .scratch-text-overlay {
    top: -40px;
    max-width: 65%;
    left: 50%;
    transform: translateX(-50%);
  }

  .grid-container {
    /* slightly larger spacing on small devices for readability */
    gap: 10px;
    padding: 12px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
  }

  .pop-out-tryagain img {
    max-width: 250px;
    min-width: 180px;
  }

  .tryagain-button img {
    max-width: 180px;
    min-width: 130px;
  }

  .pop-out-win img {
    max-width: 220px;
    min-width: 160px;
  }

  .pop-out-win .money-amount {
    max-width: 100px;
    min-width: 70px;
  }

  .pop-out-win .win-prize {
    max-width: 240px;
    min-width: 180px;
  }

  .btn-win img {
    max-width: 200px;
    min-width: 150px;
  }
}

/* Mobile responsive */
@media (max-width: 440px) {
  .bg-image {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    object-fit: fill;
  }

  .logo-container {
    width: 100%;
    padding: 3px;
    object-fit: cover;
    box-sizing: border-box;
    top: 10px;
  }

  .logo {
    max-width: 78%;
  }

  .logo:nth-child(3) {
    margin-top: -20px;
  }

  .scratch-text-container {
    top: 40%;
    left: 26%;
    transform: translate(-75%, -50%);
    width: 50%;
    max-width: 50%;
  }

  .scratch-text {
    font-size: 20px;
    font-weight: bold;
    font-family: Arial, sans-serif;
    text-shadow:
      -1px -1px 0 #fff,
      1px -1px 0 #fff,
      -1px 1px 0 #fff,
      1px 1px 0 #fff,
      0 0 2px rgba(255, 255, 255, 0.8),
      0 1px 3px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
  }

  .grid-wrapper {
    width: 90%;
    max-width: calc(100% - 20px);
    left: 50%;
    transform: translate(-50%, -50%);
    top: 50%;
  }

  .scratch-text-overlay {
    top: -50px;
    max-width: 70%;
    left: 50%;
    transform: translateX(-50%);
  }

  .grid-container {
    width: 100%;
    top: 0;
    max-width: 100%;
    gap: 10px;
    padding: 12px;
    margin: 0 auto;
  }

  .grid-item {
    min-width: 0;
  }

  .grid-item img {
    min-width: 0;
  }

  .layer-container {
    width: 90%;
    max-width: 500px;
    gap: 10px;
    bottom: 10px;
  }

  .layer-left,
  .layer-right {
    max-width: 120px;
    max-height: 180px;
  }

  .pop-out-tryagain {
    top: 49%;
    gap: 10px;
  }

  .pop-out-tryagain img {
    max-width: 280px;
    min-width: 200px;
  }

  .tryagain-button {
    margin-top: -5px;
  }

  .tryagain-button img {
    max-width: 200px;
    min-width: 150px;
  }

  .pop-out-win {
    top: 49%;
    gap: 10px;
  }

  .pop-out-win img {
    max-width: 250px;
    min-width: 180px;
  }

  .pop-out-win .money-amount {
    max-width: 110px;
    min-width: 85px;
  }

  .pop-out-win .win-prize {
    max-width: 280px;
    min-width: 180px;
  }

  .btn-win {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: -5px;
    width: 100%;
  }

  .btn-win a {
    display: flex;
    justify-content: center;
  }

  .btn-win img {
    width: 100%;
    max-width: 180px;
    min-width: 0;
  }

  .download-link,
  .tg-link {
    z-index: 1002;
  }
}

/* Mobile responsive */
@media (max-width: 428px) {
  .bg-image {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    object-fit: cover;
  }

  .logo-container {
    width: 100%;
    padding: 3px;
    object-fit: cover;
    box-sizing: border-box;
    top: 10px;
  }

  .logo {
    max-width: 78%;
  }

  .logo:nth-child(3) {
    margin-top: -20px;
  }

  .scratch-text-container {
    top: 40%;
    left: 26%;
    transform: translate(-75%, -50%);
    width: 50%;
    max-width: 50%;
  }

  .scratch-text {
    font-size: 20px;
    font-weight: bold;
    font-family: Arial, sans-serif;
    text-shadow:
      -1px -1px 0 #fff,
      1px -1px 0 #fff,
      -1px 1px 0 #fff,
      1px 1px 0 #fff,
      0 0 2px rgba(255, 255, 255, 0.8),
      0 1px 3px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
  }

  .grid-wrapper {
    width: 90%;
    max-width: calc(100% - 20px);
    left: 50%;
    transform: translate(-50%, -50%);
    top: 50%;
  }

  .scratch-text-overlay {
    top: -50px;
    max-width: 70%;
    left: 50%;
    transform: translateX(-50%);
  }

  .grid-container {
    width: 100%;
    top: 0;
    max-width: 100%;
    gap: 10px;
    padding: 12px;
    margin: 0 auto;
  }

  .grid-item {
    min-width: 0;
  }

  .grid-item img {
    min-width: 0;
  }

  .layer-container {
    width: 90%;
    max-width: 500px;
    gap: 10px;
    bottom: 10px;
  }

  .layer-left,
  .layer-right {
    max-width: 120px;
    max-height: 180px;
  }

  .pop-out-tryagain {
    top: 49%;
    gap: 10px;
  }

  .pop-out-tryagain img {
    max-width: 280px;
    min-width: 200px;
  }

  .tryagain-button {
    margin-top: -5px;
  }

  .tryagain-button img {
    max-width: 200px;
    min-width: 150px;
  }

  .pop-out-win {
    top: 49%;
    gap: 10px;
  }

  .pop-out-win img {
    max-width: 250px;
    min-width: 180px;
  }

  .pop-out-win .money-amount {
    max-width: 110px;
    min-width: 85px;
  }

  .pop-out-win .win-prize {
    max-width: 280px;
    min-width: 180px;
  }

  .btn-win {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: -5px;
    width: 100%;
  }

  .btn-win a {
    display: flex;
    justify-content: center;
  }

  .btn-win img {
    width: 100%;
    max-width: 180px;
    min-width: 0;
  }

  .download-link,
  .tg-link {
    z-index: 1002;
  }
}
