:root {
  --bg: #0a0a12;
  --bg-mid: #12101c;
  --surface: rgba(255, 255, 255, 0.06);
  --text: #f4f4ff;
  --muted: rgba(244, 244, 255, 0.5);
  --accent: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mult: "Oxanium", var(--font);
  --mult-color: #6ee7b7;
  --mult-glow: rgba(110, 231, 183, 0.45);
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(124, 58, 237, 0.22), transparent 55%),
    radial-gradient(ellipse 90% 60% at 100% 100%, rgba(6, 182, 212, 0.12), transparent 50%),
    radial-gradient(ellipse 70% 50% at 0% 80%, rgba(245, 158, 11, 0.06), transparent 45%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255, 255, 255, 0.015) 2px,
      rgba(255, 255, 255, 0.015) 4px
    );
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  touch-action: none;
  user-select: none;
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.app-shell.shake {
  animation: shakeShell 0.45s ease;
}

@keyframes shakeShell {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  15% {
    transform: translate3d(-6px, 2px, 0);
  }
  30% {
    transform: translate3d(6px, -2px, 0);
  }
  45% {
    transform: translate3d(-4px, -3px, 0);
  }
  60% {
    transform: translate3d(4px, 2px, 0);
  }
  75% {
    transform: translate3d(-2px, 0, 0);
  }
}

.screen {
  width: 100%;
  max-width: 360px;
  text-align: center;
  animation: screenIn 0.28s ease both;
}

/* Semi-transparent film over the whole game card (no backdrop-filter — RN WebView often renders it opaque black) */
.tap-start-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  border-radius: 0;
  background: rgba(8, 10, 22, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s ease;
  -webkit-tap-highlight-color: transparent;
}

.tap-start-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.tap-start-overlay.hidden {
  display: none !important;
}

.tap-start-label {
  font-size: clamp(1.15rem, 4.8vw, 1.7rem);
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 0 22px rgba(245, 158, 11, 0.55), 0 0 40px rgba(6, 182, 212, 0.25);
  text-align: center;
  padding: 0 12px;
  line-height: 1.35;
}

.btn.hidden {
  display: none !important;
}

.screen.hidden {
  display: none;
  animation: none;
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.title.sm {
  font-size: 1.35rem;
}

.rule {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
  margin-bottom: 28px;
}

.session-bank {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.session-bank-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  width: 100%;
  text-align: center;
  margin-bottom: 2px;
}

.session-bank-value {
  font-family: var(--font-mult);
  font-size: 1.65rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #a7f3d0;
  line-height: 1;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 16px 28px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.btn.primary {
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  color: #fff;
}

.btn.cash {
  width: 100%;
  max-width: 320px;
  margin-top: 24px;
  background: var(--accent);
  color: #04120a;
  font-size: 1.15rem;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.35);
}

.btn.cash.continue-mode {
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  color: #fff;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35);
}

.mult-wrap {
  margin-bottom: 10px;
}

.muted {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 8px;
}

.mult {
  font-family: var(--font-mult);
  font-size: 3.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--mult-color);
  text-shadow: 0 0 28px var(--mult-glow);
  transition: color 0.15s ease, text-shadow 0.15s ease, transform 0.12s ease;
}

.mult[data-risk="low"] {
  --mult-color: #6ee7b7;
  --mult-glow: rgba(110, 231, 183, 0.4);
}

.mult[data-risk="mid"] {
  --mult-color: #fde047;
  --mult-glow: rgba(253, 224, 71, 0.45);
}

.mult[data-risk="high"] {
  --mult-color: #fb923c;
  --mult-glow: rgba(251, 146, 60, 0.5);
}

.mult[data-risk="extreme"] {
  --mult-color: #f87171;
  --mult-glow: rgba(248, 113, 113, 0.55);
}

.mult.mult-pop {
  transform: scale(1.06);
}

.chart-wrap {
  width: 100%;
  height: 160px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.chart-canvas {
  display: block;
  width: 100%;
  height: 100%;
  vertical-align: middle;
}

.bar-track {
  position: relative;
  width: 100%;
  height: 12px;
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
}

.bar-fill {
  position: relative;
  height: 100%;
  width: 0%;
  border-radius: 8px;
  background: linear-gradient(90deg, #eab308, #22d3ee, #22c55e);
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.35);
  transition: width 0.05s linear;
}

.bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.35) 0%,
    rgba(255, 255, 255, 0) 50%,
    rgba(0, 0, 0, 0.12) 100%
  );
  pointer-events: none;
}

body.state-crash {
  animation: flashRed 0.35s ease;
}

body.state-win {
  animation: flashGreen 0.35s ease;
}

@keyframes flashRed {
  from {
    background-color: rgba(239, 68, 68, 0.28);
  }
  to {
    background-color: var(--bg);
  }
}

@keyframes flashGreen {
  from {
    background-color: rgba(34, 197, 94, 0.22);
  }
  to {
    background-color: var(--bg);
  }
}
