:root {
    --bg-color: #f7f9fa;
    --sidebar-bg: rgba(255, 255, 255, 0.85);
    --primary-color: #ff65a3;
    --primary-hover: #ff3c88;
    --secondary-color: #2ec4b6;
    --secondary-hover: #1eb3a5;
    --dark-green: #1f5c45;
    --light-green: #e6f6f1;
    --pink-felt: #ffd2e4;
    --pink-felt-dark: #fcaed0;
    --board-line-color: #1e5a44;
    --board-line-hover: #ff3c88;
    --text-main: #2b2d42;
    --text-muted: #6c757d;
    --border-radius: 20px;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    --glow-shadow: 0 0 15px rgba(255, 101, 163, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background: radial-gradient(circle at 10% 20%, rgb(253, 239, 244) 0%, rgb(242, 246, 251) 90.1%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* App Container Layout */
.game-container {
    position: relative;
    display: flex;
    flex-direction: row;
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    max-height: 850px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    padding: 20px;
    gap: 20px;
}

/* Sidebar Styling */
.sidebar {
    flex: 0 0 380px;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 24px;
    padding: 24px;
    gap: 20px;
    box-shadow: var(--card-shadow);
    overflow-y: auto;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 2rem;
    color: var(--primary-color);
    filter: drop-shadow(0 2px 5px rgba(255, 101, 163, 0.3));
}

.header-logo h1 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.8rem;
    background: linear-gradient(45deg, var(--primary-color), #ff3c88);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Stanley Avatar & Chat */
.avatar-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, #f7fdfb, #f6f7fb);
    border: 1px solid #eef1f6;
    border-radius: 20px;
    padding: 16px;
    position: relative;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.02);
}

.avatar-container {
    position: relative;
    width: 90px;
    height: 90px;
    margin-bottom: 12px;
}

#stanley-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.avatar-badge {
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark-green);
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.chat-bubble {
    background: white;
    border-radius: 16px;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 5px 15px rgba(0,0,0,0.03);
    position: relative;
    width: 100%;
}

.chat-bubble p {
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text-main);
    font-weight: 500;
}

.chat-arrow {
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid white;
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
}

/* Scoreboard */
.scoreboard {
    background: linear-gradient(135deg, #ffffff, #fafbfd);
    border: 1px solid #edf2f7;
    border-radius: 20px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.scoreboard h3 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--dark-green);
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.score-player {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 12px;
    background: #f8fafc;
}

.player-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.blonde-dot {
    background: #ffd97d;
    box-shadow: 0 0 8px #ffd97d;
}

.grey-dot {
    background: #a5a5a5;
    box-shadow: 0 0 8px #a5a5a5;
}

.player-info {
    display: flex;
    flex-direction: column;
}

.player-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.pieces-left {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.game-status-box {
    margin-top: 5px;
    border-top: 1px solid #edf2f7;
    padding-top: 12px;
}

.status-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.status-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--dark-green);
}

.highlight-turn {
    color: var(--primary-color);
    animation: pulseTurn 2s infinite ease-in-out;
}

@keyframes pulseTurn {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.02); }
}

/* Button Styling */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
}

.btn {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    padding: 12px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(255, 101, 163, 0.3);
}

.btn-secondary {
    background: var(--light-green);
    color: var(--dark-green);
    border: 1px solid rgba(46, 196, 182, 0.2);
}

.btn-secondary:hover {
    background: var(--secondary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(46, 196, 182, 0.2);
}

/* Main Board Area Layout */
.board-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    height: 100%;
}

/* Reserve grid of unplaced pieces */
.reserve-container {
    width: 100%;
    max-width: 580px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 15px;
    padding: 10px 15px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.01);
}

.reserve-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--dark-green);
    margin-bottom: 6px;
}

.reserve-grid {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    min-height: 48px;
}

/* Reserve piece representations */
.reserve-piece {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid white;
    background-size: cover;
    background-position: center;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.reserve-piece:hover {
    transform: scale(1.1) translateY(-2px);
}

/* Board Felt container (Pink Velvet) */
.board-wrapper {
    position: relative;
    width: 100%;
    max-width: 520px;
    aspect-ratio: 1 / 1;
    background: linear-gradient(135deg, var(--pink-felt), var(--pink-felt-dark));
    border: 12px solid var(--dark-green);
    border-radius: 28px;
    box-shadow: 0 15px 35px rgba(31, 92, 69, 0.25), inset 0 2px 10px rgba(255,255,255,0.4);
    padding: 15px;
}

.board-felt {
    position: relative;
    width: 100%;
    height: 100%;
}

/* SVG Line Drawing */
.board-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.board-line {
    stroke: var(--board-line-color);
    stroke-width: 1.5px;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.85;
}

/* Board Points (Intersections) */
.board-points {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.point {
    position: absolute;
    width: 48px;
    height: 48px;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Invisible hit box has small elegant visual indicator inside */
.point::after {
    content: '';
    width: 18px;
    height: 18px;
    background: white;
    border: 3px solid var(--board-line-color);
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.point:has(.piece)::after {
    display: none;
}

/* Point status indicators */
.point:hover::after {
    transform: scale(1.3);
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
}

.point.legal-placement::after {
    background: #e6fdf6;
    border-color: var(--secondary-color);
    animation: pulseGreen 1.5s infinite alternate;
}

.point.legal-move-target::after {
    background: #fff0f5;
    border-color: var(--primary-color);
    animation: pulsePink 1.5s infinite alternate;
}

@keyframes pulseGreen {
    from { box-shadow: 0 0 2px var(--secondary-color); }
    to { box-shadow: 0 0 12px var(--secondary-color); }
}

@keyframes pulsePink {
    from { box-shadow: 0 0 2px var(--primary-color); }
    to { box-shadow: 0 0 12px var(--primary-color); }
}

/* Game Pieces on Board */
.piece {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    border-radius: 50%;
    border: 3px solid white;
    background-size: cover;
    background-position: center;
    z-index: 20;
    pointer-events: none;
    box-shadow: 0 5px 12px rgba(0,0,0,0.15);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Piece highlights */
.point:hover .piece {
    transform: scale(1.1);
    box-shadow: 0 8px 18px rgba(0,0,0,0.25);
}

.piece.user-piece {
    border-color: #ffd97d; /* Blonde trim */
    box-shadow: 0 4px 10px rgba(255, 217, 125, 0.4);
}

.piece.ai-piece {
    border-color: #cbd5e1; /* Grey trim */
    box-shadow: 0 4px 10px rgba(203, 213, 225, 0.4);
}

.piece.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px var(--primary-color);
    animation: bobPiece 1s infinite alternate;
}

.piece.removable {
    animation: shakePiece 0.15s infinite alternate;
    cursor: pointer;
    border-color: #dc2626;
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.6);
}

@keyframes bobPiece {
    from { transform: translateY(-2px); }
    to { transform: translateY(2px); }
}

@keyframes shakePiece {
    0% { transform: rotate(-4deg); }
    100% { transform: rotate(4deg); }
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    z-index: 100;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s;
}

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

.modal-content {
    background: white;
    border-radius: 24px;
    padding: 30px;
    width: 90%;
    max-width: 550px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    position: relative;
    animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 85vh;
    overflow-y: auto;
}

@keyframes scaleIn {
    from { transform: scale(0.8); }
    to { transform: scale(1); }
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--primary-color);
}

.modal h2 {
    font-family: 'Fredoka One', cursive;
    margin-bottom: 20px;
    font-size: 1.8rem;
    color: var(--dark-green);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.rule-section {
    background: #f8fafc;
    border-left: 4px solid var(--secondary-color);
    padding: 12px 16px;
    border-radius: 0 12px 12px 0;
}

.rule-section h4 {
    margin-bottom: 6px;
    color: var(--dark-green);
    display: flex;
    align-items: center;
    gap: 8px;
}

.rule-section p {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #475569;
}

.badge {
    background: var(--secondary-color);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 6px;
    text-transform: uppercase;
    font-weight: 800;
}

.mill-rule {
    border-left-color: var(--primary-color);
}

.mill-rule h4 {
    color: var(--primary-hover);
}

.warning-text {
    font-size: 0.85rem;
    color: #991b1b;
    background: #fee2e2;
    padding: 6px 10px;
    border-radius: 6px;
    margin-top: 8px;
}

/* Game Over Modal additions */
.text-center {
    text-align: center;
}

.game-over-emoji {
    font-size: 4.5rem;
    margin: 15px 0;
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.1));
    animation: bounceEmoji 1.5s infinite alternate;
}

@keyframes bounceEmoji {
    from { transform: translateY(-10px) scale(1); }
    to { transform: translateY(10px) scale(1.1); }
}

.game-over-message {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 25px;
    color: var(--text-main);
}

.btn-large {
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
}

/* Text color helpers */
.text-primary {
    color: var(--primary-color) !important;
}

.mt-2 {
    margin-top: 8px;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .game-container {
        flex-direction: column;
        height: auto;
        max-height: none;
        overflow-y: auto;
        padding: 12px;
    }
    
    .sidebar {
        flex: none;
        width: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .header-logo {
        order: 1;
    }
    
    .scoreboard {
        order: 2;
    }
    
    .button-group {
        order: 3;
    }
    
    .avatar-card {
        order: 4;
    }
    
    .board-area {
        height: auto;
        padding: 10px 0;
        order: 5;
    }
}

/* Theme Toggle Button */
.theme-toggle-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--sidebar-bg);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.25rem;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

.theme-toggle-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

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

/* Dark Theme Variables & Adjustments */
body.dark-theme {
    --bg-color: #0f172a;
    --sidebar-bg: rgba(30, 41, 59, 0.75);
    --primary-color: #f472b6;
    --primary-hover: #db2777;
    --secondary-color: #2dd4bf;
    --secondary-hover: #0d9488;
    --dark-green: #34d399;
    --light-green: #064e3b;
    --pink-felt: #1e1b4b;
    --pink-felt-dark: #0f172a;
    --board-line-color: rgba(46, 196, 182, 0.6);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --glow-shadow: 0 0 15px rgba(244, 114, 182, 0.4);
    
    background: radial-gradient(circle at 10% 20%, rgb(15, 23, 42) 0%, rgb(8, 10, 15) 90.1%);
}

/* Specific elements that need overrides due to hardcoded light colors */
body.dark-theme .game-container {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

body.dark-theme .theme-toggle-btn {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-theme .avatar-card {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-theme .chat-bubble {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-theme .chat-arrow {
    border-bottom-color: #1e293b;
}

body.dark-theme .scoreboard {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-theme .score-player {
    background: #0f172a;
}

body.dark-theme .reserve-container {
    background: rgba(15, 23, 42, 0.4);
    border-color: rgba(255, 255, 255, 0.15);
}

body.dark-theme .modal-content {
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

body.dark-theme .rule-section {
    background: #0f172a;
    border-left-color: var(--secondary-color);
}

body.dark-theme .rule-section.mill-rule {
    border-left-color: var(--primary-color);
}

body.dark-theme .rule-section p {
    color: #cbd5e1;
}

body.dark-theme .point::after {
    background: #0f172a;
    border-color: var(--board-line-color);
}

body.dark-theme .point:hover::after {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
}

body.dark-theme .point.legal-placement::after {
    background: rgba(46, 196, 182, 0.15);
}

body.dark-theme .point.legal-move-target::after {
    background: rgba(255, 101, 163, 0.15);
}

/* Modal Actions layout styling for multiple buttons */
.modal-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.modal-actions .btn {
    flex: 1;
    margin-top: 0;
}

@media (max-width: 480px) {
    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }
}

/* Button row for rules and more */
.button-row {
    display: flex;
    gap: 10px;
    width: 100%;
}
.button-row #rules-btn {
    flex: 1.6;
}
.button-row #more-btn {
    flex: 1;
}

/* More Cat Games Modal Styles */
.more-games-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.game-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid #edf2f7;
    border-radius: 16px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 1.05rem;
    transition: all 0.25s ease;
}

.game-link:hover {
    background: var(--light-green);
    border-color: var(--secondary-color);
    color: var(--dark-green);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 196, 182, 0.15);
}

body.dark-theme .game-link {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark-theme .game-link:hover {
    background: rgba(46, 196, 182, 0.15);
    border-color: var(--secondary-color);
    color: #2ec4b6;
}

.game-favicon {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
    transition: transform 0.25s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    background: white;
    padding: 2px;
}

.game-link:hover .game-favicon {
    transform: scale(1.15) rotate(4deg);
}


