/* General App Styling */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #121212;
    color: #ffffff;
    margin: 0;
    padding: 15px;
    position: relative;
}

/* Options Button */
.options-btn {
    position: fixed;
    top: 15px;
    right: 15px;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 15px;
    font-size: 1rem;
    cursor: pointer;
    z-index: 100;
}

.options-btn:active {
    background-color: #555;
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #1e1e1e;
    border-radius: 8px;
    max-width: 480px;
    width: 95%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    max-height: 88vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #333;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
}

.close-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
}

.close-btn:active {
    background-color: transparent;
}

.modal-body {
    padding: 20px;
    flex-grow: 1;
}

/* Legend Styling */
.legend {
    background-color: #2a2a2a;
    padding: 15px;
    border-radius: 6px;
    border-left: 3px solid #4caf50;
    margin-bottom: 20px;
}

.legend h3 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    color: #4caf50;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.legend-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    width: 100%;
}

.legend-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.custom-action-input {
    margin-left: auto;
    width: 110px;
    padding: 6px 8px;
    background-color: #3a3a3a;
    border: 1px solid #555;
    border-radius: 4px;
    color: #fff;
    font-size: 0.85rem;
}

.custom-action-input:focus {
    outline: none;
    border-color: #4caf50;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-icon {
    font-size: 1.3rem;
    margin-right: 12px;
    min-width: 30px;
}

.legend-text {
    color: #ffffff;
}

.names-title {
    margin-top: 20px;
    margin-bottom: 15px;
}

.player-input-group {
    margin-bottom: 15px;
}

.player-input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.9rem;
}

.player-input-group input {
    width: 100%;
    padding: 10px;
    background-color: #333;
    color: white;
    border: 1px solid #555;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
}

.player-input-group input:focus {
    outline: none;
    border-color: #4caf50;
}

.opponent-input {
    background-color: #333;
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
    border-left: 3px solid #ff9800;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #333;
    justify-content: flex-end;
}

.btn-save {
    background-color: #4caf50;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
}

.btn-save:active {
    background-color: #45a049;
}

.btn-cancel {
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
}

.btn-cancel:active {
    background-color: #da190b;
}

/* Clear Stats Button */
.clear-stats-btn {
    width: 100%;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 1rem;
    cursor: pointer;
}

.clear-stats-btn:active {
    background-color: #da190b;
}

/* Button Row */
.button-row {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.button-row button {
    flex: 1;
}

/* Export CSV Button */
.export-csv-btn {
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 1rem;
    cursor: pointer;
}

.export-csv-btn:active {
    background-color: #0b7dda;
}

.container {
    max-width: 500px; /* Keeps it phone-sized even on desktop */
    margin: 0 auto;
}

h2 { 
    margin-top: 0; 
    border-bottom: 1px solid #333; 
    padding-bottom: 10px;
}

/* --- THE FLEXBOX MAGIC --- */
.player-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1e1e1e;
    padding: 10px 15px;
    margin-bottom: 8px;
    border-radius: 8px;
}

.player-row.opponent-row {
    background-color: #2a2a2a;
    border-left: 3px solid #ff9800;
}

.player-name {
    flex: 0 0 120px;
    font-weight: bold;
    font-size: 1.1rem;
    padding-right: 10px;
    white-space: nowrap;
}

.actions-scroll {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.button-group {
    display: flex;
    gap: 8px;
    min-width: max-content;
}

/* Button Styling */
button {
    background-color: #333;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 1.2rem;
    cursor: pointer;
    touch-action: manipulation; /* Prevents double-tap zooming on mobile */
}

button:active { 
    background-color: #555; 
}

.btn-kill { border-bottom: 3px solid #ff9800; }
.btn-ace { border-bottom: 3px solid #4caf50; }
.btn-err { border-bottom: 3px solid #f44336; }
.btn-serve-err { border-bottom: 3px solid #e53935; }
.btn-block { border-bottom: 3px solid #03a9f4; }
.btn-custom-1 { border-bottom: 3px solid #ffd54f; }
.btn-custom-2 { border-bottom: 3px solid #ab47bc; }
.btn-custom-3 { border-bottom: 3px solid #26a69a; }
.btn-custom-4 { border-bottom: 3px solid #ef5350; }
.btn-custom { border-bottom: 3px solid #ffd54f; }

/* Add / Delete custom action buttons */
.btn-add-custom {
    margin-top: 12px;
    width: 100%;
    background-color: #2e7d32;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: center;
}

.btn-add-custom:disabled {
    background-color: #444;
    color: #888;
    cursor: default;
}

.btn-add-custom:not(:disabled):active {
    background-color: #1b5e20;
}

.btn-delete-custom {
    margin-left: 8px;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #f44336;
    padding: 6px 10px;
    border-radius: 4px;
    flex-shrink: 0;
}

.btn-delete-custom:active {
    background-color: #3a1a1a;
}

/* Scoreboard Table */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid #333;
}