:root {
    --bg-color: #0d1117;
    --panel-bg: rgba(22, 27, 34, 0.6);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --tiger-color: #ff7b72;
    --goat-color: #3fb950;
    --line-color: rgba(255, 255, 255, 0.15);
    --node-color: rgba(255, 255, 255, 0.2);
    --node-hover: rgba(255, 255, 255, 0.4);
    --highlight-color: rgba(88, 166, 255, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(88, 166, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(255, 123, 114, 0.1) 0%, transparent 50%);
    padding: 20px;
}

.app-container {
    max-width: 1100px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

header {
    text-align: center;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--accent), #a371f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
    letter-spacing: -1px;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
}

.game-wrapper {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 40px;
    align-items: start;
}

/* Sidebar Styling */
.game-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.game-panel h2 {
    font-size: 1.5rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.status-card {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.status-card .label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-card .value {
    font-size: 1.2rem;
    font-weight: 600;
}

.turn-dot {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 10px currentColor;
}

.goat-turn {
    color: var(--goat-color);
    background: var(--goat-color);
}

.tiger-turn {
    color: var(--tiger-color);
    background: var(--tiger-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-num {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 5px;
}

#goats-placed {
    color: var(--goat-color);
}

#goats-captured {
    color: var(--tiger-color);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.message-box {
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
    animation: fadeIn 0.3s ease;
}

.message-box.hidden {
    display: none;
}

.message-win-tiger {
    background: rgba(255, 123, 114, 0.2);
    color: var(--tiger-color);
    border: 1px solid rgba(255, 123, 114, 0.3);
}

.message-win-goat {
    background: rgba(63, 185, 80, 0.2);
    color: var(--goat-color);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.settings-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.fancy-select {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.fancy-select option {
    background: var(--bg-color);
    color: var(--text-primary);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Board Styling */
.board-container {
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1;
    position: relative;
    margin: 0 auto;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
    padding: 40px;
    /* Internal padding for the board to sit inside */
}

/* Lines SVG Wrapper */
#board-lines {
    position: absolute;
    top: 40px;
    left: 40px;
    width: calc(100% - 80px);
    height: calc(100% - 80px);
    pointer-events: none;
}

#board-lines line {
    stroke: var(--line-color);
    stroke-width: 3;
    stroke-linecap: round;
}

/* Nodes and Pieces */
#nodes-container,
#pieces-container {
    position: absolute;
    top: 40px;
    left: 40px;
    width: calc(100% - 80px);
    height: calc(100% - 80px);
    pointer-events: none;
}

.node {
    position: absolute;
    width: 24px;
    height: 24px;
    background: var(--bg-color);
    border: 3px solid var(--node-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.node:hover {
    border-color: var(--node-hover);
    transform: translate(-50%, -50%) scale(1.2);
}

.node.highlight {
    background: var(--highlight-color);
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent);
}

.piece {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s, top 0.4s ease, left 0.4s ease;
    z-index: 20;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.piece.goat {
    background: linear-gradient(135deg, #7ee787, #3fb950);
    color: #000;
    border: 2px solid #2ea043;
}

.piece.tiger {
    background: linear-gradient(135deg, #ffa657, #ff7b72);
    color: #fff;
    border: 2px solid #d13b3b;
    width: 46px;
    /* Tigers slightly larger */
    height: 46px;
}

.piece:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.piece.selected {
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 0 20px currentColor;
    z-index: 30;
}

/* Rules Panel */
.rules-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 25px;
}

.rules-panel h3 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.rules-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.rule-column h4 {
    color: var(--accent);
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(88, 166, 255, 0.2);
    padding-bottom: 5px;
}

.rule-column ul {
    list-style-position: inside;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.rule-column li {
    margin-bottom: 5px;
}

/* Responsiveness */
@media (max-width: 900px) {
    .game-wrapper {
        grid-template-columns: 1fr;
    }

    .board-container {
        grid-row: 1;
        /* Board first on mobile */
    }

    .game-panel {
        grid-row: 2;
    }
}