:root {
    --cream: #fdf6ee;
    --blush: #e8b4a0;
    --rose: #c2706a;
    --deep: #6b2d3e;
    --warm: #f5e6d8;
    --gold: #c9975a;
    --text: #2a1a1a;
    --text-soft: #7a5a5a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Jost', sans-serif;
    background: var(--cream);
    color: var(--text);
    overflow-x: hidden;
    min-height: 100vh;
}

/* ── LOGOUT ── */
.btn-logout {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 50;
    font-family: 'Jost', sans-serif;
    font-weight: 200;
    font-size: 0.68rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--text-soft);
    text-decoration: none;
    opacity: 0.35;
    transition: opacity 0.2s;
    padding: 6px 2px;
}

.btn-logout:hover { opacity: 0.8; }

/* ── LANDING ── */
#page-landing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
    position: relative;
    overflow: hidden;
}

/* Decorative background */
#page-landing::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
            radial-gradient(ellipse 60% 50% at 10% 20%, rgba(232,180,160,0.25) 0%, transparent 70%),
            radial-gradient(ellipse 50% 60% at 90% 80%, rgba(194,112,106,0.15) 0%, transparent 70%),
            radial-gradient(ellipse 40% 40% at 50% 50%, rgba(245,230,216,0.5) 0%, transparent 80%);
    pointer-events: none;
    z-index: 0;
}

.petals {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.petal {
    position: absolute;
    top: -60px;
    font-size: 1.2rem;
    opacity: 0;
    animation: fall linear infinite;
    user-select: none;
}

@keyframes fall {
    0%   { transform: translateY(0) rotate(0deg); opacity: 0.7; }
    100% { transform: translateY(110vh) rotate(360deg); opacity: 0; }
}

.landing-inner {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 640px;
}

.eyebrow {
    font-family: 'Jost', sans-serif;
    font-weight: 200;
    font-size: 0.75rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 32px;
    animation: fadeUp 1s ease both;
}

.landing-title {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 300;
    font-size: clamp(3rem, 8vw, 5.5rem);
    line-height: 1.05;
    color: var(--deep);
    animation: fadeUp 1s 0.15s ease both;
    margin-bottom: 28px;
}

.landing-title em {
    font-style: normal;
    color: var(--rose);
    position: relative;
}

.landing-title em::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 0; right: 0;
    height: 2px;
    background: var(--blush);
    border-radius: 2px;
    animation: lineGrow 1.2s 0.8s ease both;
    transform-origin: left;
}

@keyframes lineGrow {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

.landing-desc {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.25rem;
    line-height: 1.75;
    color: var(--text-soft);
    margin-bottom: 48px;
    animation: fadeUp 1s 0.3s ease both;
    font-weight: 300;
}

.landing-desc strong {
    color: var(--rose);
    font-weight: 400;
}

.btn-play {
    display: inline-block;
    font-family: 'Jost', sans-serif;
    font-weight: 300;
    font-size: 0.8rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    padding: 18px 52px;
    background: transparent;
    border: 1px solid var(--rose);
    color: var(--rose);
    cursor: pointer;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    transition: color 0.4s;
    animation: fadeUp 1s 0.5s ease both;
}

.btn-play::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--rose);
    transform: translateX(-101%);
    transition: transform 0.4s cubic-bezier(0.76,0,0.24,1);
    z-index: 0;
}

.btn-play:hover::before { transform: translateX(0); }
.btn-play:hover { color: var(--cream); }
.btn-play span { position: relative; z-index: 1; }

.ornament {
    font-size: 1.5rem;
    color: var(--blush);
    margin-bottom: 24px;
    animation: fadeUp 1s 0.1s ease both;
    letter-spacing: 0.5em;
}

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

/* ── GAME PAGE ── */
#page-game {
    display: none;
    min-height: 100vh;
    padding: 40px 20px 80px;
    background: var(--cream);
    position: relative;
}

#page-game::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
            radial-gradient(ellipse 80% 40% at 50% 0%, rgba(232,180,160,0.2) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.game-header {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-bottom: 40px;
}

.game-title {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: clamp(2rem, 5vw, 3.2rem);
    color: var(--deep);
    font-weight: 300;
    margin-bottom: 8px;
}

.game-subtitle {
    font-family: 'Jost', sans-serif;
    font-weight: 200;
    font-size: 0.78rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 16px;
}

.progress-bar-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-family: 'Jost', sans-serif;
    font-size: 0.78rem;
    color: var(--text-soft);
    font-weight: 300;
}

.progress-bar {
    width: 200px;
    height: 2px;
    background: rgba(194,112,106,0.2);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blush), var(--rose));
    border-radius: 2px;
    transition: width 0.5s ease;
}

.grid-container {
    position: relative;
    z-index: 1;
    max-width: 860px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 8px;
}

@media (max-width: 600px) {
    .grid-container { grid-template-columns: repeat(5, 1fr); gap: 6px; }
}

.cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Jost', sans-serif;
    font-size: clamp(0.65rem, 1.5vw, 0.85rem);
    font-weight: 300;
    cursor: pointer;
    border: 1px solid rgba(194,112,106,0.25);
    background: rgba(255,255,255,0.6);
    color: var(--text-soft);
    transition: all 0.25s;
    position: relative;
    user-select: none;
    border-radius: 2px;
}

.cell:hover:not(.opened):not(.locked) {
    border-color: var(--blush);
    background: rgba(232,180,160,0.2);
    transform: scale(1.06);
    z-index: 2;
}

.cell.opened {
    background: linear-gradient(135deg, var(--deep), var(--rose));
    border-color: transparent;
    color: rgba(255,255,255,0.9);
    box-shadow: 0 4px 16px rgba(107,45,62,0.25);
}

.cell.opened::after {
    content: '♥';
    position: absolute;
    font-size: 0.55em;
    bottom: 3px;
    right: 4px;
    opacity: 0.5;
}

.cell.locked {
    background: rgba(245,230,216,0.4);
    border-color: rgba(194,112,106,0.15);
    color: rgba(122,90,90,0.3);
    cursor: not-allowed;
}

.cell.locked::before {
    content: '🔒';
    position: absolute;
    font-size: 0.7em;
    top: 2px;
    right: 2px;
    opacity: 0.4;
}

.cell.bounce {
    animation: cellBounce 0.4s ease;
}

@keyframes cellBounce {
    0%,100% { transform: scale(1); }
    40%     { transform: scale(1.18); }
    70%     { transform: scale(0.93); }
}

/* ── BACK BTN ── */
.btn-back {
    position: relative;
    z-index: 1;
    display: block;
    margin: 0 auto 32px;
    font-family: 'Jost', sans-serif;
    font-weight: 300;
    font-size: 0.72rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--text-soft);
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.btn-back:hover { opacity: 1; }

/* ── POPUP ── */
.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(42,26,26,0.55);
    backdrop-filter: blur(6px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.popup-overlay.show { display: flex; }

.popup-box {
    background: var(--cream);
    max-width: 480px;
    width: 100%;
    position: relative;
    text-align: center;
    animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
    border: 1px solid rgba(194,112,106,0.2);
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* ── Image area ── */
.popup-img-wrap {
    flex-shrink: 0;
    width: 100%;
    height: 220px;
    overflow: hidden;
    background: var(--warm);
    position: relative;
}

.popup-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    background: var(--warm);
    transition: transform 5s ease;
}

.popup-img-wrap img:hover { transform: scale(1.03); }

.popup-img-wrap.no-image {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--warm), rgba(232,180,160,0.3));
}

.popup-img-wrap.no-image::after {
    content: '📷';
    font-size: 2rem;
    opacity: 0.2;
}

/* ── Text body ── */
.popup-body {
    padding: 28px 40px 36px;
    overflow-y: auto;
    position: relative;
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.88) translateY(16px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.popup-number {
    font-family: 'Cormorant Garamond', serif;
    font-size: 4rem;
    font-weight: 300;
    color: rgba(194,112,106,0.12);
    line-height: 1;
    position: absolute;
    top: 10px;
    left: 16px;
    pointer-events: none;
}

.popup-icon {
    font-size: 2rem;
    margin-bottom: 14px;
    display: block;
    animation: heartbeat 1.5s ease infinite;
}

@keyframes heartbeat {
    0%,100% { transform: scale(1); }
    14%     { transform: scale(1.2); }
    28%     { transform: scale(1); }
    42%     { transform: scale(1.1); }
}

.popup-title {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 1.05rem;
    color: var(--gold);
    letter-spacing: 0.15em;
    margin-bottom: 16px;
    font-weight: 300;
    text-transform: uppercase;
}

.popup-msg {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.55rem;
    line-height: 1.55;
    color: var(--deep);
    font-weight: 300;
    margin-bottom: 36px;
}

.popup-close {
    font-family: 'Jost', sans-serif;
    font-weight: 300;
    font-size: 0.72rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    padding: 14px 40px;
    background: transparent;
    border: 1px solid var(--rose);
    color: var(--rose);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: color 0.35s;
}

.popup-close::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--rose);
    transform: translateX(-101%);
    transition: transform 0.35s cubic-bezier(0.76,0,0.24,1);
    z-index: 0;
}

.popup-close:hover::before { transform: translateX(0); }
.popup-close:hover { color: var(--cream); }
.popup-close span { position: relative; z-index: 1; }

/* Special popup for #2 */
.popup-special .popup-box {
    border-color: rgba(232,180,160,0.3);
}

.popup-special .popup-body {
    background: linear-gradient(160deg, var(--deep) 0%, #4a1a2a 100%);
}

.popup-special .popup-number { color: rgba(255,255,255,0.08); }
.popup-special .popup-title  { color: var(--blush); }
.popup-special .popup-msg    { color: var(--warm); }
.popup-special .popup-close  {
    border-color: var(--blush);
    color: var(--blush);
}
.popup-special .popup-close::before { background: var(--blush); }
.popup-special .popup-close:hover   { color: var(--deep); }

/* confetti */
.confetti-piece {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 1px;
    pointer-events: none;
    z-index: 200;
    animation: confettiFall 3s ease forwards;
}

@keyframes confettiFall {
    0%   { opacity: 1; transform: translate(0,0) rotate(0deg); }
    100% { opacity: 0; transform: translate(var(--cx),var(--cy)) rotate(720deg); }
}