:root {
  /* Bottom of page gradient — iOS fills safe area behind browser chrome with this */
  --ios-root-fill: #0a1610;
  --bg-deep: #0d1f18;
  --bg-mid: #1b4332;
  --accent: #95d5b2;
  --accent-hot: #d8f3dc;
  --sun: #fefae0;
  --claw-metal: #6c757d;
  --claw-dark: #343a40;
  --pit-bg: rgba(15, 41, 30, 0.92);
  --font: "Fredoka", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  touch-action: manipulation;
}

html {
  margin: 0;
  min-height: 100%;
  min-height: -webkit-fill-available;
  background-color: var(--ios-root-fill);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

body.claw-page {
  font-family: var(--font);
  color: var(--sun);
  min-height: 100%;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  background-color: var(--ios-root-fill);
  background-image: radial-gradient(ellipse 100% 70% at 50% 0%, #2d6a4f 0%, transparent 50%),
    linear-gradient(180deg, #152e24 0%, var(--bg-deep) 45%, #0a1610 100%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: none) and (pointer: coarse), (max-width: 640px) {
  html {
    overscroll-behavior: none;
  }

  body.claw-page {
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  input,
  textarea,
  select {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
  }

  img {
    -webkit-user-drag: none;
    user-select: none;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }
}

.claw-top {
  padding: max(1.15rem, calc(env(safe-area-inset-top) + 0.45rem)) 1rem 0.5rem;
  text-align: center;
}

.claw-top__label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.claw-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 0.75rem 1.25rem;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

.claw-hint {
  text-align: center;
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--accent);
  opacity: 0.95;
}

.claw-play-stack {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.claw-controls-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-top: 1rem;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
}

.claw-back-home {
  grid-column: 1;
  justify-self: start;
  align-self: center;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  padding: 0.35rem 0.25rem;
  border-radius: 0.5rem;
  transition: color 0.15s ease, background 0.15s ease;
}

.claw-back-home:hover {
  color: var(--accent-hot);
  background: rgba(149, 213, 178, 0.12);
}

.claw-back-home:active {
  opacity: 0.88;
}

.claw-arena {
  position: relative;
  flex: 1;
  min-height: min(58vh, 420px);
  border-radius: 1.25rem;
  border: 3px solid rgba(149, 213, 178, 0.35);
  background: linear-gradient(180deg, rgba(45, 106, 79, 0.35) 0%, rgba(27, 67, 50, 0.55) 100%);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.25), 0 12px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.claw-arena--inactive .claw-machine {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.claw-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28%;
  max-width: 140px;
  z-index: 4;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  opacity: 0;
}

.claw-zone--left {
  left: 0;
}

.claw-zone--right {
  right: 0;
}

.claw-zone:focus-visible {
  opacity: 1;
  background: rgba(149, 213, 178, 0.12);
  outline: 2px solid var(--accent);
}

.claw-machine {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 42%;
  z-index: 2;
  pointer-events: none;
}

.claw-rail {
  position: absolute;
  top: 0.35rem;
  left: 4%;
  right: 4%;
  height: 14px;
  background: linear-gradient(180deg, #868e96 0%, #495057 50%, #343a40 100%);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.claw-dolly {
  position: absolute;
  top: 0.35rem;
  left: var(--claw-x, 50%);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 64px;
  transition: left 0.14s linear;
  z-index: 3;
}

.claw-page.claw--dropping .claw-dolly,
.claw-page.claw--rising .claw-dolly {
  transition: none;
}

.claw-cable {
  width: 5px;
  flex: 0 0 auto;
  flex-shrink: 0;
  height: var(--cable-len, 48px);
  min-height: 28px;
  background: linear-gradient(90deg, #212529 0%, #495057 40%, #adb5bd 50%, #495057 60%, #212529 100%);
  border-radius: 2px;
  transition: height 1.05s cubic-bezier(0.45, 0, 0.55, 1);
  box-shadow: 1px 0 2px rgba(0, 0, 0, 0.3);
}

.claw-page.claw--rising .claw-cable {
  transition: height 1.15s cubic-bezier(0.25, 0.9, 0.35, 1);
}

.claw-head {
  position: relative;
  width: 64px;
  height: 36px;
  margin-top: -2px;
  flex-shrink: 0;
}

.claw-finger {
  position: absolute;
  bottom: 0;
  width: 13px;
  height: 34px;
  background: linear-gradient(90deg, #495057, #868e96);
  border-radius: 0 0 8px 8px;
  transform-origin: top center;
  transition: transform 0.35s cubic-bezier(0.34, 1.3, 0.64, 1);
  box-shadow: inset -2px 0 4px rgba(0, 0, 0, 0.25);
}

.claw-finger--l {
  left: 2px;
  transform: rotate(-52deg);
}

.claw-finger--r {
  right: 2px;
  transform: rotate(52deg);
}

.claw-page.claw--descending:not(.claw--closed) .claw-finger--l {
  transform: rotate(-58deg);
}

.claw-page.claw--descending:not(.claw--closed) .claw-finger--r {
  transform: rotate(58deg);
}

.claw-page.claw--closed .claw-finger--l {
  transform: rotate(5deg);
}

.claw-page.claw--closed .claw-finger--r {
  transform: rotate(-5deg);
}

.claw-grab-slot {
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  width: 48px;
  height: 54px;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.claw-grab-slot .pit-egg {
  position: relative !important;
  left: auto !important;
  bottom: auto !important;
  transform: none !important;
  margin-bottom: 0;
  width: 38px !important;
  height: 48px !important;
}

.egg-pit {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48%;
  background: linear-gradient(180deg, transparent 0%, var(--pit-bg) 18%);
  z-index: 1;
}

.pit-egg {
  position: absolute;
  width: clamp(36px, 11vw, 52px);
  height: clamp(44px, 13vw, 64px);
  border-radius: 50% 50% 50% 50% / 58% 58% 42% 42%;
  background: radial-gradient(circle at 32% 24%, #fffcef 0%, #f0dcb8 45%, #d4b896 100%);
  box-shadow: inset -4px -4px 10px rgba(90, 60, 30, 0.2), 0 6px 14px rgba(0, 0, 0, 0.35);
  transform: translateX(-50%) translateY(var(--egg-y, 0px)) rotate(var(--egg-rot, 0deg));
  transform-origin: 50% 100%;
  pointer-events: none;
}

.pit-egg::after {
  content: "";
  position: absolute;
  top: 14%;
  left: 22%;
  width: 35%;
  height: 20%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.55), transparent);
  border-radius: 50%;
  transform: rotate(-20deg);
}

/* Lucky eggs — silver 1.5×, golden 2×, rainbow 3×, ruby 5× on rainbow/golden/silver dino variants */
.pit-egg--golden {
  background: radial-gradient(circle at 30% 22%, #fffef5 0%, #ffe066 35%, #e6a800 62%, #a67c00 100%);
  box-shadow:
    inset -4px -4px 10px rgba(100, 65, 15, 0.35),
    0 0 16px rgba(255, 210, 80, 0.55),
    0 6px 14px rgba(0, 0, 0, 0.38);
}

.pit-egg--golden::after {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.85), transparent);
}

.pit-egg--rainbow {
  background: linear-gradient(
    145deg,
    #ff6b9d 0%,
    #c77dff 18%,
    #7bf1ff 36%,
    #95d5b2 52%,
    #ffe066 68%,
    #ff9f1c 85%,
    #e63946 100%
  );
  background-size: 180% 180%;
  box-shadow:
    inset -3px -3px 10px rgba(40, 20, 60, 0.25),
    0 0 18px rgba(200, 120, 255, 0.45),
    0 6px 14px rgba(0, 0, 0, 0.35);
}

.pit-egg--rainbow::after {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.75), transparent);
}

.pit-egg--silver {
  background: radial-gradient(circle at 32% 24%, #f8f9fa 0%, #ced4da 38%, #adb5bd 62%, #868e96 100%);
  box-shadow:
    inset -4px -4px 10px rgba(40, 48, 58, 0.35),
    0 0 14px rgba(206, 212, 218, 0.55),
    0 6px 14px rgba(0, 0, 0, 0.34);
}

.pit-egg--silver::after {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), transparent);
}

.pit-egg--ruby {
  overflow: hidden;
  background:
    linear-gradient(122deg, rgba(255, 255, 255, 0.22) 0%, transparent 42%),
    linear-gradient(302deg, rgba(0, 0, 0, 0.18) 0%, transparent 48%),
    linear-gradient(58deg, transparent 35%, rgba(255, 180, 195, 0.35) 50%, transparent 62%),
    linear-gradient(198deg, transparent 40%, rgba(120, 0, 24, 0.25) 52%, transparent 64%),
    radial-gradient(ellipse 90% 85% at 32% 26%, #ffc9d2 0%, #ff6b7a 18%, #e63946 42%, #9d0208 72%, #3d0208 100%);
  box-shadow:
    inset -4px -4px 12px rgba(40, 0, 8, 0.45),
    0 0 20px rgba(255, 50, 80, 0.55),
    0 6px 14px rgba(0, 0, 0, 0.38);
}

/* Geometric facet grid (gem-cut look) */
.pit-egg--ruby::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 1;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      -36deg,
      rgba(255, 255, 255, 0.06) 0 1px,
      transparent 1px 11px,
      rgba(0, 0, 0, 0.07) 11px 12px,
      transparent 12px 22px
    ),
    repeating-linear-gradient(
      54deg,
      transparent 0 9px,
      rgba(255, 220, 230, 0.12) 9px 10px,
      transparent 10px 24px
    ),
    repeating-linear-gradient(
      128deg,
      rgba(0, 0, 0, 0.05) 0 1px,
      transparent 1px 14px
    );
  mix-blend-mode: soft-light;
}

.pit-egg--ruby::after {
  z-index: 2;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.88), transparent);
}

.claw-controls {
  grid-column: 2;
  justify-self: center;
  margin-top: 0;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.65rem;
}

.claw-pay-btn {
  font-family: var(--font);
  font-size: max(1.05rem, 16px);
  font-weight: 700;
  color: var(--bg-deep);
  padding: 0.85rem 1.4rem;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(180deg, #ffe066 0%, #f4a261 55%, #e85d04 100%);
  box-shadow: 0 5px 0 #9d3410, 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s;
}

.claw-pay-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #9d3410, 0 12px 28px rgba(0, 0, 0, 0.38);
}

.claw-pay-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #9d3410, 0 6px 16px rgba(0, 0, 0, 0.3);
}

.claw-pay-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 3px 0 #5c3d2e, 0 6px 14px rgba(0, 0, 0, 0.25);
}

.claw-reset-btn {
  grid-column: 3;
  justify-self: end;
  align-self: center;
  min-width: 0;
  max-width: 100%;
  font-family: var(--font);
  font-size: max(0.95rem, 15px);
  font-weight: 700;
  color: var(--sun);
  padding: 0.8rem 1.15rem;
  border: 2px solid rgba(149, 213, 178, 0.55);
  border-radius: 999px;
  cursor: pointer;
  background: rgba(27, 67, 50, 0.65);
  box-shadow: 0 4px 0 rgba(15, 41, 30, 0.9), 0 6px 18px rgba(0, 0, 0, 0.3);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s, border-color 0.15s ease;
}

.claw-reset-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(149, 213, 178, 0.85);
  box-shadow: 0 6px 0 rgba(15, 41, 30, 0.9), 0 10px 22px rgba(0, 0, 0, 0.35);
}

.claw-reset-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(15, 41, 30, 0.9), 0 4px 14px rgba(0, 0, 0, 0.28);
}

.claw-reset-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 3px 0 rgba(15, 41, 30, 0.65), 0 5px 12px rgba(0, 0, 0, 0.22);
}

.claw-pay-btn[hidden],
.claw-drop-btn[hidden],
.claw-reset-btn[hidden] {
  display: none !important;
}

.claw-drop-btn {
  font-family: var(--font);
  font-size: max(1.2rem, 16px);
  font-weight: 700;
  color: var(--bg-deep);
  padding: 0.9rem 1.6rem;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(180deg, #ff9f1c 0%, #e85d04 100%);
  box-shadow: 0 5px 0 #9d3410, 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s;
}

.claw-drop-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #9d3410, 0 12px 28px rgba(0, 0, 0, 0.38);
}

.claw-drop-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #9d3410, 0 6px 16px rgba(0, 0, 0, 0.3);
}

.claw-drop-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 3px 0 #5c3d2e, 0 6px 14px rgba(0, 0, 0, 0.25);
}

.claw-win-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: rgba(5, 18, 12, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: claw-win-fade 0.45s ease both;
}

.claw-win-overlay[hidden] {
  display: none !important;
}

@keyframes claw-win-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.claw-win-cta {
  display: inline-block;
  font-size: clamp(2rem, 8vw, 3.25rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-decoration: none;
  text-align: center;
  color: var(--sun);
  text-shadow: 0 4px 0 #1b4332, 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 48px rgba(149, 213, 178, 0.45);
  transform: rotate(-1deg) scale(0.92);
  animation: claw-win-pop 0.55s cubic-bezier(0.34, 1.45, 0.64, 1) 0.1s both;
  transition: color 0.2s ease, transform 0.2s ease;
}

.claw-win-cta:hover {
  color: var(--accent-hot);
  transform: rotate(0deg) scale(1.02);
}

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

@keyframes claw-win-pop {
  to {
    transform: rotate(-1deg) scale(1);
  }
}

body.claw-page.claw--won .claw-zone {
  pointer-events: none;
  cursor: default;
}
