/* ========================================
   DUCK RACE - Canvas Water Racing
   Realistic flowing river via HTML5 Canvas
   ======================================== */

.duck-race-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0;
  font-family: 'Roboto', sans-serif;
}

/* ─── Race Arena ─── */
.race-arena {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 3px solid #1a5e1f;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  isolation: isolate;
  z-index: 1;
}

/* ─── Green shore ─── */
.arena-shore {
  background: linear-gradient(180deg,
      #4caf50 0%, #43a047 40%, #388e3c 70%, #5d4037 92%, #4e342e 100%);
  height: 28px;
  position: relative;
}

.arena-shore::before {
  content: '🌿';
  position: absolute;
  top: -8px;
  left: 30px;
  font-size: 14px;
  opacity: 0.5;
}

.arena-shore::after {
  content: '🌿';
  position: absolute;
  top: -8px;
  right: 80px;
  font-size: 14px;
  opacity: 0.5;
}

/* ─── Timer bar ─── Normal flow */
.race-timer-bar {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.52));
  backdrop-filter: blur(6px);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  font-weight: 700;
}

.race-timer-bar .round-info {
  font-size: 13px;
  color: #b2dfdb;
}

.race-timer-bar .timer-display {
  font-size: 34px;
  font-family: 'Courier New', monospace;
  font-weight: 900;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  padding: 3px 20px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  letter-spacing: 4px;
}

.race-timer-bar .phase-label {
  font-size: 13px;
  padding: 5px 16px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 800;
  color: #fff;
}

.phase-betting {
  background: linear-gradient(135deg, #00e676, #00c853);
  box-shadow: 0 0 12px rgba(0, 230, 118, 0.5);
}

.phase-racing {
  background: linear-gradient(135deg, #ff5252, #d32f2f);
  box-shadow: 0 0 12px rgba(255, 82, 82, 0.5);
  animation: flash-phase 0.8s ease-in-out infinite;
}

.phase-finished {
  background: linear-gradient(135deg, #ffc107, #ff9800);
  box-shadow: 0 0 12px rgba(255, 193, 7, 0.5);
}

@keyframes flash-phase {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

/* ─── Water Arena (Canvas renders here) ─── */
.arena-water {
  position: relative;
  min-height: 600px;
  background: #1a6885;
  overflow: hidden;
}

/* ─── Racing lanes ─── */
.race-lanes {
  position: relative;
  z-index: 5;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
}

.race-lane {
  position: relative;
  height: 145px;
  margin: 0;
  display: flex;
  align-items: center;
}

/* Swimming bob animation for ducks during race */
@keyframes duck-swim-bob {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-3px);
  }
}

/* ─── Duck number badge overlaid ON the duck image ─── */
.duck-number-badge {
  display: none;
  /* Hidden — we use the one inside duck-sprite */
}

/* Lane number (large ghosted on right) */
.lane-number {
  position: absolute;
  right: 10px;
  font-size: 52px;
  font-weight: 900;
  color: rgba(0, 30, 50, 0.07);
  z-index: 1;
  font-family: 'Arial Black', sans-serif;
  user-select: none;
  pointer-events: none;
}

/* ─── Duck sprite (PNG image) ─── */
.duck-sprite {
  position: absolute;
  left: 5px;
  z-index: 8;
  filter: drop-shadow(2px 3px 6px rgba(0, 0, 0, 0.45));
  cursor: default;
  transition: none;
}

.duck-img {
  width: 160px;
  height: auto;
  display: block;
  user-select: none;
  pointer-events: none;
}

/* Number badge ON the duck (top-left corner) */
.duck-number-overlay {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 12;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.9);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Arial Black', sans-serif;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.duck-sprite.resetting {
  transition: left 0.8s ease-in-out;
}

/* Duck water wake */
.duck-wake {
  position: absolute;
  z-index: 7;
  width: 20px;
  height: 8px;
  left: 42px;
  bottom: 14px;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center top, rgba(255, 255, 255, 0.25), transparent 70%);
  border-radius: 50%;
}

/* ─── Start line (to the RIGHT of ducks, visible during betting) ─── */
.start-line {
  position: absolute;
  left: 175px;
  top: 0;
  bottom: 0;
  width: 10px;
  z-index: 9;
  background: repeating-linear-gradient(180deg, #fff 0px, #fff 12px, #222 12px, #222 24px);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.5);
  border-radius: 3px;
  opacity: 0.9;
  transition: opacity 1s ease;
}

.start-line.hidden {
  opacity: 0;
}

/* ─── Finish line (hidden by default, slides in from right in final stretch) ─── */
.finish-line {
  position: absolute;
  right: 25%;
  top: 0;
  bottom: 0;
  width: 10px;
  z-index: 9;
  background: repeating-linear-gradient(180deg, #fff 0px, #fff 12px, #222 12px, #222 24px);
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
  border-radius: 3px;
  opacity: 0;
  transform: translateX(300px);
  transition: transform 2s ease-out, opacity 1s ease;
  pointer-events: none;
}

.finish-line.visible {
  opacity: 0.9;
  transform: translateX(0);
}

/* ─── Winner effect ─── */
.duck-sprite.winner {
  filter: drop-shadow(0 0 15px #ffd700) drop-shadow(0 0 30px rgba(255, 215, 0, 0.4));
  z-index: 20;
}

/* Losers slide back and fade after race */
.duck-sprite.loser-slide {
  transition: left 1.5s ease-in, opacity 1.5s ease-in;
  opacity: 0.5;
}

/* ═════════════════════════════ */
/* ─── Fake Winner Ticker ────── */
/* ═════════════════════════════ */

.winner-ticker {
  width: 100%;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(30, 60, 80, 0.9), rgba(20, 50, 70, 0.95));
  border-bottom: 1px solid rgba(255, 215, 0, 0.3);
  padding: 8px 0;
  position: relative;
}

.ticker-inner {
  display: flex;
  gap: 60px;
  white-space: nowrap;
  animation: ticker-scroll 25s linear infinite;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ffd700;
  font-size: 13px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.ticker-item .ticker-name {
  color: #4dd0e1;
}

.ticker-item .ticker-duck {
  color: #ff9800;
}

.ticker-item .ticker-amount {
  color: #69f0ae;
  font-weight: 800;
}

@keyframes ticker-scroll {
  0% {
    transform: translateX(100%);
  }

  100% {
    transform: translateX(-100%);
  }
}

/* ═════════════════════════════ */
/* ─── Below-arena SOLID WHITE ─ */
/* ═════════════════════════════ */

.betting-panel {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  margin-top: 20px;
  border: 1px solid #e0e0e0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  color: #333;
}

.dark .betting-panel {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

.duck-bet-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 15px;
}

.duck-bet-card {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  padding: 15px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.dark .duck-bet-card {
  background: #1e3a5f;
  border-color: #334155;
}

.duck-bet-card:hover {
  border-color: #f59e0b;
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.25);
}

.duck-bet-card.selected {
  border-color: #f59e0b;
  background: #fffbeb;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.dark .duck-bet-card.selected {
  background: #78350f;
}

.duck-bet-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Duck image in betting cards */
.duck-card-img {
  width: 60px;
  height: auto;
  display: block;
  margin: 0 auto 8px auto;
  user-select: none;
  pointer-events: none;
}

.duck-bet-card .duck-label {
  font-weight: 800;
  font-size: 15px;
  color: #1e40af;
}

.dark .duck-bet-card .duck-label {
  color: #93c5fd;
}

.duck-bet-card .duck-pool {
  font-size: 11px;
  color: #64748b;
  margin-top: 4px;
}

.duck-bet-card .bet-placed-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  background: #10b981;
  color: white;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
}

.bet-input-area {
  display: flex;
  gap: 10px;
  align-items: center;
}

.bet-input-area input {
  flex: 1;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  color: #1e293b;
  border-radius: 10px;
  padding: 12px 15px;
  font-size: 16px;
  font-weight: 700;
}

.dark .bet-input-area input {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

.bet-input-area input:focus {
  border-color: #f59e0b;
  outline: none;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.bet-input-area input::placeholder {
  color: #94a3b8;
}

.bet-input-area .btn-bet {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 32px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.35);
}

.bet-input-area .btn-bet:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

.bet-input-area .btn-bet:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.kc-balance-display {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ecfdf5;
  padding: 10px 16px;
  border-radius: 10px;
  color: #065f46;
  font-weight: 700;
  font-size: 16px;
  border: 1px solid #a7f3d0;
}

.dark .kc-balance-display {
  background: #064e3b;
  color: #6ee7b7;
  border-color: #047857;
}

.btn-exchange-kc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  border-radius: 10px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.3);
}

.btn-exchange-kc:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.5);
  color: #fff;
  text-decoration: none;
}

.multiplier-info {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 10px;
  padding: 10px 16px;
}

.dark .multiplier-info {
  background: #4c1d95;
  border-color: #6d28d9;
}

.multiplier-info .mult-label {
  font-size: 13px;
  color: #6d28d9;
}

.dark .multiplier-info .mult-label {
  color: #c4b5fd;
}

.multiplier-info .mult-value {
  font-size: 22px;
  font-weight: 900;
  color: #7c3aed;
}

.dark .multiplier-info .mult-value {
  color: #a78bfa;
}

.quick-bets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  align-items: center;
}

.quick-bets-label {
  font-size: 13px;
  color: #64748b;
  font-weight: 600;
}

.quick-bet-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #334155;
  padding: 5px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 700;
}

.dark .quick-bet-btn {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

.quick-bet-btn:hover {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.bet-limit-info {
  text-align: center;
  margin-top: 8px;
  font-size: 12px;
  color: #94a3b8;
}

.result-banner {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  color: white;
  margin-top: 15px;
  border: 2px solid #fbbf24;
  box-shadow: 0 0 30px rgba(251, 191, 36, 0.15);
  animation: result-appear 0.5s ease-out;
}

@keyframes result-appear {
  from {
    transform: scale(0.9);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.result-banner .winner-text {
  font-size: 22px;
  font-weight: 900;
  color: #fbbf24;
}

.result-banner .reward-text {
  font-size: 18px;
  color: #34d399;
  font-weight: 700;
  margin-top: 6px;
}

.result-banner .loss-text {
  font-size: 18px;
  color: #fb7185;
  font-weight: 700;
  margin-top: 6px;
}

.race-history,
.bets-log,
.login-prompt {
  margin-top: 20px;
  background: #ffffff;
  border-radius: 14px;
  padding: 16px 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.dark .race-history,
.dark .bets-log,
.dark .login-prompt {
  background: #1e293b;
  border-color: #334155;
}

.race-history-title,
.bets-log-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 12px;
  color: #1e40af;
}

.dark .race-history-title,
.dark .bets-log-title {
  color: #93c5fd;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-radius: 10px;
  margin-bottom: 4px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  transition: background 0.2s;
}

.dark .history-item {
  background: #0f172a;
  border-color: #1e293b;
}

.history-item:hover {
  background: #eff6ff;
}

.history-round-code {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  min-width: 130px;
}

.history-winner {
  font-size: 16px;
  font-weight: 800;
  color: #d97706;
}

.history-time {
  font-size: 11px;
  color: #94a3b8;
}

.btn-show-more {
  display: block;
  width: 100%;
  background: transparent;
  border: 1px dashed #cbd5e1;
  color: #3b82f6;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  margin-top: 8px;
}

.btn-show-more:hover {
  background: #eff6ff;
}

.bet-log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 4px;
  font-size: 13px;
  border: 1px solid #f1f5f9;
}

.dark .bet-log-item {
  background: #0f172a;
  border-color: #1e293b;
}

.bet-log-item .bet-user {
  font-weight: 700;
  min-width: 100px;
  color: #334155;
}

.dark .bet-log-item .bet-user {
  color: #cbd5e1;
}

.bet-log-item .bet-duck {
  font-weight: 700;
}

.bet-log-item .bet-amount {
  color: #d97706;
  font-weight: 800;
}

.bet-log-item.won {
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.bet-log-item.lost {
  background: #fef2f2;
  border-color: #fecaca;
}

.login-prompt {
  text-align: center;
  padding: 30px;
}

/* ─── User Bet History ─── */
.user-bet-history {
  margin-top: 20px;
  background: #ffffff;
  border-radius: 14px;
  padding: 16px 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.dark .user-bet-history {
  background: #1e293b;
  border-color: #334155;
}

.user-bet-history-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 12px;
  color: #7c3aed;
}

.dark .user-bet-history-title {
  color: #a78bfa;
}

.ubh-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 5px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
  font-size: 13px;
  transition: background 0.2s;
}

.dark .ubh-item {
  background: #0f172a;
  border-color: #1e293b;
}

.ubh-item:hover {
  background: #f1f5f9;
}

.ubh-item.ubh-won {
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.dark .ubh-item.ubh-won {
  background: #064e3b;
  border-color: #047857;
}

.ubh-item.ubh-lost {
  background: #fef2f2;
  border-color: #fecaca;
}

.dark .ubh-item.ubh-lost {
  background: #450a0a;
  border-color: #7f1d1d;
}

.ubh-round {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
  min-width: 120px;
}

.ubh-duck {
  font-weight: 800;
  color: #1e40af;
  min-width: 70px;
}

.dark .ubh-duck {
  color: #93c5fd;
}

.ubh-amount {
  font-weight: 700;
  color: #d97706;
  min-width: 70px;
}

.ubh-result {
  font-weight: 800;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  min-width: 80px;
  text-align: center;
}

.ubh-result.ubh-result-won {
  background: #10b981;
  color: #fff;
}

.ubh-result.ubh-result-lost {
  background: #ef4444;
  color: #fff;
}

.ubh-result.ubh-result-pending {
  background: #94a3b8;
  color: #fff;
}

.ubh-winner-info {
  font-size: 11px;
  color: #64748b;
  min-width: 80px;
  text-align: right;
}

.ubh-no-data {
  text-align: center;
  padding: 20px;
  color: #94a3b8;
  font-size: 14px;
}

@media (max-width: 768px) {
  .duck-race-container {
    padding: 0 5px;
  }

  .duck-bet-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .race-arena {
    border-radius: 10px;
  }

  .duck-img {
    width: 90px;
    min-width: 90px;
  }

  .race-lane {
    height: 95px;
    overflow: visible;
  }

  .duck-sprite {
    left: 3px;
    flex-shrink: 0;
  }

  .race-timer-bar {
    padding: 6px 10px;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
  }

  .race-timer-bar .timer-display {
    font-size: 22px;
    padding: 2px 10px;
    letter-spacing: 2px;
  }

  .race-timer-bar .round-info {
    font-size: 11px;
  }

  .race-timer-bar .phase-label {
    font-size: 11px;
    padding: 4px 10px;
  }

  .bet-input-area {
    flex-direction: column;
  }

  .bet-input-area .btn-bet {
    width: 100%;
  }

  .lane-number {
    font-size: 32px;
  }

  .duck-number-overlay {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }

  .arena-water {
    min-height: 440px;
  }

  .duck-card-img {
    width: 50px;
  }

  .finish-line {
    right: 25%;
    width: 7px;
  }

  .start-line {
    left: 100px;
    width: 7px;
  }

  .arena-shore {
    height: 20px;
  }

  .kc-balance-display {
    font-size: 14px;
    padding: 8px 12px;
  }

  .multiplier-info {
    padding: 8px 12px;
  }

  .multiplier-info .mult-value {
    font-size: 18px;
  }
}