/* ================================================
   RESET & BASE
   ================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden; /* No scrolling — everything fits on one screen */
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  color: #e0f0ff;
}

/* ================================================
   UNDERWATER BACKGROUND ECOSYSTEM
   ================================================ */
#ocean-bg {
  position: fixed;
  inset: 0;
  /* Deep ocean gradient */
  background: linear-gradient(
    180deg,
    #0a1628 0%,
    #0d2847 20%,
    #0f3460 40%,
    #1a5276 60%,
    #1e6f8f 80%,
    #1a8a7a 100%
  );
  z-index: 0;
  overflow: hidden;
}

/* ---------- Light rays from surface ---------- */
.light-ray {
  position: absolute;
  top: -10%;
  width: 80px;
  height: 120%;
  background: linear-gradient(180deg, rgba(120, 220, 255, 0.08) 0%, transparent 70%);
  transform-origin: top center;
  animation: ray-sway 8s ease-in-out infinite;
}
.ray-1 { left: 15%; animation-delay: 0s; width: 100px; }
.ray-2 { left: 50%; animation-delay: 2.5s; width: 60px; }
.ray-3 { left: 78%; animation-delay: 5s; width: 90px; }

@keyframes ray-sway {
  0%, 100% { transform: rotate(-3deg); opacity: 0.5; }
  50%      { transform: rotate(3deg);  opacity: 1;   }
}

/* ---------- Coral reef ---------- */
.coral {
  position: absolute;
  bottom: 0;
  border-radius: 50% 50% 0 0;
}
.coral-1 { left: 2%;  width: 80px;  height: 70px;  background: radial-gradient(ellipse, #e74c6f, #c0392b); }
.coral-2 { left: 18%; width: 60px;  height: 50px;  background: radial-gradient(ellipse, #f39c12, #e67e22); }
.coral-3 { left: 55%; width: 90px;  height: 60px;  background: radial-gradient(ellipse, #e74c6f, #8e44ad); }
.coral-4 { left: 75%; width: 70px;  height: 80px;  background: radial-gradient(ellipse, #f1c40f, #e67e22); }
.coral-5 { left: 90%; width: 85px;  height: 55px;  background: radial-gradient(ellipse, #e74c6f, #c0392b); }

/* ---------- Seaweed ---------- */
.seaweed {
  position: absolute;
  bottom: 0;
  width: 18px;
  height: 120px;
  background: linear-gradient(to top, #1e8449, #27ae60);
  border-radius: 40% 40% 0 0;
  transform-origin: bottom center;
  animation: seaweed-sway 4s ease-in-out infinite;
}
.seaweed-1 { left: 10%;  height: 110px; animation-delay: 0s; }
.seaweed-2 { left: 30%;  height: 140px; animation-delay: 1s; }
.seaweed-3 { left: 65%;  height: 100px; animation-delay: 0.5s; }
.seaweed-4 { left: 85%;  height: 130px; animation-delay: 1.5s; }

@keyframes seaweed-sway {
  0%, 100% { transform: rotate(-5deg); }
  50%      { transform: rotate(5deg);  }
}

/* ---------- Bubbles ---------- */
.bubble {
  position: absolute;
  bottom: -20px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(200, 240, 255, 0.5), rgba(100, 200, 255, 0.15));
  border: 1px solid rgba(200, 240, 255, 0.25);
  animation: bubble-rise linear infinite;
}
.bubble-1  { left: 8%;  width: 12px; height: 12px; animation-duration: 7s;  animation-delay: 0s;   }
.bubble-2  { left: 20%; width: 8px;  height: 8px;  animation-duration: 9s;  animation-delay: 1s;   }
.bubble-3  { left: 35%; width: 14px; height: 14px; animation-duration: 8s;  animation-delay: 2s;   }
.bubble-4  { left: 48%; width: 6px;  height: 6px;  animation-duration: 11s; animation-delay: 0.5s; }
.bubble-5  { left: 60%; width: 10px; height: 10px; animation-duration: 7.5s;animation-delay: 3s;   }
.bubble-6  { left: 72%; width: 16px; height: 16px; animation-duration: 10s; animation-delay: 1.5s; }
.bubble-7  { left: 82%; width: 7px;  height: 7px;  animation-duration: 8.5s;animation-delay: 4s;   }
.bubble-8  { left: 92%; width: 11px; height: 11px; animation-duration: 9.5s;animation-delay: 2.5s; }
.bubble-9  { left: 42%; width: 9px;  height: 9px;  animation-duration: 12s; animation-delay: 5s;   }
.bubble-10 { left: 55%; width: 13px; height: 13px; animation-duration: 6.5s;animation-delay: 0.8s; }

@keyframes bubble-rise {
  0%   { transform: translateY(0) translateX(0);     opacity: 0.7; }
  25%  { transform: translateY(-25vh) translateX(10px);  opacity: 0.8; }
  50%  { transform: translateY(-50vh) translateX(-8px);  opacity: 0.6; }
  75%  { transform: translateY(-75vh) translateX(12px);  opacity: 0.4; }
  100% { transform: translateY(-105vh) translateX(0);    opacity: 0;   }
}

/* ---------- Swimming fish ---------- */
.fish {
  position: absolute;
  font-size: 2rem;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.3));
  z-index: 1;
}
.fish-1 { top: 12%; animation: swim-right 18s linear infinite; animation-delay: 0s; font-size: 2.2rem; }
.fish-2 { top: 30%; animation: swim-left  22s linear infinite; animation-delay: 3s; font-size: 1.8rem; }
.fish-3 { top: 55%; animation: swim-right 15s linear infinite; animation-delay: 1s; font-size: 2.5rem; }
.fish-4 { top: 70%; animation: swim-left  25s linear infinite; animation-delay: 5s; font-size: 3rem;   }
.fish-5 { top: 20%; animation: swim-right 20s linear infinite; animation-delay: 8s; font-size: 1.6rem; }
.fish-6 { top: 45%; animation: swim-left  17s linear infinite; animation-delay: 6s; font-size: 2rem;   }

@keyframes swim-right {
  0%   { left: -5%;  transform: scaleX(1); }
  100% { left: 105%; transform: scaleX(1); }
}
@keyframes swim-left {
  0%   { left: 105%; transform: scaleX(-1); }
  100% { left: -5%;  transform: scaleX(-1); }
}

/* ---------- Other sea creatures ---------- */
.creature {
  position: absolute;
  font-size: 2rem;
  z-index: 1;
}
.jellyfish-1 {
  top: 15%; left: 80%;
  animation: jellyfish-drift 12s ease-in-out infinite;
  font-size: 2.5rem;
}
.jellyfish-2 {
  top: 40%; left: 10%;
  animation: jellyfish-drift 15s ease-in-out infinite;
  animation-delay: 4s;
  font-size: 2rem;
}
.seahorse-1 {
  bottom: 80px; left: 45%;
  animation: seahorse-bob 5s ease-in-out infinite;
  font-size: 1.8rem;
}
.turtle-1 {
  top: 60%;
  animation: swim-right 35s linear infinite;
  animation-delay: 10s;
  font-size: 2.8rem;
}
.starfish-1 { bottom: 8px; left: 38%; font-size: 1.4rem; }
.starfish-2 { bottom: 5px; left: 70%; font-size: 1.2rem; transform: rotate(35deg); }

@keyframes jellyfish-drift {
  0%, 100% { transform: translateY(0) translateX(0); }
  25%      { transform: translateY(-30px) translateX(15px); }
  50%      { transform: translateY(-10px) translateX(-10px); }
  75%      { transform: translateY(-40px) translateX(5px); }
}
@keyframes seahorse-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-15px); }
}

/* ================================================
   GAME CONTAINER
   ================================================ */
#game-container {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 10px 16px;
}

/* ---------- Top bar ---------- */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(5, 15, 35, 0.7);
  border-radius: 12px;
  border: 1px solid rgba(100, 180, 255, 0.2);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

#balance-display {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 700;
}
#balance-display .label {
  color: #7fb3e0;
  font-size: 0.7rem;
  letter-spacing: 2px;
}
#balance-amount {
  color: #ffd700;
  font-size: 1.4rem;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
  min-width: 60px;
}
.token-icon { font-size: 1.3rem; }

#game-title {
  font-size: 1.2rem;
  letter-spacing: 4px;
  background: linear-gradient(90deg, #00d4ff, #7b2ffc, #ff6bcb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#top-controls {
  display: flex;
  gap: 8px;
}
#top-controls button {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #e0f0ff;
  font-size: 1.2rem;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
#top-controls button:hover {
  background: rgba(255,255,255,0.18);
}

/* ---------- Main area layout ---------- */
#main-area {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 12px;
  min-height: 0;
  padding-top: 10px;
}

/* ---------- Side panels (stats & history) ---------- */
#stats-panel, #history-panel {
  width: 170px;
  flex-shrink: 0;
  background: rgba(5, 15, 35, 0.65);
  border-radius: 12px;
  border: 1px solid rgba(100, 180, 255, 0.15);
  backdrop-filter: blur(8px);
  padding: 12px;
  overflow-y: auto;
}
#stats-panel h3, #history-panel h3 {
  font-size: 0.85rem;
  letter-spacing: 1px;
  margin-bottom: 10px;
  color: #7fb3e0;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.stat-label { font-size: 0.72rem; color: #8ab4d8; }
.stat-value { font-size: 0.85rem; font-weight: 700; color: #fff; }

#history-list {
  list-style: none;
  font-size: 0.72rem;
}
#history-list li {
  padding: 4px 6px;
  margin-bottom: 3px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
}
#history-list li.history-win {
  border-left: 3px solid #2ecc71;
}
#history-list li.history-loss {
  border-left: 3px solid #e74c3c;
}
.history-empty {
  color: #5a8aaa;
  font-style: italic;
}

/* ================================================
   SLOT MACHINE
   ================================================ */
#slot-machine {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

#machine-frame {
  background: rgba(5, 12, 30, 0.75);
  border: 2px solid rgba(100, 180, 255, 0.25);
  border-radius: 18px;
  padding: 12px 18px 14px;
  backdrop-filter: blur(12px);
  box-shadow:
    0 0 30px rgba(0, 100, 255, 0.15),
    inset 0 0 30px rgba(0, 50, 120, 0.2);
  width: 100%;
  max-width: 400px;
}

/* AI quip banner */
#ai-quip {
  text-align: center;
  font-size: 0.7rem;
  font-style: italic;
  color: #7b8fa8;
  margin-bottom: 10px;
  min-height: 1.2em;
}

/* ---------- 3x3 Reel grid ---------- */
#reel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  aspect-ratio: 1;
  max-height: 320px;
  width: 100%;
}

.reel-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 25, 55, 0.8);
  border: 2px solid rgba(80, 160, 255, 0.2);
  border-radius: 12px;
  transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
  overflow: hidden;
  position: relative;
}

.reel-cell .symbol {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  transition: transform 0.1s;
  user-select: none;
}

/* Spinning animation on individual cells */
.reel-cell.spinning .symbol {
  animation: symbol-blur 0.1s linear infinite;
}

@keyframes symbol-blur {
  0%   { transform: translateY(-100%); opacity: 0.3; }
  50%  { transform: translateY(0);     opacity: 1;   }
  100% { transform: translateY(100%);  opacity: 0.3; }
}

/* Winning cell glow */
.reel-cell.winning {
  border-color: #ffd700;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.6), inset 0 0 15px rgba(255, 215, 0, 0.15);
  background: rgba(255, 215, 0, 0.1);
  animation: winner-pulse 0.8s ease-in-out infinite;
}

@keyframes winner-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.6), inset 0 0 15px rgba(255, 215, 0, 0.15); }
  50%      { box-shadow: 0 0 35px rgba(255, 215, 0, 0.9), inset 0 0 25px rgba(255, 215, 0, 0.3); }
}

/* ---------- Bet controls ---------- */
#bet-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

#bet-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(100,180,255,0.2);
  border-radius: 8px;
  padding: 4px 16px;
  min-width: 70px;
}
#bet-display .label {
  font-size: 0.55rem;
  letter-spacing: 2px;
  color: #7fb3e0;
}
#bet-amount {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffd700;
}

#bet-down, #bet-up {
  background: rgba(100, 180, 255, 0.12);
  border: 1px solid rgba(100, 180, 255, 0.25);
  color: #a0d0ff;
  font-size: 1rem;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
#bet-down:hover, #bet-up:hover {
  background: rgba(100, 180, 255, 0.25);
}

#all-in-btn {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  border: none;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.15s, box-shadow 0.2s;
}
#all-in-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(231, 76, 60, 0.5);
}

#spin-btn {
  background: linear-gradient(135deg, #00b894, #00cec9);
  border: none;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  padding: 10px 32px;
  border-radius: 10px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: transform 0.15s, box-shadow 0.2s;
}
#spin-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 0 25px rgba(0, 184, 148, 0.5);
}
#spin-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
#all-in-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ================================================
   WIN OVERLAY
   ================================================ */
#win-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
}
#win-overlay.hidden { display: none; }

#win-content {
  text-align: center;
  animation: win-entrance 0.5s ease-out;
}

@keyframes win-entrance {
  0%   { transform: scale(0.3) rotate(-10deg); opacity: 0; }
  60%  { transform: scale(1.15) rotate(2deg);  opacity: 1; }
  100% { transform: scale(1) rotate(0deg);     opacity: 1; }
}

#win-title {
  font-size: clamp(3rem, 10vw, 6rem);
  font-weight: 900;
  letter-spacing: 6px;
  background: linear-gradient(90deg, #ffd700, #ff6b6b, #ffd700, #ff6bcb, #ffd700);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer-text 2s linear infinite;
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
}

@keyframes shimmer-text {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

#win-amount {
  font-size: clamp(1.5rem, 5vw, 3rem);
  font-weight: 800;
  color: #ffd700;
  margin-top: 10px;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
  animation: amount-bounce 0.6s ease-in-out infinite alternate;
}
@keyframes amount-bounce {
  0%   { transform: scale(1); }
  100% { transform: scale(1.08); }
}

#win-subtitle {
  font-size: 1rem;
  color: #8ab4d8;
  font-style: italic;
  margin-top: 14px;
}

/* ---------- Confetti ---------- */
#confetti-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg);       opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg);  opacity: 0; }
}

/* ================================================
   GAME OVER SCREEN
   ================================================ */
#game-over {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
}
#game-over.hidden { display: none; }

#game-over-content {
  text-align: center;
  animation: win-entrance 0.6s ease-out;
}
#game-over-content h2 {
  font-size: 3rem;
  letter-spacing: 6px;
  color: #e74c3c;
  text-shadow: 0 0 30px rgba(231, 76, 60, 0.5);
}
#game-over-content p {
  color: #8ab4d8;
  margin-top: 10px;
  font-size: 1rem;
}
.ai-taunt {
  font-style: italic;
  color: #5a8aaa !important;
  margin-top: 8px !important;
  font-size: 0.9rem !important;
}
#game-over-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-top: 18px;
  color: #7fb3e0;
  font-size: 0.9rem;
}
#game-over-stats strong { color: #ffd700; }

#game-over-restart {
  margin-top: 24px;
  background: linear-gradient(135deg, #00b894, #00cec9);
  border: none;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  padding: 14px 30px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}
#game-over-restart:hover {
  transform: scale(1.06);
  box-shadow: 0 0 25px rgba(0, 184, 148, 0.5);
}

/* ================================================
   RESPONSIVE TWEAKS
   ================================================ */
@media (max-width: 900px) {
  #stats-panel, #history-panel { width: 140px; padding: 8px; }
}
@media (max-width: 700px) {
  #stats-panel, #history-panel { display: none; }
  #main-area { justify-content: center; }
}
