body {
    margin: 0;
    overflow: hidden;
    background-color: #888;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* --- Dark Sidebar --- */
#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 275px;
    color: #ccc;
    background: rgba(10, 10, 16, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 22px 18px;
    pointer-events: none;
    user-select: none;
    z-index: 50;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    box-sizing: border-box;
    transition: opacity 0.3s;
}

#ui-container.hidden {
    opacity: 0;
    pointer-events: none;
}

#ui-container h1 {
    margin: 0 0 2px 0;
    font-size: 22px;
    color: #c9a84c;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 0 12px rgba(201, 168, 76, 0.3);
}

#ui-container .subtitle {
    font-size: 11px;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 16px;
}

.section-sep {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 12px 0;
}

/* Score pillars — stacked modules */
.score-pillars {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: flex-end;
    height: 160px;
    margin: 0;
    padding: 0 8px;
}

.score-pillar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    flex: 1;
}

.pillar-stack {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    width: 28px;
    padding: 2px 0;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.pillar-segment {
    width: 22px;
    height: 4px;
    border-radius: 1px;
    margin-bottom: 1px;
}

/* Empty / grayed-out segments */
.pillar-segment.seg-empty {
    background: rgba(255, 255, 255, 0.04);
}

/* Active player segments (dynamic color) */
.pillar-segment.seg-white {
    background: linear-gradient(to right, rgba(200, 205, 215, 0.45), rgba(255, 255, 255, 0.85), rgba(200, 205, 215, 0.45));
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.2);
    animation: segmentPop 0.3s ease-out;
}

/* Active AI segments (dynamic color) */
.pillar-segment.seg-black {
    background: linear-gradient(to right, rgba(5, 5, 10, 1), rgba(25, 25, 35, 1), rgba(5, 5, 10, 1));
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5), inset 0 0 1px rgba(255, 255, 255, 0.1);
    animation: segmentPop 0.3s ease-out;
}

/* Separator rings */
.pillar-segment.seg-separator {
    height: 1px;
    width: 26px;
    margin-bottom: 0;
    border-radius: 0;
    animation: none;
    box-shadow: none;
}

.pillar-segment.seg-separator.sep-white {
    background: rgba(200, 210, 220, 0.3);
}

.pillar-segment.seg-separator.sep-black {
    background: rgba(100, 100, 130, 0.35);
}

.pillar-segment.seg-separator.sep-empty {
    background: rgba(255, 255, 255, 0.02);
}

.score-pillar .score-label {
    font-size: 9px;
    font-weight: bold;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.score-pillar .score-num {
    font-size: 15px;
    font-weight: bold;
    color: #aaa;
    margin-top: 1px;
    text-align: center;
    min-width: 20px;
}

@keyframes segmentPop {
    0% {
        transform: scaleX(0.3);
        opacity: 0;
    }

    100% {
        transform: scaleX(1);
        opacity: 1;
    }
}

/* Turn indicator */
#turn-indicator {
    margin-top: 10px;
    padding: 7px 10px;
    text-align: center;
    border-radius: 6px;
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: background 0.3s, color 0.3s;
}

/* Goal */
.goal-line {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: bold;
    color: #e8d48b;
    letter-spacing: 0.5px;
}

.goal-line .icon {
    font-size: 15px;
}

/* Actions header */
.actions-header {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #999;
    margin-bottom: 8px;
}

/* Action cards */
.action-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.action-card .action-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: bold;
    color: #e0e0e0;
    margin-bottom: 5px;
}

.action-card .action-title .icon {
    font-size: 16px;
}

.action-card .action-desc {
    font-size: 11px;
    color: #888;
    line-height: 1.5;
    margin: 0;
}

/* Spacer pushes bottom section down */
.sidebar-spacer {
    flex: 1;
}

/* Controls hint inside sidebar */
.controls-hint-inline {
    font-size: 10px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 10px;
}

.controls-hint-inline span {
    color: #777;
    font-weight: bold;
}

/* Restart button */
#ui-container button.restart-btn {
    pointer-events: auto;
    width: 100%;
    padding: 9px 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #888;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}

#ui-container button.restart-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #bbb;
    border-color: rgba(255, 255, 255, 0.25);
}

/* Generic buttons (game-over, etc.) */
button {
    pointer-events: auto;
    margin-top: 15px;
    width: 100%;
    padding: 10px 0;
    background: #000;
    border: none;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
}

button:hover:not(.side-btn):not(.restart-btn) {
    background: #333;
}

/* Hide old controls-hint (now inline in sidebar) */
#controls-hint {
    display: none;
}

/* --- Side Selection Overlay --- */
#side-select-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 300;
    pointer-events: auto;
}

#side-select-overlay h2 {
    display: none;
    /* Replaced by h1 in landing-content */
}

.landing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 600px;
    margin-bottom: 20px;
    animation: fadeInDown 0.8s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.landing-content h1 {
    font-size: 56px;
    color: #c9a84c;
    text-transform: uppercase;
    letter-spacing: 8px;
    margin: 0 0 20px 0;
    text-shadow: 0 0 30px rgba(201, 168, 76, 0.4);
}

.goal-highlight {
    background: linear-gradient(90deg, transparent, rgba(201, 168, 76, 0.15), transparent);
    padding: 15px 40px;
    margin-bottom: 30px;
    border-top: 1px solid rgba(201, 168, 76, 0.2);
    border-bottom: 1px solid rgba(201, 168, 76, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.goal-label {
    font-size: 11px;
    color: #c9a84c;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: bold;
}

.goal-text {
    font-size: 24px;
    color: #eee;
    font-weight: 300;
    text-align: center;
}

.goal-text .secondary {
    opacity: 0.5;
    font-size: 20px;
}

.choose-side-prompt {
    color: #666 !important;
    font-size: 14px !important;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px !important;
}

#side-select-overlay p {
    color: #aaa;
    font-size: 16px;
    margin-bottom: 40px;
}

.side-buttons {
    display: flex;
    gap: 40px;
}

.side-btn {
    width: 180px;
    height: 200px;
    border: 3px solid #555;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 20px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    gap: 16px;
}

.side-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
}

.side-btn-white {
    background: linear-gradient(135deg, #f0f0f0, #cccccc);
    color: #111;
    border-color: #ddd;
}

.side-btn-white:hover {
    background: linear-gradient(135deg, #ffffff, #e0e0e0);
    border-color: #fff;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
}

.side-btn-black {
    background: linear-gradient(135deg, #333, #111);
    color: #eee;
    border-color: #555;
}

.side-btn-black:hover {
    border-color: #888;
    box-shadow: 0 0 30px rgba(100, 100, 255, 0.4);
}

.side-btn .piece-icon {
    font-size: 64px;
    line-height: 1;
}

.side-hint {
    color: #666;
    font-size: 13px;
    margin-top: 30px;
}

/* --- 3D Dice Overlay --- */
.dice-overlay {
    position: absolute;
    /* Dynamic positioning set by class */
    display: flex;
    justify-content: flex-start;
    /* Align left */
    align-items: center;
    /* Default center, overridden by specific classes */
    z-index: 150;

    /* Sidebar offset */
    left: 295px;
    /* 275px sidebar + 20px gap */
    right: 0;

    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.dice-overlay.bottom {
    top: 20%;
    /* occupy bottom area */
    bottom: 40px;
    /* padding from bottom */
    align-items: flex-end;
    /* align to bottom of the flex container */
}

.dice-overlay.top {
    top: 40px;
    /* padding from top */
    bottom: 20%;
    /* occupy top area */
    align-items: flex-start;
    /* align to top of the flex container */
}

.dice-overlay.visible {
    opacity: 1;
}

.dice-overlay.fade-out {
    opacity: 0;
}

.dice-face {
    width: 120px;
    height: 120px;
    border-radius: 16px;
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 0;
    box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.12);
}

.dice-face.white-die {
    background: linear-gradient(135deg, #f8f8f8, #e0e0e0);
    border: 2px solid #ccc;
}

.dice-face.white-die .dot {
    background: #222;
}

.dice-face.black-die {
    background: linear-gradient(135deg, #333, #1a1a1a);
    border: 2px solid #555;
}

.dice-face.black-die .dot {
    background: #eee;
}

.dice-face .dot-grid {
    width: 90px;
    height: 90px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    place-items: center;
}

.dice-face .dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.dice-face .dot.hidden {
    visibility: hidden;
}

#game-over-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 140px;
    /* Fixed height bottom bar */
    background: linear-gradient(to top, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0.8));
    display: none;
    flex-direction: row;
    /* Horizontal layout */
    justify-content: center;
    align-items: center;
    gap: 40px;
    /* Space between text and button */
    color: white;
    z-index: 200;
    pointer-events: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
}

#game-over-overlay h2 {
    font-size: 32px;
    margin: 0;
    /* Reset margin */
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    letter-spacing: 2px;
}

#game-over-overlay button {
    width: auto;
    padding: 12px 30px;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
    margin-top: 0;
    /* Reset margin */
}

#game-over-overlay button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* --- Dev Menu --- */
#dev-menu {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 20px;
    color: #ccc;
    z-index: 1000;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    gap: 15px;
    font-family: monospace;
}

#dev-menu.visible {
    transform: translateX(0);
}

#dev-menu h2 {
    margin: 0 0 10px 0;
    font-size: 18px;
    color: #00ffff;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
    padding-bottom: 5px;
}

#dev-menu h3 {
    margin: 10px 0 5px 0;
    font-size: 14px;
    color: #aaa;
    text-transform: uppercase;
}

.dev-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    font-size: 12px;
}

.dev-control label {
    flex: 1;
}

.dev-control input[type="color"] {
    border: none;
    width: 30px;
    height: 20px;
    cursor: pointer;
    background: none;
    padding: 0;
}

.dev-control input[type="range"] {
    width: 100px;
    cursor: pointer;
}

.dev-control span {
    width: 30px;
    text-align: right;
    font-size: 10px;
    color: #888;
}

.section-group {
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.02);
}

/* --- Proximity Glow Overlays --- */
.glow-overlay {
    position: absolute;
    left: 0;
    right: 0;
    height: 15vh;
    min-height: 100px;
    pointer-events: none;
    z-index: 40;
    /* Above canvas, below standard ui-container */
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

.glow-overlay.active {
    opacity: 1;
    animation: pulseGlow 2s infinite alternate ease-in-out;
}

#glow-top {
    top: 0;
    background: linear-gradient(to bottom, rgba(255, 30, 30, 0.4), transparent);
}

#glow-bottom {
    bottom: 0;
    background: linear-gradient(to top, rgba(135, 206, 235, 0.4), transparent);
}

@keyframes pulseGlow {
    0% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}