/* 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: #ef4444;
    --highlight-move: #10b981;
    --highlight-diminish: #f59e0b;
    --shadow-subtle: rgba(0, 0, 0, 0.1);
}

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

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

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

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

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

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

.action-btn:hover:not(:disabled) {
    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:not(:disabled) {
    transform: translateY(0);
}

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

.cancel-btn {
    background: linear-gradient(135deg, rgba(200, 190, 180, 0.3) 0%, rgba(180, 170, 160, 0.25) 100%);
}

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

/* Game Board */
.game-board {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    width: 90vmin;
    height: 90vmin;
    max-width: 600px;
    max-height: 600px;
    background: rgba(255, 255, 255, 0.15);
    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);
}

/* Board Squares */
.board-square {
    background-color: var(--light-stone);
    border: 0.5px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    position: relative;
    aspect-ratio: 1 / 1;
}

.board-square.removed {
    background-color: transparent;
    border: none;
    pointer-events: none;
}

.board-square.place-target,
.board-square.move-target {
    background-color: var(--highlight-move);
    cursor: pointer;
}

.board-square.place-target:hover,
.board-square.move-target:hover {
    background-color: #059669;
}

/* Dice */
.die {
    width: 85%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    user-select: none;
    box-shadow: 0 2px 6px var(--shadow-subtle);
}

.die-p1 {
    background-color: white;
    color: black;
    border-color: rgba(0, 0, 0, 0.15);
}

.die-p2 {
    background-color: black;
    color: white;
    border-color: rgba(255, 255, 255, 0.15);
}

.die.selected {
    transform: scale(1.1);
}

.die-p1.selected {
    border-color: var(--player1-color);
    box-shadow: 0 0 12px var(--player1-color);
}

.die-p2.selected {
    border-color: var(--player2-color);
    box-shadow: 0 0 12px var(--player2-color);
}

.die:hover:not(.selected) {
    opacity: 0.9;
    transform: scale(1.05);
}

.die.diminish-target {
    cursor: pointer;
    border-color: var(--highlight-diminish) !important;
    box-shadow: 0 0 12px var(--highlight-diminish);
}

.die.forced-select-target {
    cursor: pointer;
}

.die-p1.forced-select-target {
    border-color: var(--player1-color) !important;
    box-shadow: 0 0 12px var(--player1-color);
}

.die-p2.forced-select-target {
    border-color: var(--player2-color) !important;
    box-shadow: 0 0 12px var(--player2-color);
}

/* Message Panel */
.message-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;
    max-width: 600px;
    width: 100%;
    font-size: 0.95rem;
    letter-spacing: 0.03em;
    line-height: 1.6;
    box-shadow: 0 4px 12px var(--shadow-subtle);
    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;
    }

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

    .die {
        font-size: 1rem;
    }
}

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

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

    .action-panel {
        gap: 8px;
    }

    .action-btn {
        font-size: 0.8rem;
        padding: 8px 14px;
    }

    .die {
        font-size: 0.9rem;
    }
}

/* Modal Styles */
.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);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.message-text {
    font-size: 1.1rem;
    letter-spacing: 0.03em;
    line-height: 1.6;
    color: rgba(42, 37, 32, 0.9);
    font-weight: 500;
}

.reset-btn {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9) 0%, rgba(220, 38, 38, 0.85) 100%);
    color: white;
    border-color: rgba(185, 28, 28, 0.5);
    min-width: 160px;
}

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

.hidden {
    display: none !important;
}