/* 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: #3b82f6;
    --player2-color: #1f2937;
    --highlight-move: #10b981;
    --shadow-subtle: rgba(0, 0, 0, 0.1);
    --grid-line: rgba(100, 90, 80, 0.25);
}

/* 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 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.player-name {
    font-weight: 700;
}

.stone-counts {
    font-size: 0.9rem;
    letter-spacing: 0.03em;
    color: rgba(42, 37, 32, 0.8);
}

.separator {
    margin: 0 12px;
    opacity: 0.5;
}

/* 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: 600px;
    height: 600px;
    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);
}

#reset-button {
    display: block;
    margin: 20px auto;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    position: relative;
    z-index: 1001;
}

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

.field-spot {
    fill: rgba(161, 161, 170, 0.9);
    stroke: rgba(63, 63, 70, 0.3);
    stroke-width: 1;
    transition: fill 0.2s, stroke 0.2s;
}

.field-spot.valid-move {
    fill: var(--highlight-move);
    stroke: #16a34a;
    stroke-width: 1.5;
}

.field-hitbox {
    fill: transparent;
    cursor: pointer;
}

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

.stone.player-1 {
    fill: #ffffff;
}

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

.stone.selected {
    filter: drop-shadow(0 0 8px var(--player1-color));
    stroke: var(--player1-color);
    stroke-width: 2;
    transform-origin: center;
}

.stone.player-2.selected {
    filter: drop-shadow(0 0 8px #f97316);
    stroke: #f97316;
}



/* Action Button */
.action-btn {
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    padding: 12px 24px;
    margin: 20px 0;
    border: 2px solid var(--border-color);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, rgba(240, 235, 225, 0.25) 100%);
    color: var(--dark-stone);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow-subtle);
    z-index: 1;
}

.action-btn:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(240, 235, 225, 0.35) 100%);
    border-color: rgba(100, 90, 80, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-subtle);
}

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

/* Message Overlay */
.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: 90vmin;
    }
}

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

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

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

    .message-content {
        padding: 30px 20px;
    }

    .message-title {
        font-size: 1.5rem;
    }
}