:root
{
    --pink: #f48fb1;
    --pink-deep: #d9668f;
    --ink: #4a3348;
    --card: rgba(255, 250, 247, 0.94);
    --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*
{
    box-sizing: border-box;
}

html,
body
{
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: #f6dcd2;
    color: var(--ink);
    font-family: var(--font);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: none;
}

#game
{
    position: fixed;
    inset: 0;
    touch-action: none;
}

#game canvas
{
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.hidden
{
    display: none !important;
}

#vignette
{
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(60, 30, 60, 0.55) 100%);
    transition: opacity 1.2s ease;
}

#tips
{
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.tip
{
    position: absolute;
    left: 0;
    top: 0;
    padding: 3px 10px;
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    border: 2px solid var(--tip, var(--pink));
    font-weight: 800;
    font-size: 14px;
    white-space: nowrap;
    box-shadow: 0 3px 0 rgba(74, 51, 72, 0.15);
}

/* HUD */
#hud
{
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) 14px 0 14px;
    pointer-events: none;
}

.hud-left
{
    flex-shrink: 0;
    white-space: nowrap;
}

.hud-day
{
    font-size: 26px;
    font-weight: 800;
    line-height: 1.05;
    text-shadow: 0 2px 0 rgba(255, 255, 255, 0.75);
}

/* 28 dots, one per day, coloured by phase: done = full, today = big and pulsing */
.hud-cycle
{
    display: flex;
    gap: 2px;
    margin: 4px 0 3px;
}

.hud-cycle span
{
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.75);
    box-shadow: inset 0 0 0 1.5px var(--dot);
}

.hud-cycle span.done
{
    background: var(--dot);
}

.hud-cycle span.now
{
    background: var(--dot);
    transform: scale(1.45);
    animation: pulse 1.2s ease-in-out infinite;
}

.hud-phase
{
    font-size: 14px;
    font-weight: 700;
    opacity: 0.85;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.hud-glow
{
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 800;
}

.hud-glow-bar
{
    display: inline-block;
    width: 74px;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: inset 0 1px 2px rgba(74, 51, 72, 0.25);
    overflow: hidden;
}

#hud-glow-fill
{
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #ffe08a, #ffb36b);
    transition: width 0.25s ease;
}

.hud-glow.full #hud-glow-fill
{
    background: linear-gradient(90deg, #fff2a8, #ffd166);
    animation: glowPulse 1s ease-in-out infinite;
}

.hud-right
{
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.hud-hearts
{
    font-size: 24px;
    letter-spacing: 2px;
    color: var(--pink-deep);
    text-shadow: 0 2px 0 rgba(255, 255, 255, 0.75);
}

.hud-hearts .empty
{
    opacity: 0.25;
}

.hud-hearts.bump
{
    animation: bump 0.4s ease;
}

.hud-gauge
{
    display: grid;
    gap: 3px;
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.6);
    width: 128px;
}

.gauge-row
{
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 6px;
}

.gauge-row.pulse
{
    animation: gaugePulse 0.9s ease;
}

.gauge-label
{
    width: 26px;
    font-size: 10px;
    font-weight: 900;
    text-align: right;
}

.gauge-bar
{
    flex: 1;
    height: 7px;
    border-radius: 999px;
    background: rgba(74, 51, 72, 0.12);
    overflow: hidden;
}

.gauge-fill
{
    display: block;
    height: 100%;
    width: 4%;
    border-radius: 999px;
    transition: width 0.4s ease;
}

/* Signpost note: slides in at the top, fades away; never pauses the game */
.caption
{
    position: fixed;
    top: max(84px, calc(env(safe-area-inset-top) + 74px));
    left: 50%;
    max-width: min(420px, calc(100% - 32px));
    width: max-content;
    padding: 8px 14px;
    border-radius: 14px;
    background: rgba(255, 250, 247, 0.92);
    box-shadow: 0 4px 0 rgba(74, 51, 72, 0.12);
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -8px);
}

.caption.show
{
    animation: captionShow 4.6s ease forwards;
}

.caption-title
{
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0.6;
}

.caption-text
{
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.tip-big
{
    font-size: 15px;
    padding: 4px 12px;
}

.end-chart
{
    margin: 8px 0 4px;
}

.end-chart figcaption
{
    font-size: 12px;
    font-weight: 800;
    opacity: 0.7;
    margin-bottom: 2px;
}

#end-chart
{
    display: block;
    width: 100%;
    height: 110px;
}

.chart-legend
{
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 10px;
    font-size: 11px;
    font-weight: 800;
}

.chart-legend span::before
{
    content: "● ";
}

.chart-legend .e
{
    color: #ff6fa3;
}

.chart-legend .p
{
    color: #9b82e8;
}

.chart-legend .lh
{
    color: #d99a1a;
}

.chart-legend .fsh
{
    color: #2fae7f;
}

/* LH surge banner */
.banner
{
    position: fixed;
    top: 32%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    padding: 10px 22px;
    border-radius: 18px;
    background: #ffcf5c;
    color: #6b4a00;
    font-size: 30px;
    font-weight: 900;
    letter-spacing: 1px;
    box-shadow: 0 6px 0 #d9a52f;
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
}

.banner.show
{
    animation: bannerPop 1.8s ease forwards;
}

/* a phase already seen this visit: a calm one-liner instead of its card */
.banner.soft
{
    top: 42%;
    padding: 8px 18px;
    background: rgba(255, 250, 247, 0.92);
    color: var(--ink);
    font-size: 17px;
    letter-spacing: 0;
    box-shadow: 0 4px 0 rgba(74, 51, 72, 0.12);
}

/* Overlay screens */
.screen
{
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    pointer-events: none;
}

.card
{
    pointer-events: auto;
    max-width: 380px;
    width: 100%;
    max-height: calc(100% - 20px);
    overflow-y: auto;
    background: var(--card);
    border-radius: 26px;
    padding: 22px 20px;
    text-align: center;
    box-shadow: 0 6px 0 rgba(74, 51, 72, 0.12), 0 14px 34px rgba(74, 51, 72, 0.18);
}

#screen-start .card,
#screen-fact .card
{
    pointer-events: none;
}

/* quick death panel: small, so the frozen scene stays visible */
.down-card
{
    max-width: 300px;
    padding: 16px 18px;
}

.down-card .buttons
{
    margin-top: 6px;
}

.down-card .btn
{
    padding: 10px 20px;
    font-size: 16px;
}

/* the player's own cycle note on the end card (kept in this browser only) */
.note
{
    margin: 12px 0 4px;
    text-align: left;
}

.note label
{
    display: block;
    font-size: 13px;
    font-weight: 900;
    margin-bottom: 4px;
}

.note textarea
{
    display: block;
    width: 100%;
    box-sizing: border-box;
    font: inherit;
    font-size: 14px;
    padding: 8px 10px;
    border: 2px solid rgba(244, 143, 177, 0.35);
    border-radius: 12px;
    background: #fff;
    color: var(--ink);
    resize: vertical;
}

.note textarea:focus
{
    outline: none;
    border-color: var(--pink-deep);
}

.note .small
{
    margin: 4px 0 0;
}

.card h1,
.card h2
{
    margin: 0 0 8px;
    font-weight: 900;
}

.card h1
{
    font-size: 34px;
    color: var(--pink-deep);
}

.card h2
{
    font-size: 24px;
}

.card p
{
    margin: 8px 0;
    line-height: 1.4;
}

.cta
{
    font-weight: 900;
    font-size: 19px;
    animation: pulse 1.6s ease-in-out infinite;
}

.best
{
    font-size: 14px;
    opacity: 0.75;
}

.small
{
    font-size: 12px;
    opacity: 0.65;
}

.fact-card h2
{
    color: var(--pink-deep);
}

.fact-days
{
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.6;
}

.fact-text
{
    font-size: 16px;
}

.fact-card .tap
{
    font-size: 13px;
    font-weight: 800;
    opacity: 0.7;
}

.fact-bar
{
    height: 5px;
    border-radius: 999px;
    background: rgba(74, 51, 72, 0.1);
    overflow: hidden;
    margin-top: 10px;
}

#fact-progress
{
    display: block;
    height: 100%;
    background: var(--pink);
    transform-origin: left center;
    transform: scaleX(0);
}

.outside
{
    font-size: 26px;
    font-weight: 900;
    color: #3e8a52;
}

#screen-end .stats
{
    display: none;
}

#screen-end.won .stats
{
    display: flex;
}

#screen-end:not(.won) .outside
{
    display: none;
}

.stats
{
    justify-content: center;
    gap: 14px;
    margin: 10px 0;
}

.stats div
{
    background: rgba(244, 143, 177, 0.14);
    border-radius: 14px;
    padding: 8px 10px;
    min-width: 82px;
}

.stats dt
{
    font-size: 11px;
    font-weight: 700;
    opacity: 0.7;
}

.stats dd
{
    margin: 2px 0 0;
    font-size: 22px;
    font-weight: 900;
}

.buttons
{
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.btn
{
    font: inherit;
    font-weight: 900;
    font-size: 18px;
    padding: 12px 26px;
    border: 0;
    border-radius: 999px;
    background: var(--pink);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--pink-deep);
}

.btn-soft
{
    background: #fff;
    color: var(--ink);
    box-shadow: 0 4px 0 rgba(74, 51, 72, 0.2);
}

.btn:active
{
    transform: translateY(2px);
    box-shadow: 0 2px 0 var(--pink-deep);
}

.btn:focus-visible,
.store-link:focus-visible
{
    outline: 3px solid var(--pink-deep);
    outline-offset: 2px;
}

.store-link
{
    display: inline-block;
    margin-top: 14px;
    font-size: 14px;
    font-weight: 800;
    color: var(--pink-deep);
}

/* Share section on the end card */
.share
{
    margin-top: 16px;
    padding-top: 14px;
    border-top: 2px dashed rgba(244, 143, 177, 0.35);
}

.share h3
{
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 900;
    color: var(--pink-deep);
}

.share-preview
{
    display: block;
    width: 150px;
    margin: 0 auto 10px;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(74, 51, 72, 0.2);
}

.share-links
{
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
}

.chip
{
    font: inherit;
    font-size: 13px;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: 999px;
    border: 0;
    background: rgba(244, 143, 177, 0.16);
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
}

.chip:hover,
.chip:focus-visible
{
    background: rgba(244, 143, 177, 0.32);
    outline: none;
}

/* Touch pad: ◀ ▶ bottom-left, a big jump button bottom-right (tapping anywhere else jumps too). Shown on
   touch devices while playing. */
.pad
{
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: flex-end;
    gap: 14px;
    padding: 0 16px max(18px, env(safe-area-inset-bottom)) 16px;
    pointer-events: none;
}

.pad.on.playing
{
    display: flex;
}

.pad-btn
{
    pointer-events: auto;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    border: 0;
    background: rgba(255, 255, 255, 0.55);
    color: var(--ink);
    font-size: 28px;
    box-shadow: 0 5px 0 rgba(74, 51, 72, 0.18);
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.pad-btn.down
{
    transform: translateY(3px);
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 0 rgba(74, 51, 72, 0.18);
}

.pad-jump
{
    margin-left: auto;
    width: 104px;
    height: 104px;
    background: rgba(244, 143, 177, 0.7);
    color: #fff;
    font: inherit;
    font-size: 20px;
    font-weight: 900;
    box-shadow: 0 5px 0 rgba(217, 102, 143, 0.5);
}

.pad-jump.down
{
    background: rgba(244, 143, 177, 0.9);
    box-shadow: 0 2px 0 rgba(217, 102, 143, 0.5);
}

@media (max-width: 380px)
{
    .hud-day
    {
        font-size: 22px;
    }

    .hud-gauge
    {
        width: 108px;
    }



    .card h1
    {
        font-size: 28px;
    }
}

@keyframes pulse
{
    0%, 100%
    {
        opacity: 1;
    }
    50%
    {
        opacity: 0.55;
    }
}

@keyframes glowPulse
{
    0%, 100%
    {
        filter: brightness(1);
    }
    50%
    {
        filter: brightness(1.25);
    }
}

@keyframes gaugePulse
{
    0%, 100%
    {
        background: transparent;
        transform: scale(1);
    }
    30%
    {
        background: rgba(255, 255, 255, 0.95);
        transform: scale(1.08);
    }
}

@keyframes captionShow
{
    0%
    {
        opacity: 0;
        transform: translate(-50%, -8px);
    }
    8%, 85%
    {
        opacity: 1;
        transform: translate(-50%, 0);
    }
    100%
    {
        opacity: 0;
        transform: translate(-50%, -4px);
    }
}

@keyframes bump
{
    0%
    {
        transform: scale(1);
    }
    40%
    {
        transform: scale(1.3);
    }
    100%
    {
        transform: scale(1);
    }
}

@keyframes bannerPop
{
    0%
    {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3) rotate(-6deg);
    }
    15%
    {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.15) rotate(3deg);
    }
    25%
    {
        transform: translate(-50%, -50%) scale(1) rotate(-2deg);
    }
    80%
    {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotate(0);
    }
    100%
    {
        opacity: 0;
        transform: translate(-50%, -60%) scale(0.9);
    }
}

@media (prefers-reduced-motion: reduce)
{
    .cta,
    .hud-cycle span.now,
    .hud-glow.full #hud-glow-fill,
    .hud-hearts.bump
    {
        animation: none;
    }

    .banner.show
    {
        animation-duration: 2.4s;
    }
}

/* Short landscape phones: compact cards so they fit without scrolling (fact cards can't scroll). */
@media (max-height: 460px)
{
    .card
    {
        padding: 12px 16px;
        max-width: 520px;
    }

    .card h1
    {
        font-size: 26px;
    }

    .card h2
    {
        font-size: 20px;
        margin-bottom: 4px;
    }

    .card p
    {
        margin: 4px 0;
    }

    .fact-text
    {
        font-size: 14px;
    }

    .outside
    {
        font-size: 20px;
    }

    .stats div
    {
        padding: 4px 8px;
    }

    .stats dd
    {
        font-size: 18px;
    }

    .buttons
    {
        margin-top: 6px;
    }

    .btn
    {
        padding: 8px 20px;
        font-size: 16px;
    }

    .store-link
    {
        margin-top: 8px;
    }

    .share-preview
    {
        width: 96px;
    }

    #end-chart
    {
        height: 70px;
    }

    .end-chart
    {
        margin: 4px 0 2px;
    }
}

/* Phones: keep the signpost note below the HUD so it doesn't hide the hormone gauge */
@media (max-width: 700px)
{
    /* a smaller cycle strip so the hearts and the gauge still fit beside it */
    .hud-cycle
    {
        gap: 1.5px;
    }

    .hud-cycle span
    {
        width: 5px;
        height: 5px;
    }

    .caption
    {
        top: max(146px, calc(env(safe-area-inset-top) + 136px));
    }
}
