:root {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --text-primary: #333;
    --text-secondary: #666;
    --border-color: #ddd;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --modal-bg: #ffffff;
    --card-bg: #ffffff;
    --header-bg: rgba(255, 255, 255, 0.95);
    --input-bg: #ffffff;
    --hover-bg: #f8f9fa;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --border-color: #444444;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --modal-bg: #2d2d2d;
    --card-bg: #2d2d2d;
    --header-bg: rgba(45, 45, 45, 0.95);
    --input-bg: #404040;
    --hover-bg: #404040;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--bg-primary) 0%, #c3cfe2 100%);
    min-height: 100vh;
    transition: all 0.3s ease;
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
}

/* Header */
header {
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    box-shadow: 0 2px 20px var(--shadow-color);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    transition: all 0.3s ease;
}

.header-left {
    display: flex;
    align-items: center;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

header h1 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    text-align: center;
    flex: 1;
}

.controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.action-buttons {
    display: flex;
    gap: 0.25rem;
    justify-content: flex-end;
}

.free-parking-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 2px solid #28a745;
    transition: all 0.3s ease;
}

.free-parking-display.clickable {
    cursor: pointer;
    transition: all 0.3s ease;
}

.free-parking-display.clickable:hover {
    background: var(--card-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.free-parking-display.clickable:active {
    transform: translateY(0);
}

.free-parking-icon {
    font-size: 1.2rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.btn:active {
    transform: translateY(0);
}

.btn-icon {
    padding: 0.5rem 0.75rem;
    font-size: 1.2rem;
    min-width: auto;
    width: auto;
    height: auto;
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
    background: var(--hover-bg);
    border-color: var(--text-primary);
}

.btn-icon:active {
    transform: translateY(0);
    background: var(--hover-bg);
}

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

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:disabled {
    background: #6c757d;
    color: #999;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-success:disabled:hover {
    transform: none;
    box-shadow: none;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
    background: var(--hover-bg);
    border-color: var(--text-primary);
}

.btn-icon:active {
    transform: translateY(0);
    background: var(--hover-bg);
}

/* Main content */
main {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Players grid */
.players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

/* Player cards */
.player-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px var(--shadow-color);
    position: relative;
    overflow: hidden;
}


/* Player-specific colors */
.player-card[data-player-id="1"] {
    border: 4px solid #e74c3c;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.3);
}

.player-card[data-player-id="2"] {
    border: 4px solid #27ae60;
    box-shadow: 0 0 10px rgba(39, 174, 96, 0.3);
}

.player-card[data-player-id="3"] {
    border: 4px solid #3498db;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.3);
}

.player-card[data-player-id="4"] {
    border: 4px solid #f39c12;
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.3);
}

.player-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.player-card.selected {
    border: 3px solid #667eea;
    transform: scale(1.05);
}

.player-card.target-mode {
    cursor: pointer;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3); }
    50% { box-shadow: 0 4px 30px rgba(102, 126, 234, 0.6); }
    100% { box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3); }
}

.player-avatar {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.player-avatar img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Player initials styles */
.player-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    text-align: center;
    border: 3px solid;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.player-initials-large {
    width: 100px;
    height: 100px;
    font-size: 2.5rem;
    border-width: 4px;
}

.player-initials-small {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    border-width: 3px;
    margin-bottom: 0.5rem;
}

/* Ensure initials work in target and payout cards */
.target-player-card .player-initials-small,
.payout-player-card .player-initials-small {
    margin: 0 auto 0.5rem auto;
}

.player-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.player-balance {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--modal-bg);
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px var(--shadow-color);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

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

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.transfer-options {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
}

.transfer-options .btn {
    flex: 1;
}

#amountInput {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--hover-bg);
    border-radius: 8px;
}

#amountInput label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

#amountInput input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 1rem;
    background: var(--input-bg);
    color: var(--text-primary);
}

#amountInput input:focus {
    outline: none;
    border-color: #667eea;
}

.target-players {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.target-player-card {
    background: var(--hover-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.target-player-card:hover {
    background: var(--hover-bg);
    border-color: #667eea;
    transform: translateY(-2px);
}

.target-player-card img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 0.5rem;
}

.bank-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* Modal sections */
#amountSection {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--hover-bg);
    border-radius: 8px;
}

.amount-input-container {
    margin-bottom: 1rem;
}

.amount-input-container label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.amount-display input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    background: var(--input-bg);
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.amount-display input:focus {
    outline: none;
    border-color: #667eea;
}

/* Keypad styling */
.keypad {
    display: grid;
    gap: 0.5rem;
    margin-top: 1rem;
}

.keypad-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.keypad-btn {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 50px;
}

.keypad-btn:hover {
    background: var(--hover-bg);
    border-color: #667eea;
    transform: translateY(-1px);
}

.keypad-btn:active {
    transform: translateY(0);
    background: var(--hover-bg);
}

.keypad-btn.clear-btn {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.keypad-btn.clear-btn:hover {
    background: #c82333;
    border-color: #c82333;
}

.amount-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.amount-actions .btn {
    flex: 1;
}

#targetSection {
    margin-top: 1rem;
}

/* Responsive design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 200px;
    }
    
    .players-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
    }
    
    main {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .players-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
}

/* Edit Players Modal Styles */
.edit-players-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.player-edit-field {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--hover-bg);
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

.player-edit-field .player-color-indicator {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    cursor: default;
    transition: all 0.2s ease;
}

.player-edit-field .player-color-indicator.clickable {
    cursor: pointer;
}

.player-edit-field .player-color-indicator.clickable:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.player-edit-field input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text-primary);
}

.player-edit-field input:focus {
    outline: none;
    border-color: #667eea;
}

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

.color-picker {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

.color-picker:hover {
    border-color: #667eea;
}

.name-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text-primary);
}

/* Predefined color picker styles */
.predefined-colors {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.color-option {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: var(--text-primary);
}

.color-option.selected {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.color-option.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 12px;
    text-shadow: 0 0 2px rgba(0,0,0,0.8);
}

/* Bold color palette that works well in both light and dark modes */
.color-red { background-color: #e74c3c; }
.color-blue { background-color: #3498db; }
.color-green { background-color: #27ae60; }
.color-yellow { background-color: #f39c12; }
.color-purple { background-color: #9b59b6; }
.color-orange { background-color: #e67e22; }
.color-pink { background-color: #e91e63; }
.color-cyan { background-color: #00bcd4; }
.color-teal { background-color: #009688; }
.color-indigo { background-color: #3f51b5; }
.color-lime { background-color: #8bc34a; }
.color-amber { background-color: #ffc107; }
.color-emerald { background-color: #10b981; }
.color-rose { background-color: #f43f5e; }
.color-sky { background-color: #0ea5e9; }
.color-violet { background-color: #8b5cf6; }

/* Color Picker Popup Styles */
.color-picker-popup {
    background: var(--modal-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 10px 30px var(--shadow-color);
    min-width: 280px;
    animation: fadeInScale 0.2s ease;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.color-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.color-picker-header span {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.close-picker-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-picker-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.color-picker-popup .predefined-colors {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.5rem;
}

.color-picker-popup .color-option {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.color-picker-popup .color-option:hover {
    transform: scale(1.15);
    border-color: var(--text-primary);
}

.color-picker-popup .color-option.selected {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.color-picker-popup .color-option.selected::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 10px;
    text-shadow: 0 0 2px rgba(0,0,0,0.8);
}

/* History Modal Styles */
.history-container {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.history-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--hover-bg);
    margin-bottom: 0.5rem;
    border-radius: 8px;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item .timestamp {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.history-item .description {
    font-weight: 600;
    color: var(--text-primary);
}

.history-item .amount {
    font-weight: 700;
    margin-left: 0.5rem;
}

.history-item .amount.positive {
    color: #28a745;
}

.history-item .amount.negative {
    color: #dc3545;
}

.player-name-in-history {
    font-weight: 700;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.modal-actions .btn {
    flex: 1;
    max-width: 150px;
}

/* Small modal content for alerts and confirmations */
.modal-content-small {
    max-width: 400px;
    width: 90%;
}

/* Confirmation Modal Styles */
#confirmModal .modal-body {
    text-align: center;
}

#confirmModal p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
}

/* Alert Modal Styles */
#alertModal .modal-body {
    text-align: center;
}

#alertModal p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
}

/* Free Parking Modal Styles */
.free-parking-info {
    text-align: center;
    margin-bottom: 2rem;
}

.free-parking-amount {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.free-parking-icon-large {
    font-size: 4rem;
    opacity: 0.8;
}

.amount-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.amount-label {
    font-size: 1rem;
    color: #666;
    font-weight: 500;
}

.amount-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #28a745;
}

/* Free Parking Payout Modal Styles */
.payout-players {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.payout-player-card {
    background: var(--hover-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.payout-player-card:hover {
    background: var(--hover-bg);
    border-color: #28a745;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.2);
}

.payout-player-card img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 0.5rem;
}

.payout-player-card div:nth-child(2) {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.payout-player-card div:nth-child(3) {
    color: #667eea;
    font-weight: 700;
}
