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

:root {
    /* Light mode colors (default) */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --bg-input: #FFFFFF;
    --text-primary: #1F2937;
    --text-secondary: #1F2937;
    --border-color: #E5E7EB;
    --table-header-bg: #F9FAFB;
    --table-hover: #F3F4F6;
    --balance-bg: #F5F5F5;
    --shadow: rgba(0, 0, 0, 0.1);
    --modal-overlay: rgba(0, 0, 0, 0.5);
    --accent-primary: #10a37f;
    --accent-hover: #0d8968;
    --accent-secondary: #ef4444;
    --accent-warning: #f59e0b;
}

body.dark-mode {
    /* Dark mode colors */
    --bg-primary: #1E1E1E;
    --bg-secondary: #2C2C2C;
    --bg-input: #383838;
    --text-primary: #ECECF1;
    --text-secondary: #ECECF1;
    --border-color: #2A2A2A;
    --table-header-bg: #2C2C2C;
    --table-hover: #2A2A2A;
    --balance-bg: #2C2C2C;
    --shadow: rgba(0, 0, 0, 0.3);
    --modal-overlay: rgba(0, 0, 0, 0.8);
    --accent-primary: #19c37d;
    --accent-hover: #15a86d;
}

body {
    font-family: 'Söhne', 'ui-sans-serif', 'system-ui', -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 14px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    background-color: var(--bg-secondary);
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 0 0 1px var(--border-color), 0 2px 8px var(--shadow);
    transition: background-color 0.2s ease;
}

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

.header-buttons {
    display: flex;
    gap: 8px;
}

h1 {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 28px;
    letter-spacing: -0.5px;
    transition: color 0.2s ease;
}

.control-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
}

.control-row:last-child {
    margin-bottom: 0;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.session-name {
    font-size: 14px;
    color: var(--text-secondary);
    opacity: 0.7;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-block;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

.session-name:hover {
    background-color: rgba(16, 163, 127, 0.1);
    opacity: 1;
    border-color: var(--accent-primary);
}

.banker-name {
    font-size: 14px;
    color: var(--text-primary);
    opacity: 0.7;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-block;
    border: 1px solid var(--border-color);
}

.banker-name:hover {
    background-color: rgba(16, 163, 127, 0.1);
    opacity: 1;
    border-color: var(--accent-primary);
}

.banker-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.banker-select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.controls {
    margin-bottom: 24px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}

.control-group button + .blind-display {
    margin-left: 0;
}

.control-group label + input {
    margin-left: 0;
}

.control-group label + .player-count {
    margin-left: 0;
}

.control-group label {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.control-group input {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    width: 120px;
    background-color: var(--bg-input);
    color: var(--text-primary);
    transition: all 0.2s ease;
    outline: none;
}

.control-group input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    outline: none;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-success {
    background-color: var(--accent-primary);
    color: white;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border-radius: 6px;
}

.btn-success:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-danger {
    background-color: var(--accent-secondary);
    color: white;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border-radius: 6px;
}

.btn-danger:hover {
    background-color: #dc2626;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-theme {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    position: relative;
}

.btn-theme:hover {
    background-color: var(--table-hover);
    border-color: var(--text-primary);
}

.theme-icon {
    width: 18px;
    height: 18px;
    position: absolute;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sun-icon {
    opacity: 1;
    transform: rotate(0deg);
}

.moon-icon {
    opacity: 0;
    transform: rotate(180deg);
}

body.dark-mode .sun-icon {
    opacity: 0;
    transform: rotate(180deg);
}

body.dark-mode .moon-icon {
    opacity: 1;
    transform: rotate(0deg);
}

body:not(.dark-mode) .theme-icon {
    color: #6b7280;
}

/* Compact Mode Styles */
body.compact-mode {
    font-size: 11px;
}

body.compact-mode .container {
    padding: 16px;
}

body.compact-mode h1 {
    font-size: 18px;
}

body.compact-mode .header {
    margin-bottom: 20px;
    padding-bottom: 16px;
}

body.compact-mode .controls {
    margin-bottom: 12px;
}

body.compact-mode .control-row {
    gap: 8px;
    margin-bottom: 8px;
}

body.compact-mode .control-row:last-child {
    padding-top: 8px;
}

body.compact-mode .control-group {
    gap: 4px;
}

body.compact-mode .control-group label {
    font-size: 11px;
}

body.compact-mode .control-group input {
    padding: 5px 6px;
    font-size: 11px;
    width: 70px;
}

body.compact-mode .btn {
    padding: 5px 10px;
    font-size: 11px;
}

body.compact-mode .btn-primary {
    padding: 6px 10px;
}

body.compact-mode .btn-success,
body.compact-mode .btn-stack-minus {
    padding: 3px 8px;
    font-size: 13px;
    min-width: 28px;
}

body.compact-mode .btn-theme {
    width: 30px;
    height: 30px;
    padding: 6px;
}

body.compact-mode .theme-icon {
    width: 14px;
    height: 14px;
}

body.compact-mode table {
    font-size: 11px;
}

body.compact-mode th,
body.compact-mode td {
    padding: 8px 4px;
    font-size: 11px;
}

body.compact-mode th {
    font-size: 10px;
    padding: 10px 4px;
}

body.compact-mode .cashout-input {
    padding: 4px 6px;
    font-size: 11px;
    width: 65px;
}

body.compact-mode .balance-section {
    padding: 12px;
    margin-bottom: 16px;
}

body.compact-mode .balance-section h3 {
    font-size: 13px;
}

body.compact-mode #totalBalance {
    font-size: 14px;
}

body.compact-mode .player-count {
    font-size: 12px;
    padding: 3px 8px;
}

body.compact-mode .blind-display {
    font-size: 10px;
    padding: 3px 6px;
}

body.compact-mode .player-name {
    font-size: 11px;
}

body.compact-mode .action-buttons {
    gap: 8px;
}

body.compact-mode .action-buttons .btn {
    padding: 6px 12px;
    font-size: 12px;
}

body.compact-mode .modal-content {
    padding: 24px;
    max-width: 350px;
}

body.compact-mode .modal-content h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

body.compact-mode .form-group {
    margin-bottom: 16px;
}

body.compact-mode .form-group label {
    font-size: 12px;
}

body.compact-mode .form-group input {
    padding: 8px;
    font-size: 13px;
}

body.compact-mode .footer {
    font-size: 11px;
    padding: 24px 20px;
}

/* Force table to fit on screen in compact mode */
body.compact-mode table {
    table-layout: fixed;
    width: 100%;
}

body.compact-mode th:nth-child(1), /* Player Name */
body.compact-mode td:nth-child(1) {
    width: 20%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.compact-mode th:nth-child(2), /* Total Buy-in */
body.compact-mode td:nth-child(2) {
    width: 18%;
}

body.compact-mode th:nth-child(3), /* Stack Control */
body.compact-mode td:nth-child(3) {
    width: 22%;
}

body.compact-mode th:nth-child(4), /* Cash Out */
body.compact-mode td:nth-child(4) {
    width: 20%;
}

body.compact-mode th:nth-child(5), /* P&L */
body.compact-mode td:nth-child(5) {
    width: 20%;
}

.btn-stack-minus {
    background-color: var(--accent-warning);
    color: white;
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 600;
    margin-right: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    min-width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-stack-minus:hover {
    background-color: #ea580c;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.blind-display {
    font-weight: 500;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    display: inline-block;
}

.blind-display:hover {
    background-color: rgba(16, 163, 127, 0.1);
    border-color: var(--accent-primary);
}

.player-count {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 14px;
    padding: 6px 14px;
    background-color: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.table-container {
    overflow-x: auto;
    margin-bottom: 30px;
    -webkit-overflow-scrolling: touch;
}

body.compact-mode .table-container {
    overflow-x: visible;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
}

thead {
    background-color: var(--table-header-bg);
    color: var(--text-secondary);
}

th, td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

th {
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.3px;
}

tbody tr:hover {
    background-color: var(--table-hover);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody td {
    font-size: 14px;
    color: var(--text-primary);
}

.player-name {
    cursor: pointer;
    transition: color 0.2s ease;
    font-weight: 500;
}

.player-name:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

.cashout-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 110px;
    font-size: 14px;
    background-color: var(--bg-input);
    color: var(--text-primary);
    transition: all 0.2s ease;
    outline: none;
}

.cashout-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.pnl-positive {
    color: var(--accent-primary);
    font-weight: 600;
}

.pnl-negative {
    color: var(--accent-secondary);
    font-weight: 600;
}

.pnl-zero {
    color: var(--text-primary);
    font-weight: 500;
    opacity: 0.6;
}

.balance-section {
    text-align: center;
    padding: 24px;
    background-color: var(--bg-primary);
    border-radius: 8px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.balance-section h3 {
    font-weight: 500;
    font-size: 28px;
    color: var(--text-primary);
    transition: color 0.2s ease;
}

#totalBalance {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 14px;
}

.action-buttons {
    text-align: center;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.action-buttons .btn {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    min-width: auto;
}

.footer {
    text-align: center;
    padding: 32px 20px;
    margin-top: 48px;
    margin-bottom: 24px;
    color: var(--text-primary);
    font-size: 14px;
    opacity: 0.5;
    transition: all 0.2s ease;
    font-weight: 400;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: var(--modal-overlay);
    transition: background-color 0.2s ease;
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--bg-secondary);
    margin: 10% auto;
    padding: 32px;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.modal-content h2 {
    margin-bottom: 24px;
    font-weight: 600;
    font-size: 20px;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.close {
    color: var(--text-primary);
    float: right;
    font-size: 24px;
    font-weight: 300;
    line-height: 20px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.close:hover,
.close:focus {
    opacity: 1;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background-color: var(--bg-input);
    color: var(--text-primary);
    transition: all 0.2s ease;
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.form-buttons {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-top: 8px;
}

.form-buttons .btn {
    flex: 1;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 20px 12px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    .header {
        margin-bottom: 20px;
        padding-bottom: 16px;
    }
    
    .control-row {
        gap: 6px;
        margin-bottom: 10px;
    }
    
    .control-row:first-child {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 4px;
    }
    
    .control-row:first-child .control-group {
        flex-shrink: 0;
        margin: 0;
    }
    
    .control-row:first-child .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .control-row:first-child .blind-display {
        padding: 4px 8px;
        font-size: 12px;
    }
    
    .control-row:first-child .control-group input {
        padding: 6px 8px;
        font-size: 12px;
        width: 80px;
    }
    
    .control-row:first-child .player-count {
        padding: 4px 8px;
        font-size: 12px;
    }
    
    .control-row .control-group {
        gap: 4px;
    }
    
    .control-row:nth-child(2) {
        justify-content: center;
    }
    
    .control-row:nth-child(2) .session-name,
    .control-row:nth-child(2) .banker-name {
        flex: 1;
        min-width: 100px;
    }
    
    .control-row:last-child {
        justify-content: center;
    }
    
    .control-row:last-child .control-group {
        flex: 1;
    }
    
    .control-row:last-child #addPlayerBtn {
        flex: 1;
        min-width: 120px;
    }
    
    table {
        font-size: 12px;
    }
    
    th, td {
        padding: 10px 6px;
        font-size: 12px;
    }
    
    th {
        font-size: 11px;
    }
    
    .cashout-input {
        width: 70px;
        font-size: 12px;
    }
    
    .modal-content {
        padding: 24px;
        margin: 20% auto;
        width: 95%;
    }
    
    /* Extra compact for mobile when compact mode is on */
    body.compact-mode .container {
        padding: 12px 6px;
    }
    
    body.compact-mode h1 {
        font-size: 14px;
    }
    
    body.compact-mode .header {
        margin-bottom: 12px;
        padding-bottom: 10px;
    }
    
    body.compact-mode .header-buttons {
        gap: 6px;
    }
    
    body.compact-mode .btn-theme {
        width: 28px;
        height: 28px;
        padding: 5px;
    }
    
    body.compact-mode .theme-icon {
        width: 12px;
        height: 12px;
    }
    
    body.compact-mode .controls {
        margin-bottom: 10px;
    }
    
    body.compact-mode .control-row {
        gap: 6px;
        margin-bottom: 6px;
    }
    
    body.compact-mode .control-row:last-child {
        padding-top: 6px;
    }
    
    body.compact-mode table {
        font-size: 9px;
        table-layout: fixed;
    }
    
    body.compact-mode th,
    body.compact-mode td {
        padding: 5px 2px;
        font-size: 9px;
        word-wrap: break-word;
    }
    
    body.compact-mode th {
        font-size: 8px;
        padding: 6px 2px;
        letter-spacing: 0;
    }
    
    body.compact-mode th:nth-child(1),
    body.compact-mode td:nth-child(1) {
        width: 22%;
        font-size: 9px;
    }
    
    body.compact-mode th:nth-child(2),
    body.compact-mode td:nth-child(2) {
        width: 16%;
        font-size: 8px;
    }
    
    body.compact-mode th:nth-child(3),
    body.compact-mode td:nth-child(3) {
        width: 24%;
    }
    
    body.compact-mode th:nth-child(4),
    body.compact-mode td:nth-child(4) {
        width: 18%;
    }
    
    body.compact-mode th:nth-child(5),
    body.compact-mode td:nth-child(5) {
        width: 20%;
        font-size: 9px;
    }
    
    body.compact-mode .cashout-input {
        width: 100%;
        max-width: 50px;
        padding: 2px 3px;
        font-size: 9px;
        border-radius: 3px;
    }
    
    body.compact-mode .btn-success,
    body.compact-mode .btn-stack-minus {
        padding: 2px 5px;
        font-size: 11px;
        border-radius: 3px;
        margin-right: 2px;
        min-width: 24px;
    }
    
    body.compact-mode .control-group input {
        width: 55px;
        font-size: 9px;
        padding: 4px 5px;
    }
    
    body.compact-mode .control-group label {
        font-size: 10px;
    }
    
    body.compact-mode .btn {
        padding: 5px 8px;
        font-size: 10px;
    }
    
    body.compact-mode .player-count,
    body.compact-mode .blind-display {
        font-size: 9px;
        padding: 2px 5px;
    }
    
    body.compact-mode .balance-section {
        padding: 10px;
        margin-bottom: 12px;
    }
    
    body.compact-mode .balance-section h3 {
        font-size: 12px;
    }
    
    body.compact-mode #totalBalance {
        font-size: 13px;
    }
    
    body.compact-mode .player-name {
        font-size: 9px;
    }
}
