.menu-hero {
  position: absolute;
  left: 50%;
  top: 38%;
  width: min(78vw, 340px);
  height: min(52vw, 280px);
  transform: translate(-50%, -50%);
  z-index: 22;
  pointer-events: none;
  perspective: 820px;
}

.device.is-playing .menu-hero {
  display: none;
}

.device.is-loading .menu-hero {
  display: none;
}

.hero-stage {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  animation: hero-bob 4.6s ease-in-out infinite;
}

@keyframes hero-bob {
  0%,
  100% {
    transform: rotateX(12deg) translateY(0);
  }
  50% {
    transform: rotateX(12deg) translateY(-10px);
  }
}

.hero-aura {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 6%;
  height: 42%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 196, 90, 0.45), transparent 68%);
  animation: aura-pulse 2.8s ease-in-out infinite;
}

@keyframes aura-pulse {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

.hero-plate-img,
.hero-cover-img {
  position: absolute;
  left: 50%;
  object-fit: contain;
  height: auto;
  max-width: 100%;
}

.hero-plate-img {
  bottom: 4%;
  width: 92%;
  transform: translateX(-50%);
  filter: drop-shadow(0 16px 14px rgba(0, 0, 0, 0.45));
}

.hero-cover-img {
  bottom: 18%;
  width: 58%;
  transform: translateX(-50%);
  transform-origin: 50% 90%;
  filter: drop-shadow(0 12px 10px rgba(20, 6, 0, 0.4));
  transition: transform 0.85s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.6s ease;
}

.menu-hero.is-lift .hero-cover-img {
  transform: translateX(-50%) translateY(-36%) rotate(-8deg) scale(0.96);
}

.menu-hero.is-reveal .hero-cover-img {
  transform: translateX(-50%) translateY(-58%) rotate(-12deg) scale(0.9);
  opacity: 0.12;
}

.hero-spark {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff6c4;
  box-shadow: 0 0 10px #ffe08a;
  animation: spark-orbit 3.6s linear infinite;
}

.hero-spark.s1 {
  left: 18%;
  top: 30%;
  animation-delay: 0s;
}
.hero-spark.s2 {
  left: 78%;
  top: 26%;
  animation-delay: -0.6s;
}
.hero-spark.s3 {
  left: 12%;
  top: 58%;
  animation-delay: -1.2s;
}
.hero-spark.s4 {
  left: 84%;
  top: 54%;
  animation-delay: -1.8s;
}
.hero-spark.s5 {
  left: 48%;
  top: 12%;
  animation-delay: -2.4s;
}
.hero-spark.s6 {
  left: 50%;
  top: 78%;
  animation-delay: -3s;
}

@keyframes spark-orbit {
  0%,
  100% {
    opacity: 0.2;
    transform: translateY(0) scale(0.6);
  }
  50% {
    opacity: 1;
    transform: translateY(-14px) scale(1);
  }
}

.screens {
  position: absolute;
  inset: 0;
  z-index: 24;
  display: grid;
  pointer-events: none;
}

.screens.is-off {
  display: none;
}

.screen {
  grid-area: 1 / 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: max(16px, var(--safe-t)) max(18px, var(--safe-r)) max(22px, var(--safe-b)) max(18px, var(--safe-l));
  background: linear-gradient(180deg, rgba(8, 2, 6, 0.12) 0%, rgba(8, 2, 6, 0.2) 38%, rgba(8, 2, 6, 0.82) 72%);
}

.screen.is-on {
  display: flex;
}

.screen-loading {
  justify-content: center;
  align-items: stretch;
  padding: max(18px, var(--safe-t)) max(18px, var(--safe-r)) max(22px, var(--safe-b)) max(18px, var(--safe-l));
  background:
    radial-gradient(ellipse at 48% 34%, rgba(255, 210, 120, 0.18), transparent 30%),
    linear-gradient(90deg, rgba(5, 2, 5, 0.54), rgba(5, 2, 5, 0.18) 42%, rgba(5, 2, 5, 0.68)),
    linear-gradient(180deg, rgba(5, 2, 5, 0.12), rgba(5, 2, 5, 0.88));
}

.loading-shell {
  width: min(100%, 1180px);
  min-height: min(100%, 680px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.48fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "brand brand"
    "table status"
    "table status";
  align-items: center;
  gap: clamp(18px, 4vw, 56px);
  pointer-events: none;
}

.loading-brand {
  grid-area: brand;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: right;
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, 0.55));
}

.loading-crown {
  width: clamp(62px, 8vw, 118px);
  height: auto;
  object-fit: contain;
}

.loading-table {
  grid-area: table;
  position: relative;
  justify-self: center;
  align-self: center;
  width: min(58vw, 620px);
  aspect-ratio: 1.45;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  animation: loading-float 4.2s ease-in-out infinite;
}

.loading-ring {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 12%;
  height: 24%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 220, 140, 0.4), rgba(255, 220, 140, 0.08) 44%, transparent 70%);
  filter: blur(2px);
}

.loading-plate {
  position: absolute;
  bottom: 10%;
  width: 86%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 24px 22px rgba(0, 0, 0, 0.42));
}

.loading-cover {
  position: absolute;
  bottom: 24%;
  width: 50%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 20px 18px rgba(0, 0, 0, 0.5));
  animation: loading-cover-lift 2.8s ease-in-out infinite;
}

.loading-spark {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff4c4;
  box-shadow: 0 0 16px rgba(255, 232, 160, 0.95);
  animation: loading-spark 2.6s ease-in-out infinite;
}

.loading-spark.a {
  left: 28%;
  top: 36%;
}

.loading-spark.b {
  right: 24%;
  top: 42%;
  animation-delay: -0.8s;
}

.loading-spark.c {
  left: 52%;
  bottom: 18%;
  animation-delay: -1.6s;
}

.loading-status {
  grid-area: status;
  align-self: end;
  justify-self: stretch;
  margin-bottom: min(8vh, 70px);
  padding: 18px 0 0;
  border-top: 1px solid rgba(240, 208, 120, 0.35);
}

.screen-copy {
  width: min(100%, 380px);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
}

.screen h2,
.screen .brand-title {
  font-family: var(--font-khmer);
  font-size: clamp(22px, 5.5vw, 34px);
  color: var(--gold-shine);
  text-align: center;
  text-shadow: 0 2px 0 #5a3208, 0 10px 28px rgba(0, 0, 0, 0.6);
  margin-bottom: 6px;
}

.brand-year {
  letter-spacing: 0.28em;
  color: var(--gold);
  font-size: 13px;
  margin-bottom: 0;
}

.load-track {
  width: min(72vw, 420px);
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 244, 196, 0.1);
  border: 1px solid rgba(240, 208, 120, 0.42);
  overflow: hidden;
  box-shadow: 0 0 22px rgba(240, 208, 120, 0.12);
}

.load-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8a5a14, var(--gold), #fff4c4, var(--gold));
  box-shadow: 0 0 12px rgba(240, 208, 120, 0.55);
  transition: width 0.25s linear;
}

.load-label {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(12px, 1.6vw, 18px);
  letter-spacing: 0.14em;
  color: var(--gold-shine);
  text-transform: uppercase;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

@keyframes loading-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes loading-cover-lift {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(-1.5deg);
  }
}

@keyframes loading-spark {
  0%,
  100% {
    opacity: 0.25;
    transform: translateY(0) scale(0.7);
  }
  50% {
    opacity: 1;
    transform: translateY(-14px) scale(1);
  }
}

.intro-line {
  max-width: 28rem;
  text-align: center;
  font-size: clamp(16px, 4vw, 22px);
  color: #fff6d8;
  line-height: 1.55;
  min-height: 4.2em;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.65);
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 340px);
  margin-top: 10px;
}

.menu-btn {
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 700;
  color: #2a1608;
  background: linear-gradient(180deg, #ffe7a0, #c9962e);
  border: 1px solid #8a5a14;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28), inset 0 1px 0 #fff6cc;
}

.menu-btn.ghost {
  color: var(--gold-shine);
  background: rgba(18, 8, 4, 0.5);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 244, 196, 0.15);
}

.menu-lang {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.menu-lang button {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--gold-shine);
}

.menu-lang button.is-on {
  background: linear-gradient(180deg, rgba(240, 208, 120, 0.45), rgba(165, 110, 28, 0.4));
}

.screen .fair,
.rules-body {
  max-width: 36rem;
  text-align: center;
  color: #f3e6c8;
  font-size: 14px;
  line-height: 1.6;
  margin: 12px 0 18px;
}

.skip-link {
  margin-top: 16px;
  color: var(--gold-shine);
  font-size: 14px;
  border-bottom: 1px solid rgba(240, 208, 120, 0.4);
  padding-bottom: 2px;
}

.glass-sheet {
  background: rgba(10, 4, 4, 0.72);
  border: 1px solid rgba(240, 208, 120, 0.4);
  border-radius: 16px;
  padding: 18px 16px;
  backdrop-filter: blur(12px);
}

.records-list {
  list-style: none;
  width: min(100%, 280px);
  margin: 8px 0 18px;
  color: var(--gold-shine);
}

.records-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(240, 208, 120, 0.2);
}

.device:not(.is-playing) .hud-top,
.device:not(.is-playing) .bet-dock,
.device:not(.is-playing) .playfield,
.device:not(.is-playing) .lock-block,
.device:not(.is-playing) .outcome-toast,
.device:not(.is-playing) .game-fun,
.device:not(.is-playing) .tiger {
  visibility: hidden;
  pointer-events: none;
}

.device:not(.is-playing) .history {
  visibility: hidden;
  pointer-events: none;
}

.device.is-playing .history {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  margin: 4px 0 8px max(8px, var(--safe-l));
}

.device.is-home .history {
  visibility: hidden;
  pointer-events: none;
}

.device.is-home .history.is-pulse {
  box-shadow: 0 0 0 2px #e8c56a, 0 0 24px rgba(240, 208, 120, 0.55);
  animation: hist-pulse 0.7s ease 2;
}

@keyframes hist-pulse {
  0%,
  100% {
    transform: translateY(-50%) scale(1);
  }
  50% {
    transform: translateY(-50%) scale(1.04);
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  .device.is-home .history.is-pulse {
    animation: hist-pulse-mobile 0.7s ease 2;
  }

  @keyframes hist-pulse-mobile {
    0%,
    100% {
      transform: scale(1);
    }
    50% {
      transform: scale(1.03);
    }
  }
}

.screen.home-screen {
  background: none;
  justify-content: stretch;
  align-items: stretch;
}

.home-screen.is-on {
  display: grid;
  grid-template-columns: minmax(96px, 20vw) minmax(0, 1fr) minmax(210px, 30vw);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "gear brand brand"
    "hist hero menu"
    "foot foot foot";
  align-items: stretch;
  justify-content: stretch;
  gap: 8px;
  padding: max(12px, var(--safe-t)) max(14px, var(--safe-r)) max(12px, var(--safe-b)) max(12px, var(--safe-l));
  background: linear-gradient(90deg, rgba(6, 2, 4, 0.28) 0%, transparent 24%, transparent 58%, rgba(6, 2, 4, 0.4) 100%);
  pointer-events: none;
}

.home-gear {
  grid-area: gear;
  justify-self: start;
  align-self: start;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gold-shine);
  font-size: 12px;
  background: rgba(10, 4, 4, 0.45);
  border: 1px solid rgba(240, 208, 120, 0.4);
  border-radius: 999px;
  padding: 6px 10px;
}

.home-brand {
  grid-area: brand;
  justify-self: end;
  text-align: right;
  pointer-events: none;
  max-width: min(52vw, 420px);
}

.home-crown {
  width: min(28vw, 120px);
  height: auto;
  margin-left: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45));
}

.home-title-km {
  font-size: clamp(28px, 6vw, 52px);
  line-height: 1.1;
  color: #f6d56a;
  text-shadow: 0 2px 0 #6a3a08, 0 8px 18px rgba(0, 0, 0, 0.55);
}

.home-title-en {
  font-family: var(--font-display);
  letter-spacing: 0.18em;
  font-size: clamp(11px, 2vw, 16px);
  color: #fff4c4;
}

.home-divider {
  display: block;
  width: min(70%, 220px);
  height: 1px;
  margin: 8px 0 6px auto;
  background: linear-gradient(90deg, transparent, #e8c56a, transparent);
}

.home-tag {
  margin-top: 6px;
  font-size: 12px;
  color: #e8c56a;
}

.home-hero-space {
  grid-area: hero;
  min-height: 4vh;
  pointer-events: none;
}

.home-menu {
  grid-area: menu;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  justify-self: end;
  pointer-events: auto;
}

.play-cta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(180deg, #6a2018, #3a0e0c);
  border: 2px solid #e8c56a;
  color: #fff8e0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 220, 140, 0.25);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.play-cta:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

.play-cta:active {
  transform: scale(0.98);
}

.play-cta.compact {
  justify-content: center;
}

.play-cta-icon {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: transparent;
}

.play-cta-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.play-cta-text b {
  font-size: 16px;
}

.play-cta-text small {
  opacity: 0.8;
  letter-spacing: 0.12em;
  font-size: 11px;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(8, 4, 4, 0.55);
  border: 1px solid rgba(240, 208, 120, 0.4);
  color: var(--gold-shine);
  text-align: left;
  transition: background 0.15s ease, transform 0.15s ease;
}

.menu-row:hover {
  background: rgba(40, 16, 8, 0.7);
  transform: translateX(-2px);
}

.menu-row span {
  display: flex;
  flex-direction: column;
}

.menu-row small {
  font-size: 10px;
  letter-spacing: 0.1em;
  opacity: 0.75;
}

.menu-ico {
  width: 28px;
  color: #e8c56a;
}

.home-foot {
  grid-area: foot;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  pointer-events: auto;
  flex-wrap: wrap;
}

.fun-only {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: #f0d078;
  max-width: 42vw;
}

.fun-only small {
  opacity: 0.75;
}

.orbs {
  display: flex;
  gap: 10px;
}

.orb {
  width: 74px;
  min-height: 74px;
  border-radius: 50%;
  border: 1px solid rgba(240, 208, 120, 0.5);
  background: rgba(8, 4, 4, 0.55);
  color: var(--gold-shine);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  backdrop-filter: blur(8px);
}

.orb.is-on {
  box-shadow: 0 0 14px rgba(240, 208, 120, 0.35);
}

.orb-ico {
  font-size: 16px;
  color: #e8c56a;
}

.orb-label {
  font-size: 9px;
  letter-spacing: 0.02em;
}

.device.is-home .menu-hero {
  left: 42%;
  top: 52%;
  width: min(46vw, 380px);
  height: min(42vw, 300px);
}

@media (max-width: 900px) and (orientation: portrait) {
  .loading-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "brand"
      "table"
      "status";
    gap: 12px;
  }

  .loading-brand {
    justify-self: center;
    text-align: center;
    flex-direction: column;
    gap: 4px;
  }

  .loading-table {
    width: min(88vw, 430px);
  }

  .loading-status {
    justify-self: center;
    width: min(86vw, 420px);
    margin-bottom: 0;
  }

  .home-screen.is-on {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas:
      "gear"
      "brand"
      "hero"
      "menu"
      "foot";
    background: linear-gradient(180deg, rgba(6, 2, 4, 0.2), rgba(6, 2, 4, 0.55));
  }

  .home-brand {
    justify-self: center;
    text-align: center;
    max-width: 100%;
  }

  .home-divider {
    margin-left: auto;
    margin-right: auto;
  }

  .home-crown {
    margin: 0 auto;
  }

  .home-menu {
    justify-self: center;
    max-width: min(100%, 360px);
  }

  .device.is-home .menu-hero {
    left: 50%;
    top: 38%;
    width: min(72vw, 280px);
    height: min(48vw, 220px);
    transform: translate(-50%, -50%);
    position: absolute;
    margin: 0;
  }

  .home-hero-space {
    min-height: 32vh;
  }

  .device.is-home .history {
    left: 8px;
    right: 8px;
    top: 42%;
    bottom: auto;
    transform: none;
    width: auto;
    max-height: 18%;
  }

  .device.is-home .hist-list {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .home-foot {
    flex-direction: column;
    align-items: center;
  }

  .fun-only {
    max-width: 100%;
    text-align: center;
  }
}

@media (orientation: landscape) and (min-width: 821px) {
  .menu-hero {
    top: 50%;
    left: 40%;
    width: min(40vw, 360px);
    height: min(46vh, 300px);
  }

  .screen:not(.home-screen) {
    align-items: flex-end;
  }

  .screen-copy {
    width: min(42vw, 340px);
    margin-right: 4vw;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .home-title-km {
    font-size: 22px;
  }

  .orb {
    width: 58px;
    min-height: 58px;
  }

  .play-cta-icon {
    width: 32px;
    height: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-stage,
  .hero-aura,
  .hero-spark {
    animation: none !important;
  }
}
