:root {
  --green: #00a321;
  --green-dark: #008f1d;
  --mint: #c5ffd7;
  --text: #142019;
  --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;
}

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

*::before,
*::after {
  -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: #9c9c9c;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.game {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0) 58%, rgba(255, 255, 255, 0.72) 100%), url("assets/bg.png");
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  touch-action: manipulation;
}

.game::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  /* background: linear-gradient(180deg, rgba(255, 255, 255, 0) 62%, rgba(255, 255, 255, 0.64) 100%); */
}





.intro,
.countdown,
.final-modal {
  position: absolute;
  inset: 0;
  z-index: 30;
}

.intro[hidden],
.countdown[hidden],
.final-modal[hidden] {
  display: none;
}

.intro {
  display: grid;
  align-items: end;
  justify-items: center;
  padding: 0 16px 56px;
  /* background: linear-gradient(180deg, rgba(255, 255, 255, 0) 42%, rgba(255, 255, 255, 0.88) 100%); */
}

.intro-content {
  width: fit-content;
  display: grid;
  justify-items: center;
  text-align: center;
}

.intro-cart {
  width: clamp(220px, 35vw, 308px);
  height: auto;
  margin-bottom: clamp(22px, 6vh, 44px);
  filter: drop-shadow(0 14px 20px rgba(45, 25, 10, 0.25));
}

.intro p {
  margin: 0;
  color: #ffffff;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
  font-size: clamp(18px, 2.45vw, 24px);
  line-height: 130%;
  letter-spacing: 0;
  -webkit-text-shadow: 0px 4px 4px 4px rgba(0,0,0,0.25); 
text-shadow: 0px 4px 4px 4px rgba(0,0,0,0.25);
}

.intro h1 {
  font-weight: 600;
}

.intro p {
  width: min(620px, 100%);
  font-weight: 600;
}

.primary-button,
.throw-button {
  width: clamp(170px, 31.4vw, 278px);
  height: clamp(40px, 6.3vw, 56px);
  padding: 0 24px;
  border: 0;
  border-radius: 8.65px;
  background: var(--green);
  color: #ffffff;
  font-size: clamp(12px, 1.45vw, 16px);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.primary-button:hover,
.primary-button:focus-visible,
.throw-button:hover,
.throw-button:focus-visible {
  background: var(--green-dark);
}

.primary-button {
  margin-top: clamp(14px, 2.7vh, 24px);
}

.countdown {
  display: grid;
  place-items: center;
  backdrop-filter: blur(3px);
  background: rgba(255, 255, 255, 0.12);
}

.countdown-value {
  min-width: clamp(96px, 13vw, 126px);
  height: clamp(118px, 16vw, 156px);
  display: grid;
  place-items: center;
  color: #ffffff;
  font-size: clamp(112px, 16vw, 164px);
  font-weight: 700;
  line-height: 0.9;
  text-shadow:
    0 7px 14px rgba(32, 19, 9, 0.42),
    0 0 1px rgba(32, 19, 9, 0.35);
}

.countdown-value.is-ticking {
  animation: countdownPop 820ms cubic-bezier(0.18, 0.86, 0.22, 1) both;
}

.hud {
  position: absolute;
  top: calc(var(--host-header-offset) + clamp(16px, 2.8vh, 24px));
  left: clamp(18px, 4.8vw, 70px);
  right: clamp(18px, 4.8vw, 70px);
  z-index: 20;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.pill {
  width: clamp(86px, 14.5vw, 128px);
  height: clamp(38px, 6.3vw, 56px);
  display: flex;
  justify-content: center;
  place-items: center;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--green-dark);
  font-size: clamp(16px, 2.75vw, 24px);
  font-weight: 600;
  line-height: 1;
  text-align: center;
}

.score-pill {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.field-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  perspective: 900px;
  perspective-origin: 50% 32%;
  transform-style: preserve-3d;
}

.cart {
  position: absolute;
  left: 50%;
  top: var(--cart-top, 30%);
  width: var(--cart-size, 150px);
  height: var(--cart-size, 150px);
  transform: translateX(-50%);
  filter: drop-shadow(0 16px 14px rgba(40, 22, 10, 0.24));
}

.cart img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cart-back {
  z-index: 1;
}

.cart-fill {
  position: absolute;
  left: 23%;
  right: 23%;
  top: 18%;
  height: 24%;
  z-index: 2;
  overflow: hidden;
  border-radius: 50%;
}

.cart-front {
  z-index: 3;
}

.cart-paper {
  position: absolute;
  width: 13%;
  height: 13%;
  object-fit: contain;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.12));
}

.arrow,
.paper-ready,
.flying-paper,
.feedback {
  position: absolute;
  left: 0;
  top: -20px;
  will-change: transform, opacity;
}

.arrow {
  z-index: 9;
  width: var(--arrow-width, 62px);
  height: auto;
  transform-origin: 50% 88%;
  filter: drop-shadow(0 3px 4px rgba(35, 24, 15, 0.23));
}

.paper-ready {
  z-index: 99;
  width: var(--paper-size, 77px);
  height: var(--paper-size, 114px);
  object-fit: contain;
  filter: drop-shadow(0 5px 4px rgba(35, 24, 15, 0.24));
  /* background-color: var(--mint);
  border-radius: 50%;
  border: 4px solid white; */
}


.flying-paper {
  z-index: 12;
  width: var(--paper-size, 44px);
  height: var(--paper-size, 44px);
  object-fit: contain;
  transition: transform 460ms cubic-bezier(0.2, 0.82, 0.2, 1), opacity 460ms ease;
}

.flying-paper.is-miss {
  transition: none;
}

.feedback {
  z-index: 14;
  width: clamp(54px, 8vw, 86px);
  height: auto;
  transform: translate(-50%, -50%);
  transition: transform 860ms ease, opacity 860ms ease;
}

.throw-button {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 20;
  transform: translateX(-50%);
}

.throw-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.game.is-intro .hud,
.game.is-intro .field-layer,
.game.is-intro .throw-button,
.game.is-countdown .hud,
.game.is-countdown .throw-button,
.game.is-finished .hud,
.game.is-finished .field-layer,
.game.is-finished .arrow,
.game.is-finished .paper-ready,
.game.is-finished .throw-button {
  visibility: hidden;
}

.game.is-countdown .arrow,
.game.is-countdown .paper-ready {
  visibility: hidden;
}

.final-modal {
  z-index: 36;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 50% 52%, rgba(255, 255, 255, 0.28), rgba(244, 235, 226, 0.74) 62%),
    rgba(239, 229, 218, 0.62);
  backdrop-filter: blur(5px);
  animation: finalOverlayIn 240ms ease both;
}

.final-card {
  position: relative;
  width: min(670px, calc(100vw - 44px));
  min-height: 148px;
  display: grid;
  place-items: center;
  padding: 48px clamp(28px, 5vw, 66px) 36px;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(197, 255, 215, 0.94), rgba(255, 255, 255, 0.96));
  box-shadow: 0 24px 72px rgba(48, 31, 18, 0.14);
  text-align: center;
  animation: finalCardIn 260ms cubic-bezier(0.2, 0.78, 0.2, 1) both;
}

.final-logo {
  position: absolute;
  left: 50%;
  top: 0;
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  transform: translate(-50%, -50%);
}

.final-logo img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.final-card h2 {
  max-width: 560px;
  margin: 0;
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.22;
  letter-spacing: 0;
  font-weight: 500;
  padding-left: 14px;
  padding-right: 14px;
}

@keyframes finalOverlayIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes countdownPop {
  0% {
    opacity: 0;
    transform: scale(0.62);
  }
  24% {
    opacity: 1;
    transform: scale(1.04);
  }
  100% {
    opacity: 0;
    transform: scale(0.92);
  }
}

@keyframes finalCardIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 1200px) and (min-width: 561px) {
  .intro {
    padding-bottom: clamp(42px, 6vh, 64px);
  }

  .intro-cart {
    width: clamp(250px, 38vw, 330px);
  }

  .hud {
    left: clamp(22px, 5vw, 56px);
    right: clamp(22px, 5vw, 56px);
  }

  .pill {
    width: clamp(110px, 15vw, 138px);
    height: clamp(48px, 6.5vw, 58px);
    font-size: clamp(20px, 2.7vw, 25px);
  }

  .primary-button,
  .throw-button {
    width: clamp(220px, 33vw, 302px);
    height: clamp(50px, 6.8vw, 60px);
    font-size: clamp(15px, 1.8vw, 17px);
  }
}

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

  .game {
    background-size: auto 100%;
  }

  .hud {
    top: calc(var(--host-header-offset) + 12px);
    left: 10px;
    right: 10px;
    justify-content: space-between;
  }

  .pill {
    width: 86px;
    height: 50px;
    padding: 0 12px;
    font-size: 16px;
  }

  .score-pill {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }

  .intro {
    padding: 0 10px 28px;
  }

  .intro-cart {
    width: min(56vw, 220px);
    margin-bottom: clamp(18px, 6vh, 42px);
  }

  .intro h1,
  .intro p {
    font-size: 16px;
  }

  .primary-button,
  .throw-button {
    width: min(72vw, 278px);
    height: 56px;
    padding: 0 12px;
    font-size: 16px;
  }

  .throw-button {
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .final-modal {
    padding: 18px;
  }

  .final-card {
    width: min(330px, calc(100vw - 36px));
    min-height: 260px;
    padding: 42px 18px 26px;
    border-radius: 18px;
  }

  .final-logo {
    width: 86px;
    height: 86px;
  }

  .final-logo img {
    width: 42px;
    height: 42px;
  }

  .final-card h2 {
    font-size: 16px;
    line-height: 1.2;
  }

}
