/* ═══════════════════════════════════════════
   The Launch — Crash Game (RiskQuest Theme)
   ═══════════════════════════════════════════ */

* { box-sizing: border-box; }

body {
  background: linear-gradient(135deg, #3d5a80 0%, #4d6a90 50%, #3d6090 100%);
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  min-height: 100vh;
  color: white;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

button { cursor: pointer; }

/* ══════════════════════════════════════════
   HEADER (Universal RiskQuest — matches flip/darts/etc.)
   ══════════════════════════════════════════ */

.header {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0 40px;
  border-bottom: 2px solid rgba(94, 190, 255, 0.3);
  position: sticky;
  top: 0;
  height: 90px;
  background: linear-gradient(135deg, rgba(20, 40, 80, 0.95), rgba(30, 50, 100, 0.95));
  backdrop-filter: blur(10px);
  z-index: 100;
  gap: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.games-header {
  color: white;
  font-family: "Orbitron", sans-serif;
  font-size: 28px;
  margin: 0;
  cursor: pointer;
  white-space: nowrap;
}
.games-header:hover { color: #5ebeff; }

.header-left { display: flex; align-items: center; gap: 20px; }

.version-badge {
  background: rgba(94, 190, 255, 0.2);
  border: 1px solid rgba(94, 190, 255, 0.4);
  color: #5ebeff;
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.header-nav { display: flex; gap: 15px; margin-left: auto; align-items: center; }

.header-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-family: Arial, sans-serif;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-weight: 600;
}
.header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(94, 190, 255, 0.3);
}

.header-btn.shop-btn {
  background: linear-gradient(135deg, #5ebeff, #7dd3ff);
  border: 2px solid rgba(255, 255, 255, 0.4);
  color: white;
  font-weight: bold;
}
.header-btn.shop-btn:hover {
  background: linear-gradient(135deg, #70c8ff, #90ddff);
  box-shadow: 0 4px 20px rgba(94, 190, 255, 0.5);
}
.header-btn.inventory-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.4);
}
.header-btn.inventory-btn:hover { background: rgba(255, 255, 255, 0.25); }

.money-amount {
  color: white;
  font-family: Arial, sans-serif;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(94, 190, 255, 0.15);
  border: 2px solid rgba(94, 190, 255, 0.4);
  padding: 8px 15px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.header-auth { display: flex; align-items: center; gap: 8px; margin-left: 15px; }
.header-auth-link {
  color: white;
  text-decoration: none;
  font-size: 13px;
  font-family: Arial, sans-serif;
  padding: 8px 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  transition: all 0.2s ease;
  font-weight: 600;
}
.header-auth-link:hover { background: rgba(255, 255, 255, 0.15); border-color: rgba(255, 255, 255, 0.5); }
.header-auth-link.signup {
  color: white;
  background: linear-gradient(135deg, #5ebeff, #7dd3ff);
  border: 2px solid rgba(255, 255, 255, 0.4);
}
.header-auth-link.signup:hover {
  background: linear-gradient(135deg, #70c8ff, #90ddff);
  box-shadow: 0 4px 15px rgba(94, 190, 255, 0.4);
}

.user-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  display: flex; align-items: center; justify-content: center;
  color: white; font-family: 'Orbitron', sans-serif; font-size: 18px;
  font-weight: bold; cursor: pointer; transition: all 0.3s ease;
  text-decoration: none; border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  position: relative; overflow: hidden;
}
.user-avatar:hover {
  transform: scale(1.15) rotate(5deg);
  box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6), 0 0 35px rgba(240, 147, 251, 0.4);
}

model-viewer.riskcoin {
  display: inline-block; vertical-align: middle;
  --poster-color: transparent; background: transparent;
}
model-viewer.riskcoin::part(default-progress-bar) { display: none; }
model-viewer.riskcoin::part(default-ar-button) { display: none; }
model-viewer.riskcoin-header { width: 42px; height: 42px; }


/* ══════════════════════════════════════════
   GAME LAYOUT
   ══════════════════════════════════════════ */

.crash-layout {
  display: flex;
  flex-direction: column;
  max-width: 1500px;
  margin: 10px auto;
  padding: 0 16px;
  gap: 10px;
  align-items: stretch;
  width: 100%;
  box-sizing: border-box;
}

/* Desktop: controls LEFT, game canvas RIGHT
   The whole layout is sized to fit within the remaining viewport height,
   so the game never gets cut off and the canvas resizes with the window. */
@media (min-width: 769px) {
  .crash-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: stretch;
    /* Reserved: header (~90) + metrics row (~80) + footer (~70) + margins */
    height: calc(100vh - 260px);
    min-height: 380px;
    max-height: 760px;
  }
  .crash-layout > .control-panel {
    grid-column: 1;
    grid-row: 1 / -1;
    min-width: 0;
    max-height: 100%;
    overflow-y: auto;
  }
  .crash-layout > .crash-canvas-container {
    grid-column: 2;
    grid-row: 1;
    height: auto;
    min-height: 0;
    max-height: none;
    min-width: 0;
    width: 100%;
  }
  .crash-layout > .crash-history-rail {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
  }
}

/* ── Game Area (canvas + history) ── */
.crash-game-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Canvas Container (single-column / mobile fallback) ── */
.crash-canvas-container {
  position: relative;
  width: 100%;
  height: 42vh;
  min-height: 240px;
  max-height: 460px;
  background: radial-gradient(ellipse at center, rgba(15, 25, 55, 0.9), rgba(10, 15, 40, 0.95));
  border: 2px solid rgba(94, 190, 255, 0.3);
  border-radius: 12px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.3), 0 0 20px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.crash-canvas-container canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ── History Rail ── */
.crash-history-rail {
  position: relative;
  height: 38px;
  overflow: hidden;
}
.crash-history-fade {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 40px;
  background: linear-gradient(to right, #4a6a90, transparent);
  z-index: 2;
  pointer-events: none;
}
.crash-history-strip {
  display: flex;
  gap: 6px;
  align-items: center;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0 8px;
  flex-direction: row;
}
.crash-history-strip::-webkit-scrollbar { display: none; }

.crash-history-pill {
  flex-shrink: 0;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.2s;
  font-family: 'Orbitron', sans-serif;
}
.crash-history-pill:hover { transform: scale(1.08); }
.crash-history-pill.low    { background: linear-gradient(135deg, #d32f2f, #b71c1c); }
.crash-history-pill.medium { background: linear-gradient(135deg, #0097a7, #00838f); }
.crash-history-pill.high   { background: linear-gradient(135deg, #2e7d32, #1b5e20); }
.crash-history-pill.legend { background: linear-gradient(135deg, #f9a825, #f57f17); text-shadow: 0 1px 2px rgba(0,0,0,0.4); }


/* ══════════════════════════════════════════
   CONTROL PANEL (matches flip/darts)
   ══════════════════════════════════════════ */

.control-panel {
  width: 100%;
  min-width: 0;
  background: linear-gradient(135deg, rgba(61, 90, 128, 0.3), rgba(77, 106, 144, 0.3));
  border: 2px solid rgba(94, 190, 255, 0.3);
  border-radius: 12px;
  padding: 18px;
  position: relative;
  box-sizing: border-box;
}


/* ── Bet Row (matches flip) ── */
.bet-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 2px;
}
.bet-display {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.bet-display-prefix {
  color: rgba(255, 255, 255, 0.4);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.bet-display-value {
  color: white;
  font-size: 17px;
  font-weight: 700;
  font-family: "Orbitron", sans-serif;
  white-space: nowrap;
}
.clear-bet-btn {
  width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.4);
  font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s; padding: 0; flex-shrink: 0;
}
.clear-bet-btn:hover {
  background: rgba(244, 67, 54, 0.2);
  border-color: rgba(244, 67, 54, 0.5);
  color: #f44336;
}

.form-error {
  color: #f44336;
  font-size: 12px;
  margin-top: 4px;
  min-height: 16px;
}

/* ── Field Groups ── */
.crash-field-group {
  margin-bottom: 14px;
}
.crash-field-row {
  display: flex;
  gap: 12px;
}
.crash-field-row > div { flex: 1; }

.crash-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.crash-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.crash-input {
  flex: 1;
  background: rgba(61, 90, 128, 0.3);
  border: 2px solid rgba(94, 190, 255, 0.2);
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  outline: none;
  transition: all 0.2s ease;
  min-width: 0;
  font-family: 'Orbitron', sans-serif;
}
.crash-input:focus {
  border-color: rgba(94, 190, 255, 0.5);
  box-shadow: 0 0 10px rgba(94, 190, 255, 0.15);
}
.crash-input::placeholder { color: rgba(255,255,255,0.25); }
.crash-input::-webkit-inner-spin-button,
.crash-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.crash-input[type=number] { -moz-appearance: textfield; }

.crash-input-sm {
  width: 56px;
  background: rgba(61, 90, 128, 0.3);
  border: 1px solid rgba(94, 190, 255, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  color: #fff;
  font-size: 14px;
  text-align: center;
  outline: none;
}
.crash-input-sm::-webkit-inner-spin-button,
.crash-input-sm::-webkit-outer-spin-button { -webkit-appearance: none; }
.crash-input-sm[type=number] { -moz-appearance: textfield; }

.crash-input-btn {
  padding: 10px 12px;
  border: 2px solid rgba(94, 190, 255, 0.2);
  border-radius: 8px;
  background: rgba(61, 90, 128, 0.3);
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.crash-input-btn:hover {
  background: rgba(94, 190, 255, 0.15);
  color: #5ebeff;
  border-color: rgba(94, 190, 255, 0.4);
}
.crash-input-btn.active {
  background: rgba(94, 190, 255, 0.2);
  color: #5ebeff;
  border-color: rgba(94, 190, 255, 0.5);
}

/* ── Cashout Presets ── */
.crash-cashout-presets {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.crash-cashout-preset {
  padding: 6px 10px;
  border: 1px solid rgba(94, 190, 255, 0.15);
  border-radius: 6px;
  background: rgba(61, 90, 128, 0.2);
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.crash-cashout-preset:hover {
  background: rgba(94, 190, 255, 0.12);
  color: #5ebeff;
  border-color: rgba(94, 190, 255, 0.3);
}
.crash-cashout-preset.active {
  background: rgba(94, 190, 255, 0.2);
  color: #5ebeff;
  border-color: rgba(94, 190, 255, 0.4);
}

/* ── Profit Preview ── */
.crash-profit-display {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 14px;
}
.crash-profit-display span {
  color: #4caf50;
  font-weight: 700;
  font-family: 'Orbitron', sans-serif;
}

/* ── Radio Rows ── */
.crash-radio-row {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.crash-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}
.crash-radio input[type="radio"] {
  accent-color: #5ebeff;
}


/* ══════════════════════════════════════════
   ACTION BUTTON (matches flip green button)
   ══════════════════════════════════════════ */

.crash-action-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
  overflow: hidden;
  font-family: "Orbitron", sans-serif;
  letter-spacing: 1px;
  min-height: 42px;
  margin-bottom: 10px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.crash-action-btn.state-bet {
  background: linear-gradient(135deg, #00c853, #00e676);
  color: #fff;
}
.crash-action-btn.state-bet:hover:not(:disabled) {
  background: linear-gradient(135deg, #00e676, #69f0ae);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 230, 118, 0.4);
}

.crash-action-btn.state-waiting {
  background: rgba(61, 90, 128, 0.4);
  color: rgba(255, 255, 255, 0.4);
  cursor: not-allowed;
}

.crash-action-btn.state-cashout {
  background: linear-gradient(135deg, #ff8f00, #e65100);
  color: #fff;
  box-shadow: 0 4px 20px rgba(255, 143, 0, 0.5);
  animation: cashout-pulse 1s ease-in-out infinite;
}

.crash-action-btn.state-cashed {
  background: linear-gradient(135deg, #00c853, #00e676);
  color: #fff;
  cursor: default;
  opacity: 0.8;
}

.crash-action-btn.state-next {
  background: linear-gradient(135deg, rgba(94, 190, 255, 0.3), rgba(94, 190, 255, 0.15));
  color: #5ebeff;
  border: 2px solid rgba(94, 190, 255, 0.3);
}

.crash-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.crash-cancel-btn {
  width: 100%;
  padding: 10px;
  border: 2px solid rgba(244, 67, 54, 0.4);
  border-radius: 8px;
  background: rgba(244, 67, 54, 0.1);
  color: #f44336;
  font-family: "Orbitron", sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 10px;
}
.crash-cancel-btn:hover {
  background: rgba(244, 67, 54, 0.2);
  border-color: rgba(244, 67, 54, 0.6);
}
.crash-cancel-btn.hidden { display: none; }

@keyframes cashout-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(255, 143, 0, 0.5); }
  50% { box-shadow: 0 4px 35px rgba(255, 143, 0, 0.8); }
}

.crash-action-sub {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.8;
  letter-spacing: 0;
  font-family: Arial, sans-serif;
}


/* ── Hotkeys ── */
.crash-hotkeys {
  position: absolute;
  bottom: 12px;
  right: 12px;
}
.crash-hotkey-toggle {
  background: rgba(61, 90, 128, 0.3);
  border: 1px solid rgba(94, 190, 255, 0.15);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.3);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.crash-hotkey-toggle:hover { color: #5ebeff; border-color: rgba(94, 190, 255, 0.4); }
.crash-hotkey-list {
  position: absolute;
  bottom: 32px;
  right: 0;
  background: linear-gradient(135deg, rgba(20, 40, 80, 0.95), rgba(30, 50, 100, 0.95));
  border: 1px solid rgba(94, 190, 255, 0.3);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
}
.crash-hotkey-list.hidden { display: none; }
.crash-hotkey-list kbd {
  background: rgba(94, 190, 255, 0.1);
  border: 1px solid rgba(94, 190, 255, 0.2);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: monospace;
  margin-right: 6px;
  color: #5ebeff;
}


/* ══════════════════════════════════════════
   WIN POPUP & CONFETTI
   ══════════════════════════════════════════ */

.crash-win-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 500;
  pointer-events: none;
}
.crash-win-popup.hidden { display: none; }
.crash-win-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 36px;
  font-weight: 900;
  color: #4caf50;
  text-shadow: 0 0 30px rgba(76, 175, 80, 0.6), 0 0 60px rgba(76, 175, 80, 0.3);
  animation: win-float 1.5s ease-out forwards;
}
.crash-win-text.big-win {
  font-size: 48px;
  color: #ffd700;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.6), 0 0 60px rgba(255, 215, 0, 0.3);
}
.crash-win-text.massive-win {
  font-size: 56px;
  color: #ffd700;
  text-shadow: 0 0 40px rgba(255, 215, 0, 0.8), 0 0 80px rgba(255, 215, 0, 0.4);
}
@keyframes win-float {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  70% { opacity: 1; transform: translateY(-40px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-80px) scale(0.9); }
}

.crash-confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 400;
  overflow: hidden;
}
.confetti-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(100vh) rotate(720deg); }
}


/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */

@media (max-width: 768px) {
  .header {
    padding: 6px 14px;
    height: auto;
    min-height: 60px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .games-header { font-size: 20px; }
  .header-btn { padding: 10px 14px; font-size: 13px; }
  .money-amount { font-size: 14px; padding: 8px 12px; }

  .crash-layout { padding: 0 8px 12px; gap: 6px; }
  .crash-canvas-container {
    border-radius: 10px;
    border-width: 1px;
  }
  .control-panel { padding: 14px; border-radius: 10px; }
  .crash-action-btn { min-height: 54px; font-size: 15px; padding: 12px; }
  .crash-cancel-btn { padding: 8px; font-size: 12px; }
  .rq-game-metrics { margin: 6px 8px; }
}

@media (max-width: 480px) {
  .crash-layout { padding: 0 4px 10px; gap: 4px; }
  .crash-canvas-container {
    min-height: 180px;
    border-radius: 8px;
  }
  .control-panel { padding: 10px; border-radius: 8px; }
  .crash-input { padding: 8px 10px; font-size: 14px; }
  .crash-input-btn { padding: 8px 8px; font-size: 11px; }
  .crash-action-btn { min-height: 56px; font-size: 14px; padding: 10px; margin-bottom: 10px; }
  .crash-cancel-btn { padding: 7px; font-size: 11px; margin-bottom: 8px; }
  .crash-cashout-presets { gap: 3px; }
  .crash-cashout-preset { padding: 5px 7px; font-size: 10px; }
  .crash-field-group { margin-bottom: 10px; }
  .crash-label { font-size: 9px; margin-bottom: 4px; }
  .crash-profit-display { font-size: 12px; margin-bottom: 10px; }
  .crash-history-rail { height: 32px; }
  .crash-history-pill { padding: 3px 8px; font-size: 11px; }
  .bet-display-value { font-size: 15px; }
}
