/* 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;
    --valid-move: #10b981;
    --artemis-glow: #a855f7;
    --shadow-subtle: rgba(0, 0, 0, 0.1);
    --connection-line: rgba(100, 90, 80, 0.4);
}

/* 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;
}

/* SVG Game Board */
#game-board {
    max-width: 90vmin;
    max-height: 90vmin;
    width: 500px;
    height: 700px;
    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);
}

/* SVG Elements */
.connection-line {
    stroke: var(--connection-line);
    stroke-width: 1.5;
}

.node-spot {
    fill: rgba(161, 161, 170, 1.0);
    stroke: rgba(63, 63, 70, 0.4);
    stroke-width: 1.5;
    transition: fill 0.2s, stroke 0.2s;
    cursor: pointer;
}

.node-spot.artemis {
    fill: rgba(168, 85, 247, 0.2);
    stroke: var(--artemis-glow);
    stroke-width: 2;
}

.node-spot.valid-move {
    fill: rgba(16, 185, 129, 0.3);
    stroke: var(--valid-move);
    stroke-width: 2;
    opacity: 1;
    filter: drop-shadow(0 0 4px var(--valid-move));
}

.stone {
    stroke: rgba(0, 0, 0, 0.3);
    stroke-width: 1.5;
    transition: transform 0.2s, filter 0.2s, stroke 0.2s;
    cursor: pointer;
}

.stone.white {
    fill: var(--player1-color);
}

.stone.black {
    fill: var(--player2-color);
}

.stone.selected {
    filter: drop-shadow(0 0 10px var(--selection-glow));
    stroke: var(--selection-glow);
    stroke-width: 2;
    /* Removed scale transform for flatter look */
}

.stone.in-leap-chain {
    filter: drop-shadow(0 0 6px var(--artemis-glow));
    stroke: var(--artemis-glow);
    stroke-width: 2.5;
}

.leap-of-faith-spot {
    fill: rgba(239, 68, 68, 0.7);
    stroke: #dc2626;
    stroke-width: 2.5;
    cursor: pointer;
    transition: all 0.2s;
    animation: pulse-red 1.5s ease-in-out infinite;
}

.leap-of-faith-spot:hover {
    fill: rgba(239, 68, 68, 0.9);
    stroke: #b91c1c;
    stroke-width: 3;
    /* Removed scale transform for flatter look */
}

@keyframes pulse-red {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

/* 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);
}

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

.cancel-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;
}

/* Game Over Modal */
.message-overlay {
    position: fixed;
    inset: 0;
    background: rgba(42, 37, 32, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 100;
}

.message-overlay.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

.message-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(240, 235, 225, 0.9) 100%);
    border: 2px solid var(--border-color);
    padding: 40px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.message-title {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-bottom: 16px;
    color: var(--dark-stone);
}

.message-text {
    font-size: 1rem;
    letter-spacing: 0.03em;
    line-height: 1.6;
    margin-bottom: 24px;
    color: rgba(42, 37, 32, 0.8);
}

/* 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;
    }

    #game-board {
        width: 90vmin;
        height: calc(90vmin * 1.4);
    }
}

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

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

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

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