:root {
    --bg: #0a0a0a;
    --surface: #111111;
    --surface-elevated: #161616;
    
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #999999;
    --text-faint: #666666;
    
    --border-subtle: #222222;
    --border-default: #333333;
    
    --accent: #ff6b35;
    --status-go: #22c55e;
    --status-stop: #ef4444;
    --status-wait: #f59e0b;
    
    --heatmap-low: #1a1a1a;
    --heatmap-mid: #333333;
    --heatmap-high: #4a4a4a;
    
    --shadow-panel: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-inset: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 14px;
    background: var(--bg);
    color: var(--text-secondary);
    padding: 16px;
    min-height: 100vh;
}

/* Header */
.main-header {
    margin-bottom: 16px;
}

.header-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.header-title-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

h1.brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    text-align: center;
}

.subtitle {
    color: var(--text-muted);
    font-size: 12px;
    margin: 0;
}

.header-attribution {
    width: 100%;
    text-align: center;
}

.header-attribution a {
    color: var(--text-faint);
    text-decoration: none;
    font-size: 11px;
}

.header-attribution a:hover {
    color: var(--text-muted);
}

/* Layout */
.container {
    max-width: 1600px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto auto;
    gap: 16px;
    justify-content: center;
}

@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr;
        justify-content: stretch;
    }
    
    .container > * {
        order: 0;
    }
    
    .history-sidebar {
        order: -1;
    }
}

.main-content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.history-sidebar {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Panels */
.panel {
    background: var(--surface);
    box-shadow: var(--shadow-panel);
    border-radius: 0;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.main-content > .panel,
.history-sidebar > .panel {
    width: 590px;
}

.panel h2 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: 400;
}

/* Inputs */
.input-group {
    margin-bottom: 10px;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.input-row .input-group {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-faint);
    font-size: 11px;
    letter-spacing: 0.02em;
}

input, select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border-subtle);
    border-radius: 0;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    box-shadow: var(--shadow-inset);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--border-default);
}

input::placeholder {
    color: var(--text-faint);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    box-shadow: none;
}

/* Buttons */
.button-row {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

button {
    padding: 8px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 400;
    border: none;
    border-radius: 0;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#startBtn {
    background: var(--status-go);
    color: var(--bg);
}

#startBtn:hover {
    background: #16a34a;
}

#stopBtn, button.stop {
    background: var(--status-stop);
    color: var(--text-primary);
}

#stopBtn:hover, button.stop:hover {
    background: #dc2626;
}

button.secondary, #clearBtn {
    background: var(--border-default);
    color: var(--text-secondary);
}

button.secondary:hover, #clearBtn:hover {
    background: #444444;
}

button:disabled {
    background: var(--border-subtle);
    color: var(--text-faint);
    cursor: not-allowed;
}

.view-board-btn {
    padding: 3px 8px;
    font-size: 10px;
    background: var(--border-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-default);
}

.view-board-btn:hover {
    background: var(--border-default);
    color: var(--text-primary);
}

/* Status Display */
.status {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.status.stopped {
    color: var(--status-stop);
    background: rgba(239, 68, 68, 0.1);
}

.status.running {
    color: var(--status-go);
    background: rgba(34, 197, 94, 0.1);
}

.status.waiting {
    color: var(--status-wait);
    background: rgba(245, 158, 11, 0.1);
}

/* Stats Section */
.stats-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stats-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stats-group-label {
    font-size: 11px;
    color: var(--text-faint);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-subtle);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.stat-item {
    background: var(--surface);
    padding: 10px 12px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}

.stat-label {
    font-size: 11px;
    color: var(--text-faint);
    letter-spacing: 0.02em;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 16px;
    color: var(--text-primary);
}

/* Log Container */
.log {
    background: var(--bg);
    padding: 10px;
    font-size: 11px;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

.log-entry {
    padding: 2px 0;
    border-left: 2px solid transparent;
    padding-left: 8px;
    margin-bottom: 1px;
}

.log-entry .timestamp {
    color: var(--text-faint);
    margin-right: 8px;
}

.log-entry.info {
    border-left-color: var(--text-faint);
}

.log-entry.success {
    border-left-color: var(--status-go);
}

.log-entry.error {
    border-left-color: var(--status-stop);
}

.log-entry.warning {
    border-left-color: var(--status-wait);
}

/* Bet History */
.history-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-header-row h2 {
    margin: 0;
}

.hide-skipped-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
}

.hide-skipped-label input {
    width: auto;
    box-shadow: none;
}

.history-header, .history-row {
    display: grid;
    grid-template-columns: 45px 50px 50px 55px 55px 55px 45px 45px 45px;
    gap: 4px;
    padding: 6px 8px;
    font-size: 10px;
}

.history-header {
    background: var(--surface-elevated);
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.history-row {
    background: var(--surface);
    border-left: 2px solid var(--border-default);
    margin-bottom: 2px;
}

.history-row.win {
    border-left-color: var(--status-go);
}

.history-row.loss {
    border-left-color: var(--status-stop);
}

.history-scroll {
    max-height: 400px;
    overflow-y: auto;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
    background: var(--bg);
    padding: 3px;
    width: 100%;
    max-width: 480px;
}

.grid-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    position: relative;
}

.grid-cell:hover {
    opacity: 0.9;
}

.grid-cell.bet-on {
    border: 2px solid var(--accent);
    box-shadow: 0 0 8px rgba(255, 107, 53, 0.4);
}

.grid-cell.optimal-square {
    border: 2px solid var(--accent);
    box-shadow: 0 0 8px rgba(255, 107, 53, 0.4);
}

.grid-cell.optimal-square::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-top: 6px solid var(--text-muted);
}

.grid-cell.lowest-5 {
    border: 1px dashed var(--text-faint);
}

.grid-cell.lowest-1 {
    border: 1px dashed var(--status-go);
}

.cell-value {
    font-size: 11px;
    color: var(--text-primary);
    text-align: center;
    font-weight: 400;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Accordion */
.accordion {
    width: 100%;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 8px 0;
    user-select: none;
}

.accordion-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 400;
}

.accordion-toggle {
    color: var(--text-muted);
    font-size: 12px;
}

.accordion.active .accordion-toggle {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
}

.accordion.active .accordion-content {
    max-height: 2000px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    padding: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.modal-edit {
    max-width: 600px;
    max-height: 90vh;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h2 {
    font-size: 15px;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: var(--border-default);
    color: var(--text-muted);
    padding: 4px 10px;
    font-size: 14px;
}

.modal-close:hover {
    background: #444444;
    color: var(--text-primary);
}

.modal-info {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 10px;
}

.edit-modal-body {
    padding: 10px 0;
}

/* Heatmap Grid (Modal) */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
    background: var(--bg);
    padding: 3px;
}

.heatmap-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    border: 2px solid transparent;
    position: relative;
}

.heatmap-cell.bet-on {
    border: 2px solid var(--accent);
    box-shadow: 0 0 8px rgba(255, 107, 53, 0.4);
}

.heatmap-cell.variance-reduction {
    border: 2px solid var(--status-wait);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.heatmap-cell .cell-value {
    font-size: 11px;
}

.heatmap-legend {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding: 10px;
    background: var(--bg);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text-muted);
}

.legend-color {
    width: 16px;
    height: 16px;
}

.legend-low {
    background: var(--heatmap-low);
}

.legend-mid {
    background: var(--heatmap-mid);
}

.legend-high {
    background: var(--heatmap-high);
}

.legend-bet {
    width: 16px;
    height: 16px;
    border: 2px solid var(--accent);
}

.legend-variance {
    width: 16px;
    height: 16px;
    border: 2px solid var(--status-wait);
}

/* Strategy Comparison (Modal) */
.strategy-comparison {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg);
}

.strategy-comparison h3 {
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 400;
    margin-bottom: 10px;
}

.strategy-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.strategy-item {
    background: var(--surface);
    padding: 10px;
    border-left: 2px solid var(--border-default);
}

.strategy-item.your-strategy {
    border-left-color: var(--accent);
}

.strategy-name {
    font-size: 10px;
    color: var(--text-faint);
    margin-bottom: 4px;
}

.strategy-ev {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-primary);
}

/* Bet Size Item */
.bet-size-item {
    background: var(--surface);
    padding: 10px;
    border-left: 2px solid var(--border-default);
    text-align: center;
}

.bet-size-item.optimal {
    border-left-color: var(--status-go);
}

/* Results Box */
.results-box {
    background: var(--bg);
    padding: 12px;
    margin-bottom: 8px;
}

.results-box h3 {
    font-size: 11px;
    color: var(--text-faint);
    font-weight: 400;
    margin-bottom: 6px;
}

.results-value {
    font-size: 16px;
    font-weight: 400;
}

.results-value.positive {
    color: var(--status-go);
}

.results-value.negative {
    color: var(--status-stop);
}

.results-value.neutral {
    color: var(--text-muted);
}

/* Timestamp */
.timestamp {
    color: var(--text-faint);
    font-size: 11px;
    margin-right: 8px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
}

::-webkit-scrollbar-thumb:hover {
    background: #444444;
}
