:root {
  --bg: #0c0e12;
  --bg-elev: #141820;
  --line: rgba(255, 214, 120, 0.14);
  --gold: #e8c36a;
  --gold-bright: #ffe7a3;
  --gold-deep: #b8892f;
  --heads: #f0d78c;
  --tails: #c9a24a;
  --win: #3dd68c;
  --lose: #ff6b6b;
  --text: #f4efe4;
  --muted: #9a9284;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --font-display: "Bebas Neue", sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
  --radius: 18px;
}

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

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

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: -20% -10% auto;
  height: 70vh;
  background:
    radial-gradient(ellipse 50% 45% at 50% 0%, rgba(232, 195, 106, 0.18), transparent 70%),
    radial-gradient(ellipse 35% 40% at 15% 30%, rgba(61, 214, 140, 0.06), transparent 60%),
    radial-gradient(ellipse 30% 35% at 85% 25%, rgba(255, 107, 107, 0.05), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.bg-noise {
  position: fixed;
  inset: 0;
  opacity: 0.04;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.topbar,
.stage,
.toast {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  max-width: 1100px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold-deep));
  box-shadow: 0 0 0 3px rgba(232, 195, 106, 0.2);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.65rem;
  letter-spacing: 0.12em;
  line-height: 1;
}

.balance-chip {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 24, 32, 0.75);
  backdrop-filter: blur(10px);
}

.balance-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.balance-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--gold-bright);
  font-size: 1.05rem;
}

.balance-value::before {
  content: "₹";
  opacity: 0.7;
  margin-right: 2px;
}

.stage {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 28px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 22px 40px;
  align-items: stretch;
}

.arena {
  position: relative;
  min-height: 560px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: #080a0e;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
}

.video-frame {
  position: relative;
  flex: 1;
  min-height: 480px;
  background: #050608;
}

.flip-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
  background: #050608;
}

.video-scrim {
  position: absolute;
  inset: auto 0 0;
  height: 28%;
  background: linear-gradient(transparent, rgba(5, 6, 8, 0.88));
  pointer-events: none;
}

.idle-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 36px;
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.1em;
  color: rgba(255, 231, 163, 0.75);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65);
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.idle-hint.is-hidden {
  opacity: 0;
}

.result-line {
  position: absolute;
  bottom: 22px;
  left: 0;
  right: 0;
  text-align: center;
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 0.08em;
  min-height: 1.2em;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease, color 0.2s ease;
  z-index: 2;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.8);
}

.result-line.is-shown {
  opacity: 1;
  transform: translateY(0);
}

.result-line.is-win { color: var(--win); }
.result-line.is-lose { color: var(--lose); }
.result-line.is-neutral { color: var(--gold-bright); }

.panel {
  border-radius: 28px;
  border: 1px solid var(--line);
  background: rgba(20, 24, 32, 0.92);
  box-shadow: var(--shadow);
  padding: 26px 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.2rem;
  letter-spacing: 0.04em;
  line-height: 1;
}

.panel-sub {
  margin: -4px 0 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.side-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.side-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.side-btn:hover {
  border-color: rgba(232, 195, 106, 0.35);
}

.side-btn.is-active {
  border-color: rgba(232, 195, 106, 0.7);
  background: rgba(232, 195, 106, 0.1);
  box-shadow: inset 0 0 0 1px rgba(232, 195, 106, 0.15);
}

.side-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.side-orb {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: #5a3808;
  flex-shrink: 0;
}

.side-orb.heads {
  background: linear-gradient(145deg, #ffe9ad, #c99836);
}

.side-orb.tails {
  background: linear-gradient(145deg, #f0d27a, #8f6418);
}

.side-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-text strong {
  font-size: 0.98rem;
}

.side-text small {
  color: var(--muted);
  font-size: 0.75rem;
}

.field-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-top: 4px;
}

.bet-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr) 1.3fr;
  gap: 8px;
}

.chip-btn,
.bet-input,
.flip-btn {
  font: inherit;
}

.chip-btn {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 12px 0;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.chip-btn:hover {
  border-color: rgba(232, 195, 106, 0.4);
}

.chip-btn.is-active {
  border-color: var(--gold);
  background: rgba(232, 195, 106, 0.14);
  color: var(--gold-bright);
}

.chip-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bet-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0a0c10;
  color: var(--text);
  padding: 12px 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  outline: none;
}

.bet-input:focus {
  border-color: rgba(232, 195, 106, 0.55);
}

.bet-input:disabled {
  opacity: 0.55;
}

.flip-btn {
  position: relative;
  margin-top: 6px;
  border: 0;
  border-radius: 16px;
  padding: 18px 16px;
  cursor: pointer;
  overflow: hidden;
  background: linear-gradient(180deg, #ffe7a3 0%, #e0b84f 48%, #b8892f 100%);
  color: #3d2808;
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: 0.08em;
  box-shadow:
    0 10px 28px rgba(184, 137, 47, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.flip-btn:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

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

.flip-btn:disabled {
  cursor: not-allowed;
  filter: grayscale(0.35) brightness(0.85);
}

.flip-btn-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 20%, rgba(255, 255, 255, 0.35) 50%, transparent 80%);
  transform: translateX(-120%);
  animation: sheen 3.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes sheen {
  0%, 55% { transform: translateX(-120%); }
  80%, 100% { transform: translateX(120%); }
}

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

.payout-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.payout-hint strong {
  color: var(--gold-bright);
}

.history {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 168px;
  overflow: auto;
}

.history:empty::after {
  content: "No flips yet — make your first call.";
  color: var(--muted);
  font-size: 0.85rem;
  display: block;
  padding: 8px 0;
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.86rem;
}

.history-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: #5a3808;
  background: linear-gradient(145deg, #ffe9ad, #c99836);
}

.history-meta {
  color: var(--muted);
}

.history-meta strong {
  color: var(--text);
  font-weight: 600;
}

.history-delta {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.history-delta.win { color: var(--win); }
.history-delta.lose { color: var(--lose); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #1a1f2a;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 20;
}

.toast.is-shown {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 900px) {
  .stage {
    grid-template-columns: 1fr;
    padding-bottom: 28px;
  }

  .arena {
    min-height: 460px;
  }

  .video-frame {
    min-height: 400px;
  }

  .bet-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .bet-input {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .topbar,
  .stage {
    padding-left: 14px;
    padding-right: 14px;
  }

  .panel {
    padding: 20px 16px;
  }

  .result-line {
    font-size: 1.55rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flip-btn-glow {
    animation: none;
  }
}
