/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

/* Game Container */
.game-container {
    width: 100%;
    max-width: 1400px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 30px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Top Controls */
.top-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.guide-btn,
.restart-game-btn,
.music-toggle-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.guide-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.guide-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(240, 147, 251, 0.4);
}

.restart-game-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.restart-game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 15px;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.music-toggle-btn {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
    width: 50px;
    height: 50px;
    padding: 0;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.music-toggle-btn:hover {
    transform: scale(1.1) rotate(15deg);
}

.music-toggle-btn.muted {
    opacity: 0.5;
}

.volume-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.volume-slider-container label {
    font-size: 0.9rem;
    font-weight: bold;
    color: #4a5568;
    white-space: nowrap;
}

.volume-slider {
    width: 150px;
    height: 6px;
    border-radius: 5px;
    background: linear-gradient(to right, #fa709a 0%, #fee140 100%);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
}

.volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.volume-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
}

.volume-percentage {
    font-size: 0.9rem;
    font-weight: bold;
    color: #fa709a;
    min-width: 40px;
    text-align: right;
}

/* Game Header */
.game-header {
    text-align: center;
    margin-bottom: 30px;
}

.win-condition {
    font-size: 1.1rem;
    color: #f59e0b;
    font-weight: bold;
    margin-top: 10px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.game-header h1 {
    font-size: 2.5rem;
    color: #2d3748;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
    font-size: 1.2rem;
    color: #718096;
    font-style: italic;
}

/* Game Board - Split Layout */
.game-board {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 40px;
    margin-bottom: 30px;
    align-items: start;
}

/* Player Sides */
.player-side {
    background: linear-gradient(135deg, #f6f8fb 0%, #e9ecef 100%);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.human-side {
    border: 3px solid #48bb78;
}

.ai-side {
    border: 3px solid #ed8936;
}

.player-header {
    text-align: center;
    margin-bottom: 25px;
}

.player-header h2 {
    font-size: 1.8rem;
    color: #2d3748;
    margin-bottom: 10px;
}

/* AI Face */
.ai-face {
    font-size: 3.5rem;
    margin: 10px 0;
    transition: transform 0.3s ease;
}

.ai-face.face-animate {
    animation: facePopIn 0.5s ease-out;
}

@keyframes facePopIn {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.coin-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: white;
    padding: 15px 25px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
}

.coin-amount {
    font-size: 2rem;
    font-weight: bold;
    color: #f59e0b;
}

.coin-icon {
    font-size: 1.8rem;
    animation: coinFloat 2s ease-in-out infinite;
}

@keyframes coinFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Button Container */
.button-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Action Buttons */
.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 30px;
    border: none;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.action-btn:active:not(:disabled) {
    transform: translateY(-1px);
}

.cooperate-btn {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.steal-btn {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    color: white;
}

.action-btn.selected {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    animation: pulse 0.5s ease-in-out;
}

.action-btn.dimmed {
    opacity: 0.4;
    filter: grayscale(80%);
    transform: scale(0.95);
}

.action-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

@keyframes pulse {
    0%, 100% { transform: scale(1.1); }
    50% { transform: scale(1.15); }
}

.btn-icon {
    font-size: 1.5rem;
}

.btn-text {
    font-size: 1.1rem;
}

/* AI Buttons (disabled state) */
.ai-buttons .action-btn {
    cursor: default;
}

/* Player Choice Display */
.player-choice-display {
    margin-top: 20px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: bold;
    color: #2d3748;
}

/* Center Area */
.center-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    min-width: 250px;
}

/* Piggy Bank */
.piggy-bank {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    width: 150px;
    height: 150px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.4);
    transition: transform 0.3s ease;
}

.piggy-icon {
    font-size: 5rem;
    animation: piggyBounce 3s ease-in-out infinite;
}

@keyframes piggyBounce {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.piggy-bank.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px) rotate(-5deg); }
    75% { transform: translateX(10px) rotate(5deg); }
}

/* Round Info */
.round-info {
    text-align: center;
    background: white;
    padding: 15px 30px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.round-number {
    font-size: 1.3rem;
    font-weight: bold;
    color: #5a67d8;
    margin-bottom: 8px;
}

.game-status {
    font-size: 1rem;
    color: #718096;
    font-style: italic;
}

.game-status.thinking {
    animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Result Box */
.result-box {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
    animation: fadeIn 0.5s ease-in-out;
}

.result-box.hidden {
    display: none;
}

.result-text {
    font-size: 1.2rem;
    font-weight: bold;
    color: #2d3748;
}

.result-outcome {
    font-size: 1.05rem;
    color: #4a5568;
    line-height: 1.6;
}

.result-net {
    font-size: 0.95rem;
    color: #2d3748;
    font-weight: bold;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
}

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

/* History Panel */
.history-panel {
    background: #f7fafc;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.history-panel h3 {
    font-size: 1.3rem;
    color: #2d3748;
    margin-bottom: 15px;
    text-align: center;
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-empty {
    text-align: center;
    color: #a0aec0;
    font-style: italic;
}

.history-item {
    background: white;
    padding: 12px 15px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.history-round {
    font-weight: bold;
    color: #5a67d8;
}

.history-choices {
    color: #2d3748;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-in-out;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-title {
    font-size: 2rem;
    color: #2d3748;
    margin-bottom: 20px;
}

.modal-body {
    margin-bottom: 30px;
}

.modal-stat {
    font-size: 1.2rem;
    color: #4a5568;
    margin: 10px 0;
}

.modal-stat strong {
    color: #2d3748;
}

.modal-summary {
    font-size: 1.1rem;
    color: #718096;
    font-style: italic;
    margin-top: 20px;
    padding: 15px;
    background: #f7fafc;
    border-radius: 10px;
}

.restart-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.restart-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

/* Coin Animation */
@keyframes coinPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.coin-amount.animate {
    animation: coinPop 0.5s ease-in-out;
}

/* Floating Coin Animations */
.floating-coin {
    position: absolute;
    font-size: 1.5rem;
    font-weight: bold;
    pointer-events: none;
    z-index: 100;
    animation: floatUp 2s ease-out forwards;
}

.floating-coin.gain {
    color: #48bb78;
    animation: floatUp 2s ease-out forwards;
}

.floating-coin.loss {
    color: #f56565;
    animation: floatDown 2s ease-out forwards;
}

@keyframes floatUp {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-60px);
        opacity: 0;
    }
}

@keyframes floatDown {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(40px);
        opacity: 0;
    }
}

/* Flying Coin to Piggy Bank */
.flying-coin {
    position: fixed;
    font-size: 2rem;
    pointer-events: none;
    z-index: 200;
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .game-board {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .center-area {
        order: -1;
    }
}

@media (max-width: 768px) {
    .game-header h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .action-btn {
        padding: 15px 20px;
        font-size: 1rem;
    }
    
    .piggy-bank {
        width: 120px;
        height: 120px;
    }
    
    .piggy-icon {
        font-size: 4rem;
    }
}

/* Scrollbar Styling */
.history-list::-webkit-scrollbar {
    width: 8px;
}

.history-list::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 10px;
}

.history-list::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 10px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Statistics Button */
.stats-button-container {
    text-align: center;
    margin-top: 20px;
}

.stats-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.stats-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

/* Statistics Modal */
.stats-modal-content {
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.stats-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: #f7fafc;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.stat-card h3 {
    font-size: 1.2rem;
    color: #2d3748;
    margin-bottom: 15px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.stat-card p {
    margin: 8px 0;
    font-size: 1rem;
    color: #4a5568;
}

.ai-behavior-summary {
    background: #fff5e6;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid #f59e0b;
}

.ai-behavior-summary p {
    margin: 0;
    color: #2d3748;
    font-style: italic;
}

.round-history-table h3 {
    font-size: 1.3rem;
    color: #2d3748;
    margin-bottom: 15px;
}

.table-container {
    max-height: 400px;
    overflow-y: auto;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.history-table thead {
    background: #667eea;
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.history-table th {
    padding: 12px;
    text-align: left;
    font-weight: bold;
    font-size: 0.95rem;
}

.history-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

.history-table tbody tr:hover {
    background: #f7fafc;
}

.history-table td.gain {
    color: #48bb78;
    font-weight: bold;
}

.history-table td.loss {
    color: #f56565;
    font-weight: bold;
}

.stats-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.download-csv-btn,
.close-stats-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-csv-btn {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
}

.download-csv-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.5);
}

.close-stats-btn {
    background: #e2e8f0;
    color: #2d3748;
}

.close-stats-btn:hover {
    background: #cbd5e0;
}

/* Table scrollbar */
.table-container::-webkit-scrollbar {
    width: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 10px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 10px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Guide Modal */
.guide-modal-content {
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

.guide-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.guide-section {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    padding: 20px;
    border-radius: 15px;
    border-left: 4px solid #667eea;
    transition: transform 0.3s ease;
}

.guide-section:hover {
    transform: translateX(5px);
}

.guide-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.guide-section h3 {
    color: #2d3748;
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.guide-section p {
    color: #4a5568;
    line-height: 1.6;
    margin: 8px 0;
}

.guide-section.payoff-table {
    background: linear-gradient(135deg, #f093fb15 0%, #f5576c15 100%);
    border-left-color: #f5576c;
}

.payoff-table-content {
    width: 100%;
    margin-top: 15px;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
}

.payoff-table-content th,
.payoff-table-content td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.payoff-table-content th {
    background: #667eea;
    color: white;
    font-weight: bold;
}

.payoff-table-content tr.positive td {
    background: #f0fdf4;
}

.payoff-table-content tr.negative td {
    background: #fef2f2;
}

.payoff-table-content tr.mixed td {
    background: #fffbeb;
}

.close-guide-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.close-guide-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

/* Win Animation */
@keyframes winCelebration {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(5deg); }
    50% { transform: scale(1.1) rotate(-5deg); }
    75% { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.win-celebration {
    animation: winCelebration 0.6s ease-in-out;
}

/* Responsive for stats modal */
@media (max-width: 768px) {
    .stats-summary {
        grid-template-columns: 1fr;
    }
    
    .stats-modal-content {
        max-width: 95%;
    }
    
    .history-table {
        font-size: 0.8rem;
    }
    
    .history-table th,
    .history-table td {
        padding: 8px 6px;
    }
    
    .top-controls {
        justify-content: center;
        flex-direction: column;
    }
    
    .guide-btn,
    .restart-game-btn {
        font-size: 0.9rem;
        padding: 8px 15px;
    }
    
    .volume-control {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .volume-slider-container {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .volume-slider {
        width: 120px;
    }
    
    .guide-modal-content {
        max-width: 95%;
    }
    
    .payoff-table-content {
        font-size: 0.85rem;
    }
    
    .payoff-table-content th,
    .payoff-table-content td {
        padding: 8px;
    }
}
