﻿/* ============================
   Durian Drop Catch - Styles
   (warm-cream theme, modelled on durian-memory)
   ============================ */

:root {
    --ink:       #18311d;
    --ink-soft:  rgba(24, 49, 29, 0.78);
    --card-bg:   rgba(255, 250, 240, 0.95);
    --line:      rgba(24, 49, 29, 0.12);
    --green:     #5f8128;
    --green-deep:#284b2d;
    --orange:    #e8a03f;
    --shadow:    0 22px 60px rgba(15, 35, 17, 0.18);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(232, 160, 63, 0.35), transparent 26%),
        radial-gradient(circle at top right, rgba(95, 129, 40, 0.28), transparent 22%),
        linear-gradient(180deg, #16361f 0%, #2f6a3d 23%, #dce6bf 58%, #f5e8ce 100%);
}

a { color: var(--green-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

.game-page {
    width: min(1280px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.25rem 0 2.5rem;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 1.25rem;
    margin-top: 1.25rem;
}

.game-panel {
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 1.8rem;
    padding: 1.4rem;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
    min-width: 0;
}

.card, .overlay-card {
    background: var(--card-bg);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.card {
    border-radius: 1.2rem;
    padding: 1.1rem;
}

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
}

.title-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    justify-content: flex-end;
}

.eyebrow {
    margin: 0;
    color: #75510a;
    letter-spacing: .08em;
    text-transform: uppercase;
    font-size: .82rem;
    font-weight: 700;
}

h1, h2 { font-family: Georgia, "Times New Roman", serif; }

h1 {
    margin: .25rem 0 0;
    font-size: clamp(1.75rem, 4vw, 3rem);
    line-height: 1;
    color: var(--ink);
}

.lead {
    margin: .75rem 0 0;
    color: var(--ink-soft);
    line-height: 1.7;
    max-width: 52rem;
    font-size: .96rem;
}

.primary-button, .control-button {
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 150ms ease, background-color 150ms ease;
}

.primary-button {
    padding: .72rem 1.5rem;
    border: none;
    background: var(--green-deep);
    color: #fffaf0;
    font-weight: 700;
    font-size: .96rem;
}

.primary-button:hover { background: #1a3320; transform: translateY(-1px); }
.primary-button:active { transform: translateY(0); }

.control-button {
    min-width: 4rem;
    padding: .5rem 1rem;
    background: rgba(24, 49, 29, 0.08);
    border: 1px solid var(--line);
    color: var(--ink);
    font-weight: 600;
    font-size: .9rem;
}

.control-button:hover { background: rgba(24, 49, 29, 0.15); transform: translateY(-1px); }
.control-button:active { transform: translateY(0); }

.hud {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: .75rem;
    margin-top: 1rem;
}

.hud-item {
    padding: .65rem .85rem;
    border-radius: .75rem;
    background: rgba(95, 129, 40, 0.12);
    text-align: center;
}

.hud-label {
    display: block;
    font-size: .68rem;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
}

.hud-item strong {
    display: block;
    margin-top: .15rem;
    font-size: 1.5rem;
    color: var(--green-deep);
    line-height: 1.1;
    font-weight: 800;
}

.canvas-shell {
    margin-top: 1rem;
    position: relative;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 5 / 3;
    border-radius: 1.2rem;
    overflow: hidden;
    background: linear-gradient(180deg, #16361f 0%, #2f6a3d 100%);
    border: 1px solid var(--line);
}

.canvas-fullscreen-button {
    position: absolute;
    top: .75rem;
    right: .75rem;
    z-index: 4;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: rgba(24, 49, 29, 0.12);
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 150ms ease, background-color 150ms ease;
    fill: var(--ink);
}

.canvas-fullscreen-button:hover { transform: translateY(-1px); background: rgba(24, 49, 29, 0.22); }
.canvas-fullscreen-button svg { width: 1.15rem; height: 1.15rem; fill: currentColor; }

#game-canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 100%;
    aspect-ratio: 5 / 3;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(22, 54, 31, 0.55);
    backdrop-filter: blur(6px);
}

.overlay.hidden { display: none; }

.overlay-card {
    max-width: 34rem;
    text-align: center;
    border-radius: 1.2rem;
    padding: 2rem;
}

.overlay-brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: .9rem;
    justify-content: center;
}

.overlay-brand-icon, .brand-ribbon-icon { border-radius: 50%; }
.overlay-brand-icon { width: 32px; height: 32px; }
.overlay-brand-name { font-weight: 700; letter-spacing: .02em; color: var(--ink-soft); }

.overlay-kicker {
    margin: 0;
    color: var(--orange);
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    font-size: .88rem;
}

.overlay-card h2 { margin: .5rem 0 .6rem; font-size: clamp(1.4rem, 3vw, 2rem); color: var(--ink); }
.overlay-card p { margin: 0; line-height: 1.7; color: var(--ink-soft); font-size: .96rem; }

.overlay-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: 1rem;
}

.hidden-action { display: none; }
.hidden-action.is-visible { display: inline-flex; }

.controls-row {
    display: flex;
    justify-content: center;
    gap: .75rem;
    margin-top: 1rem;
}

.brand-ribbon {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    margin-top: .85rem;
    padding: .45rem .85rem;
    border-radius: 999px;
    background: rgba(95, 129, 40, 0.08);
    border: 1px solid var(--line);
    font-weight: 700;
    font-size: .82rem;
    color: var(--green-deep);
}

.brand-ribbon-icon { width: 26px; height: 26px; }

.info-panel { display: grid; gap: 1rem; }

.card h2 {
    margin: 0 0 .65rem;
    font-size: 1rem;
    color: var(--green-deep);
    font-family: Georgia, "Times New Roman", serif;
    font-weight: 700;
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .65rem;
}

.card-header-row h2 { margin-bottom: 0; }

.card-link-button {
    border: none;
    cursor: pointer;
    font: inherit;
    padding: .28rem .65rem;
    border-radius: 999px;
    background: rgba(24, 49, 29, 0.08);
    color: var(--green-deep);
    font-weight: 700;
    font-size: .78rem;
    transition: background .15s;
}

.card-link-button:hover { background: rgba(24, 49, 29, 0.15); }

.card ul {
    margin: 0;
    padding-left: 1.25rem;
    line-height: 1.75;
    color: var(--ink-soft);
    font-size: .9rem;
}

.score-list { display: grid; gap: .4rem; }

.score-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .5rem .7rem;
    border-radius: .5rem;
    background: rgba(95, 129, 40, 0.06);
}

.score-meta { display: grid; gap: .1rem; }
.score-meta strong { font-size: .88rem; color: var(--ink); }
.score-meta span   { font-size: .75rem; color: var(--ink-soft); }

.score-points {
    font-size: 1rem;
    font-weight: 800;
    color: var(--orange);
    white-space: nowrap;
}

.learn-links { display: grid; gap: .35rem; }

.learn-links a {
    display: block;
    padding: .38rem .6rem;
    border-radius: .4rem;
    color: var(--green-deep);
    font-size: .9rem;
    font-weight: 600;
    transition: color .15s;
    text-decoration: none;
}

.learn-links a:hover { color: var(--green); text-decoration: underline; }

.leaderboard-intro, .leaderboard-status, .leaderboard-note {
    margin: 0;
    color: var(--ink-soft);
    line-height: 1.6;
    font-size: .85rem;
}

.leaderboard-status { margin-top: .5rem; }
.leaderboard-note   { margin-top: .2rem; font-size: .78rem; }

.leaderboard-tabs {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    margin-top: .6rem;
}

.leaderboard-tab {
    border: 1px solid var(--line);
    cursor: pointer;
    font: inherit;
    padding: .35rem .75rem;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-soft);
    font-weight: 700;
    font-size: .82rem;
    transition: background .15s, color .15s, border-color .15s;
}

.leaderboard-tab:hover { background: var(--green); border-color: var(--green); color: #fff; }

.leaderboard-tab.is-active {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.leaderboard-form {
    display: grid;
    gap: .45rem;
    margin-top: .6rem;
}

.leaderboard-form.is-hidden { display: none; }
.leaderboard-label { font-weight: 700; font-size: .88rem; color: var(--ink); }

.leaderboard-form-row, .leaderboard-actions {
    display: flex;
    gap: .45rem;
    flex-wrap: wrap;
}

.leaderboard-input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: .5rem;
    padding: .45rem .75rem;
    font: inherit;
    font-size: .9rem;
    background: rgba(255, 252, 244, 0.9);
    color: var(--ink);
    outline: none;
}

.leaderboard-input::placeholder { color: var(--ink-soft); }
.leaderboard-input:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: var(--green); }

.leaderboard-list {
    list-style: none;
    padding: 0;
    margin: .5rem 0 0;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    max-height: 220px;
    overflow-y: auto;
}

.leaderboard-entry {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: .5rem;
    align-items: center;
    padding: .3rem .45rem;
    border-radius: .4rem;
    font-size: .88rem;
}

.leaderboard-entry:nth-child(odd) { background: rgba(95, 129, 40, 0.06); }

.leaderboard-rank {
    min-width: 1.5rem;
    font-weight: 700;
    color: var(--ink-soft);
    font-size: .8rem;
    text-align: right;
}

.leaderboard-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-score { font-weight: 700; color: var(--green-deep); white-space: nowrap; }
.leaderboard-empty { color: var(--ink-soft); font-size: .88rem; padding: .5rem 0; text-align: center; }

.share-card .social-share-container { margin: 0; }

/* How to play */
.how-list {
    padding: 0;
    margin: 0;
    list-style: none;
    font-size: .88rem;
    color: var(--ink-soft);
    display: flex;
    flex-direction: column;
    gap: .4rem;
}
.how-list li {
    display: flex;
    gap: .5rem;
    line-height: 1.5;
    align-items: flex-start;
}
.how-list li::before {
    content: "›";
    color: var(--green);
    font-weight: 700;
    flex-shrink: 0;
    min-width: 1.2rem;
    text-align: center;
}
.how-list li:has(.icon)::before { display: none; }

#game-stage:fullscreen,
#game-stage:-webkit-full-screen,
#game-stage:-moz-full-screen,
#game-stage:-ms-fullscreen {
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: min(1rem, 2.5vw);
    box-sizing: border-box;
    overflow: hidden;
    background: linear-gradient(180deg, #16361f 0%, #2f6a3d 100%);
}

#game-stage:fullscreen .overlay,
#game-stage:-webkit-full-screen .overlay,
#game-stage:-moz-full-screen .overlay,
#game-stage:-ms-fullscreen .overlay {
    inset: 0;
    overflow-y: auto;
}

#game-stage:fullscreen #game-canvas,
#game-stage:-webkit-full-screen #game-canvas,
#game-stage:-moz-full-screen #game-canvas,
#game-stage:-ms-fullscreen #game-canvas {
    width: auto;
    height: min(calc(100vh - min(2rem, 5vw)), calc((100vw - min(2rem, 5vw)) * 3 / 5));
    max-width: calc(100vw - min(2rem, 5vw));
    max-height: calc(100vh - min(2rem, 5vw));
    aspect-ratio: 5 / 3;
}

@media (max-width: 980px) {
    .layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .game-page { width: 100%; padding: .75rem .35rem 1.5rem; }
    .game-panel, .card, .overlay-card { border-radius: .75rem; }
    .game-panel { padding: .75rem; }
    .canvas-shell {
        width: calc(100% + .75rem);
        max-width: calc(100% + .75rem);
        margin-left: -.375rem;
        margin-right: -.375rem;
        border-radius: .95rem;
        aspect-ratio: auto;
        padding-bottom: 7rem;
    }
    #game-canvas {
        height: auto;
    }
    .overlay {
        overflow-y: auto;
    }
    .overlay-card {
        padding: 1.25rem;
    }
    .overlay-card h2 {
        font-size: 1.2rem;
    }
    .overlay-card p {
        font-size: .85rem;
        line-height: 1.5;
    }
    .title-row { flex-direction: column; }
    .title-actions { width: 100%; justify-content: stretch; }
    .title-actions .primary-button { width: 100%; }
    .hud { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .controls-row { justify-content: stretch; }
    .control-button { flex: 1; min-width: 0; }
    .leaderboard-form-row, .leaderboard-actions, .leaderboard-tabs, .overlay-actions { flex-direction: column; }

    /* Mobile fullscreen: proportional, no stretch */
    #game-stage:fullscreen,
    #game-stage:-webkit-full-screen {
        padding: .5rem;
    }
    #game-stage:fullscreen #game-canvas,
    #game-stage:-webkit-full-screen #game-canvas {
        width: min(calc(100vw - 1rem), calc((100vh - 1rem) * 5 / 3));
        height: auto;
        max-width: calc(100vw - 1rem);
        max-height: calc(100vh - 1rem);
        aspect-ratio: 5 / 3;
    }
    #game-stage:fullscreen .overlay,
    #game-stage:-webkit-full-screen .overlay {
        overflow-y: auto;
    }
}

@media (max-width: 480px) {
    .game-page { padding: .5rem .25rem 1.25rem; }
    .game-panel { padding: .6rem; }
    .canvas-shell {
        width: calc(100% + .9rem);
        max-width: calc(100% + .9rem);
        margin-left: -.45rem;
        margin-right: -.45rem;
        margin-top: .85rem;
        border-radius: .85rem;
        padding-bottom: 8rem;
    }
    .canvas-fullscreen-button {
        top: .5rem;
        right: .5rem;
        width: 2.15rem;
        height: 2.15rem;
    }
    .overlay {
        padding: .75rem;
    }
    .overlay-card {
        padding: 1rem;
    }
    .overlay-card p {
        font-size: .8rem;
    }
}