/* ============================================
   Game Theory Simulator Styles
   Color-coded payoff matrices and interactive design
   ============================================ */

/* Scoped classes with game-theory- prefix to prevent global pollution */

.game-theory-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Header */
.game-theory-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
}

.game-theory-header h1 {
    margin: 0 0 10px 0;
    font-size: 2em;
    font-weight: 600;
}

.game-theory-header .subtitle {
    margin: 0;
    font-size: 1em;
    opacity: 0.95;
}

/* Tab Navigation */
.game-theory-content {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
}

.tab-navigation {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-button {
    flex: 1;
    min-width: 150px;
    padding: 12px 20px;
    background: #e0e0e0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    color: #333;
}

.tab-button:hover {
    background: #d0d0d0;
    transform: translateY(-2px);
}

.tab-button.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Game Sections */
.game-section {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.game-section h2 {
    margin-top: 0;
    color: #667eea;
    font-size: 1.8em;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

.game-section h3 {
    color: #555;
    font-size: 1.3em;
    margin-top: 25px;
    margin-bottom: 15px;
}

.description {
    color: #666;
    font-size: 1.05em;
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Payoff Matrix */
.matrix-container {
    margin: 30px 0;
}

.payoff-matrix {
    display: grid;
    grid-template-columns: 150px repeat(2, 1fr);
    gap: 2px;
    max-width: 600px;
    margin: 0 auto;
    background: #ddd;
    border: 2px solid #667eea;
    border-radius: 8px;
    overflow: hidden;
}

.matrix-header {
    display: contents;
}

.matrix-header > div {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9em;
}

.matrix-header > div:first-child {
    background: transparent;
}

.matrix-row {
    display: contents;
}

.player-header {
    background: #f0f0f0;
    padding: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    border-right: 2px solid #ddd;
}

.payoff-cell {
    background: white;
    padding: 20px;
    text-align: center;
    position: relative;
    transition: all 0.3s ease;
    cursor: default;
}

.payoff-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.payoff-cell.nash-equilibrium {
    border: 3px solid #FFD700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.payoff-cell.selected-outcome {
    background: #FFF9C4 !important;
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.payoff-cell.optimal-cell {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    color: white;
}

.payoff-cell.worst-cell {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    color: white;
}

.payoff-cell.safe-cell {
    background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
    color: white;
}

.payoff-values {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 8px;
}

.payoff-label {
    font-size: 0.85em;
    opacity: 0.9;
    font-weight: 500;
}

.matrix-legend {
    text-align: center;
    margin-top: 15px;
    color: #666;
    font-size: 0.9em;
}

/* Strategy Section */
.strategy-section {
    margin: 30px 0;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
}

.strategy-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.strategy-btn {
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.strategy-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.strategy-btn:active {
    transform: translateY(-1px);
}

.cooperate-btn,
.stag-btn {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    color: white;
}

.defect-btn,
.rabbit-btn {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    color: white;
}

.opponent-section {
    margin-top: 20px;
    text-align: center;
}

.opponent-section label {
    font-weight: 600;
    margin-right: 10px;
    color: #555;
}

.opponent-section select {
    padding: 8px 15px;
    font-size: 1em;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.opponent-section select:hover {
    border-color: #667eea;
}

.opponent-section select:focus {
    outline: none;
    border-color: #667eea;
}

/* Score Board */
.score-board {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    margin: 30px 0;
    padding: 20px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 8px;
    flex-wrap: wrap;
}

.score-item {
    text-align: center;
    flex: 1;
    min-width: 150px;
}

.score-label {
    display: block;
    color: white;
    font-size: 0.95em;
    margin-bottom: 8px;
    opacity: 0.95;
}

.score-value {
    display: block;
    color: white;
    font-size: 2.5em;
    font-weight: bold;
}

/* Game Controls */
.game-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 30px 0;
    flex-wrap: wrap;
}

.control-btn {
    padding: 12px 25px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.reset-btn {
    background: #757575;
    color: white;
}

.auto-play-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.start-btn {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    color: white;
}

.pause-btn {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    color: white;
}

.step-btn {
    background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
    color: #333;
}

/* Result Display */
.result-display {
    margin: 20px 0;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.result-content {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.result-move {
    flex: 1;
    min-width: 200px;
}

.move-label {
    display: block;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
}

.move-value {
    font-size: 1.3em;
    font-weight: bold;
}

.move-value.cooperate,
.move-value.stag {
    color: #4CAF50;
}

.move-value.defect,
.move-value.rabbit {
    color: #f44336;
}

.result-payoff {
    text-align: center;
}

.payoff-received {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
}

/* Analysis Section */
.analysis-section {
    margin: 30px 0;
    padding: 20px;
    background: #e3f2fd;
    border-radius: 8px;
    border-left: 4px solid #2196F3;
}

.analysis-text {
    color: #333;
    line-height: 1.6;
    font-size: 1em;
}

.best-response {
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: 6px;
}

.best-response p {
    margin: 10px 0;
}

.best-response ul {
    margin: 10px 0;
    padding-left: 20px;
}

.best-response li {
    margin: 8px 0;
    color: #555;
}

.nash-conclusion {
    font-weight: 600;
    color: #2196F3;
    margin-top: 15px;
}

/* Equilibria Info */
.equilibria-info {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.equilibrium-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: white;
    border-radius: 6px;
    flex-wrap: wrap;
    gap: 10px;
}

.equilibrium-label {
    font-weight: 600;
    color: #555;
    flex: 1;
    min-width: 200px;
}

.equilibrium-value {
    color: #667eea;
    font-weight: 600;
}

/* Population Controls */
.population-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 20px 0;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
}

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

.control-group label {
    font-weight: 600;
    color: #555;
}

.control-group select,
.control-group input[type="range"] {
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: white;
}

.slider-value {
    font-weight: 600;
    color: #667eea;
}

/* Population Visualization */
.population-visualization {
    margin: 20px 0;
    text-align: center;
}

#population-canvas {
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    max-width: 100%;
}

/* Strategy Distribution */
.strategy-distribution {
    margin: 30px 0;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
}

.distribution-chart {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 15px;
}

.distribution-bar-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.bar-label {
    font-weight: 600;
    color: #555;
    min-width: 100px;
}

.bar-container {
    flex: 1;
    height: 30px;
    background: #ddd;
    border-radius: 15px;
    overflow: hidden;
}

.bar {
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 15px;
}

.bar-value {
    font-weight: 600;
    min-width: 60px;
    text-align: right;
}

/* Evolution Graph */
.evolution-graph {
    margin: 30px 0;
    text-align: center;
}

#evolution-canvas {
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    max-width: 100%;
}

/* Generation Info */
.generation-info {
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    font-size: 1.2em;
}

.generation-value {
    font-weight: bold;
    font-size: 1.3em;
}

/* Learn Section */
.learn-section {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.learn-section h2 {
    margin-top: 0;
    color: #667eea;
    font-size: 2em;
    border-bottom: 3px solid #667eea;
    padding-bottom: 15px;
}

.concept-block {
    margin: 40px 0;
    padding: 25px;
    background: #f9f9f9;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.concept-block h3 {
    color: #667eea;
    font-size: 1.6em;
    margin-top: 0;
    margin-bottom: 20px;
}

.concept-block p {
    color: #555;
    line-height: 1.7;
    font-size: 1.05em;
}

.key-points {
    display: grid;
    gap: 20px;
    margin-top: 25px;
}

.key-point {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #764ba2;
}

.key-point h4 {
    color: #764ba2;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.key-point p {
    color: #666;
    line-height: 1.6;
}

.example-card {
    background: white;
    padding: 25px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.example-card h4 {
    color: #667eea;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.example-card p {
    color: #555;
    line-height: 1.7;
}

.game-type-tag {
    position: absolute;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: 600;
}

.guidance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 25px;
}

.guidance-card {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.trust-card {
    border-left: 4px solid #4CAF50;
}

.question-card {
    border-left: 4px solid #f44336;
}

.guidance-card h4 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.trust-card h4 {
    color: #4CAF50;
}

.question-card h4 {
    color: #f44336;
}

.guidance-card ul {
    list-style: none;
    padding: 0;
}

.guidance-card li {
    padding: 8px 0;
    color: #555;
    line-height: 1.6;
    border-bottom: 1px solid #eee;
}

.guidance-card li:last-child {
    border-bottom: none;
}

.escape-strategies {
    display: grid;
    gap: 20px;
    margin-top: 25px;
}

.strategy-item {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #FFD700;
}

.strategy-item h4 {
    color: #FF9800;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.strategy-item p {
    color: #666;
    line-height: 1.6;
}

.reading-list {
    list-style: none;
    padding: 0;
}

.reading-list li {
    background: white;
    padding: 20px;
    margin: 15px 0;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.reading-list strong {
    color: #667eea;
    font-size: 1.1em;
}

.reading-note {
    display: block;
    color: #999;
    font-size: 0.95em;
    margin-top: 8px;
    font-style: italic;
}

/* Footer */
.game-theory-footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: #666;
    font-size: 0.9em;
    border-top: 1px solid #ddd;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-theory-container {
        padding: 10px;
    }

    .game-theory-header h1 {
        font-size: 1.5em;
    }

    .game-theory-header .subtitle {
        font-size: 0.9em;
    }

    .tab-navigation {
        flex-direction: column;
    }

    .tab-button {
        width: 100%;
        min-width: auto;
    }

    .payoff-matrix {
        grid-template-columns: 100px repeat(2, 1fr);
        font-size: 0.9em;
    }

    .payoff-values {
        font-size: 1.5em;
    }

    .strategy-buttons {
        flex-direction: column;
    }

    .strategy-btn {
        width: 100%;
    }

    .score-board {
        flex-direction: column;
    }

    .result-content {
        flex-direction: column;
    }

    .guidance-grid {
        grid-template-columns: 1fr;
    }

    .population-controls {
        grid-template-columns: 1fr;
    }

    .equilibrium-item {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .game-theory-header h1 {
        font-size: 1.3em;
    }

    .game-section h2 {
        font-size: 1.5em;
    }

    .payoff-matrix {
        grid-template-columns: 1fr;
        font-size: 0.85em;
    }

    .matrix-header > div:first-child {
        display: none;
    }

    .player-header {
        border-right: none;
        border-bottom: 2px solid #ddd;
    }
}

/* Print Styles */
@media print {
    .game-theory-container {
        box-shadow: none;
    }

    .tab-button,
    .control-btn,
    .strategy-btn {
        display: none;
    }

    .tab-content {
        display: block !important;
    }

    .game-theory-footer {
        display: none;
    }
}

/* Accessibility */
.game-theory-container *:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.strategy-btn:focus,
.control-btn:focus,
.tab-button:focus {
    outline: 3px solid #FFD700;
    outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .game-theory-container {
        border: 2px solid #000;
    }

    .payoff-cell {
        border: 1px solid #000;
    }

    .strategy-btn,
    .control-btn {
        border: 2px solid #000;
    }
}
