:root {
    color-scheme: light;
    --bg: #f5f0e8;
    --paper: #fbf8f3;
    --paper-strong: #ffffff;
    --ink: #1c1713;
    --muted: #6d645c;
    --accent: #8b3c31;
    --line: rgba(28, 23, 19, 0.12);
    --line-strong: rgba(28, 23, 19, 0.18);
    --shadow: 0 18px 56px rgba(28, 23, 19, 0.06);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    font-family: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
    color: var(--ink);
    background: linear-gradient(180deg, #f8f3eb 0%, var(--bg) 100%);
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: inherit;
}

.tarot-page {
    width: min(920px, calc(100vw - 24px));
    margin: 0 auto;
    padding: 10px 0 28px;
}

.tarot-section,
.result-shell {
    display: grid;
    gap: 26px;
}

.tarot-section--compact {
    min-height: 40vh;
    align-content: center;
}

.tarot-intro {
    display: grid;
    gap: 10px;
    text-align: center;
}

.tarot-intro--result {
    gap: 16px;
}

.tarot-eyebrow,
.card-position,
.question-label,
.field-note {
    margin: 0;
    font-family: "Helvetica Neue", "Segoe UI", sans-serif;
    font-size: 0.74rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
}

.tarot-eyebrow--left {
    text-align: left;
}

.tarot-title {
    margin: 0;
    font-size: clamp(2.8rem, 8vw, 4.6rem);
    line-height: 0.94;
    font-weight: 600;
    letter-spacing: -0.04em;
}

.tarot-copy,
.subtle-note,
.field-hint,
.form-footnote,
.status-text,
.card-meaning,
.question-text,
.interpretation-body,
.waiting-panel p {
    margin: 0;
    font-size: 1.06rem;
    line-height: 1.6;
    color: var(--muted);
}

.message-stack,
.reading-form,
.promo-form,
.result-actions,
.result-actions-secondary {
    display: grid;
    gap: 12px;
}

.tarot-message {
    padding: 14px 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.74);
    font-size: 1rem;
    line-height: 1.5;
}

.tarot-message--success {
    border-color: rgba(73, 110, 70, 0.28);
    color: #496e46;
}

.tarot-message--error {
    border-color: rgba(139, 60, 49, 0.28);
    color: #7a3a31;
}

.tarot-panel,
.question-panel,
.interpretation-panel,
.drawn-card,
.cooldown-panel {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow);
}

.tarot-panel {
    padding: 24px;
    display: grid;
    gap: 22px;
}

.cooldown-panel {
    padding: 20px;
    display: grid;
    gap: 18px;
}

.panel-title {
    margin: 0;
    font-size: clamp(1.7rem, 4vw, 2.4rem);
    line-height: 1;
    font-weight: 600;
}

.countdown {
    font-size: clamp(2.4rem, 6vw, 3.6rem);
    line-height: 1;
}

.promo-panel {
    display: grid;
    gap: 12px;
}

.promo-form {
    grid-template-columns: minmax(0, 1fr);
}

.reading-form {
    gap: 18px;
}

.field-group {
    display: grid;
    gap: 8px;
}

.field-label {
    font-size: 1.2rem;
    line-height: 1.2;
}

.field-note {
    margin-left: 8px;
}

.field-error {
    margin: 0;
    color: #7a3a31;
    font-size: 0.95rem;
}

.form-input {
    width: 100%;
    padding: 15px 16px;
    border: 1px solid var(--line);
    background: rgba(251, 248, 243, 0.96);
    color: var(--ink);
    border-radius: 0;
    appearance: none;
}

select.form-input,
input.form-input,
textarea.form-input {
    background-color: rgba(251, 248, 243, 0.96);
    color: var(--ink);
}

.form-input::placeholder {
    color: rgba(109, 100, 92, 0.78);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 60, 49, 0.08);
}

textarea.form-input {
    min-height: 160px;
    resize: vertical;
}

.action-block {
    display: grid;
    gap: 10px;
    padding-top: 6px;
}

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-width: 180px;
    padding: 15px 18px;
    border: 1px solid var(--line-strong);
    border-radius: 0;
    font-family: "Helvetica Neue", "Segoe UI", sans-serif;
    font-size: 0.8rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-primary {
    width: 100%;
    background: var(--accent);
    color: var(--paper);
    border-color: var(--accent);
}

.btn-primary:hover {
    background: #733127;
    border-color: #733127;
}

.btn-secondary:hover {
    background: #f5ede1;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.86);
    color: var(--muted);
}

.btn-primary:disabled,
.btn-primary.is-loading {
    cursor: wait;
    opacity: 0.72;
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 10px;
    border: 2px solid rgba(139, 60, 49, 0.18);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-spinner--large {
    width: 34px;
    height: 34px;
    margin-right: 0;
    border-width: 3px;
}

.reading-layout {
    display: grid;
    gap: 24px;
}

.cards-grid {
    display: grid;
    width: min(100%, 640px);
    margin: 0 auto;
    gap: 18px 20px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
        ". top ."
        "left center right"
        ". bottom .";
    align-items: start;
}

.drawn-card {
    display: grid;
    gap: 14px;
    padding: 14px;
}

.cards-grid > .drawn-card:nth-child(1) {
    grid-area: center;
}

.cards-grid > .drawn-card:nth-child(2) {
    grid-area: top;
}

.cards-grid > .drawn-card:nth-child(3) {
    grid-area: left;
}

.cards-grid > .drawn-card:nth-child(4) {
    grid-area: right;
}

.cards-grid > .drawn-card:nth-child(5) {
    grid-area: bottom;
}

.card-figure {
    margin: 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--line);
}

.card-figure img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: contain;
}

.is-reversed .card-figure img {
    transform: rotate(180deg);
}

.card-meta {
    display: grid;
    gap: 8px;
}

.card-name {
    margin: 0;
    font-size: 1.65rem;
    line-height: 1;
    font-weight: 600;
}

.card-orientation {
    margin: 0;
    color: var(--accent);
    font-size: 0.98rem;
}

.question-panel,
.interpretation-panel {
    padding: 20px;
}

.question-text {
    font-size: clamp(1.4rem, 4vw, 2rem);
    line-height: 1.2;
    color: var(--ink);
}

.interpretation-panel {
    display: grid;
    gap: 16px;
    align-content: start;
}

.interpretation-header {
    display: grid;
    gap: 8px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.interpretation-body p {
    margin: 0 0 1em;
}

.waiting-panel {
    min-height: 220px;
    display: grid;
    gap: 14px;
    place-items: center;
    text-align: center;
}

.result-actions {
    justify-items: center;
}

.result-actions-secondary {
    grid-template-columns: repeat(2, minmax(0, max-content));
    justify-content: center;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@media (min-width: 960px) {
    .cards-column {
        display: flex;
        justify-content: center;
    }

    .cards-grid {
        width: min(100%, 640px);
    }

    .drawn-card {
        padding: 12px;
    }

    .card-figure {
        padding: 10px;
    }

    .card-name {
        font-size: 1.35rem;
    }

    .card-meaning {
        font-size: 0.96rem;
        line-height: 1.45;
    }
}

@media (max-width: 640px) {
    .tarot-page {
        width: min(100vw - 12px, 920px);
        padding-bottom: 18px;
    }

    .tarot-panel,
    .question-panel,
    .interpretation-panel,
    .cooldown-panel {
        padding: 16px;
    }

    .cards-grid {
        width: min(100%, 360px);
        gap: 10px 8px;
    }

    .drawn-card {
        gap: 8px;
        padding: 8px;
    }

    .card-figure {
        padding: 6px;
    }

    .card-meta {
        gap: 5px;
    }

    .card-position {
        font-size: 0.54rem;
        letter-spacing: 0.12em;
    }

    .card-name {
        font-size: 0.98rem;
        line-height: 1.05;
    }

    .card-orientation {
        font-size: 0.78rem;
    }

    .card-meaning {
        font-size: 0.72rem;
        line-height: 1.28;
    }

    .result-actions-secondary {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
}

@media print {
    .result-actions {
        display: none !important;
    }

    body {
        background: #ffffff !important;
    }

    .tarot-panel,
    .question-panel,
    .interpretation-panel,
    .drawn-card,
    .cooldown-panel {
        box-shadow: none !important;
        background: #ffffff !important;
    }
}
