/* ===== Mobile-first CSS ===== */

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background: #f5f5f5;
    color: #333;
    height: 100%;
    overflow-x: hidden;
}

.page-container {
    min-height: 100vh;
    padding-bottom: 80px; /* space for bottom nav */
}

/* Header */
.app-header {
    background: #2c7a7b;
    color: white;
    padding: 12px 16px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.header-logout {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.header-logout:active {
    background: rgba(255,255,255,0.4);
}

/* Content */
.content {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-around;
    padding: 4px 0;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 8px;
    text-decoration: none;
    color: #888;
    min-width: 48px;
    min-height: 48px;
    font-size: 0.7rem;
    transition: color 0.2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

.nav-item.active {
    color: #2c7a7b;
}

.nav-icon {
    font-size: 1.4rem;
    margin-bottom: 2px;
}

/* Cards */
.card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 48px;
    min-width: 48px;
    transition: transform 0.1s, opacity 0.2s;
    text-align: center;
}

.btn:active {
    transform: scale(0.97);
}

.btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn.loading::after {
    content: '...';
}

.btn-primary {
    background: #2c7a7b;
    color: white;
}

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

.btn-secondary {
    background: #e2e8f0;
    color: #333;
}

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

/* Player cards */
.player-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.player-card {
    background: white;
    border-radius: 10px;
    padding: 10px 4px;
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
    user-select: none;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    position: relative;
}

.player-card:active {
    transform: scale(0.97);
}

.player-card.selected {
    border-color: #2c7a7b;
    background: #e6fffa;
    color: #2c7a7b;
    box-shadow: 0 0 0 3px rgba(44, 122, 123, 0.3);
}

.player-card.admin-add {
    border-style: dashed;
    border-color: #2c7a7b;
    color: #2c7a7b;
    font-size: 1.2rem;
}

/* Slot count - same player selected multiple times */
.player-card.count-1 { border-color: #2c7a7b; background: #e6fffa; color: #2c7a7b; }
.player-card.count-2 { border-color: #2c7a7b; background: #b2dfdb; color: #1a5c5d; }
.player-card.count-3 { border-color: #dd6b20; background: #feebc8; color: #c05621; }
.player-card.count-4 { border-color: #e53e3e; background: #fed7d7; color: #c53030; }

.player-card .count-badge {
    position: absolute; top: 2px; right: 2px;
    background: #2c7a7b; color: white;
    font-size: 0.65rem; font-weight: 700;
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.player-card.count-3 .count-badge { background: #dd6b20; }
.player-card.count-4 .count-badge { background: #e53e3e; }

/* Bottom selection bar (replaces bottom nav when players selected) */
.selection-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: white; border-top: 1px solid #e0e0e0;
    z-index: 100; box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.selection-slots {
    display: flex; gap: 0; padding: 10px 12px;
    align-items: stretch;
}

.slot {
    flex: 1; display: flex; align-items: center; justify-content: center;
    background: #f7f7f7; border: 2px dashed #ddd;
    border-radius: 10px; margin: 0 3px;
    min-height: 52px; cursor: pointer;
    font-size: 0.85rem; font-weight: 600;
    color: #999; transition: all 0.15s;
    position: relative; padding: 4px 8px;
    text-align: center;
}
.slot.filled {
    background: #e6fffa; border: 2px solid #2c7a7b;
    color: #2c7a7b; border-style: solid;
}
.slot .slot-name {
    white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 100%;
}
.slot .slot-remove {
    position: absolute; top: -6px; right: -6px;
    background: #e53e3e; color: white;
    width: 20px; height: 20px; border-radius: 50%;
    font-size: 0.7rem; display: flex; align-items: center; justify-content: center;
    border: 2px solid white; cursor: pointer; line-height: 1;
}
.slot .slot-remove:active { transform: scale(1.2); }
.slot-empty-text { color: #bbb; font-weight: 500; }

.confirm-row { padding: 0 12px 10px; }

.btn-confirm {
    display: block; width: 100%;
    padding: 14px; border: none; border-radius: 10px;
    font-size: 1rem; font-weight: 700; cursor: pointer;
    background: #2c7a7b; color: white;
    transition: all 0.15s;
}
.btn-confirm:disabled {
    background: #cbd5e0; color: #999; cursor: not-allowed;
}
.btn-confirm:active:not(:disabled) { transform: scale(0.98); }

/* Admin delete button on player card */
.player-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    background: none;
    border: none;
    padding: 2px 4px;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0.5;
    line-height: 1;
}
.player-delete:active {
    opacity: 1;
    transform: scale(1.1);
}

/* Forms */
input, select {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    min-height: 48px;
    -webkit-appearance: none;
}

input:focus, select:focus {
    outline: none;
    border-color: #2c7a7b;
}

/* Toast */
.toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    opacity: 0;
    transition: all 0.3s;
    z-index: 200;
    pointer-events: none;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: #38a169;
}

.toast.error {
    background: #e53e3e;
}

/* Admin badge */
.admin-badge {
    display: inline-block;
    background: #d69e2e;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 8px;
}

/* Utility */
.text-center { text-align: center; }
.hint { text-align: center; color: #888; font-size: 0.9rem; margin-bottom: 12px; }
.spacer { height: 160px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mt-2 { margin-top: 16px; }
.w-full { width: 100%; }

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    font-weight: 600;
    color: #666;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 16px 16px 0 0;
    padding: 20px 16px 28px;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.15rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #888;
    cursor: pointer;
    padding: 4px 8px;
    min-height: 44px;
    min-width: 44px;
}

.modal-subtitle {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 12px;
}

/* Edit player grid (inside modal) */
.edit-player-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.edit-player-card {
    background: #f7f7f7;
    border-radius: 10px;
    padding: 12px 4px;
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
    user-select: none;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    position: relative;
}

.edit-player-card:active {
    transform: scale(0.97);
}

.edit-player-card.selected {
    border-color: #2c7a7b;
    background: #e6fffa;
    color: #2c7a7b;
    box-shadow: 0 0 0 3px rgba(44, 122, 123, 0.25);
}

.edit-player-card.count-1 { border-color: #2c7a7b; background: #e6fffa; color: #2c7a7b; }
.edit-player-card.count-2 { border-color: #2c7a7b; background: #b2dfdb; color: #1a5c5d; }
.edit-player-card.count-3 { border-color: #dd6b20; background: #feebc8; color: #c05621; }
.edit-player-card.count-4 { border-color: #e53e3e; background: #fed7d7; color: #c53030; }

.edit-player-card .count-badge {
    position: absolute; top: 2px; right: 2px;
    background: #2c7a7b; color: white;
    font-size: 0.65rem; font-weight: 700;
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.edit-player-card.count-3 .count-badge { background: #dd6b20; }
.edit-player-card.count-4 .count-badge { background: #e53e3e; }

.edit-player-card .pos-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #2c7a7b;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Player badges in match list */
.player-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.player-badge {
    display: inline-block;
    background: #edf2f7;
    color: #718096;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid #e2e8f0;
}

.player-badge.active {
    background: #e6fffa;
    color: #2c7a7b;
    border: 1px solid #b2dfdb;
}
