:root {
    --bg-color: #f0f0f0;
    --board-bg: #008080;
    --tile-bg: #006a6a;
    --black-piece: #111;
    --white-piece: #fff;
    --text-color: #333;
    --primary-green: #2d5016;
    --secondary-green: #4a7c59;
    --accent-gold: #d4af37;
    --soft-white: #f8f8f8;
    --dark-gray: #2c3e50;
    --light-gray: #ecf0f1;
    --hover-green: #3e6625;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    background: linear-gradient(135deg, var(--soft-white) 0%, var(--light-gray) 100%);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

#app {
    width: 100%;
    max-width: 1000px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--secondary-green) 100%);
    color: var(--soft-white);
    padding: 15px 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 30px;
}

#logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 0;
}

#logo {
    height: 120px;
    width: auto;
    filter: drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.4));
    transition: transform 0.3s ease;
}

#logo:hover {
    transform: scale(1.05);
}

#title-link {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--soft-white);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

#main-nav {
    display: flex;
    gap: 16px;
    align-items: center;
}

.nav-item {
    cursor: pointer;
    padding: 10px 18px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--soft-white);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    font-weight: 600;
}

.nav-item:hover,
.nav-item:focus-visible {
    background: rgba(255, 255, 255, 0.2);
    color: var(--accent-gold);
    transform: translateY(-2px);
    outline: none;
}

#game-container {
    display: flex;
    gap: 25px;
    background: var(--soft-white);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

#board-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
}

#board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 60vmin;
    height: 60vmin;
    max-width: 500px;
    max-height: 500px;
    background-color: var(--board-bg);
    border: 5px solid var(--board-bg);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
    border-radius: 8px;
}

.tile {
    background-color: var(--tile-bg);
    border: 1px solid var(--board-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    min-width: 0;
    min-height: 0;
}

.tile .piece {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.black-piece {
    background-color: var(--black-piece);
}

.white-piece {
    background-color: var(--white-piece);
}

.valid-move-indicator {
    width: 50%;
    height: 50%;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.3);
    border: 2px dashed rgba(255, 255, 255, 0.5);
}

.analysis-score {
    position: absolute;
    top: 2px;
    right: 2px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    pointer-events: none;
    z-index: 10;
}

.tile.analysis-very-good {
    background: linear-gradient(rgba(0, 255, 0, 0.6), rgba(0, 255, 0, 0.6)), var(--tile-bg);
}

.tile.analysis-good {
    background: linear-gradient(rgba(127, 255, 0, 0.5), rgba(127, 255, 0, 0.5)), var(--tile-bg);
}

.tile.analysis-neutral {
    background: linear-gradient(rgba(255, 255, 0, 0.4), rgba(255, 255, 0, 0.4)), var(--tile-bg);
}

.tile.analysis-bad {
    background: linear-gradient(rgba(255, 127, 0, 0.5), rgba(255, 127, 0, 0.5)), var(--tile-bg);
}

.tile.analysis-very-bad {
    background: linear-gradient(rgba(255, 0, 0, 0.6), rgba(255, 0, 0, 0.6)), var(--tile-bg);
}

.last-move-player {
    box-shadow: inset 0 0 0 3px #00ff00;
}

.flipped-player {
    box-shadow: inset 0 0 0 2px #008000;
}

.last-move-ai {
    box-shadow: inset 0 0 0 3px #ff0000;
}

.flipped-ai {
    box-shadow: inset 0 0 0 2px #8b0000;
}

#game-info {
    width: 250px;
    padding: 20px;
    background: linear-gradient(135deg, var(--soft-white) 0%, var(--light-gray) 100%);
    border: 1px solid rgba(45, 80, 22, 0.1);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

#game-info h2 {
    color: var(--primary-green);
    margin-top: 0;
    text-align: center;
    font-size: 1.3rem;
}

#score,
#turn {
    background: rgba(45, 80, 22, 0.05);
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 6px;
    font-weight: 500;
    text-align: center;
}

#game-controls button {
    width: 100%;
    padding: 12px;
    margin-top: 12px;
    font-size: 1em;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--secondary-green) 100%);
    color: var(--soft-white);
    border: none;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

#game-controls button:hover,
#game-controls button:focus-visible {
    background: linear-gradient(135deg, var(--hover-green) 0%, var(--primary-green) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    outline: none;
}

#game-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-weight: 500;
    color: var(--dark-gray);
}

#game-controls input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

#detailed-analysis-view {
    margin-top: 25px;
    background: var(--soft-white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

#detailed-analysis-view h2,
#dav-content h3 {
    color: var(--primary-green);
}

.hidden {
    display: none !important;
}

.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
    padding: 20px;
    z-index: 50;
}

.modal-content {
    background: linear-gradient(135deg, var(--soft-white) 0%, var(--light-gray) 100%);
    padding: 30px 40px;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid rgba(45, 80, 22, 0.1);
}

.modal-content.wide {
    width: min(700px, 90vw);
}

.modal-content h3 {
    color: var(--primary-green);
    margin-top: 0;
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-content input,
.modal-content select {
    padding: 12px 15px;
    border: 2px solid rgba(45, 80, 22, 0.2);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: var(--soft-white);
}

.modal-content input:focus,
.modal-content select:focus {
    outline: none;
    border-color: var(--secondary-green);
    box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.1);
}

.modal-content label {
    font-weight: 500;
    color: var(--dark-gray);
}

.modal-content button,
.modal-actions button {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--secondary-green) 100%);
    color: var(--soft-white);
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.modal-content button:hover,
.modal-content button:focus-visible {
    background: linear-gradient(135deg, var(--hover-green) 0%, var(--primary-green) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    outline: none;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.full-width {
    width: 100%;
    margin-top: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

th {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--secondary-green) 100%);
    color: var(--soft-white);
    font-weight: 600;
    padding: 12px;
    text-align: left;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(45, 80, 22, 0.1);
}

tr:nth-child(even) {
    background-color: rgba(45, 80, 22, 0.03);
}

td button {
    margin-right: 6px;
}

#message-region {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    max-width: min(560px, calc(100vw - 32px));
    background: rgba(44, 62, 80, 0.95);
    color: var(--soft-white);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 60;
}

#message-region.visible {
    opacity: 1;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        flex-direction: column;
        padding: 20px;
        text-align: center;
    }

    #logo {
        height: 100px;
    }

    #game-container {
        flex-direction: column;
        gap: 20px;
    }

    #game-info {
        width: 100%;
        max-width: 420px;
        margin: 0 auto;
    }

    #board {
        width: 90vmin;
        height: 90vmin;
        max-width: 90vmin;
        max-height: 90vmin;
    }

    .modal-content {
        padding: 20px 25px;
    }
}

@media (max-width: 480px) {
    #logo {
        height: 80px;
    }

    #title-link {
        font-size: 1.5rem;
    }

    table {
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 8px;
    }
}
