/* ═══════════════════════════════════
   SPACEMAN — style.css
═══════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #050a1a;
  --bg2:       #0a1428;
  --blue:      #1a3a6a;
  --accent:    #00aaff;
  --accent2:   #0066cc;
  --gold:      #FFD700;
  --green:     #00dd66;
  --red:       #ff3344;
  --text:      #e0eeff;
  --text-dim:  rgba(180,210,255,0.5);
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  font-family: 'Arial Black', Arial, sans-serif;
  color: var(--text);
  overflow: hidden;
}

.app {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
}

/* ── TOP BAR ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg2);
  border-bottom: 1px solid rgba(0,170,255,0.2);
  flex-shrink: 0;
  gap: 10px;
}

.back-btn {
  color: rgba(0,170,255,0.6);
  text-decoration: none;
  font-size: 0.7rem;
  letter-spacing: 2px;
  border: 1px solid rgba(0,170,255,0.2);
  padding: 4px 10px;
  border-radius: 8px;
  transition: all 0.2s;
}
.back-btn:hover { color: var(--accent); border-color: var(--accent); }

.top-title {
  font-size: 1.1rem;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent);
  letter-spacing: 3px;
}

.balance-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,170,255,0.1);
  border: 1px solid rgba(0,170,255,0.3);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.85rem;
  color: var(--gold);
  font-weight: bold;
  text-shadow: 0 0 6px gold;
}

/* ── HISTORY BAR ── */
.history-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid rgba(0,170,255,0.1);
  flex-shrink: 0;
  overflow: hidden;
}

.history-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  letter-spacing: 2px;
  flex-shrink: 0;
}

.history-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}
.history-list::-webkit-scrollbar { display: none; }

.hist-item {
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: bold;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.hist-item.low  { background: rgba(255,50,50,0.2);  color: #ff6677; border: 1px solid rgba(255,50,50,0.4); }
.hist-item.mid  { background: rgba(0,200,100,0.2);  color: #44ff88; border: 1px solid rgba(0,200,100,0.4); }
.hist-item.high { background: rgba(0,170,255,0.2);  color: #44ccff; border: 1px solid rgba(0,170,255,0.4); }
.hist-item.mega { background: rgba(255,200,0,0.2);  color: #FFD700; border: 1px solid rgba(255,200,0,0.5); }

/* ── GAME AREA ── */
.game-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 80%, #0a1a3a 0%, #050a1a 70%);
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── MULTIPLIER OVERLAY ── */
.multiplier-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 10;
}

.mult-value {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 0 20px var(--accent),
    0 0 40px var(--accent2);
  letter-spacing: 2px;
  transition: color 0.3s;
  line-height: 1;
}

.mult-value.danger {
  color: #ff6644;
  text-shadow: 0 0 20px #ff4422, 0 0 40px #ff2200;
}

.mult-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 4px;
  margin-top: 6px;
}

/* ── CRASH OVERLAY ── */
.crash-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  z-index: 20;
  animation: crashFadeIn 0.3s ease-out;
}
.crash-overlay.show { display: flex; }

@keyframes crashFadeIn {
  from { opacity: 0; transform: scale(1.1); }
  to   { opacity: 1; transform: scale(1); }
}

.crash-text {
  font-size: clamp(2rem, 7vw, 4rem);
  color: var(--red);
  text-shadow: 0 0 30px var(--red);
  font-weight: 900;
  letter-spacing: 4px;
  animation: crashPulse 0.4s ease-in-out infinite alternate;
}

@keyframes crashPulse {
  from { transform: scale(1); }
  to   { transform: scale(1.05); }
}

.crash-mult {
  font-size: clamp(1.2rem, 4vw, 2rem);
  color: #ff8888;
  letter-spacing: 2px;
}

/* ── WAITING OVERLAY ── */
.waiting-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  z-index: 20;
}
.waiting-overlay.show { display: flex; }

.waiting-text {
  font-size: 1.2rem;
  color: var(--text-dim);
  letter-spacing: 4px;
}

.waiting-timer {
  font-size: clamp(3rem, 10vw, 6rem);
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent);
  font-weight: 900;
  animation: timerPulse 1s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(0.9); opacity: 0.7; }
}

/* ── CONTROLS ── */
.controls {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg2);
  border-top: 1px solid rgba(0,170,255,0.15);
  flex-shrink: 0;
}

/* ── BET PANEL ── */
.bet-panel {
  flex: 1;
  background: rgba(0,170,255,0.05);
  border: 1px solid rgba(0,170,255,0.2);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.bet-panel-header {
  font-size: 0.65rem;
  color: var(--accent);
  letter-spacing: 3px;
  text-align: center;
}

.bet-amount-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bet-adj {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(0,170,255,0.4);
  background: rgba(0,170,255,0.1);
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  display: flex; 
  align-items: center; 
  justify-content: center;
  line-height: 1;
}
.bet-adj:hover { 
  background: rgba(0,170,255,0.25); 
  border-color: var(--accent);
  transform: scale(1.05);
}
.bet-adj:active {
  transform: scale(0.95);
}

.bet-adj-minus {
  background: rgba(255,100,100,0.1);
  border-color: rgba(255,100,100,0.4);
  color: #ff6677;
}
.bet-adj-minus:hover {
  background: rgba(255,100,100,0.25);
  border-color: #ff6677;
}

.bet-adj-plus {
  background: rgba(0,200,100,0.1);
  border-color: rgba(0,200,100,0.4);
  color: #44ff88;
}
.bet-adj-plus:hover {
  background: rgba(0,200,100,0.25);
  border-color: #44ff88;
}

.bet-display {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(0,0,0,0.4);
  border: 2px solid rgba(0,170,255,0.3);
  border-radius: 12px;
  padding: 12px 16px;
  min-height: 50px;
}

.bet-currency { 
  font-size: 0.9rem; 
  color: var(--text-dim);
}

.bet-value {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 8px gold;
  letter-spacing: 1px;
  min-width: 80px;
  text-align: center;
}

.auto-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auto-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  cursor: pointer;
  flex-shrink: 0;
}

.auto-label input[type=checkbox] {
  accent-color: var(--accent);
  width: 14px; height: 14px;
}

.auto-row input[type=number] {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(0,170,255,0.2);
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: bold;
  font-family: inherit;
  padding: 4px 6px;
  outline: none;
  min-width: 0;
}

/* ── ACTION BUTTON ── */
.action-btn {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: none;
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.bet-btn {
  background: linear-gradient(to bottom, #00cc55, #008833);
  color: #fff;
  box-shadow: 0 0 14px rgba(0,200,80,0.5), 0 3px 0 #004422;
  position: relative;
  top: 0;
}
.bet-btn:hover:not(:disabled) { box-shadow: 0 0 22px rgba(0,255,100,0.7), 0 3px 0 #004422; }
.bet-btn:active:not(:disabled) { top: 2px; box-shadow: 0 0 14px rgba(0,200,80,0.5), 0 1px 0 #004422; }

.cashout-btn {
  background: linear-gradient(to bottom, #ff8800, #cc5500);
  color: #fff;
  box-shadow: 0 0 14px rgba(255,120,0,0.6), 0 3px 0 #662200;
  animation: cashoutPulse 0.6s ease-in-out infinite alternate;
}

@keyframes cashoutPulse {
  from { box-shadow: 0 0 14px rgba(255,120,0,0.6), 0 3px 0 #662200; }
  to   { box-shadow: 0 0 28px rgba(255,160,0,0.9), 0 3px 0 #662200; }
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  animation: none;
}

/* ── WIN TOAST ── */
.win-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #004422, #006633);
  border: 2px solid #00ff88;
  border-radius: 12px;
  padding: 10px 24px;
  color: #00ff88;
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: 2px;
  z-index: 100;
  box-shadow: 0 0 20px rgba(0,255,100,0.5);
  animation: toastIn 0.3s ease-out, toastOut 0.4s ease-in 2s forwards;
  pointer-events: none;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
  .controls { padding: 6px 6px; gap: 6px; }
  .bet-panel { padding: 8px; }
  .action-btn { font-size: 0.75rem; padding: 8px; }
  
  .bet-adj {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
  }
  
  .bet-display {
    padding: 10px 12px;
    min-height: 44px;
  }
  
  .bet-value {
    font-size: 1.1rem;
    min-width: 70px;
  }
}

.cancel-btn {
  background: linear-gradient(to bottom, #555, #333);
  color: #ccc;
  box-shadow: 0 0 8px rgba(100,100,100,0.3), 0 3px 0 #111;
}
.cancel-btn:hover { background: linear-gradient(to bottom, #666, #444); }

/* ── NEXT BET INDICATOR ── */
.next-bet-indicator {
  background: rgba(255,200,0,0.1);
  border: 1px solid rgba(255,200,0,0.3);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  animation: nextBetPulse 1.5s ease-in-out infinite;
}

@keyframes nextBetPulse {
  0%, 100% { border-color: rgba(255,200,0,0.3); background: rgba(255,200,0,0.1); }
  50%      { border-color: rgba(255,200,0,0.5); background: rgba(255,200,0,0.15); }
}

.next-bet-icon {
  font-size: 1.2rem;
  animation: nextBetBounce 1s ease-in-out infinite;
}

@keyframes nextBetBounce {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(3px); }
}

.next-bet-text {
  font-size: 0.7rem;
  color: rgba(255,200,0,0.8);
  letter-spacing: 1px;
  flex: 1;
}

.next-bet-text strong {
  color: #FFD700;
  text-shadow: 0 0 6px gold;
}
