:root {
  --bg-1: #070b1f;
  --bg-2: #111a3f;
  --card: rgba(11, 20, 51, 0.72);
  --line: rgba(167, 189, 255, 0.2);
  --text: #e8f0ff;
  --muted: #9eb0d1;
  --gold: #ffd27a;
  --mint: #72ffd7;
  --red: #ff7b8f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  background: radial-gradient(circle at 20% 20%, #172758 0%, transparent 25%),
    radial-gradient(circle at 80% 10%, #0f3c52 0%, transparent 30%),
    linear-gradient(150deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  overflow-x: hidden;
}

.stars,
.nebula {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.stars::before,
.stars::after {
  content: "";
  position: absolute;
  inset: -20%;
  background-image: radial-gradient(2px 2px at 20% 30%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 60% 70%, #d4e9ff, transparent),
    radial-gradient(1.6px 1.6px at 75% 25%, #fff, transparent),
    radial-gradient(1px 1px at 35% 65%, #fff, transparent);
  background-size: 380px 380px;
  animation: drift 120s linear infinite;
  opacity: 0.42;
}

.stars::after {
  animation-duration: 180s;
  opacity: 0.26;
}

.nebula {
  background: radial-gradient(circle at 70% 80%, rgba(114, 255, 215, 0.12), transparent 35%),
    radial-gradient(circle at 20% 70%, rgba(255, 210, 122, 0.12), transparent 40%);
  filter: blur(10px);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.login-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: min(100%, 460px);
  background: rgba(11, 20, 51, 0.84);
  border: 1px solid rgba(255, 210, 122, 0.24);
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.34);
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.login-form label {
  display: grid;
  gap: 8px;
}

.login-form span {
  color: var(--muted);
  font-weight: 600;
}

.login-form input {
  width: 100%;
  border: 1px solid rgba(167, 189, 255, 0.2);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 13px 14px;
  font: inherit;
  outline: none;
}

.login-form input:focus {
  border-color: rgba(255, 210, 122, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 210, 122, 0.12);
}

.action-btn {
  border: 1px solid rgba(167, 189, 255, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.action-btn.primary {
  background: linear-gradient(135deg, rgba(255, 210, 122, 0.95), rgba(114, 255, 215, 0.88));
  color: #081123;
  border-color: transparent;
}

.action-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: stretch;
}

.hero > div:first-child {
  min-width: 0;
}

.eyebrow {
  color: var(--gold);
  letter-spacing: 0.16em;
  font-weight: 700;
  margin: 6px 0;
}

h1, h2, h3 {
  margin: 0 0 12px;
  font-family: "Sora", sans-serif;
}

h1 { font-size: clamp(1.5rem, 4vw, 2.5rem); }
h2 { font-size: 1.1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.28);
}

.clock-wrap {
  min-width: 260px;
}

.auth-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.value {
  font-size: 1.45rem;
  font-weight: 700;
  margin: 8px 0;
}

.countdown {
  color: var(--gold);
  margin: 4px 0;
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.highlight {
  border-color: rgba(255, 210, 122, 0.5);
  box-shadow: 0 0 40px rgba(255, 210, 122, 0.15);
}

.pill {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
}

.prediction {
  margin: 14px 0 8px;
  font-size: 2rem;
  font-weight: 800;
}

.subtle { color: var(--muted); }

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

.timing-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  border-bottom: 1px solid rgba(167, 189, 255, 0.15);
  padding: 10px 8px;
  text-align: left;
  font-size: 0.92rem;
}

.chart {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 170px 1fr 56px;
  align-items: center;
  gap: 10px;
}

.bar {
  height: 10px;
  border-radius: 20px;
  background: rgba(167, 189, 255, 0.2);
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, #72ffd7, #ffd27a);
}

.bankroll-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.stat-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.02);
}

.stat-box strong {
  font-size: 1.1rem;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(167, 189, 255, 0.16);
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-track > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd27a, #72ffd7);
}

.pattern-card,
.history-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bankroll-item {
  align-items: flex-start;
}

.win {
  color: var(--mint);
  font-weight: 700;
}

.lose {
  color: var(--red);
  font-weight: 700;
}

.rules ul {
  margin: 8px 0;
  padding-left: 18px;
}

.win-popup {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 20, 0.55);
  z-index: 50;
}

.hidden {
  display: none;
}

.popup-card {
  background: #0d1534;
  border: 1px solid rgba(255, 210, 122, 0.6);
  border-radius: 14px;
  padding: 18px 24px;
  text-align: center;
}

.fireworks {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255, 210, 122, 0.95) 0 2px, transparent 3px),
    radial-gradient(circle, rgba(114, 255, 215, 0.95) 0 2px, transparent 3px),
    radial-gradient(circle, rgba(255, 123, 143, 0.95) 0 2px, transparent 3px);
  background-size: 120px 120px;
  background-position: 20% 20%, 70% 30%, 50% 70%;
  animation: fireworks 1.1s ease-out 2;
  opacity: 0.75;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(0, -120px, 0); }
}

@keyframes fireworks {
  0% { transform: scale(0.8); opacity: 0.2; }
  60% { transform: scale(1.05); opacity: 0.85; }
  100% { transform: scale(1.2); opacity: 0; }
}

@media (max-width: 900px) {
  .app { padding: 18px 12px 28px; }
  .hero { flex-direction: column; }
  .grid.two { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr; }
  .clock-wrap { min-width: 0; }
  .prediction { font-size: 1.7rem; }
}

@media (max-width: 640px) {
  .app {
    padding: 14px 10px 24px;
  }

  .card {
    padding: 14px;
    border-radius: 14px;
  }

  h1 {
    font-size: 1.7rem;
  }

  h2 {
    font-size: 1rem;
  }

  .value {
    font-size: 1.2rem;
  }

  .pill {
    display: block;
    width: 100%;
    text-align: center;
  }

  .prediction {
    font-size: 1.55rem;
    line-height: 1.1;
  }

  .timing-item {
    font-size: 0.92rem;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tr {
    border: 1px solid rgba(167, 189, 255, 0.15);
    border-radius: 12px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.02);
  }

  td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(167, 189, 255, 0.12);
    font-size: 0.9rem;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
    flex: 0 0 auto;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .bankroll-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stars::before,
  .stars::after,
  .fireworks {
    animation: none;
  }
}
