/* ============================================
   Thisgun Tarot – Mystical Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@400;700;900&display=swap');

#thisgun-tarot-app {
    --clr-bg: #0d0b1a;
    --clr-surface: #1a1530;
    --clr-surface2: #251f42;
    --clr-gold: #d4a843;
    --clr-gold-light: #f0d07a;
    --clr-purple: #7b5ea7;
    --clr-purple-light: #a78bdb;
    --clr-text: #e8e0f0;
    --clr-text-dim: #9a8fb5;
    --clr-card-back: #2a1f4e;
    --clr-accent: #e84393;
    --radius: 12px;
    --shadow: 0 8px 32px rgba(0,0,0,.5);

    font-family: 'Noto Serif KR', 'Georgia', serif;
    background: var(--clr-bg);
    color: var(--clr-text);
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px 60px;
    min-height: 80vh;
    position: relative;
    overflow: hidden;
}

#thisgun-tarot-app *,
#thisgun-tarot-app *::before,
#thisgun-tarot-app *::after {
    box-sizing: border-box;
}

/* Background stars */
#thisgun-tarot-app::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,.4) 50%, transparent 50%),
        radial-gradient(1px 1px at 40% 60%, rgba(255,255,255,.3) 50%, transparent 50%),
        radial-gradient(1.5px 1.5px at 70% 30%, rgba(255,255,255,.5) 50%, transparent 50%),
        radial-gradient(1px 1px at 90% 80%, rgba(255,255,255,.3) 50%, transparent 50%),
        radial-gradient(1px 1px at 25% 90%, rgba(255,255,255,.4) 50%, transparent 50%),
        radial-gradient(1.5px 1.5px at 55% 10%, rgba(255,255,255,.35) 50%, transparent 50%),
        radial-gradient(1px 1px at 80% 50%, rgba(255,255,255,.3) 50%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

#thisgun-tarot-app > * {
    position: relative;
    z-index: 1;
}

/* Sections */
.tarot-section {
    display: none;
    animation: fadeUp .5s ease;
}

.tarot-section.active {
    display: block;
}

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

/* Header */
.tarot-header {
    text-align: center;
    padding: 40px 0 20px;
}

.tarot-logo {
    font-size: 48px;
    color: var(--clr-gold);
    text-shadow: 0 0 20px rgba(212,168,67,.6);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.1); }
}

.tarot-header h1 {
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--clr-gold), var(--clr-gold-light), var(--clr-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 12px 0 8px;
}

.tarot-subtitle {
    color: var(--clr-text-dim);
    font-size: .95rem;
    margin: 0;
}

/* Spread Selection */
.spread-selection {
    text-align: center;
    margin-top: 40px;
}

.spread-selection h2 {
    font-size: 1.2rem;
    color: var(--clr-purple-light);
    margin-bottom: 24px;
}

.spread-options {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.spread-btn {
    background: var(--clr-surface);
    border: 2px solid var(--clr-purple);
    border-radius: var(--radius);
    padding: 28px 24px;
    color: var(--clr-text);
    cursor: pointer;
    transition: all .3s ease;
    width: 200px;
    text-align: center;
    font-family: inherit;
}

.spread-btn:hover {
    border-color: var(--clr-gold);
    background: var(--clr-surface2);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(212,168,67,.2);
}

.spread-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.spread-btn strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 6px;
    color: var(--clr-gold);
}

.spread-btn span {
    font-size: .85rem;
    color: var(--clr-text-dim);
}

/* History toggle */
.history-toggle {
    text-align: center;
    margin-top: 40px;
}

.btn-history {
    background: none;
    border: 1px solid var(--clr-purple);
    color: var(--clr-purple-light);
    padding: 10px 24px;
    border-radius: 24px;
    cursor: pointer;
    font-family: inherit;
    font-size: .9rem;
    transition: all .3s;
}

.btn-history:hover {
    background: var(--clr-purple);
    color: #fff;
}

/* Buttons */
.btn-primary {
    display: inline-block;
    background: linear-gradient(135deg, var(--clr-gold), #c4922e);
    color: #1a1530;
    border: none;
    padding: 14px 36px;
    border-radius: 28px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all .3s;
    margin: 8px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212,168,67,.4);
}

.btn-primary:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.btn-secondary {
    display: inline-block;
    background: none;
    border: 1px solid var(--clr-text-dim);
    color: var(--clr-text-dim);
    padding: 10px 24px;
    border-radius: 24px;
    font-size: .9rem;
    font-family: inherit;
    cursor: pointer;
    transition: all .3s;
    margin: 8px;
}

.btn-secondary:hover {
    border-color: var(--clr-text);
    color: var(--clr-text);
}

/* ============================================
   Card Pool (selection screen)
   ============================================ */

.card-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 20px 0;
    max-width: 800px;
    margin: 0 auto;
}

.pool-card {
    width: 60px;
    height: 90px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .3s ease;
    position: relative;
    transform-style: preserve-3d;
}

.pool-card .card-back-mini {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    background: linear-gradient(135deg, #2a1f4e, #3d2d6b);
    border: 1.5px solid var(--clr-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.pool-card .card-back-mini::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(212,168,67,.3);
    border-radius: 6px;
}

.pool-card .card-back-mini::after {
    content: '★';
    font-size: 18px;
    color: var(--clr-gold);
    opacity: .6;
}

.pool-card:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 8px 20px rgba(123,94,167,.4);
}

.pool-card.selected {
    transform: translateY(-12px) scale(1.1);
    box-shadow: 0 12px 28px rgba(212,168,67,.5);
}

.pool-card.selected .card-back-mini {
    border-color: var(--clr-gold);
    background: linear-gradient(135deg, #3d2d6b, #4e3a80);
}

.pool-card.selected .card-back-mini::after {
    content: '✓';
    opacity: 1;
    font-size: 22px;
}

.select-status {
    text-align: center;
    margin: 16px 0;
    color: var(--clr-gold);
    font-size: 1.1rem;
}

#tarot-select {
    text-align: center;
}

#tarot-select h2 {
    color: var(--clr-gold);
    font-size: 1.4rem;
}

/* ============================================
   Result Cards
   ============================================ */

.result-cards {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
    padding: 30px 0;
}

.result-card-wrapper {
    perspective: 800px;
    width: 160px;
}

.result-card {
    width: 160px;
    height: 260px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform .8s ease;
    cursor: pointer;
}

.result-card.flipped {
    transform: rotateY(180deg);
}

.result-card.reversed.flipped {
    transform: rotateY(180deg) rotate(180deg);
}

.card-face {
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    backface-visibility: hidden;
    overflow: hidden;
}

/* Card Back */
.card-back {
    background: linear-gradient(145deg, #1e1545, #2d1f5e, #1e1545);
    border: 2px solid var(--clr-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.card-back::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(212,168,67,.35);
    border-radius: 8px;
}

.card-back-pattern {
    width: 80%;
    height: 80%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-back-pattern::before {
    content: '☽';
    font-size: 48px;
    color: var(--clr-gold);
    opacity: .5;
    text-shadow: 0 0 20px rgba(212,168,67,.3);
}

.card-back-pattern::after {
    content: '';
    position: absolute;
    width: 70px;
    height: 70px;
    border: 1px solid rgba(212,168,67,.2);
    border-radius: 50%;
    animation: spinSlow 20s linear infinite;
}

@keyframes spinSlow {
    to { transform: rotate(360deg); }
}

/* Card Front */
.card-front {
    background: linear-gradient(170deg, #f5f0e8, #e8dcc8);
    border: 2px solid var(--clr-gold);
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #2a1f4e;
    padding: 12px 8px;
    text-align: center;
}

.card-number {
    font-size: .7rem;
    color: var(--clr-purple);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-symbol {
    font-size: 52px;
    margin: 8px 0;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.15));
}

.card-name-kr {
    font-size: 1rem;
    font-weight: 900;
    color: #2a1f4e;
    margin: 4px 0 2px;
}

.card-name-en {
    font-size: .65rem;
    color: #7b5ea7;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.card-keyword {
    margin-top: auto;
    font-size: .72rem;
    color: var(--clr-purple);
    padding: 4px 8px;
    border-top: 1px solid rgba(123,94,167,.3);
    width: 100%;
}

.card-reversed-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--clr-accent);
    color: #fff;
    font-size: .6rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    z-index: 2;
}

/* Position label above card */
.card-position-label {
    text-align: center;
    color: var(--clr-gold);
    font-size: .9rem;
    margin-bottom: 10px;
    font-weight: 700;
}

/* ============================================
   Interpretation
   ============================================ */

#tarot-result {
    text-align: center;
}

#tarot-result h2 {
    font-size: 1.5rem;
    color: var(--clr-gold);
}

.result-interpretation {
    max-width: 700px;
    margin: 10px auto 30px;
    text-align: left;
}

.interp-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-purple);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    animation: fadeUp .6s ease;
}

.interp-card h3 {
    color: var(--clr-gold);
    font-size: 1.15rem;
    margin: 0 0 4px;
}

.interp-card .interp-position {
    color: var(--clr-purple-light);
    font-size: .85rem;
    margin-bottom: 12px;
}

.interp-card .interp-direction {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.interp-card .interp-direction.upright {
    background: rgba(123,94,167,.3);
    color: var(--clr-purple-light);
}

.interp-card .interp-direction.reversed {
    background: rgba(232,67,147,.2);
    color: var(--clr-accent);
}

.interp-card .interp-meaning {
    color: var(--clr-text);
    line-height: 1.7;
    font-size: .92rem;
}

.interp-summary {
    background: linear-gradient(135deg, var(--clr-surface2), var(--clr-surface));
    border: 1px solid var(--clr-gold);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 24px;
}

.interp-summary h3 {
    color: var(--clr-gold);
    margin: 0 0 12px;
}

.interp-summary p {
    color: var(--clr-text);
    line-height: 1.7;
    font-size: .92rem;
}

.result-actions {
    text-align: center;
    margin-top: 20px;
}

/* ============================================
   History
   ============================================ */

#tarot-history {
    text-align: center;
}

#tarot-history h2 {
    color: var(--clr-gold);
    font-size: 1.4rem;
    margin-bottom: 20px;
}

.history-list {
    max-width: 700px;
    margin: 0 auto 24px;
    text-align: left;
}

.history-item {
    background: var(--clr-surface);
    border: 1px solid var(--clr-purple);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    cursor: pointer;
    transition: all .3s;
}

.history-item:hover {
    border-color: var(--clr-gold);
    background: var(--clr-surface2);
}

.history-info {
    flex: 1;
    min-width: 200px;
}

.history-date {
    font-size: .8rem;
    color: var(--clr-text-dim);
}

.history-spread {
    font-size: .95rem;
    color: var(--clr-gold);
    font-weight: 700;
    margin-top: 2px;
}

.history-cards-preview {
    font-size: .85rem;
    color: var(--clr-text-dim);
    margin-top: 4px;
}

.history-delete {
    background: none;
    border: 1px solid rgba(232,67,147,.4);
    color: var(--clr-accent);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: .75rem;
    font-family: inherit;
    transition: all .3s;
}

.history-delete:hover {
    background: var(--clr-accent);
    color: #fff;
}

.history-loading,
.history-empty {
    text-align: center;
    color: var(--clr-text-dim);
    padding: 40px 0;
}

/* Expanded history detail */
.history-detail {
    width: 100%;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(123,94,167,.3);
    display: none;
}

.history-item.expanded .history-detail {
    display: block;
}

.history-detail-card {
    margin-bottom: 8px;
    padding: 8px 12px;
    background: rgba(123,94,167,.1);
    border-radius: 8px;
    font-size: .85rem;
    line-height: 1.5;
}

.history-detail-card strong {
    color: var(--clr-gold);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 600px) {
    .tarot-header h1 {
        font-size: 1.5rem;
    }

    .spread-options {
        flex-direction: column;
        align-items: center;
    }

    .spread-btn {
        width: 100%;
        max-width: 280px;
    }

    .pool-card {
        width: 48px;
        height: 72px;
    }

    .pool-card .card-back-mini::after {
        font-size: 14px;
    }

    .result-card-wrapper {
        width: 130px;
    }

    .result-card {
        width: 130px;
        height: 210px;
    }

    .card-symbol {
        font-size: 38px;
    }

    .card-name-kr {
        font-size: .9rem;
    }
}

/* Flip instruction hint */
.flip-hint {
    text-align: center;
    color: var(--clr-text-dim);
    font-size: .85rem;
    margin-bottom: 20px;
    animation: fadeUp .8s ease;
}
