/* ============================== */
/* ROOT & THEME VARIABLES         */
/* ============================== */

:root {
    --bg-main: #0b0b0b;
    --bg-panel: rgba(255, 255, 255, 0.05);
    --text-color: #f5f5f5;
    --accent: #74c69d;
    --accent-hover: #95d5b2;
    --accent-selected: #52a57f;
    --border-color: rgba(255, 255, 255, 0.1);
    --select-bg: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] {
    --bg-main: #f3f3f3;
    --bg-panel: rgba(0, 0, 0, 0.05);
    --text-color: #222;
    --accent: #2b9348;
    --accent-hover: #55a630;
    --accent-selected: #408122;
    --border-color: rgba(0, 0, 0, 0.1);
    --select-bg: rgba(0, 0, 0, 0.05);
}

/* ============================== */
/* MAIN LAYOUT                    */
/* ============================== */

.vCemJeMainCanvas {
    display: grid;
    grid-template-columns: 260px auto 260px;
    gap: 20px;
    padding: 20px;
    background: transparent;
    color: var(--text-color);
    min-height: auto;
    transition: 0.3s;
    align-items: start;
}

#game {
    width: 100%;
    height: auto;
    max-width: 800px;
    justify-self: center;

    order: -1;    /* <-- forces canvas to always appear at top */
    margin-bottom: 20px;
}

.scoreBar {
    display: flex;
    justify-content: center;
    gap: 20px;
    font-size: 1.1rem;
    color: var(--text-color);
}

/* ============================== */
/* REPLAY                         */
/* ============================== */

/* Vertical list container */
#replaysAll {
    display: flex;
    flex-direction: column;
    gap: 8px; /* Reduced gap between items */
    padding: 20px;
    min-width: 500px;
    max-width: 800px; /* Increased width from 600px to 800px */
    margin: 0 auto;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Individual Replay Card */
.replay {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 18px; /* Reduced vertical padding to make cards less tall */
    border-radius: 8px;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    user-select: none;

    /* Dims the inline gradient background */
    background-blend-mode: darken;
    background-color: rgba(0, 0, 0, 0.5);
}

/* Hover effect */
.replay:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.2);
    background-color: rgba(0, 0, 0, 0.35);
}

.replay:active {
    transform: translateY(0);
}

/* Player Name */
.replay .name {
    font-weight: 600;
    font-size: 0.95rem; /* Slightly smaller text for compact height */
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

/* Scores display badge */
.replay span:last-child {
    font-family: 'Courier New', Courier, monospace;
    font-weight: 700;
    font-size: 0.95rem;
    background: rgba(0, 0, 0, 0.6);
    padding: 3px 10px; /* Reduced padding inside the score pill */
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    letter-spacing: 1px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}





/* ============================== */
/* SIDE PANELS                    */
/* ============================== */

.infoVedleMainCanvas {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.friendListPanel,
.settingsVedleCanvas {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(10px);
    transition: 0.3s;
}

.friendListPanel h3,
.settingsVedleCanvas h3 {
    color: var(--accent);
    font-size: 1rem;
    margin-bottom: 10px;
    text-transform: uppercase;
}

/* ============================== */
/* RESPONSIVE FRIEND LIST         */
/* ============================== */

.friendList {
    max-height: 450px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Friend item */
.friendEntry {
    padding: 10px;
    margin-bottom: 8px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: 0.2s;
}

.friendEntry:hover {
    transform: translateX(4px);
    border-color: var(--accent);
}

.addFriendBtn {
    margin-top: 15px;
    padding: 10px;
    width: 100%;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: 0.2s;
}

.addFriendBtn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

/* =============================== */
/* EXPANDABLE FRIEND LIST          */
/* =============================== */

.toggleFriendsBtn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    float: right;
    transform: rotate(0deg);
    transition: 0.3s;
}

.friendList.collapsed {
    height: 0;
    overflow: hidden;
    padding: 0 !important;
}

.toggleFriendsBtn.rotated {
    transform: rotate(-90deg);
}

/* ============================== */
/* SETTINGS SECTION               */
/* ============================== */

.modeButtons button,
#restartBtn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: white;
    margin-bottom: 10px;
    cursor: pointer;
    transition: 0.2s;
}

.modeButtons button.active {
    border: #000 2px dashed;
    background: var(--accent-selected);
}

.modeButtons button:hover,
#restartBtn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

/* Radio buttons */
.appleOptions input[type="radio"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    margin-right: 6px;
    position: relative;
    cursor: pointer;
}

.appleOptions input[type="radio"]:checked::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

.appleOptions label {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

/* If the wrapper HAS a child #aiBtn with the class .active... */
#wholeSettingsMenu:has(#aiBtn.active) .aiDifficulty {
    display: block;
    max-height: 150px;
    opacity: 1;
}

#wholeSettingsMenu:has(#aisBtn.active) .aiDifficulty {
    display: block;
    max-height: 150px;
    opacity: 1;
}

.aiDifficulty {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition:
            max-height 0.5s ease,
            opacity 0.3s ease;
}


/* ============================== */
/* AI DEPTH SELECTOR              */
/* ============================== */

/* 1. The hidden state */
.aiDepthContainer {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    transition: max-height 0.5s ease, opacity 0.3s ease, margin-top 0.3s ease;
}

/* 2. The visible state (Only opens if an AI mode is active AND 'Angry' is checked) */
#wholeSettingsMenu:has(#aiBtn.active):has(input[value="angry"]:checked) .aiDepthContainer,
#wholeSettingsMenu:has(#aisBtn.active):has(input[value="angry"]:checked) .aiDepthContainer {
    max-height: 100px;
    opacity: 1;
    margin-top: 10px;
}

/* 3. The Number Input Styling (Matches your theme variables) */
#aiDepthInput {
    appearance: none;
    width: 60px;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--select-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    outline: none;
    margin-left: 10px;
    transition: background 0.2s, border 0.2s;
}

#aiDepthInput:hover,
#aiDepthInput:focus {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-hover);
}

/* 4. The subtext styling */
.aiDepthContainer small {
    display: block;
    margin-top: 8px;
    color: rgba(255, 255, 255, 0.5); /* Soft, theme-agnostic gray */
}

/* Make sure the small text adapts in light mode */
[data-theme="light"] .aiDepthContainer small {
    color: rgba(0, 0, 0, 0.5);
}



/* Custom select */
#speedSelect {
    appearance: none;
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--select-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    transition: background 0.2s, border 0.2s;
}

#speedSelect:hover,
#speedSelect:focus {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent-hover);
}

/* Custom dropdown arrow */
#speedSelect {
    background-image: linear-gradient(45deg, transparent 50%, var(--text-color) 50%),
    linear-gradient(135deg, var(--text-color) 50%, transparent 50%);
    background-position: calc(100% - 15px) calc(50% - 3px),
    calc(100% - 10px) calc(50% - 3px);
    background-size: 5px 5px;
    background-repeat: no-repeat;
}

/* ============================== */
/* THEME PICKER                   */
/* ============================== */

.themeSelector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.themeOption {
    height: 45px;
    width: 100%;
    border-radius: 10px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: 0.2s;
}

.themeOption.active {
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

/* ============================== */
/* RESPONSIVE BREAKPOINTS         */
/* ============================== */

/* Medium screens — stack on two columns */
@media (max-width: 1100px) {
    .vCemJeMainCanvas {
        grid-template-columns: 220px auto;
    }
}

/* Small screens — everything stacked vertically */
@media (max-width: 800px) {
    .vCemJeMainCanvas {
        grid-template-columns: 1fr;
        justify-items: center;
        padding: 15px;
    }

    #game {
        max-width: 95vw;
        height: auto;
    }

    .infoVedleMainCanvas {
        width: 90%;
    }

    .friendListPanel,
    .settingsVedleCanvas {
        width: 100%;
    }
}

/* Extra small — shrink fonts and spacing */
@media (max-width: 500px) {
    :root {
        font-size: 14px;
    }

    .themeOption {
        height: 40px;
    }
}

/* =============================== */
/*  GENERAL                        */
/* =============================== */

.topBar {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    padding: 15px 20px;
}

/* =============================== */
/*  HAMBURGER BUTTON               */
/* =============================== */

.hamburgerBtn {
    width: 40px;
    height: 32px;
    border: none;
    background: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    padding: 0;
}

.hamburgerBtn span {
    height: 4px;
    width: 100%;
    background: var(--text-color);
    border-radius: 4px;
    transition: 0.3s;
}


/* =============================== */
/*  SIDE PANELS (DRAWERS)          */
/* =============================== */

.sidePanel {
    position: relative;
    transition: transform 0.3s ease;
}

/* left drawer */
.leftPanel {
    transform: translateX(0);
}

.leftPanel.closed {
    transform: translateX(-120%);
}

/* right drawer */
.rightPanel {
    transform: translateX(0);
}

.rightPanel.closed {
    transform: translateX(120%);
}


/* FLEX FIX FOR CANVAS ALWAYS AT TOP */
.canvasWrapper {
    grid-column: 2 / 3;
    display: flex;
    justify-content: center;
}

/* FLOATING MOBILE BUTTONS */
.floatingBtn {
    display: none; /* still hidden on desktop */
    position: fixed;
    top: 100px;
    padding: 14px;
    width: 50px;
    height: 50px;
    border-radius: 50%;

    background: rgba(0, 0, 0, 0.4);  /* transparent black */
    backdrop-filter: blur(6px);      /* glass effect */
    border: 1px solid rgba(255,255,255,0.15);

    color: var(--text-color);
    cursor: pointer;
    z-index: 9999;

    align-items: center;
    justify-content: center;

    transition: 0.25s ease;

    font-size: 22px; /* for the icon */
}

.floatingBtn:hover {
    background: rgba(0, 0, 0, 0.6);
    transform: scale(1.06);
    border-color: var(--accent);
}

/* left button */
#toggleLeft {
    left: 20px;
}

/* right button */
#toggleRight {
    right: 20px;
}

#toggleRight:hover {
    transform: rotate(90deg);
}

/* MOBILE MODE */
@media (max-width: 1250px) {

    .vCemJeMainCanvas {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .canvasWrapper {
        grid-column: 1 / 2;
        order: -1;
        margin-bottom: 20px;
    }

    .leftPanel,
    .rightPanel {
        position: fixed;
        top: 150px;
        bottom: 0;
        width: 260px;
        z-index: 9998;

        padding-top: 20px;
    }

    .leftPanel {
        left: 0;
        transform: translateX(-100%);
    }

    .rightPanel {
        right: 0;
        transform: translateX(100%);
    }

    .floatingBtn {
        display: flex;
    }

    .leftPanel.open {
        transform: translateX(0);
    }

    .rightPanel.open {
        transform: translateX(0);
    }
}
