:root {
  color-scheme: dark;
  --bg: #080407;
  --panel: rgba(28, 12, 10, 0.9);
  --panel-edge: rgba(255, 165, 64, 0.28);
  --text: #fff7e6;
  --muted: #f3c98b;
  --red: #ff3f22;
  --orange: #ff8a25;
  --gold: #ffd76d;
  --shadow: rgba(0, 0, 0, 0.45);
  --focus: #ffe58a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 118, 30, 0.18), transparent 28rem),
    radial-gradient(circle at 16% 80%, rgba(197, 35, 20, 0.18), transparent 22rem),
    linear-gradient(160deg, #120606 0%, var(--bg) 50%, #030203 100%);
}

button {
  max-width: 100%;
  font: inherit;
}

.app-shell {
  width: min(100%, 980px);
  max-width: 100%;
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem);
  display: grid;
  place-items: center;
}

.decision-card {
  position: relative;
  overflow: hidden;
  width: min(100%, 760px);
  max-width: 100%;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  border: 1px solid var(--panel-edge);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 137, 37, 0.1), transparent 30%),
    linear-gradient(0deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.025)),
    var(--panel);
  box-shadow: 0 28px 90px var(--shadow), inset 0 0 36px rgba(255, 126, 32, 0.06);
  text-align: center;
}

.hero-copy,
.coin-stage,
.result-text,
.actions,
.history-panel {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--gold);
  font-size: clamp(0.75rem, 2vw, 0.85rem);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 8vw, 4.5rem);
  line-height: 0.95;
  text-wrap: balance;
  text-shadow: 0 0 24px rgba(255, 98, 28, 0.38);
}

.subtitle {
  max-width: 34rem;
  margin: 0.85rem auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 3vw, 1.35rem);
}

.coin-stage {
  margin: clamp(1.4rem, 5vw, 2.4rem) auto 1rem;
  padding: clamp(0.75rem, 3vw, 1.5rem);
  touch-action: manipulation;
}

.coin-button {
  width: clamp(210px, 58vw, 380px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 218, 109, 0.22), rgba(255, 87, 27, 0.04) 62%, transparent 70%);
  box-shadow: 0 0 42px rgba(255, 134, 37, 0.36), 0 18px 44px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.coin-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 6px;
}

.coin-button:disabled,
.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.coin-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 24px rgba(255, 199, 87, 0.38));
  user-select: none;
  pointer-events: none;
}

.coin-image.is-flipping {
  animation: flipCoin 900ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.result-text {
  min-height: 1.8em;
  margin: 0.75rem 0 1.25rem;
  color: var(--gold);
  font-size: clamp(1.25rem, 4vw, 1.8rem);
  font-weight: 900;
  text-shadow: 0 0 18px rgba(255, 123, 32, 0.32);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.primary-button,
.secondary-button {
  min-width: 9.5rem;
  min-height: 3.1rem;
  border-radius: 999px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  border: 1px solid rgba(255, 236, 164, 0.7);
  color: #220b05;
  background: linear-gradient(135deg, var(--gold), var(--orange) 64%, var(--red));
  box-shadow: 0 10px 28px rgba(255, 89, 29, 0.28);
}

.secondary-button {
  border: 1px solid rgba(255, 165, 64, 0.42);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.history-panel {
  max-width: 27rem;
  margin: 1.5rem auto 0;
  padding: 1rem;
  border: 1px solid rgba(255, 165, 64, 0.22);
  border-radius: 18px;
  background: rgba(7, 3, 3, 0.42);
}

.history-panel h2 {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-list {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding-left: 1.4rem;
  text-align: left;
}

.history-list li {
  color: var(--text);
  font-weight: 700;
}

.empty-history {
  color: rgba(255, 247, 230, 0.65) !important;
  font-weight: 500 !important;
}

.ember {
  position: absolute;
  border-radius: 999px;
  background: var(--orange);
  opacity: 0.42;
  filter: blur(1px);
  animation: emberDrift 5s ease-in-out infinite;
}

.ember-one {
  width: 0.6rem;
  height: 0.6rem;
  left: 12%;
  bottom: 18%;
}

.ember-two {
  width: 0.42rem;
  height: 0.42rem;
  right: 16%;
  top: 22%;
  animation-delay: -1.4s;
}

.ember-three {
  width: 0.32rem;
  height: 0.32rem;
  right: 28%;
  bottom: 26%;
  animation-delay: -2.8s;
}

@keyframes flipCoin {
  0% {
    transform: rotateY(0) rotateZ(0) scale(1);
  }
  45% {
    transform: rotateY(900deg) rotateZ(14deg) scale(1.08);
  }
  100% {
    transform: rotateY(1800deg) rotateZ(0) scale(1);
  }
}

@keyframes emberDrift {
  0%, 100% {
    transform: translate3d(0, 0, 0);
    opacity: 0.2;
  }
  50% {
    transform: translate3d(0.4rem, -1.4rem, 0);
    opacity: 0.72;
  }
}

@media (max-width: 520px) {
  body {
    min-height: 100svh;
  }

  .app-shell {
    width: 100%;
    min-height: auto;
    align-items: start;
    padding: clamp(0.45rem, 2.4vw, 0.75rem);
  }

  .decision-card {
    width: 100%;
    padding: clamp(0.8rem, 3.8vw, 1.15rem);
    border-radius: 22px;
    box-shadow: 0 18px 54px var(--shadow), inset 0 0 28px rgba(255, 126, 32, 0.05);
  }

  .eyebrow {
    margin-bottom: 0.28rem;
    font-size: 0.68rem;
    letter-spacing: 0.12em;
  }

  h1 {
    font-size: clamp(1.75rem, 9vw, 2.45rem);
    line-height: 0.98;
  }

  .subtitle {
    margin-top: 0.55rem;
    font-size: clamp(0.92rem, 4vw, 1.05rem);
  }

  .coin-stage {
    margin: clamp(0.9rem, 4vw, 1.25rem) auto 0.45rem;
    padding: clamp(0.35rem, 2vw, 0.75rem);
  }

  .coin-button {
    width: clamp(172px, 50vw, 215px);
    max-width: 100%;
  }

  .result-text {
    margin: 0.45rem 0 0.85rem;
    font-size: clamp(1.05rem, 5vw, 1.35rem);
  }

  .actions {
    display: grid;
    gap: 0.55rem;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
    min-height: 2.75rem;
  }

  .history-panel {
    width: 100%;
    max-width: 100%;
    margin-top: 0.9rem;
    padding: 0.8rem;
    border-radius: 16px;
  }

  .history-panel h2 {
    margin-bottom: 0.55rem;
    font-size: 0.82rem;
  }

  .history-list {
    gap: 0.28rem;
    padding-left: 1.15rem;
  }
}

@media (max-width: 430px) {
  .app-shell {
    padding: 0.45rem;
  }

  .decision-card {
    padding: 0.75rem;
    border-radius: 18px;
  }

  h1 {
    font-size: clamp(1.55rem, 8.2vw, 2.05rem);
  }

  .coin-button {
    width: clamp(160px, 47vw, 190px);
  }
}

@media (max-width: 520px) and (max-height: 720px) {
  .decision-card {
    padding-block: 0.65rem;
  }

  .coin-stage {
    margin-top: 0.65rem;
    padding-block: 0.25rem;
  }

  .coin-button {
    width: clamp(148px, 43vw, 180px);
  }

  .result-text {
    margin-bottom: 0.6rem;
  }

  .history-panel {
    margin-top: 0.65rem;
    padding-block: 0.65rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }

  .coin-image.is-flipping {
    animation: reducedFlip 180ms ease-out both;
  }

  .ember {
    animation: none;
  }
}

@keyframes reducedFlip {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.03);
  }
}
