:root {
    --bg-color: #1a1a1a;
    --primary-color: #2a2a2e;
    --text-color: #e2e2e2;
    --accent-color: #00aaff;
    --border-color: #444;
    --win-color: #4CAF50;
    --loss-color: #F44336;
}

html, body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
}

body {
    font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-color);
    padding: 1rem;
    box-sizing: border-box;
}

.simulator-wrapper {
    background-color: var(--primary-color);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 16px rgba(0,0,0,0.4);
    width: 650px;
    max-width: 800px;
    box-sizing: border-box;
}

.sim-header {
    text-align: center;
    margin-bottom: 1rem;
}

.sim-header h2 {
    color: var(--accent-color);
    margin: 0 0 0.5rem 0;
}

.sim-header p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #ccc;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

select, button, input {
    background-color: #333;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

input {
    width: 50px;
    text-align: center;
}

button:hover {
    background-color: #444;
}

.start-sim-btn {
    background-color: var(--accent-color);
    color: white;
    font-weight: bold;
}

.progress-container {
    width: 90%;
    max-width: 400px;
    background-color: #333;
    border-radius: 5px;
    margin: 1.5rem auto 0 auto;
    display: none;
    text-align: center;
    position: relative;
    color: white;
}

.progress-bar {
    width: 0%;
    height: 20px;
    background-color: var(--accent-color);
    border-radius: 5px;
    transition: width 0.2s linear;
}

.progress-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.9rem;
}

.game-board {
    display: flex !important;
    justify-content: space-around;
    margin: 2rem 0;
    text-align: center;
}

.machine-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #222;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    width: 20%;
    max-width: 150px;
}

.machine {
    font-size: 4rem;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
    border: 3px solid transparent;
    border-radius: 10px;
}

.machine:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.machine.highlight {
    border-color: var(--accent-color);
}

.machine-flair {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-weight: bold;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.5s, top 0.5s;
    pointer-events: none;
}

.machine-flair.show {
    opacity: 1;
    top: -50px;
}

.machine-flair.win {
    color: var(--win-color);
}

.machine-flair.loss {
    color: var(--loss-color);
}

.machine-info {
    font-size: 0.9rem;
    color: #aaa;
    margin-top: 0.5rem;
    min-height: 2.4em;
    line-height: 1.2;
}

/* --- VISUALIZATION STYLES (UCB & THOMPSON) --- */
.viz-container {
    height: 40px;
    width: 90%;
    max-width: 120px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.5s;
    position: relative;
}

.viz-container.visible {
    opacity: 1;
}

.ucb-viz, .thompson-viz {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    visibility: hidden; /* Hide both types by default */
}

/* Use parent class to control visibility of specific viz type */
.viz-container.ucb-visible .ucb-viz,
.viz-container.thompson-visible .thompson-viz {
    visibility: visible;
}

.viz-bar-wrapper {
    display: flex;
    width: 100%;
    height: 10px;
    background-color: #333;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    margin-top: 10px; /* Center it vertically a bit */
}

.viz-bar {
    height: 100%;
    transition: width 0.3s ease-in-out;
}

.ucb-value-bar {
    background-color: var(--accent-color);
    z-index: 2;
}

.ucb-bonus-bar {
    background-color: rgba(0, 170, 255, 0.4);
    z-index: 1;
}

.thompson-viz-svg {
    width: 100%;
    height: 100%;
}

.thompson-viz-path {
    fill: rgba(0, 170, 255, 0.5);
    stroke: var(--accent-color);
    stroke-width: 2px;
    transition: d 0.3s ease-in-out;
}

.ui-feedback {
    display: flex;
    justify-content: space-around;
    font-size: 1.2rem;
    font-weight: bold;
}

.chart-container {
    margin-top: 2rem;
    height: 350px;
}

.agent-description {
    display: none;
    font-family: 'Vazirmatn', sans-serif;
    direction: rtl;
    text-align: right;
    line-height: 1.6;
    background-color: #222;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-top: 1.5rem;
}

.agent-description h3 {
    color: var(--accent-color);
    margin-top: 0;
}

.log-area {
    margin-top: 1.5rem;
    border: 1px solid var(--border-color);
    padding: 1rem;
    height: 150px;
    overflow-y: scroll;
    background-color: #222;
    border-radius: 5px;
}

.log-area ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    font-family: 'Courier New', Courier, monospace;
}

.summary-table-container {
    margin-top: 2rem;
    display: none;
}

.summary-table-container table {
    width: 100%;
    border-collapse: collapse;
}

.summary-table-container th, .summary-table-container td {
    border: 1px solid var(--border-color);
    padding: 8px;
    text-align: left;
}

.summary-table-container th {
    background-color: #333;
}

.sim-actions {
    text-align: center;
    margin-top: 1.5rem;
}

.payout-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: #ccc;
    margin-top: 0.5rem;
}

.machine-info .wins {
    color: var(--win-color);
    font-weight: bold;
}

.machine-info .losses {
    color: var(--loss-color);
    font-weight: bold;
}

.machine-info .estimate {
    font-size: 0.8rem;
    color: #888;
}
