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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #0a1628 0%, #1a2a4a 100%);
    color: #eee;
    line-height: 1.6;
    min-height: 100vh;
}

header {
    background: linear-gradient(135deg, #16213e 0%, #1a3a5c 100%);
    padding: 2.5rem 2rem;
    text-align: center;
    border-bottom: 3px solid #e94560;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

header h1 {
    font-size: 2.8rem;
    margin-bottom: 0.5rem;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
}

header p {
    color: #a0b0c0;
    font-size: 1.2rem;
}

main {
    max-width: 1300px;
    margin: 0 auto;
    padding: 2rem;
}

section {
    background: linear-gradient(145deg, #16213e 0%, #1a2a4a 100%);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

h2 {
    color: #e94560;
    margin-bottom: 0.5rem;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

h3 {
    color: #fff;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.section-desc {
    color: #8a9ab0;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

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

button {
    background: linear-gradient(135deg, #e94560 0%, #d63050 100%);
    color: white;
    border: none;
    padding: 0.85rem 1.8rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.3);
}

button:hover:not(:disabled) {
    background: linear-gradient(135deg, #ff6b7a 0%, #e94560 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(233, 69, 96, 0.4);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: background 0.2s;
}

.toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #e94560;
}

.toggle-label {
    color: #ccc;
    font-size: 0.95rem;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-group label {
    color: #a0b0c0;
    font-size: 0.95rem;
}

input[type="number"] {
    background: rgba(15, 52, 96, 0.8);
    border: 2px solid rgba(233, 69, 96, 0.3);
    color: white;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    width: 100px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input[type="number"]:focus {
    outline: none;
    border-color: #e94560;
}

select {
    background: rgba(15, 52, 96, 0.8);
    border: 2px solid rgba(233, 69, 96, 0.3);
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

select:focus {
    outline: none;
    border-color: #e94560;
}

.board-container {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
}

#board-canvas {
    background: linear-gradient(145deg, #0a1628 0%, #1a2a3a 100%);
    border-radius: 16px;
    border: 3px solid rgba(100, 150, 200, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 0 60px rgba(100, 150, 200, 0.05);
}

.info-panel {
    background: linear-gradient(145deg, rgba(15, 52, 96, 0.8) 0%, rgba(10, 40, 80, 0.8) 100%);
    padding: 1.5rem;
    border-radius: 12px;
    min-width: 280px;
    max-width: 320px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.info-panel h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.yield-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin: 0.5rem 0;
}

.yield-value {
    font-size: 2rem;
    font-weight: bold;
    color: #4ade80;
}

.yield-label {
    font-size: 0.85rem;
    color: #8a9ab0;
}

.yield-quality {
    text-align: center;
    font-weight: 600;
    margin-top: 0.5rem;
}

.hint {
    color: #8a9ab0;
    font-size: 0.95rem;
}

.hint-sub {
    color: #6a7a8a;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

#dice-chart {
    display: block;
    margin: 0 auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.simulation-controls, .comparison-controls {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.strategy-select {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.strategy-select label {
    font-size: 0.85rem;
    color: #8a9ab0;
}

.vs-badge {
    font-size: 1.4rem;
    font-weight: bold;
    color: #e94560;
    padding: 0.5rem 1rem;
    background: rgba(233, 69, 96, 0.1);
    border-radius: 8px;
}

.results-panel {
    background: rgba(10, 22, 40, 0.6);
    padding: 1.5rem;
    border-radius: 12px;
    min-height: 150px;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: #6a7a8a;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

/* Progress indicator */
.progress-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(233, 69, 96, 0.2);
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.progress-text {
    color: #a0b0c0;
    font-size: 1.1rem;
}

/* Results table */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.results-count {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
}

.results-time {
    font-size: 0.9rem;
    color: #6a7a8a;
}

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

.result-table th {
    padding: 0.75rem;
    text-align: left;
    color: #e94560;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 2px solid rgba(233, 69, 96, 0.3);
}

.result-table td {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.result-table tbody tr:hover {
    background: rgba(233, 69, 96, 0.05);
}

.result-table tr.winner {
    background: rgba(74, 222, 128, 0.1);
}

.result-table tr.winner td {
    color: #4ade80;
}

.rank {
    font-size: 1.2rem;
    text-align: center;
    width: 50px;
}

.strategy-name {
    font-weight: 600;
}

.win-rate {
    font-weight: bold;
    color: #60a5fa;
}

.bar-cell {
    width: 150px;
}

.mini-bar {
    height: 8px;
    background: linear-gradient(90deg, #4ade80 0%, #22c55e 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.draws-note {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #6a7a8a;
    text-align: center;
}

.wins-count {
    font-weight: 600;
    color: #60a5fa;
}

.vs-random {
    display: block;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.vs-random.positive {
    color: #4ade80;
}

.vs-random.negative {
    color: #f87171;
}

.vs-random.neutral {
    color: #6a7a8a;
}

.simulation-insights {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.simulation-insights h4 {
    color: #e94560;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.simulation-insights ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.simulation-insights li {
    padding: 0.4rem 0;
    color: #a0b0c0;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.simulation-insights li:last-child {
    border-bottom: none;
}

/* Comparison results */
.comparison-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.strategy-label {
    font-size: 1.3rem;
    font-weight: bold;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.strategy-label.winner {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

.comparison-header .vs {
    font-size: 1.2rem;
    color: #e94560;
}

.comparison-bar {
    display: flex;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.comparison-bar > div {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
    transition: width 0.5s ease;
}

.comparison-bar .a-wins {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: #0a1628;
}

.comparison-bar .b-wins {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    color: #0a1628;
}

.comparison-bar .draws {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: #fff;
}

.comparison-legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

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

.legend-color.green { background: #4ade80; }
.legend-color.blue { background: #60a5fa; }
.legend-color.gray { background: #6b7280; }

.comparison-summary {
    text-align: center;
    font-size: 1.1rem;
    color: #a0b0c0;
}

/* Strategy guide */
.strategy-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.strategy-card {
    background: rgba(15, 52, 96, 0.5);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.strategy-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.strategy-card h4 {
    color: #e94560;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.strategy-card p {
    color: #8a9ab0;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Error state */
.error {
    color: #f87171;
    padding: 1rem;
    text-align: center;
    background: rgba(248, 113, 113, 0.1);
    border-radius: 8px;
}

/* Secondary button style */
button.secondary {
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
    box-shadow: 0 4px 15px rgba(55, 65, 81, 0.3);
}

button.secondary:hover:not(:disabled) {
    background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
    box-shadow: 0 6px 20px rgba(55, 65, 81, 0.4);
}

/* Player cards for game display */
.players-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.player-card {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.75rem;
    transition: transform 0.2s;
}

.player-card.winner {
    background: rgba(74, 222, 128, 0.15);
    border-color: #4ade80 !important;
}

.player-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.player-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.player-name {
    font-weight: 600;
    flex: 1;
}

.player-vp {
    font-weight: bold;
    font-size: 1.1rem;
    color: #4ade80;
}

.player-strategy {
    font-size: 0.8rem;
    color: #8a9ab0;
    margin-bottom: 0.25rem;
}

.player-pieces {
    font-size: 0.75rem;
    color: #6a7a8a;
}

.bonus {
    font-size: 0.75rem;
    color: #fbbf24;
    margin-top: 0.25rem;
}

.winner-banner {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: #0a1628;
    padding: 0.75rem;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.game-ongoing {
    color: #8a9ab0;
    text-align: center;
    padding: 0.5rem;
}

.game-stats {
    color: #6a7a8a;
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 0.5rem;
}

footer {
    text-align: center;
    padding: 2.5rem;
    color: #6a7a8a;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 2rem;
}

.footer-sub {
    font-size: 0.9rem;
    margin-top: 0.5rem;
    color: #4a5a6a;
}

@media (max-width: 900px) {
    header h1 {
        font-size: 2rem;
    }

    main {
        padding: 1rem;
    }

    .board-container {
        flex-direction: column;
        align-items: center;
    }

    #board-canvas {
        max-width: 100%;
        height: auto;
    }

    .info-panel {
        max-width: 100%;
        width: 100%;
    }

    .controls, .simulation-controls, .comparison-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .comparison-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .comparison-legend {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }
}
