/* ============================================================
   YODES — 3D Mystical Cosmic Tarot Shop : overlay UI
   The 3D scene fills the viewport; these glass panels float on top.
   ============================================================ */
:root {
    --c-gold: #c9a45c;
    --c-gold-bright: #f0d79a;
    --c-ivory: #f4e7c5;
    --c-violet: #7b4dff;
    --c-deep: #2a104d;
    --c-navy: #050814;
    --glass-bg: rgba(16, 11, 34, 0.55);
    --glass-border: rgba(201, 164, 92, 0.35);
    --glass-blur: blur(18px) saturate(140%);
    /* serif with full Vietnamese glyph coverage (Georgia breaks ố/ề into combining marks) */
    --font-display: Cambria, 'Palatino Linotype', 'Times New Roman', serif;
}

.cosmic-app {
    position: fixed;
    inset: 0;
    overflow: hidden;
    color: var(--c-ivory);
    font-family: 'Segoe UI', system-ui, sans-serif;
    background:
        radial-gradient(circle at 52% 42%, rgba(132, 73, 210, 0.2), transparent 30%),
        linear-gradient(180deg, rgba(2, 3, 10, 0.18) 0%, rgba(2, 3, 10, 0.66) 100%),
        url('/image/cosmic/nebula-bg.png') center 44% / cover no-repeat,
        #050814;
    isolation: isolate;
}

.cosmic-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 0;
    touch-action: none;
}

/* hide the page chrome scroll only on the cosmic shop page */
body:has(.cosmic-app) { overflow: hidden; }

/* cinematic vignette above the 3D canvas, below the UI (canvas z=0, UI z>=5) */
.cosmic-app::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(ellipse 90% 75% at 50% 46%, transparent 55%, rgba(2, 3, 10, 0.55) 100%);
}

/* ambient soundtrack toggle */
.ambient-toggle {
    position: fixed;
    right: 1.4rem;
    bottom: 1.4rem;
    width: 2.6rem;
    height: 2.6rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--c-gold-bright);
    font-size: 1.05rem;
    cursor: pointer;
    z-index: 20;
    transition: transform 0.2s, box-shadow 0.3s;
}
.ambient-toggle:hover { transform: scale(1.08); box-shadow: 0 0 18px rgba(123, 77, 255, 0.5); }
.ambient-toggle.muted { color: rgba(244, 231, 197, 0.4); }
.ambient-toggle:not(.muted)::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1px solid rgba(240, 215, 154, 0.35);
    animation: ambientPulse 2.8s ease-out infinite;
}
@keyframes ambientPulse {
    0% { transform: scale(0.9); opacity: 0.9; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* ---------- glass base ---------- */
.glass {
    background: var(--glass-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.cq-eyebrow {
    display: block;
    font-size: 0.68rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--c-gold-bright);
    margin-bottom: 0.5rem;
}

.cosmic-app h1, .cosmic-app h2 {
    font-family: var(--font-display);
    line-height: 1.08;
    margin: 0 0 0.6rem;
    text-shadow: 0 0 24px rgba(123, 77, 255, 0.5);
}
.cosmic-app h1 { font-size: clamp(2rem, 4vw, 3.2rem); color: var(--c-gold-bright); }
.cosmic-app h2 { font-size: clamp(1.2rem, 2.2vw, 1.7rem); color: var(--c-ivory); }
.cosmic-app p { color: rgba(244, 231, 197, 0.82); line-height: 1.6; font-size: 0.95rem; }

/* ---------- buttons ---------- */
.cq-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.3rem;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--c-ivory);
    background: rgba(123, 77, 255, 0.12);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    text-decoration: none;
}
.cq-btn:hover { transform: translateY(-2px); }
.cq-btn.primary {
    background: linear-gradient(135deg, rgba(123, 77, 255, 0.9), rgba(201, 164, 92, 0.55));
    border-color: var(--c-gold);
    box-shadow: 0 10px 30px rgba(123, 77, 255, 0.45);
}
.cq-btn.primary:hover { box-shadow: 0 14px 40px rgba(123, 77, 255, 0.6); }
.cq-btn.ghost { background: rgba(255, 255, 255, 0.04); }
.cq-btn.block { width: 100%; justify-content: center; }
.cq-btn.small { padding: 0.45rem 0.9rem; font-size: 0.82rem; }
.cq-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.cq-btn.loading { opacity: 0.7; pointer-events: none; }

/* ---------- intro (shop overview) ---------- */
.cosmic-intro {
    position: absolute;
    left: 2.5rem;
    bottom: 2.5rem;
    width: min(420px, 86vw);
    padding: 1.8rem;
    z-index: 5;
    transition: opacity 0.5s, transform 0.5s;
}
.cosmic-intro-actions { display: flex; gap: 0.7rem; margin: 1.2rem 0 1rem; flex-wrap: wrap; }
.cosmic-intro-status { display: flex; gap: 1.2rem; font-size: 0.8rem; color: rgba(244, 231, 197, 0.75); }
.cosmic-intro-status b { color: var(--c-gold-bright); }
.cosmic-drag-hint { display: block; margin-top: 1rem; font-size: 0.75rem; color: rgba(244, 231, 197, 0.5); }
body.in-room .cosmic-intro { opacity: 0; transform: translateY(20px); pointer-events: none; }

/* ---------- Astra bubble (room) ---------- */
.astra-bubble {
    position: absolute;
    left: 2.5rem;
    top: 5rem;
    width: min(340px, 84vw);
    padding: 1.2rem 1.4rem;
    z-index: 6;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.5s 0.3s, transform 0.5s 0.3s;
    pointer-events: none;
}
.astra-bubble p { margin: 0; color: var(--c-ivory); font-size: 0.92rem; }
body.in-room .astra-bubble { opacity: 1; transform: none; }

/* ---------- exit room ---------- */
.exit-room {
    position: absolute;
    right: 2.5rem;
    top: 5rem;
    padding: 0.55rem 1rem;
    z-index: 7;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 999px;
    cursor: pointer;
    color: var(--c-ivory);
    font-size: 0.85rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
}
body.in-room .exit-room { opacity: 1; pointer-events: auto; }

/* ---------- ritual panel (room) ---------- */
.cosmic-ritual {
    position: absolute;
    right: 2.5rem;
    bottom: 2.5rem;
    width: min(440px, 90vw);
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
    padding: 1.6rem;
    z-index: 8;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.5s 0.3s, transform 0.5s 0.3s;
    pointer-events: none;
}
body.in-room .cosmic-ritual { opacity: 1; transform: none; pointer-events: auto; }

/* progress */
.cq-progress { display: flex; gap: 0.4rem; margin-bottom: 1.2rem; }
.cq-progress span {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    color: rgba(244, 231, 197, 0.5);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(201, 164, 92, 0.18);
    text-transform: uppercase;
}
.cq-progress span i {
    width: 1.3rem; height: 1.3rem;
    display: grid; place-items: center;
    border-radius: 50%;
    font-style: normal;
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.06);
}
.cq-progress span.active { color: var(--c-gold-bright); border-bottom-color: var(--c-gold); }
.cq-progress span.active i { background: var(--c-violet); color: #fff; }
.cq-progress span.done i { background: var(--c-gold); color: #1a1140; }

/* panels */
.cq-panel { display: none; animation: cqFade 0.5s ease; }
.cq-panel.is-active { display: block; }
@keyframes cqFade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.cq-hint { font-size: 0.85rem; color: rgba(244, 231, 197, 0.65); }

/* ---------- conversational reveal (game-like step flow) ---------- */
/* children of the active panel rise in one after another; --d set by JS */
.cq-anim {
    animation: cqRise 0.55s cubic-bezier(0.22, 0.9, 0.32, 1.15) both;
    animation-delay: var(--d, 0s);
}
@keyframes cqRise {
    from { opacity: 0; transform: translateY(16px) scale(0.985); filter: blur(2px); }
    to   { opacity: 1; transform: none; filter: none; }
}

/* blinking caret while Astra / headings are typing */
.is-typing::after {
    content: "▍";
    margin-left: 2px;
    color: var(--c-gold-bright);
    animation: cqCaret 0.85s steps(1) infinite;
}
@keyframes cqCaret { 50% { opacity: 0; } }

/* gentle glow on the step's main call-to-action to guide the eye */
.cq-panel.is-active .cq-btn.primary:not(:disabled):not(.loading),
.gd-actions .cq-btn.primary:not(:disabled):not(.loading) {
    animation: cqRise 0.55s cubic-bezier(0.22, 0.9, 0.32, 1.15) both, cqCta 2.6s ease-in-out 1.4s infinite;
    animation-delay: var(--d, 0s), 1.4s;
}
@keyframes cqCta {
    0%, 100% { box-shadow: 0 10px 30px rgba(123, 77, 255, 0.45); }
    50%      { box-shadow: 0 10px 34px rgba(123, 77, 255, 0.7), 0 0 22px rgba(240, 215, 154, 0.35); }
}

@media (prefers-reduced-motion: reduce) {
    .cq-anim { animation: none; }
    .cq-panel.is-active .cq-btn.primary,
    .gd-actions .cq-btn.primary { animation: none; }
    .is-typing::after { animation: none; }
    .gd-spark { display: none; }
}

/* ---------- game dialogue box (RPG-style, bottom centre) ---------- */
.game-dialogue {
    position: absolute;
    left: 50%;
    bottom: 1.6rem;
    transform: translateX(-50%) translateY(30px);
    width: min(680px, 94vw);
    z-index: 8;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s 0.3s, transform 0.5s 0.3s;
}
body.in-room .game-dialogue { opacity: 1; transform: translateX(-50%); pointer-events: auto; }

.gd-progress { display: flex; justify-content: center; gap: 0.4rem; margin-bottom: 0.6rem; }
.gd-progress span {
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    font-size: 0.6rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(244, 231, 197, 0.42);
    background: rgba(16, 11, 34, 0.55);
    border: 1px solid rgba(201, 164, 92, 0.16);
    transition: all 0.35s;
}
.gd-progress span.active { color: var(--c-gold-bright); border-color: var(--c-gold); background: rgba(123, 77, 255, 0.28); box-shadow: 0 0 14px rgba(123, 77, 255, 0.35); }
.gd-progress span.done { color: rgba(240, 215, 154, 0.75); border-color: rgba(201, 164, 92, 0.45); }

.gd-box { position: relative; overflow: hidden; padding: 1.05rem 1.3rem 1.15rem; }

/* compact dialogue while the player must see/click the 3D cards behind it
   (stages: chọn lá / mở bài) */
body.gd-compact .game-dialogue { width: min(560px, 94vw); }
body.gd-compact .gd-box { padding: 0.65rem 1rem 0.7rem; }
body.gd-compact .gd-head { margin-bottom: 0.3rem; }
body.gd-compact .gd-head .gd-avatar { display: none; }
body.gd-compact .gd-box p#astraText { font-size: 0.85rem; line-height: 1.35; }
body.gd-compact .gd-reveal-list { max-height: 96px; }
body.gd-compact .gd-progress { margin-bottom: 0.35rem; }
.gd-head { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 0.5rem; }
.gd-avatar {
    width: 2.3rem; height: 2.3rem;
    display: grid; place-items: center;
    border-radius: 50%;
    font-size: 1.1rem;
    color: #fff;
    background: linear-gradient(135deg, var(--c-violet), var(--c-gold));
    box-shadow: 0 0 16px rgba(123, 77, 255, 0.55);
    animation: gdBreathe 3.2s ease-in-out infinite;
}
@keyframes gdBreathe { 0%, 100% { box-shadow: 0 0 12px rgba(123, 77, 255, 0.45); } 50% { box-shadow: 0 0 22px rgba(123, 77, 255, 0.8); } }
.gd-name b { display: block; font-family: var(--font-display); font-size: 1.02rem; color: var(--c-gold-bright); line-height: 1.1; }
.gd-name small { font-size: 0.58rem; letter-spacing: 0.18em; text-transform: uppercase; color: rgba(244, 231, 197, 0.5); }
.gd-deck { margin-left: auto; display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.7rem; color: rgba(244, 231, 197, 0.55); }
#astraText { min-height: 2.7em; margin: 0.15rem 0 0.65rem; font-size: 0.98rem; line-height: 1.55; }

.gd-actions { display: flex; flex-direction: column; gap: 0.55rem; }
.gd-chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.gd-actions .cq-btn.chip {
    padding: 0.45rem 0.9rem;
    font-size: 0.84rem;
    background: rgba(255, 255, 255, 0.04);
}
.gd-actions .cq-btn.chip:hover { background: rgba(123, 77, 255, 0.3); border-color: var(--c-gold); }

.gd-field { position: relative; width: 100%; }
.gd-field textarea {
    width: 100%; min-height: 74px; resize: vertical;
    padding: 0.8rem 0.95rem; border-radius: 13px;
    background: rgba(5, 4, 16, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--c-ivory); font-size: 0.92rem; font-family: inherit;
}
.gd-field textarea:focus { outline: none; border-color: var(--c-gold); box-shadow: 0 0 0 3px rgba(201, 164, 92, 0.15); }
.gd-count { position: absolute; right: 0.7rem; bottom: 0.55rem; font-size: 0.68rem; color: rgba(244, 231, 197, 0.45); }

.gd-counter { font-size: 0.82rem; color: rgba(244, 231, 197, 0.7); margin-right: auto; }
.gd-counter b { color: var(--c-gold-bright); }
.gd-wait { display: flex; align-items: center; gap: 0.55rem; font-size: 0.85rem; color: rgba(244, 231, 197, 0.7); }
.gd-reveal-list { display: flex; flex-direction: column; gap: 0.4rem; max-height: 180px; overflow-y: auto; }

/* sparkle burst */
.gd-spark {
    position: absolute;
    z-index: 3;
    pointer-events: none;
    color: var(--c-gold-bright);
    font-size: 0.8rem;
    text-shadow: 0 0 8px rgba(240, 215, 154, 0.9);
    animation: gdSpark var(--dur, 0.8s) ease-out forwards;
}
@keyframes gdSpark {
    from { opacity: 1; transform: rotate(var(--ang)) translateY(0) scale(0.6); }
    to   { opacity: 0; transform: rotate(var(--ang)) translateY(calc(var(--dist) * -1)) scale(1.25); }
}

/* ---------- final reading overlay ---------- */
.result-wrap {
    position: fixed; inset: 0;
    display: grid; place-items: center;
    background: rgba(3, 2, 10, 0.6);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 30;
    animation: cqFade 0.4s ease;
}
.result-wrap .cq-result {
    position: relative;
    width: min(620px, 92vw);
    max-height: 82vh;
    overflow-y: auto;
    padding: 1.7rem 1.8rem;
    margin: 0;
}
.result-close {
    position: absolute; top: 0.8rem; right: 0.8rem;
    width: 2rem; height: 2rem;
    display: grid; place-items: center;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--c-ivory); cursor: pointer;
}
.result-close:hover { background: rgba(123, 77, 255, 0.3); }

@media (max-width: 640px) {
    .game-dialogue { bottom: 0.8rem; width: calc(100vw - 1.2rem); }
    .gd-progress span { padding: 0.24rem 0.5rem; font-size: 0.54rem; }
    #astraText { font-size: 0.92rem; }
}

/* topics */
.cq-topics { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.cq-topic {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.45rem 0.85rem; border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.03);
    color: rgba(244, 231, 197, 0.8); cursor: pointer; font-size: 0.82rem;
    transition: all 0.2s;
}
.cq-topic.active { background: rgba(123, 77, 255, 0.35); border-color: var(--c-gold); color: #fff; }

/* field */
.cq-field { position: relative; margin-bottom: 1rem; }
.cq-field textarea {
    width: 100%; min-height: 96px; resize: vertical;
    padding: 0.9rem 1rem; border-radius: 14px;
    background: rgba(5, 4, 16, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--c-ivory); font-size: 0.95rem; font-family: inherit;
}
.cq-field textarea:focus { outline: none; border-color: var(--c-gold); box-shadow: 0 0 0 3px rgba(123, 77, 255, 0.25); }
.cq-count { position: absolute; right: 0.7rem; bottom: 0.6rem; font-size: 0.72rem; color: rgba(244, 231, 197, 0.5); }
.cq-count b { color: var(--c-gold-bright); }

/* free limit */
.cq-free-limit {
    background: rgba(123, 77, 255, 0.12);
    border: 1px solid var(--glass-border);
    border-radius: 14px; padding: 1rem; margin-bottom: 1rem;
}
.cq-free-limit strong { color: var(--c-gold-bright); display: block; margin-bottom: 0.3rem; }
.cq-free-limit p { font-size: 0.82rem; margin: 0 0 0.7rem; }

/* deck grid */
.cq-deck-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin: 1rem 0; }
.cq-deck {
    position: relative; text-align: left; cursor: pointer;
    padding: 0.9rem; border-radius: 14px; overflow: hidden;
    background: rgba(5, 4, 16, 0.5);
    border: 1px solid var(--glass-border); color: var(--c-ivory);
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.cq-deck:hover { transform: translateY(-3px); }
.cq-deck.selected { border-color: var(--c-gold); box-shadow: 0 0 0 2px rgba(201, 164, 92, 0.4), 0 12px 30px rgba(123, 77, 255, 0.4); }
.cq-deck-aura {
    position: absolute; inset: -40% -40% auto auto; width: 120px; height: 120px;
    background: radial-gradient(circle, rgba(123, 77, 255, 0.5), transparent 70%);
    opacity: 0; transition: opacity 0.3s;
}
.cq-deck.selected .cq-deck-aura, .cq-deck:hover .cq-deck-aura { opacity: 1; }
.cq-deck small { display: block; font-size: 0.65rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--c-gold); }
.cq-deck strong { display: block; font-family: var(--font-display); font-size: 1rem; margin: 0.2rem 0; }
.cq-deck span { display: block; font-size: 0.74rem; color: rgba(244, 231, 197, 0.65); line-height: 1.4; }
.cq-deck em { display: block; margin-top: 0.4rem; font-size: 0.68rem; color: var(--c-gold-bright); font-style: normal; }

/* actions */
.cq-actions { display: flex; gap: 0.7rem; margin-top: 1.2rem; }
.cq-actions.center { justify-content: center; }
.cq-actions .cq-btn { flex: 1; justify-content: center; }
.cq-actions.center .cq-btn { flex: 0 1 auto; }

/* counter */
.cq-counter { font-size: 0.9rem; color: rgba(244, 231, 197, 0.7); margin-top: 0.5rem; }
.cq-counter strong { color: var(--c-gold-bright); font-size: 1.3rem; margin-left: 0.4rem; }

/* reveal list */
.cq-reveal-list { display: flex; flex-direction: column; gap: 0.6rem; margin: 1rem 0; }
.cq-reveal-row {
    padding: 0.7rem 0.9rem; border-radius: 12px;
    background: rgba(5, 4, 16, 0.5); border: 1px solid var(--glass-border);
    animation: cqFade 0.5s ease;
}
.cq-reveal-row small { color: var(--c-gold); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; }
.cq-reveal-row strong { display: block; font-family: var(--font-display); font-size: 1rem; margin: 0.15rem 0; }
.cq-reveal-row span { font-size: 0.78rem; color: rgba(244, 231, 197, 0.65); }

/* clarify */
.cq-clarify { margin-top: 1rem; }
.cq-clarify-list label { display: block; margin-bottom: 0.8rem; }
.cq-clarify-list span { display: block; font-size: 0.82rem; color: var(--c-gold-bright); margin-bottom: 0.35rem; }
.cq-clarify-list textarea {
    width: 100%; min-height: 56px; resize: vertical; padding: 0.6rem 0.8rem;
    border-radius: 10px; background: rgba(5, 4, 16, 0.6);
    border: 1px solid var(--glass-border); color: var(--c-ivory); font-family: inherit; font-size: 0.88rem;
}
.cq-clarify-list textarea:focus { outline: none; border-color: var(--c-gold); }

/* connecting */
.cq-connecting { display: flex; align-items: center; gap: 0.6rem; margin-top: 1rem; color: var(--c-gold-bright); font-size: 0.88rem; }
.cq-spinner {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid rgba(201, 164, 92, 0.3); border-top-color: var(--c-gold);
    animation: cqSpin 0.8s linear infinite;
}
@keyframes cqSpin { to { transform: rotate(360deg); } }

/* result */
.cq-result { margin-top: 1rem; animation: cqFade 0.6s ease; }
.cq-result-body { font-size: 0.9rem; line-height: 1.7; color: rgba(244, 231, 197, 0.9); }
.cq-result-body p { margin: 0 0 0.8rem; }
.cq-follow { margin-top: 1.2rem; display: flex; flex-direction: column; gap: 0.6rem; padding-top: 1rem; border-top: 1px solid var(--glass-border); }
.cq-follow input, .cq-follow textarea {
    padding: 0.6rem 0.8rem; border-radius: 10px; background: rgba(5, 4, 16, 0.6);
    border: 1px solid var(--glass-border); color: var(--c-ivory); font-family: inherit; font-size: 0.88rem;
}
.cq-follow-thanks h3 { color: var(--c-gold-bright); font-family: var(--font-display); }

/* ---------- fate gate ---------- */
.fate-gate {
    position: fixed; inset: 0; z-index: 20;
    display: grid; place-items: center;
    background: rgba(2, 3, 10, 0.7);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.fate-card { width: min(440px, 90vw); padding: 2rem; text-align: center; }
.fate-card p { margin: 0.6rem 0 0; }
.fate-wheel {
    position: relative; width: 200px; height: 200px; margin: 1.5rem auto;
    border-radius: 50%; cursor: pointer;
    border: 2px solid var(--c-gold);
    background: radial-gradient(circle, rgba(123, 77, 255, 0.4), rgba(5, 4, 16, 0.9));
    box-shadow: 0 0 50px rgba(123, 77, 255, 0.5), inset 0 0 30px rgba(123, 77, 255, 0.3);
    color: var(--c-gold-bright); display: grid; place-items: center;
    transition: transform 0.4s;
}
.fate-wheel:hover { transform: scale(1.04); }
.fate-wheel.spinning { animation: fateSpin 1.2s cubic-bezier(0.3, 0, 0.2, 1); }
@keyframes fateSpin { to { transform: rotate(1080deg); } }
.fate-wheel-ring { position: absolute; inset: 0; display: grid; place-items: center; font-size: 0.9rem; letter-spacing: 0.3em; opacity: 0.5; }
.fate-wheel b { font-family: var(--font-display); font-size: 1.3rem; }
.fate-amount { display: block; font-family: var(--font-display); font-size: 2.4rem; color: var(--c-gold-bright); margin: 1rem 0; }
.cq-qr { margin: 1rem auto; max-width: 240px; }
.cq-qr img { width: 100%; border-radius: 12px; border: 1px solid var(--glass-border); }
.cq-qr-empty { padding: 2rem; border: 1px dashed var(--glass-border); border-radius: 12px; color: rgba(244, 231, 197, 0.5); }

/* ---------- toast ---------- */
.cosmic-toast {
    position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%);
    z-index: 40; padding: 0.8rem 1.4rem; border-radius: 999px;
    background: rgba(16, 11, 34, 0.92); border: 1px solid var(--glass-border);
    color: var(--c-ivory); font-size: 0.88rem;
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.cosmic-toast.error { border-color: rgba(255, 120, 120, 0.6); color: #ffd5d5; }

/* ---------- fade curtain ---------- */
.cosmic-fade {
    position: fixed; inset: 0; z-index: 30;
    background: radial-gradient(circle at center, rgba(123, 77, 255, 0.95), rgba(5, 4, 16, 1));
    opacity: 0; pointer-events: none;
}

/* ---------- fallback ---------- */
.cosmic-fallback {
    position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
    text-align: center; padding: 2rem; background: var(--c-navy);
}
.cosmic-fallback > div { max-width: 460px; }

/* ---------- responsive ---------- */
@media (max-width: 768px) {
    /* compact intro: the full card covered the whole viewport on phones */
    .cosmic-intro { left: 1rem; right: 1rem; bottom: 1rem; width: auto; padding: 0.9rem 1.1rem; }
    .cosmic-intro > p { display: none; }
    .cosmic-app .cosmic-intro h1 { font-size: 1.3rem; margin: 0.15rem 0 0; }
    .cosmic-intro h1 br { display: none; }
    .cosmic-intro .cq-eyebrow { font-size: 0.62rem; }
    .cosmic-intro-actions { margin: 0.65rem 0 0.6rem; gap: 0.5rem; }
    .cosmic-intro-actions .cq-btn { padding: 0.45rem 0.95rem; font-size: 0.82rem; }
    .cosmic-intro-status { gap: 0.9rem; font-size: 0.72rem; flex-wrap: wrap; }
    .cosmic-drag-hint { margin-top: 0.5rem; font-size: 0.68rem; }
    .astra-bubble { left: 1rem; right: 1rem; top: 4.2rem; width: auto; }
    .exit-room { right: 1rem; top: 4.2rem; }
    .cosmic-ritual {
        left: 0; right: 0; bottom: 0; width: 100%; max-height: 64vh;
        border-radius: 22px 22px 0 0;
    }
    .cq-deck-grid { grid-template-columns: 1fr; }
    .cosmic-app h1 { font-size: 2rem; }
}

/* ---------- account panel (Hồ sơ / Lịch sử / Manifest) ---------- */
.account-panel {
    position: absolute;
    right: 2.5rem;
    top: 50%;
    transform: translateY(-50%) translateX(28px);
    width: min(360px, 88vw);
    padding: 1.6rem;
    z-index: 6;
    opacity: 0;
    transition: opacity 0.45s, transform 0.45s;
    pointer-events: none;
}
.account-panel.open { opacity: 1; transform: translateY(-50%); pointer-events: auto; }
.account-panel h2 { margin: 0.2rem 0 1rem; font-size: 1.4rem; }
.account-items { display: flex; flex-direction: column; gap: 0.6rem; }
.account-item {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    text-align: left;
    font: inherit;
    transition: background 0.25s, transform 0.25s, border-color 0.25s;
}
.account-item:hover { background: rgba(123, 77, 255, 0.16); border-color: var(--c-gold); transform: translateX(-3px); }
.account-item i { font-size: 1.35rem; color: var(--c-gold-bright); }
.account-item b { display: block; font-size: 0.95rem; }
.account-item small { color: rgba(244, 231, 197, 0.6); font-size: 0.78rem; }
@media (max-width: 640px) {
    .account-panel { right: 1rem; left: 1rem; width: auto; }
}
