/* ============ Crash game ============ */
.crash { display: flex; flex-direction: column; min-height: 0; flex: 1; }

.crash-header { display: flex; align-items: center; gap: 10px; padding: 10px 14px 0; }
.crash-header .title { font-weight: 600; display: flex; align-items: center; gap: 6px; }

.crash-badge {
  margin: 10px 14px 0; text-align: center; font-size: 11px; font-weight: 700; letter-spacing: 2px;
  padding: 5px; border-radius: 8px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); color: #1a1300;
}
.crash-badge.real { background: linear-gradient(90deg, var(--win), #0aa869); color: #04130d; }

.crash-main { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 0 14px; margin-top: 12px; --stage-h: clamp(360px, 56vh, 560px); }

/* ---- Stage ---- */
.crash-stage {
  position: relative; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line);
  background: radial-gradient(120% 80% at 50% 0%, #161b22 0%, #0a0d11 60%), #07090c;
  aspect-ratio: 16 / 11; max-height: 46vh; order: 0;
}
.crash-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.crash-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(0,0,0,.6); }

.crash-readout { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center; z-index: 4; }
.crash-mult {
  font-size: clamp(48px, 15vw, 96px); font-weight: 300; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -1px;
  color: #fff; text-shadow: 0 0 36px rgba(240,185,11,.4), 0 4px 10px rgba(0,0,0,.5); transition: color .15s ease;
}
.crash-mult.cashed { color: var(--win); text-shadow: 0 0 40px rgba(14,203,129,.55); }
.crash-mult.crashed { color: var(--lose); text-shadow: 0 0 40px rgba(246,70,93,.55); }
.crash-status { margin-top: 8px; font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: .5px; }
.crash-status.win { color: var(--win); }
.crash-status.lose { color: var(--lose); }

/* ---- Center countdown (betting phase) ---- */
.crash-countdown { display: none; flex-direction: column; align-items: center; gap: 14px; }
.cd-cap { font-size: 12px; letter-spacing: 3px; color: var(--muted); font-weight: 600; animation: cd-cap-pulse 2s ease-in-out infinite; }
@keyframes cd-cap-pulse { 50% { opacity: .55; } }
.cd-num {
  font-size: clamp(52px, 14vw, 88px); font-weight: 300; line-height: 1; color: #fff;
  font-variant-numeric: tabular-nums; letter-spacing: -1px;
  text-shadow: 0 0 30px rgba(240,185,11,.45); will-change: transform, opacity;
}
/* Per-second pop: number bounces in and the glow flares. */
.cd-num.tick { animation: cd-tick .55s cubic-bezier(.2,1.5,.4,1); }
@keyframes cd-tick {
  0%   { transform: scale(.55); opacity: 0; text-shadow: 0 0 10px rgba(240,185,11,.2); }
  45%  { transform: scale(1.14); opacity: 1; text-shadow: 0 0 44px rgba(240,185,11,.75); }
  100% { transform: scale(1); opacity: 1; text-shadow: 0 0 30px rgba(240,185,11,.45); }
}
.cd-track {
  width: clamp(160px, 42vw, 240px); height: 6px; border-radius: 999px;
  background: rgba(255,255,255,.08); overflow: hidden; position: relative;
}
.cd-track > i {
  position: absolute; inset: 0; transform-origin: left;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px rgba(240,185,11,.6);
}

.crash-potential { position: absolute; top: 12px; left: 12px; z-index: 4; background: rgba(0,0,0,.4); border: 1px solid var(--line); padding: 6px 10px; border-radius: 10px; font-size: 12px; font-weight: 500; color: var(--muted); }
.crash-potential b { color: var(--win); font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---- Rocket (real image + CSS flame) ---- */
.rocket {
  position: absolute; top: 0; left: 0; z-index: 3; width: 56px; height: 90px;
  margin-left: -28px; margin-top: -45px; transform-origin: center; will-change: transform;
  transform: translate(-200px, -200px); filter: drop-shadow(0 0 10px rgba(240,185,11,.5)); transition: opacity .2s ease, filter .2s ease;
}
.rocket.cashed { filter: drop-shadow(0 0 16px rgba(14,203,129,.9)); }
.rocket.hidden { opacity: 0; }
.rocket.idle .rocket-flame { display: none; }
/* Clean cash-out: glow green and fade away (no explosion). */
.rocket.flyoff { animation: rocket-secured 1s ease forwards; }
@keyframes rocket-secured {
  0%   { opacity: 1; filter: drop-shadow(0 0 14px rgba(14,203,129,.7)); }
  60%  { opacity: 1; filter: drop-shadow(0 0 28px rgba(14,203,129,1)); }
  100% { opacity: 0; filter: drop-shadow(0 0 34px rgba(14,203,129,1)); }
}
.rocket-img { position: absolute; left: 0; top: 0; width: 56px; height: auto; z-index: 2; }
.rocket-flame {
  position: absolute; left: 50%; bottom: -8px; width: 22px; height: 34px; z-index: 1; transform: translateX(-50%);
  background: radial-gradient(50% 62% at 50% 26%, #fff3c4 0%, #ffd23f 32%, #ff8a1e 62%, rgba(255,70,0,0) 78%);
  border-radius: 50% 50% 50% 50% / 38% 38% 62% 62%; filter: blur(1px);
  transform-origin: top center; animation: flame .09s infinite alternate;
}
@keyframes flame { from { transform: translateX(-50%) scaleY(.72) scaleX(.9); opacity: .8; } to { transform: translateX(-50%) scaleY(1.18) scaleX(1.06); opacity: 1; } }

/* ---- Explosion ---- */
.explosion { position: absolute; top: 0; left: 0; z-index: 5; width: 130px; height: 130px; pointer-events: none; transform: translate(-200px, -200px) scale(.3); opacity: 0; }
.explosion svg { width: 100%; height: 100%; }
.explosion.show { animation: boom-pop .55s ease-out forwards; }
@keyframes boom-pop {
  0% { opacity: 0; transform: translate(var(--ex), var(--ey)) scale(.3) rotate(0deg); }
  35% { opacity: 1; transform: translate(var(--ex), var(--ey)) scale(1.15) rotate(8deg); }
  100% { opacity: 0; transform: translate(var(--ex), var(--ey)) scale(1.5) rotate(14deg); }
}
@keyframes shake { 0%,100% { transform: translate(0,0); } 20% { transform: translate(-6px,3px); } 40% { transform: translate(6px,-3px); } 60% { transform: translate(-4px,-2px); } 80% { transform: translate(4px,2px); } }
.crash-stage.boom { animation: shake .4s ease; }

/* ---- Players pool ---- */
.players { order: 1; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; display: flex; flex-direction: column; min-height: 0; }
.pool-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 2px 4px 8px; }
.pool-head-l, .pool-head-r { display: flex; flex-direction: column; }
.pool-head-r { align-items: flex-end; }
.pool-count { font-weight: 600; font-size: 15px; }
.pool-total { font-weight: 600; font-size: 15px; color: var(--win); font-variant-numeric: tabular-nums; }
.pool-label { font-size: 10px; color: var(--muted); }
.pool-cols { display: grid; grid-template-columns: minmax(0,1fr) 34px 50px 62px; gap: 6px; font-size: 10px; color: var(--muted); font-weight: 600; letter-spacing: .5px; padding: 4px; border-bottom: 1px solid var(--line); }
.pool-cols span:nth-child(2), .pool-cols span:nth-child(3), .pool-cols span:nth-child(4) { text-align: right; }
.pool-list { overflow-y: auto; max-height: 230px; scrollbar-width: thin; }
.pool-row { display: grid; grid-template-columns: minmax(0,1fr) 34px 50px 62px; gap: 6px; align-items: center; font-size: 12px; padding: 6px 4px; border-bottom: 1px solid rgba(255,255,255,.04); font-variant-numeric: tabular-nums; transition: background .2s ease; }
.pool-row.cashed { background: rgba(14,203,129,.07); }
.pool-name { display: flex; align-items: center; gap: 7px; color: var(--text); overflow: hidden; white-space: nowrap; min-width: 0; text-overflow: ellipsis; }
.pool-name span:last-child { overflow: hidden; text-overflow: ellipsis; }
.pool-avatar { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 0 2px rgba(255,255,255,.06); }
.pool-stake, .pool-x, .pool-win { text-align: right; color: var(--muted); }
.pool-x.hit { color: var(--accent); font-weight: 700; }
.pool-win.win { color: var(--win); font-weight: 700; }

@media (min-width: 880px) {
  .crash-main { grid-template-columns: 320px 1fr; align-items: stretch; }
  .players { order: 0; height: var(--stage-h); }
  .crash-stage { order: 1; aspect-ratio: auto; height: var(--stage-h); max-height: none; }
  .pool-list { max-height: none; flex: 1 1 auto; min-height: 0; }
}
