:root {
    --ink: #18311d;
    --ink-soft: rgba(24, 49, 29, 0.78);
    --cream: #fff7e8;
    --card: rgba(255, 250, 240, 0.93);
    --line: rgba(24, 49, 29, 0.12);
    --green: #5f8128;
    --green-deep: #284b2d;
    --orange: #e8a03f;
    --shadow: 0 22px 60px rgba(15, 35, 17, 0.18);
    --correct: #2d7a2d;
    --wrong: #b83232;
}

* { 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: inherit; }

.game-page {
    width: min(1280px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.25rem 0 2rem;
}

.game-panel, .card, .overlay-card {
    background: var(--card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.control-button, .primary-button { border-radius: 999px; }

.layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 1.25rem;
    margin-top: 1.25rem;
}

.game-panel {
    border-radius: 1.8rem;
    padding: 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
    flex-wrap: wrap;
}

.title-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

.eyebrow {
    margin: 0;
    color: #75510a;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.82rem;
    font-weight: 700;
}

h1, h2 { font-family: Georgia, "Times New Roman", serif; }
h1 { margin: 0.25rem 0 0; font-size: clamp(1.8rem, 4vw, 3rem); line-height: 0.98; }
.lead { margin: 0; color: var(--ink-soft); line-height: 1.6; font-size: 1rem; }

/* HUD */
.hud { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.hud-item {
    display: flex; flex-direction: column; align-items: center;
    background: rgba(95, 129, 40, 0.12); border-radius: 0.75rem;
    padding: 0.5rem 1rem; min-width: 5rem; flex: 1;
}
.hud-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); font-weight: 600; }
.hud-item strong { font-size: 1.5rem; font-weight: 700; color: var(--green-deep); }

/* Guess shell */
.guess-shell {
    position: relative;
    border-radius: 1.2rem;
    overflow: hidden;
    background: rgba(255, 252, 244, 0.6);
    border: 1px solid var(--line);
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

/* Overlay */
.overlay {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(22, 54, 31, 0.55);
    backdrop-filter: blur(6px);
    border-radius: inherit; z-index: 10; padding: 1rem;
}
.overlay.hidden { display: none; }

.overlay-card {
    border-radius: 1.2rem; padding: 2rem;
    max-width: 440px; width: 100%; text-align: center;
    display: flex; flex-direction: column; gap: 0.75rem;
    background: #fff7e8;
}
.overlay-brand { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.overlay-brand-icon { width: 32px; height: 32px; border-radius: 8px; }
.overlay-brand-name { font-size: 0.85rem; font-weight: 700; color: #3d5a2e; }
.overlay-kicker { margin: 0; font-size: 0.88rem; text-transform: uppercase; letter-spacing: 0.08em; color: #c07b1a; font-weight: 700; }
.overlay-card h2 { margin: 0; font-size: clamp(1.4rem, 3vw, 2rem); color: #18311d; }
.overlay-card p { margin: 0; color: #3a5230; line-height: 1.6; font-size: 0.96rem; }
.overlay-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; margin-top: 0.5rem; }

/* Round area */
.round-area {
    flex: 1; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.2rem; align-items: center;
}

.durian-card {
    width: 100%; max-width: 500px; text-align: center;
    background: rgba(255, 250, 240, 0.85);
    border: 1px solid var(--line); border-radius: 1rem;
    padding: 1.5rem;
}
.durian-name {
    margin: 0; font-family: Georgia, serif;
    font-size: clamp(1.3rem, 3vw, 1.8rem); font-weight: 700;
    color: var(--green-deep);
}
.durian-hint { margin: 0.5rem 0 0; color: var(--ink-soft); font-size: 0.92rem; }

/* Guess input */
.guess-input-area { width: 100%; max-width: 500px; text-align: center; }
.guess-label { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.5rem; display: block; }

.input-row { display: flex; gap: 0.5rem; align-items: center; justify-content: center; }
.rm-prefix { font-weight: 700; font-size: 1.1rem; color: var(--green-deep); }
.price-input {
    width: 100px; padding: 0.6rem 0.75rem; border: 2px solid var(--line);
    border-radius: 0.6rem; font-size: 1.1rem; font-family: inherit;
    text-align: center; background: rgba(255, 252, 244, 0.9); color: var(--ink);
}
.price-input:focus { outline: none; border-color: var(--green); }

.price-slider {
    width: 100%; margin: 1rem 0 0.25rem;
    -webkit-appearance: none; appearance: none;
    height: 10px; border-radius: 5px;
    background: linear-gradient(90deg, var(--green) 0%, var(--orange) 50%, var(--wrong) 100%);
    outline: none;
}
.price-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 24px; height: 24px;
    border-radius: 50%; background: var(--green-deep);
    border: 3px solid #fff; cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.price-slider::-moz-range-thumb {
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--green-deep); border: 3px solid #fff;
    cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.slider-labels { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--ink-soft); }
#slider-display { font-weight: 700; color: var(--green-deep); font-size: 0.88rem; }

/* Feedback */
.feedback-area {
    width: 100%; max-width: 500px; text-align: center;
    background: rgba(255, 250, 240, 0.9); border: 1px solid var(--line);
    border-radius: 1rem; padding: 1.2rem;
}
.feedback-text { margin: 0; font-size: 1.1rem; font-weight: 700; }
.feedback-text.perfect { color: var(--correct); }
.feedback-text.close { color: var(--green); }
.feedback-text.far { color: var(--orange); }
.feedback-text.miss { color: var(--wrong); }
.actual-price { margin: 0.4rem 0; color: var(--ink-soft); font-size: 0.95rem; }
.points-earned { margin: 0; font-size: 1.3rem; font-weight: 700; color: var(--green-deep); }

/* Fullscreen button */
.canvas-fullscreen-button {
    background: rgba(24, 49, 29, 0.1); border: 1px solid var(--line);
    border-radius: 0.5rem; width: 2.2rem; height: 2.2rem;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    padding: 0; transition: background 0.15s; fill: var(--ink); flex-shrink: 0;
}
.canvas-fullscreen-button:hover { background: rgba(24, 49, 29, 0.2); }

/* Buttons */
.primary-button {
    background: #284b2d; color: #fffaf0; border: none;
    padding: 0.72rem 1.5rem; font-size: 0.96rem; font-weight: 700;
    font-family: inherit; cursor: pointer;
    transition: background 0.18s, transform 0.1s;
}
.primary-button:hover { background: #1a3320; transform: translateY(-1px); }
.primary-button:active { transform: none; }

.control-button {
    background: rgba(24, 49, 29, 0.08); border: 1px solid var(--line);
    color: var(--ink); padding: 0.5rem 1rem; font-size: 0.9rem;
    font-family: inherit; cursor: pointer; transition: background 0.15s;
}
.control-button:hover { background: rgba(24, 49, 29, 0.15); }
.hidden-action { display: none; }

/* Sidebar */
.sidebar { display: flex; flex-direction: column; gap: 1rem; }
.card { border-radius: 1.2rem; padding: 1.2rem; }
.card-heading { margin: 0 0 0.75rem; font-size: 1rem; font-weight: 700; color: var(--green-deep); }

/* Leaderboard */
.leaderboard-tabs { display: flex; gap: 0.4rem; margin-bottom: 0.75rem; }
.leaderboard-tab {
    padding: 0.35rem 0.75rem; border-radius: 999px;
    border: 1px solid var(--line); background: transparent;
    font-family: inherit; font-size: 0.82rem; cursor: pointer;
    color: var(--ink-soft); transition: background 0.15s, color 0.15s;
}
.leaderboard-tab.active, .leaderboard-tab:hover {
    background: var(--green); color: #fff; border-color: var(--green);
}
.leaderboard-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 0.3rem;
    max-height: 220px; overflow-y: auto;
}
.leaderboard-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; padding: 0.3rem 0.4rem; border-radius: 0.4rem; }
.leaderboard-item:nth-child(odd) { background: rgba(95, 129, 40, 0.06); }
.lb-rank { min-width: 1.5rem; font-weight: 700; color: var(--ink-soft); font-size: 0.8rem; text-align: right; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 700; color: var(--green-deep); white-space: nowrap; }
.leaderboard-empty { color: var(--ink-soft); font-size: 0.9rem; padding: 0.5rem 0; text-align: center; }
.refresh-button { margin-top: 0.5rem; font-size: 0.82rem; padding: 0.35rem 0.7rem; }

/* Submit card */
.form-label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 0.4rem; }
.form-input {
    width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--line);
    border-radius: 0.5rem; font-family: inherit; font-size: 0.95rem;
    background: rgba(255, 252, 244, 0.9); color: var(--ink); margin-bottom: 0.6rem;
}
.form-input:focus { outline: 2px solid var(--green); outline-offset: 1px; }
#leaderboard-form { display: flex; flex-direction: column; gap: 0; }
.leaderboard-status { margin: 0.5rem 0 0; font-size: 0.85rem; color: var(--ink-soft); min-height: 1.2rem; }

/* Share card */
.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; }

/* Result */
.result-banner { display: flex; flex-direction: column; align-items: center; padding: 1.5rem 1rem; gap: 0.4rem; text-align: center; }
.result-emoji { font-size: 3rem; line-height: 1; }
.result-label { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--ink-soft); }
.result-score { font-size: 3rem; font-weight: 700; color: var(--green-deep); font-family: Georgia, serif; }
.result-sub { font-size: 0.96rem; color: var(--ink-soft); }

/* FULLSCREEN MODE */
.guess-shell:fullscreen,
.guess-shell:-webkit-full-screen {
    background: #1a3d22; border-radius: 0;
    display: flex; flex-direction: column; justify-content: center; padding: 2rem;
}
.guess-shell:fullscreen .round-area,
.guess-shell:-webkit-full-screen .round-area {
    background: var(--card); border-radius: 1.2rem; max-width: 860px; margin: 0 auto; width: 100%;
}

@media (max-width: 720px) {
    .layout { grid-template-columns: 1fr; }
    .game-page { width: calc(100% - 1rem); }
    h1 { font-size: 1.8rem; }
    .input-row { flex-wrap: wrap; justify-content: center; }
}
