:root {
  --bg: #05070d;
  --bg-2: #090d18;
  --ink: #c6f7ff;
  --ink-dim: #4a6b78;
  --neon: #00ffd1;
  --neon-2: #ff2bd6;
  --neon-3: #00b7ff;
  --danger: #ff4466;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo,
    Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 20%, #0b1324 0%, var(--bg) 60%, #000 100%);
  color: var(--ink);
  font-family: var(--mono);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 85%, rgba(255, 43, 214, 0.10), transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(0, 255, 209, 0.10), transparent 40%);
  z-index: 0;
}

.grid-bg {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 255, 209, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 209, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}

.scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.02) 0,
    rgba(255, 255, 255, 0.02) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 2;
  mix-blend-mode: overlay;
}

.stage {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.hud { text-align: center; }

.tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--neon);
  padding: 3px 10px;
  border: 1px solid rgba(0, 255, 209, 0.35);
  border-radius: 2px;
  text-transform: uppercase;
  background: rgba(0, 255, 209, 0.05);
  box-shadow: 0 0 12px rgba(0, 255, 209, 0.15) inset;
}

.hud h1 {
  margin: 10px 0 6px;
  font-size: 44px;
  letter-spacing: 0.12em;
  color: #eafcff;
  text-transform: uppercase;
  text-shadow:
    0 0 6px rgba(0, 255, 209, 0.6),
    0 0 22px rgba(0, 255, 209, 0.35),
    0 0 2px #fff;
}

.hud .sub {
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 0.08em;
}

/* COIN */
.coin-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
  margin-top: 6px;
}

.coin {
  position: relative;
  width: 180px;
  height: 180px;
  transform-style: preserve-3d;
  transition: transform 0.1s linear;
  will-change: transform;
  filter: drop-shadow(0 0 18px rgba(0, 255, 209, 0.35));
}

.coin.flipping {
  animation: flip-spin 1.8s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

@keyframes flip-spin {
  0%   { transform: rotateX(0deg)    translateY(0)    scale(1); }
  15%  { transform: rotateX(540deg)  translateY(-60px) scale(1.05); }
  55%  { transform: rotateX(1620deg) translateY(-90px) scale(1.08); }
  85%  { transform: rotateX(2700deg) translateY(-20px) scale(1.02); }
  100% { transform: rotateX(var(--final-rot, 3240deg)) translateY(0) scale(1); }
}

.face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 30% 30%, #0d1628 0%, #050912 55%, #000 100%);
  border: 2px solid var(--neon);
  box-shadow:
    0 0 24px rgba(0, 255, 209, 0.45),
    inset 0 0 18px rgba(0, 255, 209, 0.25),
    inset 0 0 2px rgba(255, 255, 255, 0.25);
}

.face.heads {
  transform: rotateX(0deg);
}

.face.tails {
  transform: rotateX(180deg);
  border-color: var(--neon-2);
  box-shadow:
    0 0 24px rgba(255, 43, 214, 0.45),
    inset 0 0 18px rgba(255, 43, 214, 0.25),
    inset 0 0 2px rgba(255, 255, 255, 0.25);
}

.ring {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 1px dashed rgba(0, 255, 209, 0.5);
  animation: spin 8s linear infinite;
}
.face.tails .ring {
  border-color: rgba(255, 43, 214, 0.55);
}

@keyframes spin { to { transform: rotate(360deg); } }

.glyph {
  position: absolute;
  font-size: 78px;
  font-weight: 800;
  line-height: 1;
  color: #eafcff;
  text-shadow:
    0 0 6px var(--neon),
    0 0 18px var(--neon),
    0 0 2px #fff;
  letter-spacing: -0.05em;
}
.face.tails .glyph {
  color: #ffeaf8;
  text-shadow:
    0 0 6px var(--neon-2),
    0 0 18px var(--neon-2),
    0 0 2px #fff;
}

.label {
  position: absolute;
  bottom: 22px;
  font-size: 10px;
  letter-spacing: 0.35em;
  color: var(--neon);
  text-transform: uppercase;
}
.face.tails .label { color: var(--neon-2); }

.shadow {
  position: absolute;
  bottom: -6px;
  width: 140px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 255, 209, 0.35), transparent 70%);
  filter: blur(4px);
}

/* READOUT */
.readout {
  width: 100%;
  max-width: 420px;
  border: 1px solid rgba(0, 255, 209, 0.25);
  background: linear-gradient(180deg, rgba(0, 255, 209, 0.03), rgba(0, 0, 0, 0.2));
  padding: 14px 18px;
  border-radius: 3px;
  font-size: 13px;
  line-height: 1.8;
  box-shadow: 0 0 24px rgba(0, 255, 209, 0.08) inset;
}

.readout .line {
  display: flex;
  justify-content: space-between;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.readout .val {
  color: var(--ink);
  font-weight: 600;
}

.readout .val.accent {
  color: var(--neon);
  text-shadow: 0 0 10px rgba(0, 255, 209, 0.55);
}

.readout .val.accent.tails {
  color: var(--neon-2);
  text-shadow: 0 0 10px rgba(255, 43, 214, 0.6);
}

/* BUTTON */
.flip-btn {
  position: relative;
  display: inline-block;
  padding: 16px 38px;
  background: linear-gradient(180deg, #061019, #030711);
  color: var(--neon);
  border: 1px solid var(--neon);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 2px;
  transition: transform 0.1s ease, box-shadow 0.2s ease, color 0.2s ease;
  box-shadow:
    0 0 18px rgba(0, 255, 209, 0.25),
    inset 0 0 12px rgba(0, 255, 209, 0.12);
  clip-path: polygon(
    0 0,
    calc(100% - 14px) 0,
    100% 14px,
    100% 100%,
    14px 100%,
    0 calc(100% - 14px)
  );
}

.flip-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(0, 255, 209, 0.15);
  pointer-events: none;
}

.flip-btn:hover {
  color: #eafcff;
  box-shadow:
    0 0 28px rgba(0, 255, 209, 0.55),
    inset 0 0 18px rgba(0, 255, 209, 0.25);
  transform: translateY(-1px);
}

.flip-btn:active { transform: translateY(1px); }

.flip-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  color: var(--ink-dim);
  box-shadow: none;
}

.flip-btn-inner { position: relative; z-index: 1; }

.foot {
  margin-top: 10px;
  font-size: 10px;
  color: var(--ink-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

@media (max-width: 480px) {
  .hud h1 { font-size: 32px; }
  .coin-wrap { width: 180px; height: 180px; }
  .coin { width: 150px; height: 150px; }
  .glyph { font-size: 64px; }
}
