* { box-sizing: border-box; }

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

button { cursor: pointer; }

/* ── Header ── */
.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;
}

.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;
  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), 0 0 20px rgba(118,75,162,0.2);
  position: relative; overflow: hidden;
}
.user-avatar::before {
  content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
  background: linear-gradient(45deg, transparent 40%, rgba(255,255,255,0.2) 50%, transparent 60%);
  transform: rotate(45deg); animation: avatarShine 3s ease-in-out infinite;
}
@keyframes avatarShine {
  0%, 100% { transform: translateX(-100%) rotate(45deg); }
  50% { transform: translateX(100%) rotate(45deg); }
}

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 Metrics ── */
.rq-game-metrics {
  display: flex; justify-content: center; align-items: center; gap: 40px;
  padding: 8px 20px; margin: 0 auto; width: 100%;
  text-align: center;
}
.rq-game-metrics__cell { text-align: center; flex: 1; }
.rq-game-metrics__label {
  font-size: 11px; color: rgba(255,255,255,0.5); text-transform: uppercase;
  font-weight: 600; letter-spacing: 1px; margin-bottom: 4px;
}
.rq-game-metrics__value {
  font-family: 'Orbitron', sans-serif; font-size: 18px; color: white; font-weight: 700;
}

/* ── Game Layout ── */
.runway-game {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 20px 20px;
  gap: 8px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* Desktop: controls LEFT, game canvas RIGHT */
@media (min-width: 900px) {
  .runway-game {
    flex-direction: row;
    align-items: flex-start;
    max-width: 1200px;
    gap: 16px;
  }
  .runway-controls-container {
    order: -1;
    width: 320px !important;
    min-width: 300px;
    max-width: 320px !important;
    flex-shrink: 0;
  }
  .runway-canvas-container {
    flex: 1;
    min-width: 0;
  }
}

/* ── Canvas Container ── */
.runway-canvas-container {
  position: relative;
  width: 100%;
  max-width: 750px;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid rgba(94, 190, 255, 0.25);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  background: #0a1628;
}

#runway-3d-container > canvas {
  display: block;
  width: 100% !important;
  height: auto !important;
  max-height: 45vh;
  object-fit: contain;
}

/* Result overlay that replaces the old 2D drawResultOverlay */
.runway-result-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  z-index: 6;
  pointer-events: auto;
}
.runway-result-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 38px;
  font-weight: 700;
  text-shadow: 0 0 30px currentColor, 0 0 60px currentColor;
}
.runway-result-btns {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}
.runway-result-btns button {
  padding: 10px 28px;
  border: none;
  border-radius: 8px;
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.runway-result-btns button:hover { opacity: 0.85; }
@media (max-width: 768px) {
  .runway-result-text { font-size: 26px; }
}

/* ── Altitude Bar ── */
.runway-altitude-bar {
  position: absolute;
  left: 8px;
  top: 10%;
  bottom: 25%;
  width: 14px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
}
.runway-altitude-fill {
  width: 100%;
  height: 50%;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(to top, #ff4444, #ffaa00, #00cc66);
  transition: height 0.3s ease;
}
.runway-altitude-label {
  position: absolute;
  left: 20px;
  bottom: 0;
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}
.runway-altitude-bar.danger .runway-altitude-fill {
  animation: altPulse 0.5s ease-in-out infinite;
}
@keyframes altPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Counter Balance Overlay ── */
.runway-counter {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  z-index: 5;
}
.runway-counter-mult {
  font-family: 'Orbitron', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: white;
  text-shadow: 0 0 20px rgba(94, 190, 255, 0.6), 0 2px 8px rgba(0, 0, 0, 0.8);
  transition: transform 0.15s ease, color 0.15s ease;
}
.runway-counter-rc {
  font-family: 'Orbitron', sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}
.runway-counter.flash-green .runway-counter-mult {
  color: #00ff88;
  transform: scale(1.15);
}
.runway-counter.flash-red .runway-counter-mult {
  color: #ff4444;
  transform: scale(0.9);
  animation: counterShake 0.3s ease;
}
@keyframes counterShake {
  0%, 100% { transform: scale(0.9) translateX(0); }
  25% { transform: scale(0.9) translateX(-4px); }
  75% { transform: scale(0.9) translateX(4px); }
}

/* ── Controls Container ── */
.runway-controls-container {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* ── Speed Selector ── */
.runway-speed-selector {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 30, 0.4);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(94, 190, 255, 0.2);
}
.runway-speed-btn {
  width: 40px;
  height: 34px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 16px;
  color: rgba(255, 255, 255, 0.5);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.runway-speed-btn:hover {
  background: rgba(94, 190, 255, 0.15);
  color: white;
}
.runway-speed-btn.active {
  border-color: #5ebeff;
  background: rgba(94, 190, 255, 0.2);
  color: white;
  box-shadow: 0 0 10px rgba(94, 190, 255, 0.3);
}

/* ── Dashboard ── */
.runway-dashboard {
  display: flex;
  gap: 20px;
  width: 100%;
  justify-content: center;
  padding: 10px 0;
  border-top: 1px solid rgba(94, 190, 255, 0.15);
  border-bottom: 1px solid rgba(94, 190, 255, 0.15);
}
.runway-dash-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.runway-dash-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 700;
  letter-spacing: 1px;
}
.runway-dash-value {
  font-family: 'Orbitron', sans-serif;
  font-size: 16px;
  color: white;
  font-weight: 600;
}

/* ── Bet Controls ── */
.clear-bet-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(94,190,255,0.2);
  color: rgba(255,255,255,0.6);
  font-size: 16px; font-weight: bold;
  cursor: pointer; border-radius: 6px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.clear-bet-btn:hover {
  background: rgba(255,50,50,0.2); color: #ff6666;
  border-color: rgba(255,50,50,0.4);
}

/* ── Launch Button ── */
.runway-launch-row {
  width: 100%;
  max-width: 335px;
}
.runway-launch-btn {
  width: 100%;
  padding: 10px 0;
  color: white;
  background: linear-gradient(135deg, #0084ff, #5ebeff);
  border: 2px solid rgba(94, 190, 255, 0.5);
  border-radius: 25px;
  font-family: 'Orbitron', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  transition: all 0.2s ease;
}
.runway-launch-btn:hover {
  background: linear-gradient(135deg, #3d6090, #4d6a90);
  color: #5ebeff;
  border-color: rgba(94, 190, 255, 0.8);
  box-shadow: 0 0 20px rgba(94, 190, 255, 0.6);
}
.runway-launch-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.runway-launch-btn.flying {
  background: linear-gradient(135deg, #cc4400, #ff6622);
  border-color: rgba(255, 120, 50, 0.6);
  color: #fff;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.runway-launch-btn.flying:hover {
  background: linear-gradient(135deg, #dd5500, #ff7733);
  box-shadow: 0 0 20px rgba(255, 100, 30, 0.5);
}
.runway-launch-btn .cashout-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(255,255,255,0.35), rgba(255,200,100,0.5));
  border-radius: 25px;
  transition: none;
  pointer-events: none;
}
.runway-launch-btn.holding .cashout-fill {
  width: 100%;
  transition: width 1s linear;
}
.runway-launch-btn.holding {
  animation: cashout-pulse 0.25s ease-in-out infinite alternate;
  box-shadow: 0 0 20px rgba(255,100,30,0.6);
}
@keyframes cashout-pulse {
  0% { transform: scale(1); border-color: rgba(255,120,50,0.6); }
  100% { transform: scale(1.04); border-color: rgba(255,200,100,0.9); }
}

/* ── History Bar ── */
.runway-history {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  width: 100%;
  padding: 8px 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(94,190,255,0.3) transparent;
}
.runway-history::-webkit-scrollbar { height: 4px; }
.runway-history::-webkit-scrollbar-thumb { background: rgba(94,190,255,0.3); border-radius: 2px; }

.runway-history-pill {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 12px;
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid;
  cursor: default;
  white-space: nowrap;
}
.runway-history-pill.win {
  background: rgba(0, 204, 102, 0.15);
  border-color: rgba(0, 204, 102, 0.4);
  color: #00cc66;
}
.runway-history-pill.loss {
  background: rgba(255, 68, 68, 0.15);
  border-color: rgba(255, 68, 68, 0.4);
  color: #ff4444;
}

/* ── Footer ── */
.footer {
  background: linear-gradient(135deg, rgba(20, 40, 80, 0.9), rgba(30, 50, 100, 0.9));
  border-top: 2px solid rgba(94, 190, 255, 0.3);
  padding: 40px 60px;
  margin-top: auto;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}
.footer-content { max-width: 1600px; margin: 0 auto; text-align: center; }
.footer-links {
  display: flex; justify-content: center; align-items: center;
  gap: 15px; flex-wrap: wrap; margin-bottom: 20px;
}
.footer-link {
  color: rgba(255,255,255,0.7); text-decoration: none; font-size: 13px;
  transition: color 0.2s ease; font-weight: 500;
}
.footer-link:hover { color: #5ebeff; text-shadow: 0 0 10px rgba(94,190,255,0.5); }
.footer-divider { color: rgba(94,190,255,0.4); }
.footer-copyright { color: rgba(255,255,255,0.5); font-size: 12px; margin: 0; }

/* ── Mobile ── */
@media (max-width: 768px) {
  .header {
    padding: 6px 14px !important;
    height: auto !important;
    min-height: 60px;
    gap: 10px !important;
    flex-wrap: wrap;
  }
  .games-header { font-size: 20px !important; }
  .header-btn { padding: 10px 14px !important; font-size: 13px !important; }
  .runway-game { padding: 4px 10px 10px; gap: 4px; }
  .rq-game-metrics { padding: 4px 10px; }
  .runway-controls-container { gap: 4px; }
  .runway-launch-btn { padding: 8px 0; font-size: 14px; }
  .runway-counter-mult { font-size: 22px; }
  .runway-dashboard { gap: 12px; }
  .runway-dash-value { font-size: 14px; }
  .footer { padding: 30px 20px; }
}
