:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #bb86fc;
    --border: #333;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--accent);
}



.hidden {
    display: none;
}

/* Tabs */
.tabs {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 10px 20px;
    cursor: pointer;
    font-size: 1rem;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.hand-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.chart-samples {
    margin-top: 20px;
    padding: 10px;
    border-top: 1px solid #444;
}

.sample-hands-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.sample-hand-card {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #444;
}

.sample-hand-card h5 {
    margin-top: 0;
    margin-bottom: 8px;
    color: var(--accent);
}

.card-list.small .card-item {
    padding: 2px 5px;
    font-size: 0.85em;
}

.played-section {
    margin-top: 10px;
    border-top: 1px solid #444;
    padding-top: 5px;
}

.played-section strong {
    font-size: 0.8em;
    color: #aaa;
    display: block;
    margin-bottom: 4px;
}

.tab-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.category-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border);
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.category-title {
    font-weight: bold;
    color: var(--accent);
}

.category-count {
    background: #333;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
}

.card-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

p.hand-section h5 {
    margin: 0 0 10px 0;
    font-size: 0.9em;
    text-transform: uppercase;
    color: #888;
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
}

.controls-row {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: left;
}

.control-group label {
    font-size: 0.9em;
    color: #aaa;
}

#targetCardSelect,
#iterationsInput {
    padding: 8px;
    background: #2a2a2a;
    border: 1px solid #444;
    color: #fff;
    border-radius: 4px;
}

#iterationsInput {
    width: 150px;
}

.input-hint {
    font-size: 0.85em;
    color: #888;
    margin-left: 8px;
}

.progress-container {
    margin: 15px 0;
    padding: 15px;
    background: #2a2a2a;
    border-radius: 4px;
    border: 1px solid #444;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #1a1a1a;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #9c6fd4);
    width: 0%;
    transition: width 0.3s ease;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.8;
    }

    50% {
        opacity: 1;
    }
}

.progress-text {
    font-size: 0.9em;
    color: #aaa;
    text-align: center;
}

/* Import UI */
.import-container {
    margin-top: 15px;
    padding: 15px;
    background: #2a2a2a;
    border-radius: 4px;
    border: 1px solid #444;
}

.import-row {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.import-input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 4px;
    background: #1e1e1e;
    border: 1px solid #444;
    color: #fff;
    font-size: 0.95rem;
}

.import-input:focus {
    outline: none;
    border-color: var(--accent);
}

.action-btn.secondary {
    background: #444;
    color: #fff;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.action-btn.secondary:hover {
    background: #555;
}

.import-status {
    margin-top: 8px;
    font-size: 0.9em;
    min-height: 20px;
}

.import-status.success {
    color: #4caf50;
}

.import-status.error {
    color: #f44336;
}

.target-stats {
    margin-bottom: 20px;
}

.sample-lines {
    margin-top: 15px;
    text-align: left;
}

.sample-lines h4 {
    margin-bottom: 15px;
    color: #aaa;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
}

.sample-game {
    background: #222;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 1px solid #333;
}

.sample-game h5 {
    margin: 0 0 10px 0;
    color: #646cff;
}

.small-hand h6 {
    margin: 0 0 5px 0;
    font-size: 0.8em;
    color: #888;
    text-transform: uppercase;
}

.card-list.horizontal {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0;
    list-style: none;
    margin-bottom: 10px;
}

.card-list.horizontal li {
    background: #333;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.85em;
}

.line-box {
    background: #1a1a1a;
    padding: 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    border-left: 3px solid #646cff;
}

.line-box ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.line-box li {
    margin-bottom: 4px;
    padding: 2px 0;
}

.line-box li.interactive-step {
    text-decoration: underline dotted #666;
}

.line-box li.interactive-step:hover {
    color: #fff;
    text-decoration: underline dotted #fff;
}

.no-data {
    color: #666;
    font-style: italic;
    padding: 10px;
}

.card-list li {
    margin-bottom: 4px;
    position: relative;
}

.card-list li:hover {
    color: var(--accent);
}

.card-preview {
    position: fixed;
    z-index: 1000;
    /* width: 240px;  Removed fixed width to allow expansion */
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    display: none;
    background: transparent;
    display: flex;
    gap: 10px;
}

.card-preview img {
    width: 240px;
    border-radius: 10px;
}

.card-preview.visible {
    display: flex;
    /* Changed from block to flex */
}

.tutor-target {
    font-size: 0.8em;
    color: var(--text-secondary);
    font-style: italic;
}

.simulation-controls {
    padding: 20px;
    text-align: center;
}

.action-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.action-btn:hover {
    opacity: 0.9;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.sim-result {
    margin-top: 20px;
    font-size: 1.2rem;
}

.note {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.sim-stats table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
}

.sim-stats th,
.sim-stats td {
    text-align: center;
    padding: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sim-stats th {
    color: #aaa;
    font-weight: normal;
}

.best-hand {
    margin-top: 20px;
    text-align: left;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
}

.best-hand h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--accent);
}

.mana-details {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-left: 10px;
}

.restriction {
    color: #e74c3c;
    /* Reddish for restrictions */
    font-style: italic;
}

.mana-info {
    font-size: 0.8em;
    color: #2ecc71;
    /* Greenish for mana */
    margin-left: 5px;
}

.card-used {
    background: rgba(46, 204, 113, 0.1);
    border-left: 3px solid #2ecc71;
}

.card-unused {
    opacity: 0.6;
}

.used-badge {
    font-size: 0.8em;
    color: #2ecc71;
    font-weight: bold;
    margin-left: 10px;
}

/* Histogram Styles */
.distribution-section {
    margin-top: 30px;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
}

.hand-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid #444;
}

.hand-tab-btn {
    background: none;
    border: none;
    color: #888;
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.hand-tab-btn:hover {
    color: #ddd;
}

.hand-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.chart-samples {
    margin-top: 20px;
    padding: 10px;
    border-top: 1px solid #444;
}

.sample-hands-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.sample-hand-card {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #444;
}

.sample-hand-card h5 {
    margin-top: 0;
    margin-bottom: 8px;
    color: var(--accent);
}

.card-list.small .card-item {
    padding: 2px 5px;
    font-size: 0.85em;
}

.played-section {
    margin-top: 10px;
    border-top: 1px solid #444;
    padding-top: 5px;
}

.played-section strong {
    font-size: 0.8em;
    color: #aaa;
    display: block;
    margin-bottom: 4px;
}