:root {
  --bg: #0b1020;
  --fg: #e5e7eb;
  --muted: #94a3b8;
  --accent-blue: #38bdf8;
  --accent-orange: #fb923c;
  --danger: #ef4444;
  --panel: #111827;
}

html, body { height: 100vh; height: 100svh; overflow: hidden; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #0e1630 0%, var(--bg) 60%, #060914 100%);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Liberation Sans', sans-serif;
}

.site-header { display: grid; place-items: center; padding: 12px 16px; backdrop-filter: blur(8px); }
.nav { width: min(1200px, 100%); display: flex; align-items: center; justify-content: space-between; }
.brand { color: var(--fg); text-decoration: none; font-weight: 600; letter-spacing: .2px; }
.theme-toggle { border: 1px solid #1f2937; background: #0b1220; color: var(--fg); padding: 8px 12px; border-radius: 10px; }

#stars { position: absolute; inset: 0; }
.site-main { position: relative; width: 100vw; height: 100vh; height: 100svh; display: grid; }
.stage { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }
#stars { position: absolute; inset: 0; }
.launch-block { display: grid; place-items: center; }
.launchpad { position: relative; width: min(900px, 92vw); aspect-ratio: 16/9; display: grid; place-items: center; transform: translateY(12px); }
.pad { width: 100%; opacity: .85; filter: drop-shadow(0 10px 30px rgba(0,0,0,.6)); }
.rocket-wrap { position: absolute; bottom: 18%; left: 50%; transform: translateX(-50%); width: 12%; display: grid; place-items: center; }
.rocket { position: relative; width: 100%; z-index: 1; transition: filter .5s; }
.rocket.launch { filter: drop-shadow(0 28px 60px rgba(251, 146, 60, .5)); }

.flame { position: absolute; top: calc(100% - 18px); width: 48%; height: 74px; z-index: 0; pointer-events: none; transform-origin: 50% 0%; opacity: 0; }
.flame::before { content: ""; position: absolute; left: 50%; transform: translateX(-50%); top: -12px; width: 40%; height: 60%; background: radial-gradient(closest-side at 50% 15%, rgba(255,255,255,.95), rgba(255,220,140,.85) 50%, rgba(255,140,0,.7) 85%, rgba(255,140,0,0) 100%); filter: blur(1.2px); }
.flame::after { content: ""; position: absolute; left: 50%; transform: translateX(-50%); top: -8px; width: 100%; height: 100%; background: linear-gradient(180deg, rgba(255,200,80,.85) 0%, rgba(255,140,0,.75) 40%, rgba(255,100,0,.55) 100%); clip-path: polygon(50% 0%, 62% 8%, 75% 22%, 82% 38%, 78% 56%, 65% 76%, 50% 100%, 35% 76%, 22% 56%, 18% 38%, 25% 22%, 38% 8%); filter: blur(1.2px); mix-blend-mode: screen; }
.flame.on { opacity: 1; animation: flameFlicker .08s ease-in-out infinite alternate; }
.flame.strong::after { filter: blur(1.4px) brightness(1.05); }
.flame.perfect::before { filter: blur(1.4px) brightness(1.08); }
@keyframes flameFlicker { from { transform: scaleY(0.94) scaleX(0.98); } to { transform: scaleY(1.08) scaleX(1.02); } }

.rocket.glow-perfect { animation: fuselage-glow 2s ease-in-out 2; }
@keyframes fuselage-glow {
  0% { filter: drop-shadow(0 24px 56px rgba(56,189,248,.35)) hue-rotate(0deg) brightness(1); }
  50% { filter: drop-shadow(0 32px 72px rgba(56,189,248,.5)) hue-rotate(20deg) brightness(1.12); }
  100% { filter: drop-shadow(0 24px 56px rgba(56,189,248,.35)) hue-rotate(0deg) brightness(1); }
}

@keyframes ascend {
  0% { transform: translateY(0) scale(1); }
  20% { transform: translateY(-30px) scale(1.02); }
  40% { transform: translateY(-80px) scale(1.04); }
  60% { transform: translateY(-160px) scale(1.06); }
  100% { transform: translateY(-520px) scale(1.08); }
}

.hud { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.countdown {
  font-size: clamp(48px, 8vw, 160px);
  font-weight: 800;
  letter-spacing: 2px;
  text-shadow: 0 0 30px rgba(56,189,248,.35);
  color: var(--accent-blue);
  transform: scale(1);
  transition: transform .25s, color .25s;
}
.countdown.flash { transform: scale(1.08); color: var(--accent-orange); }
.display { margin-top: 8px; color: var(--muted); font-size: 14px; }

.controls { display: flex; gap: 12px; margin-top: 18px; pointer-events: auto; }
.btn { border: 1px solid #1f2937; background: #0b1220; color: var(--fg); padding: 12px 18px; border-radius: 14px; font-weight: 600; letter-spacing: .4px; }
.btn.primary { background: linear-gradient(180deg, #0ea5e9 0%, #0369a1 100%); border: none; box-shadow: 0 10px 24px rgba(14,165,233,.25); }
.btn.ghost { background: transparent; }
.btn.ignite { 
  background: 
    radial-gradient(120px 60px at 50% 20%, rgba(255,255,255,.18) 0%, rgba(255,255,255,0) 60%),
    linear-gradient(180deg, #ff4949 0%, #d61f1f 55%, #8a1515 100%);
  border: 1px solid #7a1010;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 14px 22px;
  border-radius: 16px;
  box-shadow: inset 0 6px 12px rgba(255,255,255,.08), inset 0 -6px 12px rgba(0,0,0,.22), 0 18px 48px rgba(239,68,68,.38);
  transform: translateZ(0);
}
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.ignite:active { transform: translateY(2px); filter: brightness(1.08) saturate(1.05); }
.btn.ignite.glow { animation: glow 1.2s ease-in-out infinite; }

@keyframes glow {
  0%,100% { box-shadow: 0 18px 48px rgba(239,68,68,.28); }
  50% { box-shadow: 0 24px 64px rgba(239,68,68,.42); }
}

.result { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; }
.result[hidden] { display: none !important; }
.result-grid { width: min(820px, 80vw); max-height: min(70vh, 540px); overflow: auto; background: linear-gradient(180deg, rgba(15,23,42,.7), rgba(2,6,23,.7)); border: 1px solid #1f2937; border-radius: 18px; padding: 20px; display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; backdrop-filter: blur(6px); box-sizing: border-box; }
.result-grid { position: relative; }
.result-grid #closeResult { position: static; }
.metric .label { color: var(--muted); font-size: 13px; }
.metric .value { font-size: 28px; font-weight: 700; }
.quote { grid-column: span 3; text-align: center; color: var(--accent-orange); font-weight: 600; }

.summary { grid-column: span 2; display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.summary .item { border: 1px solid #1f2937; border-radius: 10px; padding: 10px 12px; background: rgba(2,6,23,.5); }
.summary .item .label { color: var(--muted); font-size: 13px; }
.summary .item .value { font-size: 18px; font-weight: 700; }

.share-actions { grid-column: span 3; display: flex; gap: 10px; justify-content: center; margin-top: 8px; flex-wrap: nowrap; overflow-x: auto; }

.fab-share { display: none; }
.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.55); backdrop-filter: blur(6px); z-index: 30; }
.modal[aria-hidden="true"] { display: none; }
.modal-panel { width: min(520px, 92vw); background: linear-gradient(180deg, rgba(15,23,42,.8), rgba(2,6,23,.8)); border: 1px solid #1f2937; border-radius: 18px; padding: 22px; color: var(--fg); }
.modal-panel { max-height: 88vh; overflow: auto; }
.modal-panel { box-sizing: border-box; }
.card-panel { width: min(1000px, 95vw); }
.card-panel { position: relative; }
.card-panel #cardClose { position: static; display: block; margin: 12px auto 0; }
.card-preview { display: grid; place-items: center; margin-top: 8px; }
.card-preview canvas { width: min(960px, 94vw); height: auto; border-radius: 12px; box-shadow: 0 10px 24px rgba(0,0,0,.35); }
.card-floating { position: sticky; bottom: 12px; display: grid; place-items: center; padding: 8px 0; }
.card-floating .btn.accent { background: linear-gradient(180deg, #10b981 0%, #047857 100%); color: #fff; box-shadow: 0 6px 18px rgba(16,185,129,.35); }
.modal-title { margin: 0 0 8px; font-size: 20px; font-weight: 700; }
.modal-desc { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }

.share-status { color: var(--muted); font-size: 13px; align-self: center; }
.share-toolbar { grid-column: span 2; display: grid; place-items: center; margin-top: 6px; }
.share-toolbar .btn.accent { background: linear-gradient(180deg, #10b981 0%, #047857 100%); color: #fff; border: none; box-shadow: 0 10px 24px rgba(16,185,129,.28); }
.share-card { grid-column: span 2; display: grid; place-items: center; margin-top: 8px; }
.share-card canvas { width: min(720px, 100%); height: auto; border-radius: 12px; box-shadow: 0 10px 24px rgba(0,0,0,.35); }

.particles { position: absolute; left: 50%; transform: translateX(-50%); bottom: 20%; pointer-events: none; }

.tagline { text-align: center; color: var(--muted); font-size: 14px; margin-top: 15px; }

@media (max-width: 640px) {
  .result-grid { grid-template-columns: 1fr; max-height: 78vh; width: 88vw; }
  .result-grid #closeResult { }
  .result-grid #closeResult { }
  .rocket-wrap { width: 17.5%; }
  .rocket-wrap { width: 17.5%; }
  .rocket-wrap { width: 17.5%; }
  .flame { width: 50%; top: calc(100% - 20px); }
  .modal-panel, .card-panel { width: 98vw; padding: 16px; }
  .card-preview canvas { width: 90vw; }
}
