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

/* CSS Variables */
:root {
    --marble-bg: #d4cfc4;
    --dark-stone: #2a2520;
    --light-stone: #f5f1e8;
    --border-color: rgba(100, 90, 80, 0.3);
    --player1-color: #ffffff;
    --player2-color: #1a1a1a;
    --selection-glow: #f59e0b;
    --light-source-glow: #3b82f6;
    --target-highlight: #10b981;
    --move-path-highlight: #a855f7;
    --shadow-subtle: rgba(0, 0, 0, 0.1);
    --cell-size: min(calc(90vmin / 9), 66px);
}

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

body {
    font-family: 'Cinzel', 'Times New Roman', serif;
    background-color: var(--marble-bg);
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="4" /></filter><rect width="400" height="400" filter="url(%23noise)" opacity="0.05"/></svg>');
    background-size: 100px 100px, 100px 100px, 400px 400px;
    min-height: 100vh;
    color: var(--dark-stone);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    touch-action: manipulation;
}

/* Marble overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(200, 190, 180, 0.15) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Back Link */
.back-link {
    position: absolute;
    top: 20px;
    left: 20px;
    color: var(--dark-stone);
    text-decoration: none;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    z-index: 10;
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(100, 90, 80, 0.5);
}

/* Header */
.game-header {
    text-align: center;
    margin: 40px 0 20px;
    z-index: 1;
}

.game-title {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--dark-stone);
    text-shadow:
        2px 2px 0px rgba(255, 255, 255, 0.3),
        -1px -1px 0px rgba(0, 0, 0, 0.1);
    margin-bottom: 8px;
}

.game-subtitle {
    font-size: 1rem;
    letter-spacing: 0.1em;
    color: rgba(42, 37, 32, 0.7);
    font-weight: 400;
}

/* Status Panel */
.status-panel {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(240, 235, 225, 0.2) 100%);
    border: 1px solid var(--border-color);
    padding: 16px 24px;
    margin: 20px 0;
    text-align: center;
    box-shadow: 0 4px 12px var(--shadow-subtle);
    max-width: 600px;
    width: 100%;
    z-index: 1;
}

.turn-display {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.03em;
}

.current-player-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 12px;
    border: 2px solid var(--dark-stone);
    box-shadow: 0 2px 4px var(--shadow-subtle);
}

/* Board Wrapper */
.board-wrapper {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    z-index: 1;
}

/* Board Container */
.board-container {
    position: relative;
    width: calc(var(--cell-size) * 9);
    height: calc(var(--cell-size) * 9);
    max-width: 90vmin;
    max-height: 90vmin;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(240, 235, 225, 0.1) 100%);
    border: 2px solid var(--border-color);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    overflow: hidden;
}

/* Board Cells */
.cell {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
    border: 0.5px solid rgba(100, 90, 80, 0.2);
    aspect-ratio: 1 / 1;
}

.cell:nth-child(2n) {
    background-color: rgba(209, 213, 219, 0.3);
}

.cell:nth-child(odd) {
    background-color: rgba(229, 231, 235, 0.3);
}

/* Pieces */
.piece {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s, opacity 0.3s, box-shadow 0.15s;
    cursor: pointer;
    z-index: 10;
    position: relative;
}

.piece.white {
    background-color: var(--player1-color);
    border: 2px solid rgba(107, 114, 128, 0.5);
}

.piece.black {
    background-color: var(--player2-color);
    border: 2px solid rgba(75, 85, 99, 0.5);
}

/* Piece States */
.selected-piece {
    transform: scale(1.15);
    box-shadow: 0 0 15px 5px var(--selection-glow);
    z-index: 20;
}

.start-piece {
    box-shadow: 0 0 0 3px var(--move-path-highlight);
}

.darkened {
    opacity: 0.3;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.9);
    cursor: default;
    pointer-events: none;
}

/* Light Source Highlighting */
.available-light-source {
    border: 3px solid var(--light-source-glow);
    animation: pulse-light 1s infinite alternate;
}

@keyframes pulse-light {
    from {
        box-shadow: 0 0 10px 5px rgba(59, 130, 246, 0.7);
    }

    to {
        box-shadow: 0 0 15px 8px rgba(59, 130, 246, 0.9);
    }
}

/* Target Cell Highlighting */
.highlight-move-target {
    background-color: rgba(16, 185, 129, 0.4);
    box-shadow: inset 0 0 10px 3px var(--target-highlight);
}

/* Beacon Indicators */
.unlit-beacon-indicator {
    position: absolute;
    width: 90%;
    height: 90%;
    border-radius: 50%;
    background-color: rgba(156, 163, 175, 0.3);
    z-index: 1;
}

.beacon-lit-indicator {
    position: absolute;
    width: 90%;
    height: 90%;
    border-radius: 50%;
    opacity: 0.85;
    z-index: 5;
    transition: background-color 0.3s, box-shadow 0.3s;
    box-shadow: 0 0 12px 4px rgba(234, 179, 8, 0.7);
}

.beacon-lit-white {
    background-color: rgba(255, 255, 255, 0.8);
}

.beacon-lit-black {
    background-color: rgba(26, 26, 26, 0.8);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 16px;
    margin: 20px 0;
    position: relative;
    z-index: 1001;
}

.action-btn {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    padding: 12px 24px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow-subtle);
}

.end-turn-btn {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.9) 0%, rgba(245, 158, 11, 0.85) 100%);
    color: var(--dark-stone);
}

.end-turn-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.95) 0%, rgba(217, 119, 6, 0.9) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.reset-btn {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9) 0%, rgba(220, 38, 38, 0.85) 100%);
    color: white;
}

.reset-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.95) 0%, rgba(185, 28, 28, 0.9) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.action-btn:active:not(:disabled) {
    transform: translateY(0);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.hidden {
    display: none !important;
}

/* Message Box */
.message-box {
    background: linear-gradient(135deg, rgba(55, 65, 81, 0.95) 0%, rgba(31, 41, 55, 0.9) 100%);
    border: 1px solid rgba(156, 163, 175, 0.3);
    color: #f3f4f6;
    padding: 16px 24px;
    margin: 16px 0;
    max-width: 600px;
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
    letter-spacing: 0.03em;
    line-height: 1.6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

/* Footer */
.game-footer {
    margin-top: 20px;
    text-align: center;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    color: rgba(42, 37, 32, 0.6);
    z-index: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 2.5rem;
    }

    .game-subtitle {
        font-size: 0.9rem;
    }

    .back-link {
        font-size: 0.85rem;
        padding: 6px 12px;
    }

    .action-btn {
        font-size: 0.85rem;
        padding: 10px 20px;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 2rem;
    }

    .action-buttons {
        flex-direction: column;
        width: 100%;
        max-width: 300px;
    }

    .action-btn {
        width: 100%;
    }
}