@font-face {
  font-family: "Fugaz One";
  src: url("assets/fonts/Fugaz_One/FugazOne-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f7f1e7;
  --ink: #1f2522;
  --muted: #5e6b66;
  --coin: #c7cbd0;
  --coin-deep: #767d86;
  --coin-bright: #f8fafc;
  --surface: rgba(255, 251, 242, 0.74);
  --line: rgba(31, 37, 34, 0.12);
  --button: #15803d;
  --button-deep: #064e3b;
  --button-hover: #16a34a;
  --button-text: #ffffff;
  --ring: rgba(34, 197, 94, 0.42);
  --shadow: 0 36px 92px rgba(31, 37, 34, 0.16);
  --flip-time: 1000ms;
}

* {
  box-sizing: border-box;
}

html,
body {
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Fugaz One", "Trebuchet MS", Verdana, sans-serif;
  background:
    radial-gradient(circle at 58% 24%, rgba(255, 255, 255, 0.78), transparent 31rem),
    radial-gradient(circle at 16% 70%, rgba(255, 205, 93, 0.18), transparent 26rem),
    linear-gradient(135deg, #fbf7ef 0%, var(--bg) 48%, #e9ddca 100%);
}

button {
  font: inherit;
}

.coin-app,
.coin-app * {
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}

.coin-app {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.coin-app::before {
  content: "";
  position: fixed;
  inset: -32vmax;
  z-index: 0;
  pointer-events: none;
  background:
    conic-gradient(
      from 110deg,
      rgba(255, 196, 65, 0.19),
      rgba(229, 35, 68, 0.13),
      rgba(42, 137, 255, 0.13),
      rgba(236, 68, 183, 0.1),
      rgba(255, 220, 116, 0.18),
      rgba(22, 122, 99, 0.1),
      rgba(255, 196, 65, 0.19)
    );
  filter: blur(104px);
  opacity: 0;
  transform: scale(1.08) rotate(0deg);
  transition: opacity 900ms ease-in-out;
}

body.is-flipping .coin-app::before {
  opacity: 0.72;
}

body.is-flipping,
body.is-flipping * {
  cursor: none !important;
}

.flipper {
  position: relative;
  z-index: 1;
  width: min(100%, 440px);
  display: grid;
  justify-items: center;
  gap: 20px;
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: #9d2432;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  position: relative;
  margin: 0;
  max-width: none;
  padding: 8px 12px 16px;
  border: 0;
  border-radius: 0;
  font-family: "Fugaz One", "Trebuchet MS", Verdana, sans-serif;
  font-size: clamp(2.15rem, 8vw, 3.8rem);
  font-weight: 400;
  line-height: 0.92;
  text-transform: uppercase;
  color: #f7f8f7;
  background: none;
  box-shadow: none;
  -webkit-text-stroke: 1px rgba(58, 64, 60, 0.58);
  text-shadow:
    0 1px 0 #ffffff,
    0 2px 0 #d8d8d8,
    0 3px 0 #b9bdb9,
    2px 4px 0 #8f9890,
    4px 6px 0 #179b45,
    7px 9px 0 #128039,
    10px 12px 0 #076026,
    14px 16px 16px rgba(4, 68, 27, 0.38);
  transition:
    text-shadow 180ms ease,
    transform 180ms ease;
  transform: perspective(420px) rotateX(8deg) rotateZ(-1.5deg);
}

h1::before,
h1::after {
  content: none;
}

h1::before {
  top: 2px;
  height: 42%;
  background:
    radial-gradient(circle at 16% 28%, rgba(255, 255, 255, 0.9) 0 1px, transparent 3px),
    radial-gradient(circle at 74% 36%, rgba(22, 163, 74, 0.78) 0 1px, transparent 4px),
    radial-gradient(circle at 91% 20%, rgba(255, 255, 255, 0.78) 0 1px, transparent 3px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), transparent);
  opacity: 0.46;
}

h1::after {
  bottom: 2px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--button-hover), transparent);
  box-shadow: 0 0 12px rgba(22, 163, 74, 0.68);
  opacity: 0.82;
  transform: scaleX(0.62);
  transition: transform 320ms ease;
}

h1:hover {
  text-shadow:
    0 1px 0 #ffffff,
    0 2px 0 #e2e2e2,
    0 3px 0 #c3c7c3,
    2px 4px 0 #9ba49b,
    4px 6px 0 #22a94f,
    7px 9px 0 #168b40,
    10px 12px 0 #08702d,
    15px 17px 18px rgba(4, 68, 27, 0.42);
  transform: perspective(420px) rotateX(8deg) rotateZ(-1.5deg) translate(-1px, -1px);
}

h1:hover::after {
  transform: scaleX(1);
}

.coin-scene {
  position: relative;
  width: min(68vw, 240px);
  aspect-ratio: 1;
  perspective: 760px;
  filter:
    drop-shadow(0 22px 30px rgba(31, 37, 34, 0.1))
    drop-shadow(var(--shadow));
}

.coin {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateY(var(--coin-rotation, 0deg));
  transition: transform var(--flip-time) cubic-bezier(0.12, 0.86, 0.18, 1);
}

.coin::before {
  content: none;
}

.coin-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #30363d;
  font-size: clamp(1.2rem, 5vw, 1.85rem);
  font-weight: 700;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(4px);
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.coin-face img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

.coin-face img {
  opacity: 1;
}

.coin-tails {
  transform: rotateY(180deg) translateZ(4px);
}

.coin.is-flipping {
  animation: coin-pop var(--flip-time) cubic-bezier(0.12, 0.86, 0.18, 1);
}

.result {
  min-height: 1.5em;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.result.is-pop {
  animation: result-pop 180ms ease-out;
}

.result-side {
  display: inline-block;
  padding: 2px 8px 3px;
  border-radius: 999px;
  color: #f7fff9;
  background: var(--button);
  box-shadow:
    0 2px 0 var(--button-deep),
    0 8px 18px rgba(21, 128, 61, 0.24);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.22);
}

.flip-button {
  position: relative;
  width: 98px;
  min-height: 78px;
  display: grid;
  place-items: center;
  border: 0;
  border-bottom: 8px solid var(--button-deep);
  border-radius: 24px;
  color: var(--button-text);
  background: var(--button);
  box-shadow: 0 18px 30px -12px rgba(21, 128, 61, 0.76);
  cursor: pointer;
  overflow: hidden;
  transition:
    background 160ms ease,
    box-shadow 160ms ease,
    border-bottom-width 110ms ease,
    opacity 520ms ease,
    transform 110ms ease;
}

.flip-button:hover {
  background: var(--button-hover);
  box-shadow: 0 22px 38px -13px rgba(22, 163, 74, 0.86);
  transform: translateY(-2px);
}

.flip-button:active {
  border-bottom-width: 0;
  transform: translateY(8px);
}

.flip-button:focus-visible {
  outline: 4px solid var(--ring);
  outline-offset: 6px;
}

.flip-button:disabled {
  cursor: pointer;
  opacity: 0.72;
}

.button-shade {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.24), transparent);
}

.button-glint {
  position: absolute;
  top: 12px;
  left: 16px;
  width: 28px;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  filter: blur(2px);
}

.button-content {
  position: relative;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 3px 4px rgba(7, 70, 35, 0.28));
}

.button-icon {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
  animation: icon-pulse 1.4s ease-in-out infinite;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cursor-loader {
  position: fixed;
  left: var(--cursor-x, 50vw);
  top: var(--cursor-y, 50vh);
  z-index: 10;
  width: 34px;
  height: 34px;
  border: 6px solid rgba(221, 221, 221, 0.78);
  border-top-color: #46c380;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 120ms ease;
}

body.is-flipping .cursor-loader {
  opacity: 1;
  animation: loading 0.75s ease-out infinite;
}

.duration-control {
  width: min(100%, 330px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin: 0;
  padding: 0;
  border: 0;
}

.duration-control legend {
  grid-column: 1 / -1;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.duration-control label {
  min-width: 0;
}

.duration-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.duration-control span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(21, 61, 54, 0.2);
  border-radius: 999px;
  color: #26332f;
  background: rgba(255, 249, 237, 0.5);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 400;
  white-space: nowrap;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    color 150ms ease,
    opacity 520ms ease,
    transform 150ms ease;
}

.duration-control input:checked + span {
  border-color: #16483d;
  color: var(--button-text);
  background: #16483d;
}

.duration-control input:focus-visible + span {
  outline: 4px solid var(--ring);
  outline-offset: 4px;
}

.duration-control input:disabled + span {
  cursor: default;
  opacity: 0.62;
}

.duration-control span:hover {
  transform: translateY(-1px);
}

@keyframes coin-pop {
  0% {
    scale: 1;
    translate: 0 0;
  }
  28% {
    scale: 1.06;
    translate: 0 -22px;
  }
  68% {
    scale: 0.98;
    translate: 0 5px;
  }
  100% {
    scale: 1;
    translate: 0 0;
  }
}

@keyframes result-pop {
  0% {
    scale: 0.98;
    opacity: 0.68;
    translate: 0 -4px;
  }
  100% {
    scale: 1;
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes icon-pulse {
  0%,
  100% {
    scale: 1;
  }
  50% {
    scale: 1.08;
  }
}

@keyframes loading {
  from {
    transform: rotate(0turn);
  }
  to {
    transform: rotate(1turn);
  }
}

@keyframes neon-tube {
  0%,
  100% {
    text-shadow:
      0 1px 0 rgba(220, 252, 231, 0.8),
      0 2px 0 #16a34a,
      0 3px 0 #15803d,
      0 4px 0 #064e3b,
      0 0 7px rgba(22, 163, 74, 0.5),
      0 0 16px rgba(21, 128, 61, 0.28),
      0 0 26px rgba(21, 128, 61, 0.14);
  }
  46% {
    text-shadow:
      0 1px 0 rgba(240, 253, 244, 0.86),
      0 2px 0 #22c55e,
      0 3px 0 #16a34a,
      0 4px 0 #065f46,
      0 0 9px rgba(22, 163, 74, 0.64),
      0 0 21px rgba(21, 128, 61, 0.36),
      0 0 34px rgba(21, 128, 61, 0.2);
  }
  49%,
  53% {
    text-shadow:
      0 1px 0 rgba(220, 252, 231, 0.62),
      0 2px 0 #15803d,
      0 3px 0 #166534,
      0 4px 0 #064e3b,
      0 0 5px rgba(22, 163, 74, 0.38),
      0 0 12px rgba(21, 128, 61, 0.2),
      0 0 20px rgba(21, 128, 61, 0.1);
  }
}

@keyframes neon-sparkle {
  0%,
  100% {
    opacity: 0.35;
    transform: translateX(-2px);
  }
  42% {
    opacity: 0.62;
    transform: translateX(2px);
  }
  58% {
    opacity: 0.28;
  }
}

@keyframes neon-line {
  0%,
  100% {
    opacity: 0.65;
    box-shadow: 0 0 10px rgba(22, 163, 74, 0.5);
  }
  50% {
    opacity: 1;
    box-shadow:
      0 0 12px rgba(22, 163, 74, 0.72),
      0 0 24px rgba(21, 128, 61, 0.28);
  }
}

@keyframes casino-glow {
  0% {
    transform: scale(1.08) rotate(0deg);
  }
  50% {
    transform: scale(1.14) rotate(9deg);
  }
  100% {
    transform: scale(1.08) rotate(0deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .coin,
  .coin.is-flipping {
    animation: none;
    transition-duration: 1ms;
  }

  h1,
  h1::before,
  h1::after {
    animation: none;
  }
}

@media (max-width: 420px) {
  .coin-app {
    padding: 18px;
  }

  .flipper {
    gap: 18px;
  }
}
