*, *::before, *::after { box-sizing: border-box; }

body {
    background: #010b19;
    font-family: 'Crimson Text', Georgia, serif;
    min-height: 100vh;
    overflow-x: hidden;
}

.font-cinzel { font-family: 'Cinzel', serif; }

/* ═══════════════════════════════════════
   CELESTIAL BACKGROUND
═══════════════════════════════════════ */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(15,40,90,0.6) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 80%, rgba(10,30,70,0.5) 0%, transparent 60%),
        radial-gradient(ellipse 100% 80% at 50% 50%, rgba(1,18,40,1) 0%, #010b19 100%);
    pointer-events: none;
    z-index: 0;
}

#starfield {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

/* Stars — warm gold tint */
.star {
    position: absolute;
    border-radius: 50%;
    background: #d4af37;
    animation: twinkle var(--dur, 3s) ease-in-out infinite;
    animation-delay: var(--delay, 0s);
}
/* Some stars are white-blue */
.star:nth-child(3n) { background: #e8f0ff; }
.star:nth-child(5n) { background: #fff8dc; }

@keyframes twinkle {
    0%, 100% { opacity: 0.12; transform: scale(1); }
    50%       { opacity: 0.9;  transform: scale(1.5); }
}

/* Constellation lines overlay */
#starfield::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(212,175,55,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(212,175,55,0.03) 1px, transparent 1px);
    background-size: 80px 80px;
}

/* ═══════════════════════════════════════
   CARD FLIP
═══════════════════════════════════════ */
.card-wrap {
    perspective: 1000px;
    width: 160px;
    height: 277px;
    cursor: pointer;
}
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.7s cubic-bezier(.4,0,.2,1);
}
.card-wrap.flipped .card-inner { transform: rotateY(180deg); }
.card-face {
    position: absolute;
    inset: 0;
    border-radius: 14px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

/* Back face — real card back image */
.card-back-face {
    background: url('images/CardBacks.jpg') center/cover no-repeat;
    border: 2px solid #c9a84c;
    box-shadow: 0 0 24px rgba(201,168,76,0.25);
}

/* Front face — real card image */
.card-front-face {
    transform: rotateY(180deg);
    border: 2px solid rgba(201,168,76,0.5);
    padding: 0;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(201,168,76,0.2);
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 12px;
    background: #0a0a0a;
}

.card-wrap:not(.flipped):hover .card-inner { transform: translateY(-10px) rotateX(3deg); }

/* ═══════════════════════════════════════
   GLOW / AESTHETIC
═══════════════════════════════════════ */
.glow-gold  { text-shadow: 0 0 12px rgba(212,175,55,.9), 0 0 30px rgba(212,175,55,.4), 0 0 60px rgba(212,175,55,.15); }
.glow-border{ box-shadow: 0 0 20px rgba(201,168,76,.4), 0 0 50px rgba(201,168,76,.15); }

.divider-mystic {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(201,168,76,0.3), #d4af37, rgba(201,168,76,0.3), transparent);
    position: relative;
}
.divider-mystic::before {
    content: '✦';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #d4af37;
    font-size: 10px;
    background: #010b19;
    padding: 0 8px;
}

/* Buttons */
.btn {
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    letter-spacing: .06em;
    border: none;
    border-radius: 4px;
    padding: 14px 32px;
    font-size: 1rem;
    transition: transform .2s, box-shadow .2s, background .2s;
    text-transform: uppercase;
}
.btn:hover  { transform: translateY(-3px); }
.btn:active { transform: translateY(0); }

/* Primary gold button */
.btn-purple {
    background: linear-gradient(135deg, #1a3a6e, #0d2247);
    color: #d4af37;
    border: 1px solid rgba(212,175,55,0.5);
    box-shadow: 0 4px 20px rgba(1,11,25,0.6), inset 0 1px 0 rgba(212,175,55,0.15);
}
.btn-purple:hover {
    background: linear-gradient(135deg, #1f4480, #122b59);
    box-shadow: 0 6px 28px rgba(1,11,25,0.8), 0 0 20px rgba(212,175,55,0.2);
    border-color: rgba(212,175,55,0.8);
}

/* Solid gold button */
.btn-gold {
    background: linear-gradient(135deg, #c9a84c, #a07830, #c9a84c);
    background-size: 200% 100%;
    color: #010b19;
    border: 1px solid #e8c96a;
    box-shadow: 0 4px 20px rgba(201,168,76,.3), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-gold:hover {
    background-position: right center;
    box-shadow: 0 6px 32px rgba(201,168,76,.55), 0 0 20px rgba(212,175,55,.3);
}

/* Input */
.inp {
    background: rgba(1,15,42,0.85);
    border: 1px solid rgba(201,168,76,0.25);
    color: #e8dfc0;
    border-radius: 4px;
    padding: 12px 16px;
    width: 100%;
    font-family: 'Crimson Text', serif;
    font-size: 1.05rem;
    transition: border-color .3s, box-shadow .3s;
    resize: none;
}
.inp::placeholder { color: rgba(201,168,76,0.3); }
.inp:focus {
    outline: none;
    border-color: rgba(212,175,55,0.7);
    box-shadow: 0 0 0 3px rgba(212,175,55,0.08), 0 0 16px rgba(212,175,55,0.15);
}

/* Orb loader */
.orb {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #e8c96a, #7a5a10, #3a2a05);
    animation: pulse-orb 1.4s ease-in-out infinite;
    margin: 0 auto;
    box-shadow: 0 0 0 8px rgba(212,175,55,0.08);
}
@keyframes pulse-orb {
    0%,100% { transform: scale(1);    box-shadow: 0 0 20px rgba(212,175,55,.4), 0 0 0 8px rgba(212,175,55,0.06); }
    50%      { transform: scale(1.12); box-shadow: 0 0 50px rgba(212,175,55,.8), 0 0 0 12px rgba(212,175,55,0.1); }
}

/* Result panel */
.result-panel {
    background: linear-gradient(160deg, rgba(1,15,42,.97), rgba(2,25,70,.93));
    border: 1px solid rgba(201,168,76,0.4);
    border-radius: 4px;
    box-shadow: 0 0 60px rgba(201,168,76,.12), inset 0 0 60px rgba(1,15,42,.5);
    animation: fadeUp .7s ease both;
    position: relative;
    overflow: hidden;
}
.result-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 40px,
        rgba(212,175,55,0.015) 40px,
        rgba(212,175,55,0.015) 41px
    );
    pointer-events: none;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Paragraph spacing in result */
#resultText p { margin-bottom: 1rem; }

::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track { background: #010b19; }
::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(212,175,55,0.6); }

.section-card {
    background: rgba(1,15,42,0.7);
    border: 1px solid rgba(201,168,76,0.2);
    border-radius: 4px;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 32px rgba(1,11,25,0.4), inset 0 1px 0 rgba(212,175,55,0.08);
}

.api-row { display: flex; gap: 10px; align-items: center; }

/* spread label */
.spread-label {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    color: #c9a84c;
    text-transform: uppercase;
    letter-spacing: .15em;
    margin-top: 8px;
    opacity: 0.8;
}

/* ═══════════════════════════════════════
   CARD ORIENTATION BADGE
═══════════════════════════════════════ */
.orient-badge {
    position: absolute;
    bottom: 6px;
    font-family: 'Cinzel', serif;
    font-size: 0.5rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 3px;
}
.orient-badge.upright  { color: #86efac; border: 1px solid rgba(134,239,172,0.35); }
.orient-badge.reversed { color: #f87171; border: 1px solid rgba(248,113,113,0.35); }

/* ═══════════════════════════════════════
   CARD GRID — mobile friendly
═══════════════════════════════════════ */
.cards-grid {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 24px;
    overflow-x: auto;
    padding-bottom: 8px;
}
@media (max-width: 560px) {
    .card-wrap { width: 100px; height: 173px; }
}

/* ═══════════════════════════════════════
   MARKDOWN RESULT TEXT
═══════════════════════════════════════ */
/* ═══════════════════════════════════════
   BOTTOM-LEFT WIDGET
═══════════════════════════════════════ */
#siteWidget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#visitorCounter,
#devCredit {
    background: rgba(1, 15, 42, 0.8);
    border: 1px solid rgba(201, 168, 76, 0.25);
    border-radius: 4px;
    padding: 6px 12px;
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    color: rgba(201, 168, 76, 0.75);
    backdrop-filter: blur(6px);
    letter-spacing: .05em;
}

#devCredit strong {
    color: #d4af37;
}

.result-text p   { margin-bottom: 1rem; }
.result-text h1,
.result-text h2,
.result-text h3  { font-family: 'Cinzel', serif; color: #d4af37; margin: 1.2rem 0 .5rem; }
.result-text strong { color: #e8c96a; }
.result-text em     { color: #c9b8ff; font-style: italic; }
.result-text ul,
.result-text ol  { padding-left: 1.4rem; margin-bottom: 1rem; }
.result-text li  { margin-bottom: .4rem; }
.result-text hr  { border-color: rgba(201,168,76,0.25); margin: 1.2rem 0; }
