* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Nunito', sans-serif;
}

body {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #e8d0b3;
    background-image: url('https://www.transparenttextures.com/patterns/wood-pattern.png');
    overflow: hidden;
    touch-action: manipulation;
}

.game-container {
    width: 100%;
    height: 100%;
    max-width: 1000px;
    max-height: 800px;
    position: relative;
    background-color: #e8d0b3;
    background-image: url('https://www.transparenttextures.com/patterns/wood-pattern.png');
    overflow: hidden;
}

.screen {
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.screen.active {
    display: flex;
}

/* Home Screen */
.board-frame {
    width: 90%;
    height: 80%;
    background-color: rgba(165, 125, 85, 0.9);
    border: 15px solid #5a3921;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 40px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    position: relative;
}

.logo-container {
    width: 80%;
    height: 60%;
    background-color: #cda875;
    border: 8px solid #8b5a2b;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.logo {
    text-align: center;
}

.tabletop {
    color: #ff5722;
    font-size: 32px;
    font-weight: bold;
    font-family: 'Permanent Marker', cursive;
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.3);
    margin-bottom: -10px;
    letter-spacing: 1px;
}

.dots {
    color: #4169e1;
    font-size: 80px;
    font-weight: bold;
    font-family: 'Fredoka One', cursive;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    background: linear-gradient(to bottom, #5e7eff, #1e3a8a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
}

.connectors {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 5px 0;
}

.line {
    width: 50px;
    height: 8px;
    background-color: #333;
    border-radius: 4px;
    display: inline-block;
}

.and {
    color: #ff5722;
    font-size: 36px;
    font-weight: bold;
    font-family: 'Bangers', cursive;
    margin: 0 10px;
    transform: rotate(-5deg);
}

.boxes {
    color: #4169e1;
    font-size: 80px;
    font-weight: bold;
    font-family: 'Fredoka One', cursive;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    background: linear-gradient(to bottom, #5e7eff, #1e3a8a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
}

.menu-buttons {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.menu-button {
    width: 60%;
    padding: 15px 0;
    margin: 0 auto;
    font-size: 24px;
    font-weight: bold;
    font-family: 'Fredoka One', cursive;
    color: white;
    background-color: #00c853;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    letter-spacing: 1px;
}

.menu-button:hover {
    background-color: #00b248;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

#play-vs-player-button {
    background-color: #ff4757;
}

#play-vs-player-button:hover {
    background-color: #e04046;
}

#play-vs-bot-button {
    background-color: #2e86de;
}

#play-vs-bot-button:hover {
    background-color: #2574c2;
}

/* Game Screen */
.game-controls {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
}

.icon-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #30d5c8;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

.icon-button:hover {
    background-color: #20c5b8;
}

.menu-icon, .settings-icon {
    width: 30px;
    height: 30px;
    position: relative;
}

.menu-icon::before,
.menu-icon::after {
    content: '';
    width: 30px;
    height: 3px;
    background-color: white;
    position: absolute;
    left: 0;
    border-radius: 2px;
}

.menu-icon::before {
    top: 8px;
    box-shadow: 0 10px 0 white;
}

.menu-icon::after {
    top: 18px;
}

.settings-icon::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 3px solid white;
    border-radius: 50%;
    position: absolute;
    left: 5px;
    top: 2px;
}

.settings-icon::after {
    content: '';
    width: 3px;
    height: 8px;
    background-color: white;
    position: absolute;
    left: 14px;
    top: 22px;
    border-radius: 1px;
    box-shadow: 0 0 0 3px #0fbcf9;
}

.turn-indicator {
    display: flex;
    align-items: center;
    background-color: white;
    padding: 8px 15px;
    border-radius: 25px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    background-color: #ffb6c1;
}

.turn-indicator .player-icon {
    width: 30px;
    height: 30px;
    background-color: #ff4757;
    border-radius: 50%;
    margin-right: 10px;
    box-shadow: 0 0 5px rgba(255, 0, 0, 0.5);
}

.turn-indicator span {
    font-size: 24px;
    font-weight: bold;
}

.game-board {
    width: 76%;
    height: 76%;
    margin: 20px auto;
    background-color: #d9be9c;
    background-image: url('https://www.transparenttextures.com/patterns/wood-pattern.png');
    border: 2px solid #8b5a2b;
    border-radius: 10px;
    position: relative;
    overflow: visible;
    padding: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.game-board::before {
    content: '';
    position: absolute;
    top: 12%;
    left: 12%;
    right: 12%;
    bottom: 12%;
    background-color: #e5c9a7;
    background-image: url('https://www.transparenttextures.com/patterns/wood-pattern.png');
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    z-index: 1;
}

.grid-container {
    position: absolute;
    top: 12%;
    left: 12%;
    right: 12%;
    bottom: 12%;
    z-index: 2;
    width: 76%;
    height: 76%;
}

.dot {
    width: 20px;
    height: 20px;
    background-color: white;
    border: 2px solid #d04040;
    border-radius: 50%;
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 3;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    touch-action: none;
    box-shadow: 0 0 8px rgba(208, 64, 64, 0.7);
    pointer-events: auto;
}

.dot:hover, .dot:active {
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 0 6px rgba(255, 0, 0, 0.4);
}

.dot.active {
    background-color: white;
    border: 2px solid #d04040;
    box-shadow: 0 0 10px rgba(208, 64, 64, 0.7);
    transform: translate(-50%, -50%) scale(1.4);
    transition: all 0.2s ease;
}

.dot.potential-connection {
    background-color: rgba(255, 220, 52, 0.5);
    border: 2px solid #ff9800;
    box-shadow: 0 0 8px rgba(255, 152, 0, 0.7);
    animation: pulse 1.5s infinite alternate;
}

.temp-line {
    position: absolute;
    background-color: #8b5a2b;
    z-index: 1;
    pointer-events: none;
    opacity: 0.7;
    box-shadow: 0 0 6px rgba(139, 90, 43, 0.5);
    height: 8px !important;
}

.horizontal-line, .vertical-line {
    background-color: #40280c;
    position: absolute;
    z-index: 2;
    cursor: pointer;
    transition: all 0.25s ease;
    opacity: 0.7;
    height: 4px;
    touch-action: none;
}

.vertical-line {
    width: 4px;
}

.horizontal-line.selected, .vertical-line.selected {
    opacity: 1;
    height: 8px;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.vertical-line.selected {
    width: 8px;
}

.horizontal-line:hover, .vertical-line:hover {
    opacity: 0.8 !important;
}

.score-container {
    width: 100%;
    display: flex;
    justify-content: space-around;
    padding: 10px 20px;
}

.player-score {
    display: flex;
    align-items: center;
    background-color: white;
    padding: 8px 15px;
    border-radius: 25px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

.player-score .player-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
}

.player-score .player-icon.red {
    background-color: #ff4757;
}

.player-score .player-icon.blue {
    background-color: #2e86de;
}

.player-score .score {
    font-size: 24px;
    font-weight: bold;
}

/* Animation for active elements */
@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

.active-player {
    animation: pulse 1.5s infinite;
}

.active-selection .dot.potential-connection {
    animation: pulse 1.5s infinite;
    transform: translate(-50%, -50%) scale(1.3);
}

@media (max-width: 768px) {
    .menu-button {
        width: 80%;
        padding: 20px 0;
        font-size: 20px;
    }
    
    .dot {
        width: 16px;
        height: 16px;
        border-width: 1.5px;
    }
    
    .game-controls {
        padding: 15px;
    }
    
    .game-board {
        width: min(90vw, 90vmin);
        height: min(90vw, 90vmin);
        margin: 10px auto;
        max-width: 95%;
        aspect-ratio: 1/1;
    }
    
    .grid-container {
        position: absolute;
        top: 12%;
        left: 12%;
        right: 12%;
        bottom: 12%;
        z-index: 2;
        width: 76%;
        height: 76%;
    }
}

.completed-box {
    position: absolute;
    z-index: 2;
    border-radius: 5px;
    animation: fadeIn 0.3s ease-in-out;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Game Over Popup Styles */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease-in-out;
}

.popup.active {
    visibility: visible;
    opacity: 1;
}

.popup-content {
    background-color: rgba(165, 125, 85, 0.95);
    padding: 30px;
    border-radius: 10px;
    border: 8px solid #5a3921;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    transform: scale(0.8);
    transition: transform 0.3s ease-in-out;
    animation: popIn 0.5s forwards;
}

@keyframes popIn {
    0% {
        transform: scale(0.8);
    }
    80% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.popup-title {
    font-size: 36px;
    font-weight: bold;
    font-family: 'Bangers', cursive;
    color: white;
    margin: 0 0 20px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
}

.result-message {
    font-size: 20px;
    font-family: 'Permanent Marker', cursive;
    color: white;
    margin-bottom: 20px;
    transform: rotate(-2deg);
}

.final-scores {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
}

.player-score-final {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: white;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

.player-score-final .player-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-bottom: 10px;
}

.player-score-final .score {
    font-size: 28px;
    font-weight: bold;
}

.popup-buttons {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
}

.popup-button {
    padding: 12px 25px;
    font-size: 18px;
    font-weight: bold;
    font-family: 'Fredoka One', cursive;
    color: white;
    background-color: #00c853;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    letter-spacing: 1px;
}

.popup-button:hover {
    background-color: #00b248;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

/* Settings Popup Styles */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
}

.setting-label {
    font-size: 18px;
    font-weight: bold;
}

/* Toggle Switch Styles */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #00c853;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.setting-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.exit-button {
    background-color: #ff4757;
}

.exit-button:hover {
    background-color: #e04046;
}