:root {
    color-scheme: light;

    --main-color: #2b2620;
    --background-color: #f6efe8;
    --surface-color: #fff7f0;
    --panel-color: #f2ddd2;
    --highlight-color: #b66a4f;
    --muted-color: #7f6b59;
    --border-color: rgba(45, 42, 37, 0.12);
    --shadow-soft: rgba(45, 42, 37, 0.12);
    --shadow-bright: rgba(255, 255, 255, 0.86);

    font-family: "Quicksand", sans-serif;
    font-optical-sizing: auto;
}

.title-font {
    font-family: "Croissant One", serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100dvh;
    background: radial-gradient(circle at top, #f0dfd4 0%, var(--background-color) 65%);
    color: var(--main-color);
}

.page-shell {
    max-width: 420px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 1.5rem;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.page-header {
    flex-shrink: 0;
}

.page-heading {
    display: grid;
    gap: 0.4rem;
}

.eyebrow {
    margin: 0;
    color: var(--muted-color);
    font-size: 0.92rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.page-title {
    margin: 0;
    font-size: clamp(1.8rem, 5vw, 2.4rem);
    line-height: 1.15;
}

/* ===== Card stage ===== */

.card-stage {
    flex: 1;
    position: relative;
    min-height: 0;
}

.card-slot-back,
.card-slot-front {
    position: absolute;
    inset: 0;
}

.card-slot-back {
    z-index: 1;
    transform: translateY(8px) scale(0.97);
    transform-origin: bottom center;
}

.card-slot-front {
    z-index: 2;
}

/* ===== Deal animation ===== */

.card-stage.dealing .card-slot-front {
    animation: card-fly-away 380ms ease-in forwards;
}

.card-stage.dealing .card-slot-back {
    animation: card-rise-to-front 380ms ease-out forwards;
    z-index: 3;
}

@keyframes card-fly-away {
    to {
        transform: translateY(-110%) rotate(-6deg);
        opacity: 0;
    }
}

@keyframes card-rise-to-front {
    from {
        transform: translateY(8px) scale(0.97);
    }

    to {
        transform: none;
    }
}

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

.intro-card,
.prompt-card,
.error-card {
    height: 100%;
    background: linear-gradient(180deg, rgba(255, 247, 238, 0.98), rgba(255, 244, 236, 1));
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 28px;
    box-shadow: 14px 14px 24px var(--shadow-soft), -10px -10px 22px var(--shadow-bright);
}

.intro-card {
    padding: 2rem 1.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.25rem;
}

.prompt-card {
    overflow: hidden;
    position: relative;
}

.error-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem 1.75rem;
    background: linear-gradient(160deg, #faeae5, #f5e0da);
    border-color: rgba(182, 106, 79, 0.22);
}

/* ===== Card body ===== */

.card-body {
    height: 100%;
    overflow-y: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 2rem 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card-body::-webkit-scrollbar {
    display: none;
}

.followups {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.followup-item {
    margin: 0;
    font-size: 0.92rem;
    color: var(--muted-color);
    line-height: 1.65;
}

/* ===== Text ===== */

.intro-copy {
    margin: 0;
    line-height: 1.9;
    font-size: 1rem;
}

.respect-copy {
    margin: 0;
    padding-left: 1rem;
    border-left: 3px solid rgba(182, 106, 79, 0.32);
    color: #7f6b59;
    font-size: 0.95rem;
    line-height: 1.75;
    opacity: 0.92;
}

.prompt-text {
    margin: 0;
    line-height: 1.85;
    color: var(--main-color);
    font-size: 1.1rem;
}

.error-eyebrow {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #a04e35;
}

.error-message {
    margin: 0;
    line-height: 1.7;
    color: var(--muted-color);
    font-size: 0.97rem;
}


/* ===== Buttons ===== */

button {
    border: none;
    cursor: pointer;
    border-radius: 999px;
    font: inherit;
    padding: 0.95rem 1.4rem;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.primary-button {
    box-shadow: 12px 12px 20px rgba(45, 42, 37, 0.14), -8px -8px 18px rgba(255, 255, 255, 0.82);
    background: linear-gradient(180deg, #c58369, #ad5e44);
    color: var(--surface-color);
    width: 100%;
    justify-content: center;
    flex-shrink: 0;
}

.primary-button:disabled {
    opacity: 0.5;
    cursor: default;
    box-shadow: none;
    transform: none;
}

button:not(:disabled):hover,
button:not(:disabled):focus-visible {
    transform: translateY(-1px);
    box-shadow: 16px 16px 28px rgba(45, 42, 37, 0.16), -10px -10px 24px rgba(255, 255, 255, 0.82);
}

/* ===== Rating buttons ===== */

.rating-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
}

.rating-btn {
    background: none;
    border: none;
    padding: 0.15rem 0.3rem;
    font-size: 1.05rem;
    line-height: 1;
    border-radius: 6px;
    opacity: 0.3;
    cursor: pointer;
    box-shadow: none;
    transition: opacity 0.15s ease, transform 0.12s ease;
}

.rating-btn:hover,
.rating-btn:focus-visible {
    opacity: 0.75;
    transform: scale(1.2);
    box-shadow: none;
}

.rating-thanks {
    text-align: right;
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
    color: var(--muted-color);
    opacity: 0.55;
}

/* ===== Admin ===== */

.admin-shell {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    font-family: system-ui, sans-serif;
    font-size: 0.9rem;
    color: var(--main-color);
}

.admin-shell input,
.admin-shell textarea {
    font: inherit;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    background: #fff;
    color: var(--main-color);
}

.admin-shell textarea {
    resize: vertical;
    width: 100%;
    min-height: 52px;
}

.admin-shell button {
    font: inherit;
    font-size: 0.8rem;
    padding: 0.3rem 0.65rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: #ede8e3;
    color: var(--main-color);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: none;
    transform: none;
    transition: background 0.12s ease;
}

.admin-shell button:hover,
.admin-shell button:focus-visible {
    background: #e0d9d2;
    transform: none;
    box-shadow: none;
}

.admin-btn-danger {
    background: #f5e4e0 !important;
    color: #8b3a2a !important;
}

.admin-btn-danger:hover,
.admin-btn-danger:focus-visible {
    background: #ecd4cf !important;
}

/* Writing guide */
.admin-writing-guide {
    margin-bottom: 1.75rem;
    padding: 0.9rem 1.1rem;
    background: rgba(182, 106, 79, 0.06);
    border-left: 3px solid rgba(182, 106, 79, 0.3);
    border-radius: 0 6px 6px 0;
    font-size: 0.85rem;
    line-height: 1.65;
    color: var(--muted-color);
}

.admin-writing-guide p {
    margin: 0 0 0.6rem;
}

.admin-writing-guide p:last-child {
    margin-bottom: 0;
}

.admin-writing-guide strong {
    color: var(--main-color);
}

.admin-writing-guide-eg {
    opacity: 0.75;
    font-size: 0.82rem;
}

/* Add-story form */
.admin-add-form {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.75rem;
    display: grid;
    gap: 0.5rem;
}

.admin-label {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-color);
}

/* Story card */
.admin-story {
    border-left: 3px solid var(--highlight-color);
    background: var(--surface-color);
    border-radius: 0 6px 6px 0;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

.admin-story-fields form {
    display: grid;
    gap: 0.4rem;
}

.admin-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.admin-row input {
    flex: 1;
    min-width: 0;
    max-width: 200px;
    font-size: 0.8rem;
    color: var(--muted-color);
}

.admin-id {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted-color);
    white-space: nowrap;
    opacity: 0.6;
}

.admin-rating {
    font-size: 0.75rem;
    color: var(--highlight-color);
    white-space: nowrap;
    opacity: 0.85;
}

/* Followups */
.admin-followups {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-color);
    padding-left: 0.75rem;
}

.admin-followup {
    margin-bottom: 0.35rem;
    padding: 0.35rem 0.5rem;
    background: rgba(0, 0, 0, 0.025);
    border-radius: 4px;
}

.admin-followup form {
    display: flex;
    gap: 0.4rem;
    align-items: flex-start;
}

.admin-followup input[name="ordering"] {
    width: 52px;
    text-align: center;
    flex-shrink: 0;
}

.admin-followup textarea {
    flex: 1;
    min-width: 0;
    min-height: 36px;
}

.admin-followup input[name="created_at"] {
    width: 160px;
    flex-shrink: 0;
    font-size: 0.8rem;
    color: var(--muted-color);
}

/* Add-followup form */
.admin-add-followup {
    display: flex;
    gap: 0.4rem;
    align-items: flex-start;
    margin-top: 0.4rem;
    padding: 0.4rem 0.5rem;
    border: 1px dashed var(--border-color);
    border-radius: 4px;
}

.admin-add-followup input[name="ordering"] {
    width: 52px;
    flex-shrink: 0;
    text-align: center;
}

.admin-add-followup textarea {
    flex: 1;
    min-width: 0;
    min-height: 36px;
}