:root {
    --ink: #241815;
    --muted: #725f59;
    --paper: #fff8f1;
    --panel: #fffdf9;
    --accent: #d8325b;
    --accent-dark: #9f1d3b;
    --blue: #0f6f85;
    --green: #29845a;
    --shadow: 0 24px 70px rgba(76, 44, 34, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 12% 18%, rgba(255, 196, 68, 0.22), transparent 24rem),
        linear-gradient(145deg, #fff8f1 0%, #f7f0ff 45%, #eaf8f6 100%);
}

button,
input,
textarea {
    font: inherit;
}

.page-shell {
    width: min(1120px, calc(100% - 32px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 40px 0;
    display: grid;
    place-items: center;
}

.creator-grid {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
    gap: 28px;
    align-items: stretch;
}

.creator-panel,
.preview-panel,
.result-panel {
    background: rgba(255, 253, 249, 0.92);
    border: 1px solid rgba(82, 54, 42, 0.1);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.creator-panel,
.result-panel {
    padding: clamp(24px, 4vw, 46px);
}

.preview-panel {
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent-dark);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    line-height: 1.05;
    letter-spacing: 0;
}

h1 {
    max-width: 760px;
    font-size: clamp(2.15rem, 6vw, 4.35rem);
}

h2 {
    font-size: clamp(1.8rem, 4vw, 3rem);
}

.intro,
.preview-panel p,
.personal-message,
.sender,
[data-status] {
    color: var(--muted);
    line-height: 1.55;
}

.intro {
    max-width: 650px;
    margin: 18px 0 28px;
    font-size: 1.05rem;
}

.card-form {
    display: grid;
    gap: 18px;
}

label,
fieldset {
    display: grid;
    gap: 8px;
}

label span,
legend {
    color: #3c2a25;
    font-size: 0.95rem;
    font-weight: 750;
}

input,
textarea {
    width: 100%;
    border: 1px solid rgba(64, 42, 33, 0.18);
    border-radius: 8px;
    padding: 13px 14px;
    color: var(--ink);
    background: white;
    outline: none;
}

textarea {
    resize: vertical;
}

input:focus,
textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(15, 111, 133, 0.12);
}

small {
    color: #b4223d;
}

fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

.cake-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.cake-option {
    min-height: 74px;
    padding: 12px;
    border: 1px solid rgba(64, 42, 33, 0.14);
    border-radius: 8px;
    background: white;
    grid-template-columns: auto 1fr;
    align-items: center;
    cursor: pointer;
}

.cake-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.cake-option:has(input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(216, 50, 91, 0.12);
}

.cake-swatch {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

button,
.button-link {
    display: inline-flex;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    padding: 0 20px;
    color: white;
    background: var(--accent);
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.button-link:hover {
    background: var(--accent-dark);
}

.button-link.secondary {
    color: var(--ink);
    background: #f2e6dc;
}

.mini-stage {
    min-height: 230px;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.cake-preview,
.cake {
    position: relative;
    width: min(100%, 300px);
    aspect-ratio: 5 / 3;
}

.cake-preview img,
.cake img {
    position: absolute;
    z-index: 1;
    inset: 0;
    width: 96%;
    height: 96%;
    margin: auto;
    object-fit: contain;
    filter: drop-shadow(0 18px 24px rgba(55, 40, 34, 0.16));
    pointer-events: none;
    user-select: none;
}

.cake-swatch {
    background-position: center;
    background-repeat: no-repeat;
    background-size: 132%;
}

.cake-nata-maduixa.cake-swatch {
    background-image: url("/assets/images/cakes/nata-maduixa.png");
}

.cake-xocolata.cake-swatch {
    background-image: url("/assets/images/cakes/xocolata.png");
}

.cake-infantil.cake-swatch {
    background-image: url("/assets/images/cakes/infantil.png");
}

.cake-elegant.cake-swatch {
    background-image: url("/assets/images/cakes/elegant.png");
}

.preview-candles,
.candle-layer {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

.candle {
    position: absolute;
    width: var(--candle-width, 10px);
    height: var(--candle-height, 42px);
    transform: translate(-50%, -100%);
    transform-origin: 50% 100%;
    border-radius: 3px 3px 1px 1px;
    background: repeating-linear-gradient(
        135deg,
        #fff 0 5px,
        var(--stripe, #29a3a3) 5px 10px
    );
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.16);
}

.flame {
    position: absolute;
    left: 50%;
    top: -20px;
    width: calc(var(--candle-width, 10px) * 1.35);
    height: calc(var(--candle-width, 10px) * 2);
    border-radius: 50% 50% 45% 45%;
    background: radial-gradient(circle at 50% 70%, #fff7b0 0 22%, #ffb000 45%, #f04d2f 72%);
    transform: translateX(-50%);
    animation: flicker 0.22s infinite alternate ease-in-out;
    filter: drop-shadow(0 0 8px rgba(255, 168, 30, 0.75));
}

.candle.out .flame {
    opacity: 0;
    animation: none;
}

@keyframes flicker {
    from {
        transform: translateX(-50%) scale(0.92) rotate(-3deg);
    }
    to {
        transform: translateX(-50%) scale(1.08) rotate(3deg);
    }
}

.birthday-stage {
    width: 100%;
    text-align: center;
    display: grid;
    gap: 20px;
}

.message-area {
    max-width: 820px;
    margin: 0 auto;
}

.personal-message {
    white-space: normal;
    font-size: clamp(1.05rem, 2vw, 1.35rem);
}

.sender {
    font-weight: 800;
}

.cake-scene {
    position: relative;
    min-height: clamp(250px, 42vw, 420px);
    display: grid;
    place-items: center;
    overflow: visible;
}

.cake-scene .cake {
    width: min(720px, 92vw);
    max-width: 100%;
}

.birthday-page .page-shell {
    padding-block: 24px;
}

.controls {
    display: grid;
    justify-items: center;
    gap: 8px;
}

.controls button {
    min-width: min(330px, 100%);
}

.final-message {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 24px;
    color: white;
    background: rgba(36, 24, 21, 0.66);
}

.final-message[hidden] {
    display: none;
}

.final-message h2 {
    font-size: clamp(3.2rem, 13vw, 9rem);
    text-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.confetti-piece {
    position: fixed;
    top: -20px;
    z-index: 25;
    width: 10px;
    height: 16px;
    border-radius: 2px;
    animation: confetti-fall 2.4s linear forwards;
}

@keyframes confetti-fall {
    to {
        transform: translateY(110vh) rotate(720deg);
    }
}

.result-panel {
    width: min(720px, 100%);
}

.share-box {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.result-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 860px) {
    .page-shell {
        width: min(100% - 24px, 680px);
        padding: 24px 0;
    }

    .creator-grid {
        grid-template-columns: 1fr;
    }

    .cake-options,
    .share-box {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: clamp(2rem, 12vw, 3.6rem);
    }
}
