﻿/* =====================================================
   Durian Whack-a-Durian — style.css  (v3 full redo)
   ===================================================== */

: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;
    --green-lit:  #4ade80;
    --orange:     #e8a03f;
    --amber-lit:  #fbbf24;
    --red:        #dc2626;
    --shadow:     0 22px 60px rgba(15, 35, 17, 0.18);
}

/* -- page chrome -- */
body {
    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%);
}

.whack-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.whack-page h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--ink);
    margin-bottom: 1rem;
    font-family: Georgia, "Times New Roman", serif;
}

/* -- layout -- */
.whack-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.25rem;
    align-items: start;
}

.whack-layout > * {
    min-width: 0;
}

/* -- HUD -- */
.whack-hud {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}

.hud-item {
    flex: 1 1 80px;
    background: rgba(95, 129, 40, 0.12);
    border-radius: .75rem;
    padding: .5rem .85rem;
    text-align: center;
    min-width: 80px;
}

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

.hud-item .hud-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--green-deep);
    line-height: 1.1;
}

.hud-item.timer-low      .hud-value { color: #b45309; animation: pulse .65s ease-in-out infinite; }
.hud-item.timer-critical .hud-value { color: #dc2626; animation: pulse .35s ease-in-out infinite; }

.hud-item .hud-sub {
    font-size: .6rem;
    color: var(--ink-soft);
    margin-top: .1rem;
}

/* -- difficulty row -- */
.diff-row {
    display: flex;
    gap: .5rem;
    margin-bottom: .75rem;
    flex-wrap: wrap;
}

.diff-btn {
    padding: .35rem 1rem;
    border-radius: 2rem;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid var(--line);
    transition: all .15s;
    background: transparent;
    color: var(--ink-soft);
    font-family: inherit;
}

.diff-btn:hover  { border-color: var(--green); color: var(--green); }
.diff-btn.active { background: var(--green-deep); border-color: var(--green-deep); color: #fff; }

/* -- game shell -- */
.whack-shell {
    position: relative;
    background: #1a3e2a;
    width: 100%;
    max-width: 100%;
    border-radius: 1rem;
    padding: 1rem;
    border: 2px solid rgba(255, 255, 255, .1);
    overflow: hidden;
    box-sizing: border-box;
}

/* -- overlay -- */
.game-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .82);
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    border-radius: inherit;
}

.game-overlay h2 {
    font-size: 2rem;
    font-weight: 800;
    color: #a7f3d0;
    margin-bottom: .5rem;
}

.game-overlay .overlay-score {
    font-size: 3rem;
    font-weight: 900;
    color: var(--amber-lit);
    margin: .5rem 0;
}

.game-overlay .overlay-sub {
    color: #d1fae5;
    margin-bottom: 1.25rem;
    font-size: .95rem;
    line-height: 1.6;
}

.game-overlay .overlay-btn {
    background: var(--green-lit);
    color: #052e16;
    font-weight: 800;
    font-size: 1.05rem;
    padding: .65rem 2rem;
    border-radius: 2rem;
    border: none;
    cursor: pointer;
    transition: background .15s;
    margin: .3rem;
    font-family: inherit;
}

.game-overlay .overlay-btn:hover { background: #86efac; }

.game-overlay .overlay-btn.outline {
    background: transparent;
    border: 2px solid #22c55e;
    color: #a7f3d0;
}

.game-overlay .overlay-btn.outline:hover { background: rgba(34, 197, 94, .15); }

/* -- grid (normal mode) -- */
.whack-grid {
    display: grid;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
    margin-bottom: .75rem;
}

/* -- holes (normal mode) -- */
.hole {
    position: relative;
    padding-bottom: 100%;
    background: #0d2a1a;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #0a1f12;
    box-shadow: inset 0 6px 14px rgba(0, 0, 0, .7);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.hole::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    right: 10%;
    height: 35%;
    background: rgba(0, 0, 0, .4);
    border-radius: 50%;
}

/* -- durian sprite -- */
.durian-sprite {
    position: absolute;
    left: 50%;
    bottom: -110%;
    transform: translateX(-50%);
    width: 88%;
    aspect-ratio: 1;
    object-fit: cover;
    z-index: 5;
    pointer-events: none;
    user-select: none;
    transition: bottom .2s cubic-bezier(.175, .885, .32, 1.275);
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, .7));
}

.hole.active  .durian-sprite { bottom: 6%; }
.hole.rotten  .durian-sprite { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .6)) sepia(1) saturate(2) hue-rotate(85deg); }
.hole.whacked .durian-sprite { animation: whacked .22s ease-out forwards; }

/* -- score popup -- */
.score-popup {
    position: absolute;
    left: 50%;
    top: 30%;
    transform: translateX(-50%) translateY(0);
    font-size: 1.3rem;
    font-weight: 900;
    pointer-events: none;
    z-index: 30;
    animation: popUp .7s ease-out forwards;
    white-space: nowrap;
}

.score-popup.positive { color: var(--amber-lit); }
.score-popup.negative { color: #fca5a5; }

/* -- combo banner -- */
.combo-banner {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--amber-lit);
    height: 1.6rem;
    margin-bottom: .5rem;
    transition: opacity .3s;
}

.combo-banner.hidden { opacity: 0; }

/* -- fullscreen button -- */
.fullscreen-btn {
    display: none;
}

.fullscreen-btn:hover { background: #fff; }

/* -- sidebar -- */
.whack-sidebar {
    display: flex;
    flex-direction: column;
    gap: .85rem;
}

.sidebar-card {
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 1.2rem;
    padding: 1.1rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

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

/* -- leaderboard -- */
.lb-tabs {
    display: flex;
    gap: .35rem;
    margin-bottom: .5rem;
    flex-wrap: wrap;
}

.lb-tab {
    flex: 1;
    padding: .3rem .5rem;
    font-size: .78rem;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-soft);
    border: 1px solid var(--line);
    transition: all .15s;
    font-family: inherit;
    white-space: nowrap;
}

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

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

.lb-list li {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .4rem;
    border-radius: .4rem;
    color: var(--ink);
}

.lb-list li: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: .78rem; text-align: right; }
.lb-name  { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 700; color: var(--green-deep); }
.lb-empty { color: var(--ink-soft); font-size: .85rem; text-align: center; padding: .5rem 0; }

.submit-row {
    display: flex;
    gap: .4rem;
    margin-top: .5rem;
}

.submit-name {
    flex: 1;
    background: rgba(255, 252, 244, 0.9);
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: .5rem;
    padding: .4rem .6rem;
    font-size: .85rem;
    outline: none;
    font-family: inherit;
}

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

.submit-btn {
    background: var(--green-deep);
    border: none;
    color: #fffaf0;
    font-weight: 700;
    font-size: .85rem;
    padding: .4rem .85rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
    font-family: inherit;
}

.submit-btn:hover    { background: #1a3320; }
.submit-btn:disabled { opacity: .5; cursor: default; }

.submit-msg {
    font-size: .78rem;
    margin-top: .35rem;
    color: var(--ink-soft);
    min-height: 1rem;
}

/* -- share -- */
.share-actions {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    margin-bottom: .5rem;
}

.share-btn {
    display: flex;
    align-items: center;
    gap: .45rem;
    width: 100%;
    padding: .45rem .7rem;
    border-radius: .5rem;
    border: 1px solid var(--line);
    background: rgba(95, 129, 40, 0.08);
    color: var(--green-deep);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
    font-family: inherit;
}

.share-btn:hover { background: rgba(95, 129, 40, 0.15); }

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

/* -- how-to-play list -- */
.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 .icon { font-size: 1rem; flex-shrink: 0; width: 1.2rem; text-align: center; margin-top: .1rem; }

/* -- animations -- */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.12); }
}

@keyframes whacked {
    0%   { transform: translateX(-50%) scale(1); opacity: 1; }
    30%  { transform: translateX(-50%) scale(1.25) rotate(-8deg); opacity: .9; }
    100% { transform: translateX(-50%) scale(.4); opacity: 0; bottom: 60%; }
}

@keyframes popUp {
    0%   { transform: translateX(-50%) translateY(0);     opacity: 1; }
    70%  { transform: translateX(-50%) translateY(-40px); opacity: 1; }
    100% { transform: translateX(-50%) translateY(-60px); opacity: 0; }
}

/* =====================================================
   FULLSCREEN MODE
   KEY FIX: grid-template-rows: 1fr only works when the
   grid container has a *definite* height.  Without it,
   rows size to their content and overflow the screen.
   Solution: set BOTH width AND height on .whack-grid to
   the same value (largest square that fits the screen).
   ===================================================== */

.whack-shell:fullscreen,
.whack-shell:-webkit-full-screen,
.whack-shell:-moz-full-screen,
.whack-shell:-ms-fullscreen {
    width: 100%;
    height: 100%;
    background: #0d2a1a;
    border-radius: 0;
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-sizing: border-box;
}

.whack-shell:fullscreen .whack-grid,
.whack-shell:-webkit-full-screen .whack-grid,
.whack-shell:-moz-full-screen .whack-grid,
.whack-shell:-ms-fullscreen .whack-grid {
    width:  min(90vw, 90vh);
    height: min(90vw, 90vh);
    max-width:  720px;
    max-height: 720px;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows:    repeat(3, 1fr);
    gap: min(1rem, 1.5vmin);
    margin: 0;
}

.whack-shell:fullscreen .hole,
.whack-shell:-webkit-full-screen .hole,
.whack-shell:-moz-full-screen .hole,
.whack-shell:-ms-fullscreen .hole {
    padding-bottom: 0;
}

.whack-shell:fullscreen .game-overlay,
.whack-shell:-webkit-full-screen .game-overlay,
.whack-shell:-moz-full-screen .game-overlay,
.whack-shell:-ms-fullscreen .game-overlay {
    border-radius: 0;
}

/* =====================================================
   RESPONSIVE — MOBILE
   ===================================================== */

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

    .diff-row {
        flex-wrap: wrap;
    }

    .diff-btn {
        flex: 1;
        min-width: 80px;
    }

    .lb-tabs {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .whack-page h1 {
        font-size: 1.3rem;
    }

    .whack-page {
        padding: .75rem;
    }

    .whack-shell {
        padding: .7rem;
        border-radius: .85rem;
    }

    .whack-grid {
        gap: .5rem;
    }

    .game-overlay {
        padding: 1rem;
    }

    .game-overlay h2 {
        font-size: 1.5rem;
    }

    .game-overlay .overlay-score {
        font-size: 2.2rem;
    }

    .game-overlay .overlay-btn {
        width: 100%;
        max-width: 16rem;
        padding: .6rem 1rem;
        font-size: .95rem;
    }

    .whack-hud {
        gap: .3rem;
    }

    .hud-item {
        flex: 1 1 60px;
        min-width: 58px;
        padding: .4rem .5rem;
    }

    .hud-item .hud-value {
        font-size: 1.15rem;
    }

    .diff-btn {
        font-size: .75rem;
        padding: .3rem .6rem;
    }

    .submit-row {
        flex-direction: column;
    }

    .lb-tab {
        text-align: center;
    }

    .share-actions {
        flex-direction: column;
    }

    .share-btn {
        width: 100%;
    }
}

@media (max-width: 360px) {
    .whack-page {
        padding: .5rem;
    }

    .whack-shell {
        padding: .55rem;
    }

    .whack-grid {
        gap: .35rem;
    }

    .sidebar-card {
        padding: .85rem;
    }
}