:root {
    --primary: #5d7a5c;
    /* Forest Green */
    --primary-dark: #3e533d;
    --secondary: #8b7355;
    /* Earthy Brown */
    --bg-light: #f4f1ea;
    /* Recycled Paper / Stone */
    --bg-dark: #2c3639;
    /* Deep Slate */
    --text: #3f4e4f;
    --text-light: #f4f1ea;
    --accent: #d4a373;
    /* Autumnal Orange */
    --glass: rgba(255, 255, 255, 0.4);
    --border: rgba(93, 122, 92, 0.2);
}

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

body {
    background-color: var(--bg-light);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 380px;
    height: 100%;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 10;
    background: transparent;
    pointer-events: none;
    /* Let clicks pass through to 3D scene where possible */
}

.sidebar>* {
    pointer-events: auto;
    /* Re-enable clicks for sidebar content */
}

header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    font-size: 2.5rem;
    color: var(--primary);
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

.game-info {
    background: white;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.player-turn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.player-token {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.last-roll {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    font-size: 2rem;
    font-weight: 700;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: 0.8rem;
    color: var(--primary-dark);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    padding: 1.2rem;
    border-radius: 1rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.1rem;
}

.btn.primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 8px 20px rgba(93, 122, 92, 0.3);
}

.btn.primary:hover {
    background: var(--primary-dark);
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(93, 122, 92, 0.4);
}

.btn.secondary {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn.secondary:hover {
    background: var(--bg-light);
}

.event-log {
    flex-grow: 1;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 1rem;
    padding: 1rem;
    overflow-y: auto;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 400px;
    /* Limit height to force scroll */
}

/* Custom Scrollbar */
.event-log::-webkit-scrollbar {
    width: 6px;
}

.event-log::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 10px;
}

.event-log::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
    opacity: 0.5;
}

.event-log::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

.log-entry {
    padding: 0.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.log-entry.system {
    color: var(--secondary);
    font-style: italic;
}

.log-entry.move {
    color: var(--text);
}

.log-entry.special {
    color: var(--accent);
    font-weight: 600;
}

/* Top Right Controls */
.top-right-controls {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    z-index: 50;
}

.icon-btn {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--glass);
    color: var(--primary);
}

.icon-btn:hover {
    background: white;
    transform: rotate(45deg);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.settings-menu {
    width: 200px;
    padding: 0.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    display: none;
    /* Hide by default */
    flex-direction: column;
    gap: 0.2rem;
    margin-top: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease;
    background: var(--glass);
    backdrop-filter: blur(10px);
}

.top-right-controls:hover .settings-menu {
    display: flex;
    /* Show on hover of parent */
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    border-radius: 0.8rem;
    border: none;
    background: transparent;
    color: var(--text);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: left;
}

.menu-item:hover {
    background: rgba(93, 122, 92, 0.1);
    color: var(--primary);
}

.menu-item .material-icons {
    font-size: 1.2rem;
}

/* 3D Wrapper */
.board-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background-color: #f4f1ea;
}

canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 3.5rem;
    border-radius: 2.5rem;
    text-align: center;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.tokenLarge {
    width: 5rem;
    height: 5rem;
    border-radius: 50%;
}

/* Setup Modal */
.setup-content {
    max-width: 500px;
}

.setup-section {
    width: 100%;
    margin-bottom: 2rem;
}

.setup-section label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.player-count-btns {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.count-btn {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    background: white;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.count-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(93, 122, 92, 0.3);
}

.player-inputs {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.player-input {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.03);
    padding: 0.8rem 1.2rem;
    border-radius: 1rem;
}

.player-input input {
    background: transparent;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    width: 100%;
    color: var(--text);
}

.player-input input:focus {
    outline: none;
}

/* Rules Modal Specifics */
.rules-content {
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.rules-header {
    padding: 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rules-header h2 {
    margin: 0;
    color: var(--primary-dark);
}

.close-modal {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text);
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--danger);
}

.rules-body {
    padding: 2rem;
    overflow-y: auto;
    line-height: 1.6;
}

.rules-body::-webkit-scrollbar {
    width: 6px;
}

.rules-body::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.rules-body h3 {
    margin: 1.5rem 0 1rem 0;
    color: var(--secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rules-body ul {
    padding-left: 1rem;
    list-style: none;
}

.rules-body li {
    margin-bottom: 1rem;
    position: relative;
}

.dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

@media (max-width: 1100px) {
    .game-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 1.5rem;
        flex-direction: row;
        flex-wrap: wrap;
    }
}