/* Dark Mode Variables - Class based for toggle */
body.dark-mode {
    --bg-color: #1a1a1a;
    --stroke-color: #fdfdfd;
    --modal-bg: #2a2a2a;
    --modal-text: #fdfdfd;
}

body.dark-mode .sketchy-box, 
body.dark-mode .corner-btn, 
body.dark-mode .modal-content, 
body.dark-mode .sketchy-btn {
    background-color: var(--modal-bg) !important;
    color: var(--modal-text) !important;
}

body.dark-mode input[type="text"] {
    background-color: #333;
    color: #fff;
}

:root {
    --bg-color: #fdfdfd;
    --stroke-color: #1a1a1a;
    --font-family: 'Architects Daughter', cursive, sans-serif;
    --modal-bg: #ffffff;
    --modal-text: #1a1a1a;
}

body {
    background-color: var(--bg-color);
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    color: var(--stroke-color);
    overflow: hidden; /* App-like feel */
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#app {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    height: 100%;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.corner-btn {
    position: absolute;
    background: white;
    border: 2px solid var(--stroke-color);
    padding: 10px 15px;
    font-family: var(--font-family);
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 100;
    color: var(--stroke-color);
    
    /* Sketchy border */
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    transition: transform 0.1s;
}

.corner-btn:active {
    transform: scale(0.95);
}

.top-left { top: 20px; left: 20px; }
.top-right { top: 20px; right: 20px; }

.buzzers-grid {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    gap: 40px; /* More space */
    margin-top: 80px;
    margin-bottom: 20px;
    padding: 20px;
    overflow-y: auto; /* Scroll if content overflows */
    min-height: 0; /* Important for flex child scrolling */
}

/* Responsive Scaling */
@media (max-width: 1000px), (max-height: 800px) {
    .buzzer {
        transform: scale(0.8);
        margin: -10px;
    }
}

@media (max-width: 600px), (max-height: 600px) {
    .buzzers-grid {
        gap: 20px;
    }
    .buzzer {
        transform: scale(0.6);
        margin: -25px;
    }
}

.buzzer {
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
    background-color: transparent !important;
    margin: 10px;
}

/* 2D Side View Construction */
.buzzer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: transform 0.1s;
    filter: drop-shadow(0 10px 5px rgba(0,0,0,0.2));
}

.b-dome {
    width: 120px;
    height: 70px;
    border-radius: 60px 60px 0 0; /* Semi-circle */
    border: 3px solid var(--stroke-color);
    border-bottom: none;
    position: relative;
    z-index: 5;
    transition: transform 0.1s;
    overflow: hidden;
    /* Main color set inline */
}

/* Shadow on the left/bottom of dome for volume/2D effect */
.b-dome::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0; width: 40%;
    background: rgba(0,0,0,0.15);
    border-radius: 60px 0 0 0;
    pointer-events: none;
}

/* Highlight shine */
.b-highlight {
    position: absolute;
    right: 20px;
    top: 15px;
    width: 20px;
    height: 20px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
}
.b-highlight::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: -5px;
    width: 10px;
    height: 10px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
}

.b-neck {
    width: 100px;
    height: 16px;
    background: #34495e; /* Dark slate */
    border: 3px solid var(--stroke-color);
    border-top: none;
    border-bottom: none;
    z-index: 4;
    margin-top: -2px; /* Overlap borders */
}

.b-base {
    width: 140px;
    height: 35px;
    background: #95a5a6; /* Concrete gray */
    border: 3px solid var(--stroke-color);
    border-radius: 15px 15px 0 0;
    position: relative;
    z-index: 3;
    margin-top: -2px;
}

/* Base Shadow/Side */
.b-base::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0; width: 40%;
    background: rgba(0,0,0,0.1);
    border-radius: 15px 0 0 0;
    pointer-events: none;
}

/* Base Bottom Lip */
.b-base::after {
    content: '';
    position: absolute;
    bottom: -12px; 
    left: -10px;
    right: -10px;
    height: 16px;
    background: #7f8c8d; /* Darker gray */
    border: 3px solid var(--stroke-color);
    border-radius: 15px; /* Rounded pill shape */
    z-index: 2;
}

.b-label {
    margin-top: 25px;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    color: var(--stroke-color);
}

/* Depress Animation - only when locked (confirmed by server) */
.buzzer.locked .b-dome {
    transform: translateY(14px);
    /* Flashy color effect */
    filter: brightness(1.3) saturate(1.5);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.buzzer.locked .buzzer-content {
    /* Slightly squash shadow */
    filter: drop-shadow(0 5px 2px rgba(0,0,0,0.2));
}

/* Rank Badge */
.rank-badge {
    position: absolute;
    top: -20px;
    right: -20px;
    background: #ffdb4d; /* Gold */
    border: 2px solid var(--stroke-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    z-index: 10;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

#results-bar {
    height: 150px;
    padding: 10px;
    overflow-y: auto;
}

.sketchy-box {
    border: 2px solid var(--stroke-color);
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    background: white;
    padding: 15px;
    color: var(--stroke-color);
}

#results-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: row;
    gap: 20px;
    overflow-x: auto;
}


.result-item {
    padding: 10px;
    border: 2px solid var(--stroke-color);
    border-radius: 10px 220px 10px 200px / 200px 10px 200px 20px;
    min-width: 100px;
    text-align: center;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.hidden { display: none !important; }

.modal-content {
    width: 80%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sketchy-btn {
    background: white;
    border: 2px solid var(--stroke-color);
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    padding: 8px 16px;
    font-family: var(--font-family);
    font-size: 1rem;
    cursor: pointer;
    margin: 5px;
}

.sketchy-btn.primary {
    background: var(--stroke-color);
    color: white;
}

.setting-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 5px;
}

.setting-row input[type="text"] {
    flex: 1;
    border: 2px solid var(--stroke-color);
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    padding: 5px 10px;
    font-family: var(--font-family);
}
