:root {
  --frame-w: 844px;
  --frame-h: 1766px;
  --app-height: 100vh;
}

@font-face {
  font-family: "Jalnan";
  src: url("assets/font/Jalnan.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Jalnan Gothic";
  src: url("assets/font/JalnanGothic.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "OmniGothic";
  src: url("assets/font/210-OmniGothic-025.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: var(--app-height);
  margin: 0;
  overflow: hidden;
  background: #c9ef9f;
  font-family: "Jalnan Gothic", "Jalnan", "Cafe24 Ssurround", "Arial Rounded MT Bold", system-ui, sans-serif;
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
}

#app {
  width: 100%;
  height: var(--app-height);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.stage-shell {
  position: relative;
  width: 100vw;
  height: var(--app-height);
  overflow: hidden;
}

.stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--frame-w);
  height: var(--frame-h);
  transform-origin: center center;
  background: #c9ef9f;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

.asset,
.hit,
.piece,
.board-cell,
.screen,
.modal-layer,
.score-value,
.next-preview,
.menu-title,
.difficulty-stack,
.game-board,
.touch-controls,
.help-card,
.gameover-score,
.toast {
  position: absolute;
}

.asset {
  display: block;
  pointer-events: none;
}

.bg {
  inset: 0;
  width: 844px;
  height: 1766px;
}

.logo {
  left: 276px;
  top: 29px;
  width: 292px;
  height: 204px;
}

.panel-next {
  left: 69px;
  top: 263px;
  width: 222px;
  height: 208px;
}

.panel-score {
  left: 301px;
  top: 263px;
  width: 255px;
  height: 208px;
}

.button-help {
  left: 578px;
  top: 287px;
  width: 193.57px;
  height: 72.36px;
}

.button-retry {
  left: 578px;
  top: 374px;
  width: 193.57px;
  height: 72.36px;
}

.window-outer {
  left: 72px;
  top: 510px;
  width: 699.9px;
  height: 1137px;
}

.board-window {
  left: 72px;
  top: 510px;
  width: 699.9px;
  height: 1137px;
}

.inner-board {
  left: 116.56px;
  top: 568px;
  width: 610.44px;
  height: 1023.04px;
}

.difficulty-stars {
  left: 275px;
  top: 665px;
  width: 294.3px;
  height: 123.74px;
}

.button-start {
  left: 289px;
  top: 1403px;
  width: 265.63px;
  height: 96.53px;
}

.screen {
  inset: 0;
}

.hidden {
  display: none;
}

.hit {
  background: transparent;
  padding: 0;
  border-radius: 8px;
  z-index: 20;
}

.hit:focus-visible {
  outline: 4px solid rgba(255, 255, 255, 0.9);
  outline-offset: 2px;
}

.score-value {
  left: 324px;
  top: 384px;
  width: 209px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 13px;
  color: #fff;
  font-size: 36px;
  line-height: 1;
  font-weight: 900;
  font-family: "Jalnan", "Jalnan Gothic", system-ui, sans-serif;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
  z-index: 5;
}

.next-preview {
  left: 180px;
  top: 292px;
  width: 78px;
  height: 151px;
  z-index: 5;
}

.next-preview .piece {
  width: 44px;
  height: 44px;
}

.menu-title {
  left: 242px;
  top: 888px;
  width: 360px;
  height: 60px;
  color: #b76b20;
  font-size: 48px;
  line-height: 60px;
  font-weight: 900;
  font-family: "Jalnan", "Jalnan Gothic", system-ui, sans-serif;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 3px 0 rgba(255, 244, 188, 0.85);
}

.difficulty-stack {
  left: 179px;
  top: 984px;
  width: 482px;
  height: 262px;
  display: grid;
  gap: 17px;
  z-index: 21;
}

.difficulty-button {
  width: 482px;
  height: 76px;
  border-radius: 8px;
  color: #9d6028;
  font-size: 30px;
  font-weight: 900;
  font-family: "Jalnan Gothic", "Jalnan", system-ui, sans-serif;
  letter-spacing: 0;
  text-shadow: 0 2px 0 rgba(255, 218, 150, 0.45);
  background: transparent url("assets/figma/difficulty_button_inactive_bg.png") center / 100% 100% no-repeat;
  border: 0;
  box-shadow: none;
}

.difficulty-button.is-active {
  color: #285c10;
  text-shadow: 0 2px 0 rgba(211, 255, 85, 0.8);
  background-image: url("assets/figma/difficulty_button_active_bg.png");
}

.game-board {
  left: 0;
  top: 0;
  width: 844px;
  height: 1766px;
  z-index: 8;
  pointer-events: none;
}

.board-cell {
  width: 72.68px;
  height: 72.68px;
  border-radius: 7px;
  background: rgba(255, 224, 159, 0.58);
  border: 2px solid rgba(255, 255, 255, 0.28);
}

.piece {
  width: 72.68px;
  height: 72.68px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,231,151,0.92));
  border: 3px solid #b36a19;
  box-shadow: 0 5px 0 rgba(128, 74, 13, 0.55), inset 0 4px 5px rgba(255, 255, 255, 0.75);
  transition: transform 120ms ease, opacity 150ms ease;
  z-index: 12;
}

.piece.is-active {
  filter: drop-shadow(0 8px 8px rgba(118, 67, 17, 0.25));
}

.piece.is-clearing {
  animation: piecePop 520ms ease-out forwards;
}

.piece img {
  display: block;
  width: 58px;
  height: 58px;
  object-fit: contain;
  pointer-events: none;
}

.next-preview .piece img {
  width: 35px;
  height: 35px;
}

.burst {
  position: absolute;
  width: 72.68px;
  height: 72.68px;
  pointer-events: none;
  z-index: 32;
}

.burst::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 78px;
  height: 78px;
  border: 5px solid rgba(255, 255, 255, 0.88);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.45);
  animation: burstRing 520ms ease-out forwards;
}

.burst::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.92) 0 18%, rgba(255, 226, 79, 0.48) 34%, transparent 68%);
  transform: translate(-50%, -50%) scale(0.2);
  animation: burstFlash 520ms ease-out forwards;
}

.burst-particle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  transform: translate(-50%, -50%) scale(0.75);
  filter: drop-shadow(0 3px 2px rgba(85, 50, 12, 0.22));
  animation: burstParticle 520ms ease-out forwards;
}

@keyframes piecePop {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  38% {
    transform: scale(1.36);
    opacity: 1;
  }
  100% {
    transform: scale(0.42);
    opacity: 0;
  }
}

@keyframes burstRing {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.35);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.42);
  }
}

@keyframes burstFlash {
  0% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.25);
  }
  42% {
    opacity: 0.72;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.34);
  }
}

@keyframes burstParticle {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.85) rotate(0deg);
  }
  44% {
    opacity: 1;
    transform: translate(-50%, -50%) translate(var(--mx), var(--my)) scale(1.02) rotate(72deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) scale(0.36) rotate(var(--rot));
  }
}

.touch-controls {
  left: 78px;
  top: 1545px;
  width: 688px;
  height: 100px;
  display: none;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  z-index: 21;
}

.control-button {
  border-radius: 8px;
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.36) 0 24px, transparent 24px),
    linear-gradient(180deg, #43cde5, #168ca6);
  border: 3px solid #0c6c82;
  box-shadow: 0 5px 0 #075366;
  text-shadow: 0 2px 0 rgba(0,0,0,0.2);
}

.help-modal,
.gameover-layer {
  inset: 0;
  z-index: 40;
}

.dim {
  inset: 0;
  width: 844px;
  height: 1766px;
  opacity: 0.76;
}

.help-reference {
  inset: 0;
  width: 844px;
  height: 1766px;
  z-index: 41;
}

.help-reference-mobile {
  display: none;
}

@media (pointer: coarse), (max-width: 640px) {
  .help-reference-desktop {
    display: none;
  }

  .help-reference-mobile {
    display: block;
  }
}

.help-close-hit {
  left: 280px;
  top: 1138px;
  width: 284px;
  height: 132px;
  z-index: 42;
}

.gameover-modal-img {
  left: 144px;
  top: 523px;
  width: 555px;
  height: 720px;
}

.gameover-score {
  left: 185px;
  top: 850px;
  width: 473px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 54px;
  font-weight: 900;
  text-shadow: 0 4px 0 #8e4218;
  z-index: 45;
}

.gameover-retry-hit {
  left: 289px;
  top: 1058px;
  width: 265.63px;
  height: 96.53px;
  z-index: 46;
}

.toast {
  left: 126px;
  top: 1510px;
  width: 592px;
  padding: 18px 24px;
  border-radius: 8px;
  color: #fff;
  font-size: 28px;
  font-weight: 900;
  text-align: center;
  background: rgba(38, 74, 19, 0.78);
  z-index: 50;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.replay-ad-overlay {
  position: absolute;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: #071845;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.replay-ad-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.replay-ad-image {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.replay-ad-counter {
  position: absolute;
  right: 20px;
  top: 27px;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: center / contain no-repeat;
}

.replay-ad-count {
  display: block;
  color: #2f3340;
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.58);
  transform: translateY(4px);
}
