/* Import Cinzel font for ancient aesthetic */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;700&family=Crimson+Text:wght@400;600&display=swap');

/* CSS Variables */
:root {
    --marble-bg: #d4cfc4;
    --dark-stone: #2a2520;
    --light-stone: #f5f1e8;
    --gold: #C5A059;
    --border-color: rgba(100, 90, 80, 0.3);
    --white-stone: #ffffff;
    --black-stone: #1a1a1a;
    --highlight-move: #10b981;
    --shadow-subtle: rgba(0, 0, 0, 0.1);
    --grid-line: rgba(100, 90, 80, 0.25);
    --menu-width: 320px;
    --transition-speed: 0.4s;
}

/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Crimson Text', serif;
    background-color: #0c0c0c;
    margin: 0;
    overflow: hidden;
    color: var(--light-stone);
    height: 100vh;
    width: 100vw;
}

#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
}

/* Top Bar */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: linear-gradient(180deg, rgba(12, 12, 12, 0.9) 0%, rgba(12, 12, 12, 0) 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    z-index: 100;
}

.top-bar-btn {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    padding: 10px 20px;
    background: rgba(197, 160, 89, 0.15);
    border: 1px solid var(--gold);
    color: var(--light-stone);
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 6px;
    letter-spacing: 0.05em;
    backdrop-filter: blur(10px);
    text-decoration: none;
    display: inline-block;
}

.top-bar-btn:hover {
    background: rgba(197, 160, 89, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(197, 160, 89, 0.2);
}

.menu-toggle-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 46px;
    height: 46px;
    padding: 0;
}

.menu-toggle-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--gold);
    transition: all 0.3s;
}

.menu-toggle-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4.5px);
}

.menu-toggle-btn.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4.5px);
}

/* Side Menu */
.side-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--menu-width);
    height: 100%;
    background: linear-gradient(180deg, rgba(42, 37, 32, 0.97) 0%, rgba(20, 16, 12, 0.98) 100%);
    border-left: 2px solid var(--gold);
    z-index: 999;
    transform: translateX(100%);
    transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
}

.side-menu.open {
    transform: translateX(0);
}

.menu-content {
    padding: 80px 28px 40px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    height: 100%;
    overflow-y: auto;
}

.game-title {
    font-family: 'Cinzel', serif;
    font-size: 2.2rem;
    text-align: center;
    color: var(--gold);
    letter-spacing: 0.12em;
    text-shadow: 0 2px 12px rgba(197, 160, 89, 0.3);
    margin-bottom: 8px;
}

.player-info {
    text-align: center;
}

.current-player-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 14px 20px;
    background: rgba(197, 160, 89, 0.1);
    border: 1px solid rgba(197, 160, 89, 0.3);
    border-radius: 8px;
}

.player-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--gold);
    transition: background-color 0.3s;
    background: #fff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

#player-name {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.stone-counts-display {
    display: flex;
    justify-content: center;
    gap: 24px;
}

.count-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
    font-family: 'Cinzel', serif;
}

.count-stone {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.count-stone.white {
    background: var(--white-stone);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.count-stone.black {
    background: var(--black-stone);
    border-color: rgba(255, 255, 255, 0.1);
}

.menu-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: 0.3;
}

.menu-btn {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    padding: 15px 24px;
    background: linear-gradient(135deg, rgba(197, 160, 89, 0.2), rgba(197, 160, 89, 0.1));
    border: 1px solid var(--gold);
    color: var(--light-stone);
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 8px;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.menu-btn:hover {
    background: linear-gradient(135deg, rgba(197, 160, 89, 0.4), rgba(197, 160, 89, 0.2));
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(197, 160, 89, 0.3);
}

.menu-footer {
    margin-top: auto;
    text-align: center;
    padding-top: 20px;
    font-size: 0.8rem;
    opacity: 0.6;
    letter-spacing: 0.1em;
    line-height: 1.6;
}

/* Game Message Overlay (Old naming kept for compatibility) */
.message-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    backdrop-filter: blur(8px);
}

.message-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.message-content {
    background: linear-gradient(145deg, rgba(42, 37, 32, 0.98), rgba(20, 16, 12, 0.98));
    border: 3px solid var(--gold);
    padding: 48px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.message-overlay.visible .message-content {
    transform: scale(1);
}

.message-title {
    font-family: 'Cinzel', serif;
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-bottom: 20px;
    color: var(--gold);
}

.message-text {
    font-size: 1.2rem;
    letter-spacing: 0.03em;
    line-height: 1.6;
    margin-bottom: 30px;
    opacity: 0.9;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.modal-btn {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    padding: 12px 24px;
    background: var(--gold);
    color: var(--dark-stone);
    border: 1px solid var(--gold);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s;
    flex: 1;
    max-width: 180px;
    text-decoration: none;
    display: inline-block;
}

.modal-btn.secondary {
    background: transparent;
    color: var(--gold);
}

.modal-btn:hover {
    box-shadow: 0 0 20px rgba(197, 160, 89, 0.6);
    transform: translateY(-2px);
}

/* Rules Modal */
.rules-modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.rules-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.rules-content {
    position: relative;
    background: linear-gradient(145deg, rgba(42, 37, 32, 0.98), rgba(25, 20, 16, 0.98));
    border: 2px solid var(--gold);
    padding: 40px;
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 12px;
    z-index: 1;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.rules-content h2 {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: var(--gold);
    text-align: center;
    margin-bottom: 28px;
    letter-spacing: 0.1em;
}

.rules-body p {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 18px;
}

.rules-body strong {
    color: var(--gold);
    font-family: 'Cinzel', serif;
    display: block;
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.action-btn {
    display: block;
    width: 100%;
    margin-top: 24px;
    padding: 14px;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    background: rgba(197, 160, 89, 0.2);
    border: 1px solid var(--gold);
    color: var(--light-stone);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.action-btn:hover {
    background: var(--gold);
    color: var(--dark-stone);
}

/* Game Message Tooltip */
.game-message {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 28px;
    background: rgba(12, 12, 12, 0.95);
    border: 2px solid var(--gold);
    border-radius: 30px;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    z-index: 500;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.game-message.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
}

/* Responsive */
@media (max-width: 480px) {
    :root {
        --menu-width: 280px;
    }
    .game-title {
        font-size: 1.8rem;
    }
    .top-bar {
        padding: 0 16px;
    }
}