:root {
  --green: #00a321;
  --green-dark: #008b1c;
  --mint: #caffdc;
  --text: #102017;
  --button-insurance-width: clamp(262px, calc(248.893px + 3.495vw), 316px);
  --button-payout-width: clamp(262px, calc(258.117px + 1.036vw), 278px);
  --result-card-width: clamp(342px, calc(336.66px + 1.424vw), 364px);
  --host-header-offset: 74px;
}

@font-face {
  font-family: "SB Sans Display";
  src: url("../fonts/SBSansDisplay-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "SB Sans Display";
  src: url("../fonts/SBSansDisplay-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "SB Sans Display";
  src: url("../fonts/SBSansDisplay-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

img,
svg,
canvas,
button {
  touch-action: manipulation;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--text);
  font-family: "SB Sans Display", Arial, Helvetica, sans-serif;
  background: #7d7569;
}

button {
  font: inherit;
}

.game {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 420px;
  overflow: hidden;
  isolation: isolate;
  touch-action: manipulation;
}

.backgrounds,
.bg-layer,
.effects-canvas {
  position: absolute;
  inset: 0;
}

.backgrounds {
  z-index: 0;
  background: #928575;
}

.bg-layer {
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0;
  transform: scale(1.018);
  transition: opacity 720ms ease, transform 1600ms ease;
  will-change: opacity, transform;
}

.bg-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0) 54%, rgba(0, 0, 0, 0.52) 100%),
    radial-gradient(circle at 50% 44%, rgba(255, 255, 255, 0) 0 34%, rgba(23, 18, 14, 0.15) 100%);
}

.bg-layer-game {
  background-image: url("assets/thief_background.gif");
}

.bg-layer-locked {
  background-image: url("assets/lock_home.png");
}

.bg-layer-unlocked {
  background-image: url("assets/unlocked_home.png");
}

.bg-layer-unlocked-escape {
  background-image: url("assets/unlocked_home_escape.png");
}

.bg-game .bg-layer-game,
.bg-locked .bg-layer-locked,
.bg-unlocked .bg-layer-unlocked,
.bg-unlocked-escape .bg-layer-unlocked-escape {
  opacity: 1;
  transform: scale(1);
}

.is-intro .bg-layer-locked {
  filter: blur(4px);
}

.effects-canvas {
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hero {
  display: block;
  position: absolute;
  top: clamp(12px, 10vw, 256px);
  right: clamp(15px, 5vw, 156px);
  z-index: 5;
  width: clamp(138px, 17vw, 312px);
  aspect-ratio: 1;
  border: 4px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  object-fit: cover;
  background: #d3c2a5;
  box-shadow: 0 16px 42px rgba(20, 12, 8, 0.2);
  transform-origin: center;
  animation: heroFloat 3.8s ease-in-out infinite;
  transition: opacity 300ms ease, transform 300ms ease;
}

.is-safe .hero,
.is-breakin .hero,
.is-insurance .hero {
  opacity: 0;
  transform: translateY(-10px) scale(0.96);
  animation-play-state: paused;
}

.hud {
  position: absolute;
  left: clamp(14px, 2.4vw, 28px);
  top: calc(var(--host-header-offset) + clamp(14px, 2.4vw, 24px));
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.is-playing .hud {
  opacity: 1;
  transform: translateY(0);
}

.pill {
  min-width: 116px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--green-dark);
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 16px 38px rgba(20, 12, 8, 0.17);
}

.modal-screen,
.result-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-screen[hidden],
.result-screen[hidden] {
  display: none;
}

.intro-screen {
  z-index: 26;
  backdrop-filter: blur(2.5px);
  background: rgba(25, 20, 16, 0.12);
}

.result-screen {
  background: rgba(26, 22, 18, 0.02);
}

.modal-card,
.small-result-card {
  position: relative;
  display: grid;
  justify-items: center;
  text-align: center;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--mint) 0%, #ffffff 100%);
  box-shadow: 0 22px 70px rgba(16, 12, 9, 0.23);
  animation: cardIn 460ms cubic-bezier(0.17, 0.82, 0.24, 1) both;
}

.modal-card {
  width: clamp(333px, calc(231.544px + 27.055vw), 751px);
  max-width: 751px;
  min-height: 237px;
  gap: 18px;
  padding: 48px 42px 30px;
}

.modal-card h1,
.modal-card h2 {
  margin-top: 25px;
  color: #142019;
  font-size: clamp(1rem, calc(0.879rem + 0.518vw), 1.5rem);
  line-height: 1.16;
  font-weight: 600;
  letter-spacing: 0;
}

.modal-card h2 {
  max-width: 455px;
}

.modal-icon {
  position: absolute;
  left: 50%;
  top: 0;
  width: 87px;
  height: 87px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  transform: translate(-50%, -50%);
  box-shadow: 0 10px 22px rgba(20, 12, 8, 0.1);
}

.modal-icon img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

.intro-icon img {
  width: 86px;
  height: 86px;
  border-radius: 50%;
}

.coin-icon img {
  width: 52px;
  height: auto;
}

.primary-button {
  width: var(--button-insurance-width);
  height: 56px;
  padding: 0 28px;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: #ffffff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(0, 137, 28, 0.18);
  transition: background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--green-dark);
  outline: none;
  box-shadow: 0 10px 24px rgba(0, 137, 28, 0.24);
}

.primary-button:active {
  transform: translateY(1px);
}

.play-screen {
  position: absolute;
  inset: 0;
  z-index: 6;
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms ease;
}

.is-playing .play-screen {
  opacity: 1;
  pointer-events: auto;
}

.actions {
  position: absolute;
  left: 50%;
  bottom: clamp(70px, 12vh, 118px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(17px, 2.6vw, 36px);
  transform: translateX(-50%);
}

.action-button {
  position: relative;
  width: 92px;
  min-height: 112px;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.42);
}

.action-button-main {
  transform: translateY(-8px);
}

.action-icon,
.cooldown {
  width: clamp(60px, 6vw, 74px);
  height: clamp(60px, 6vw, 74px);
}

.action-icon {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff2d8;
  box-shadow: inset 0 0 0 3px #f6c567, 0 12px 26px rgba(16, 11, 8, 0.22);
  transition: transform 160ms ease, filter 160ms ease;
}

.action-icon::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 2px solid rgba(255, 230, 179, 0.42);
  border-radius: inherit;
  animation: actionPulse 2.1s ease-in-out infinite;
}

.action-icon img {
  width: 74%;
  height: 74%;
  object-fit: contain;
}

.action-label {
  font-size: clamp(11px, 1.15vw, 14px);
  line-height: 1.06;
  font-weight: 700;
}

.action-button:hover .action-icon,
.action-button:focus-visible .action-icon {
  transform: translateY(-3px) scale(1.04);
  filter: brightness(1.04);
}

.action-button:focus-visible {
  outline: none;
}

.action-button:disabled {
  cursor: default;
  opacity: 0.62;
}

.action-button:disabled .action-icon {
  filter: grayscale(0.38);
  transform: none;
}

.cooldown {
  position: absolute;
  left: 50%;
  top: 0;
  border-radius: 50%;
  background: conic-gradient(rgba(24, 21, 18, 0.56) var(--cooldown, 0%), transparent 0);
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
}

.action-button.is-cooling .cooldown {
  opacity: 1;
}

.action-button.is-hit .action-icon {
  animation: buttonHit 360ms ease;
}

.progress-area {
  position: absolute;
  left: 50%;
  bottom: clamp(25px, 5.6vh, 50px);
  width: clamp(295px, calc(270.485px + 6.537vw), 396px);
  display: grid;
  gap: 8px;
  transform: translateX(-50%);
  color: #ffffff;
  text-align: center;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
}

.progress-track {
  position: relative;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.83);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #69e880 0%, #ffe66b 54%, #ff5b43 100%);
  box-shadow: 0 0 18px rgba(255, 94, 61, 0.42);
  transition: width 120ms linear;
}

.progress-value {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #194018;
  font-size: 9px;
  font-weight: 800;
  text-shadow: none;
}

.progress-area p {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.small-result-card {
  width: var(--result-card-width);
  min-height: 154px;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 11px;
  padding: 20px 18px;
  text-align: left;
}

.small-result-card h2 {
  justify-self: start;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.14;
}

.result-icon {
  width: 52px;
  height: auto;
}

.small-button {
  grid-column: 1 / -1;
  justify-self: center;
  min-width: 0;
  width: 200px;
  height: 48px;
  margin-top: 13px;
  padding: 0 12px;
  font-size: 12px;
}

.small-result-card:not(.insurance-card) .small-button {
  width: 148px;
}

.insurance-card {
  width: var(--result-card-width);
}

#insuranceButton {
  width: var(--button-insurance-width);
}

#payoutButton {
  width: var(--button-payout-width);
}

.thanks-card {
  width: min(624px, calc(100vw - 36px));
}

.thanks-card h2 {
  font-size: clamp(17px, 1.55vw, 22px);
}

.coin-layer {
  position: absolute;
  inset: 0;
  z-index: 80;
  pointer-events: none;
}

.flying-coin {
  position: absolute;
  width: 44px;
  height: 34px;
  object-fit: contain;
  transform: translate(-50%, -50%);
  animation: flyCoin 900ms cubic-bezier(0.18, 0.84, 0.2, 1) forwards;
  filter: drop-shadow(0 7px 10px rgba(20, 12, 8, 0.24));
}

.screen-shake {
  animation: screenShake 360ms ease;
}

@keyframes heroFloat {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-7px) rotate(1.2deg);
  }
}

@keyframes cardIn {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes actionPulse {
  0%,
  100% {
    opacity: 0.44;
    transform: scale(0.98);
  }
  50% {
    opacity: 0.12;
    transform: scale(1.14);
  }
}

@keyframes buttonHit {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(0.9) rotate(-5deg);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes screenShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
}

@keyframes flyCoin {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.72) rotate(0deg);
  }
  16% {
    opacity: 1;
  }
  78% {
    opacity: 1;
  }
  100% {
    left: var(--target-x);
    top: var(--target-y);
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.46) rotate(380deg);
  }
}

@media (max-width: 1200px) and (min-width: 721px) {
  .hero {
    top: clamp(92px, 11vw, 132px);
    right: clamp(30px, 5.4vw, 74px);
    width: clamp(176px, 20vw, 252px);
  }

  .hud {
    top: calc(var(--host-header-offset) + 18px);
    left: clamp(18px, 3vw, 34px);
  }

  .pill {
    min-width: 126px;
    height: 56px;
    font-size: 24px;
  }

  .actions {
    bottom: clamp(96px, 13vh, 126px);
    gap: clamp(28px, 4vw, 46px);
  }

  .action-button {
    width: 104px;
    min-height: 118px;
    gap: 8px;
  }

  .action-icon,
  .cooldown {
    width: 92px;
    height: 92px;
  }

  .action-label {
    font-size: 15px;
    line-height: 1.08;
  }

  .progress-area {
    bottom: clamp(34px, 5.4vh, 52px);
    width: clamp(360px, 44vw, 440px);
  }

  .progress-area p {
    font-size: 17px;
  }
}

@media (max-width: 720px) {
  :root {
    --host-header-offset: 57px;
  }

  .game {
    min-height: 360px;
  }

  .bg-layer {
    background-size: auto 100%;
    background-position: 44% center;
  }

  .bg-layer-game,
  .bg-layer-locked {
    background-position: 50% center;
  }

  .bg-layer-unlocked {
    background-position: 20% center;
  }

  .bg-layer-unlocked-escape {
    background-position: 50% center;
  }

  .bg-layer::after {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 44%, rgba(0, 0, 0, 0.58) 100%);
  }

  .hero {
    top: 104px;
    right: 30px;
    width: 138px;
    border-width: 3px;
  }

  .hud {
    top: calc(var(--host-header-offset) + 10px);
    left: 10px;
  }

  .pill {
    min-width: 83px;
    height: 50px;
    padding: 0 7px;
    font-size: 16px;
  }

  .actions {
    bottom: 84px;
    gap: 25px;
  }

  .action-button {
    width: 80px;
    min-height: 80px;
    gap: 5px;
  }

  .action-button-main {
    transform: translateY(-5px);
  }

  .action-icon,
  .cooldown {
    width: 80px;
    height: 80px;
  }

  .action-icon::after {
    inset: -4px;
  }

  .action-label {
    font-size: 14px;
  }

  .progress-area {
    bottom: 18px;
    gap: 5px;
  }

  .progress-track {
    height: 16px;
  }

  .progress-value {
    font-size: 12px;
  }

  .progress-area p {
    font-size: 14px;
  }

  .small-result-card h2 {
    font-size: 16px;
  }

  .result-icon {
    width: 40px;
  }

  .small-button,
  .small-result-card:not(.insurance-card) .small-button {
    width: 150px;
    height: 48px;
    margin-top: 10px;
    font-size: 16px;
  }

  #insuranceButton {
    width: var(--button-insurance-width);
  }

  #payoutButton {
    width: var(--button-payout-width);
  }
}

@media (max-height: 520px) and (min-width: 721px) {
  .hero {
    width: 118px;
  }

  .actions {
    bottom: 58px;
  }

  .progress-area {
    bottom: 19px;
  }

  .modal-card {
    transform: scale(0.9);
  }
}
