:root {
  --bg: #0f1720;
  --surface: #1a2430;
  --text: #f4f7fb;
  --muted: #9aa8b8;
  --accent: #e8b84a;
  --accent-dark: #b8892a;
  --heads: #d9a441;
  --tails: #c9cdd3;
  --shadow: rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  color: var(--text);
  background: var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app {
  width: min(100%, 26rem);
  display: grid;
  gap: 1.5rem;
  justify-items: center;
  text-align: center;
}

.brand h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand p {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.labels {
  width: 100%;
  display: grid;
  gap: 0.75rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  text-align: left;
}

.field span {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input {
  width: 100%;
  border: 1px solid #2b3a4a;
  border-radius: 0.65rem;
  padding: 0.85rem 0.95rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.stage {
  width: 100%;
  display: grid;
  gap: 1rem;
  justify-items: center;
}

.coin-scene {
  width: 11rem;
  height: 11rem;
  perspective: 1000px;
}

.coin {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 1.35s cubic-bezier(0.2, 0.7, 0.2, 1);
  will-change: transform;
}

.coin.flipping {
  pointer-events: none;
}

.coin-face,
.coin-edge {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
}

.coin-face {
  display: grid;
  place-items: center;
  padding: 1rem;
  font-size: clamp(1rem, 3.5vw, 1.25rem);
  font-weight: 700;
  line-height: 1.15;
  word-break: break-word;
  box-shadow: 0 18px 35px var(--shadow);
}

.coin-face.heads {
  background: var(--heads);
  color: #2a1d05;
  transform: translateZ(8px);
}

.coin-face.tails {
  background: var(--tails);
  color: #1b2430;
  transform: rotateY(180deg) translateZ(8px);
}

.coin-edge {
  background: var(--accent-dark);
  transform: translateZ(0) scale(0.98);
}

.result {
  min-height: 1.5rem;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
}

.result[hidden] {
  display: none;
}

.flip-button {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 1rem 1.25rem;
  background: var(--accent);
  color: #1f1604;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, opacity 0.15s ease;
}

.flip-button:hover:not(:disabled) {
  background: #f0c55a;
}

.flip-button:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

.flip-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.flip-button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

@media (max-width: 420px) {
  body {
    padding: 1rem;
  }

  .coin-scene {
    width: 9.5rem;
    height: 9.5rem;
  }
}
