/* ===== Reset léger ===== */
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: #f5f7fa;
    color: #1a1a1a;
    -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.app-header {
    background: linear-gradient(135deg, #1a73e8 0%, #4285f4 100%);
    color: white;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.app-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}
.tournament-name {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 4px;
    min-height: 18px;
}
.conn-status {
    font-size: 12px;
    color: #4caf50;
    transition: color 0.3s;
}
.conn-status.offline { color: #f44336; }
.conn-status.syncing { color: #ff9800; }

/* ===== Layout ===== */
main {
    max-width: 700px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 80px;
}
.view { display: none; }
.view.active { display: block; }

.card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card.highlight {
    border-left: 4px solid #1a73e8;
    background: linear-gradient(to right, #e8f0fe 0%, white 8%);
}
.card h2, .card h3 { margin-top: 0; }

/* ===== Inputs / boutons ===== */
input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #dadce0;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 12px;
}
input.code-input {
    text-align: center;
    font-size: 24px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 600;
}
input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}
label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-top: 8px;
    margin-bottom: 4px;
    color: #5f6368;
}

.btn {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: #1a73e8; color: white; }
.btn-primary:hover { background: #1761c4; }
.btn-block { display: block; width: 100%; }
.btn-link {
    background: none;
    border: none;
    color: #1a73e8;
    text-decoration: underline;
    cursor: pointer;
    margin-top: 12px;
    padding: 8px;
    width: 100%;
    font-size: 14px;
}

.error-msg {
    color: #c5221f;
    font-size: 13px;
    margin-top: 8px;
    min-height: 18px;
}

.muted { color: #5f6368; font-size: 14px; }
.hidden { display: none !important; }
.mt-3 { margin-top: 16px; }

/* ===== Role grid ===== */
.role-grid {
    display: grid;
    gap: 12px;
    margin: 16px 0;
}
.role-btn {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.1s;
    display: grid;
    grid-template-columns: 48px 1fr;
    grid-template-rows: auto auto;
    gap: 4px 12px;
    font-family: inherit;
}
.role-btn:hover { border-color: #1a73e8; }
.role-btn.active {
    border-color: #1a73e8;
    background: #e8f0fe;
}
.role-icon {
    grid-row: 1 / 3;
    font-size: 32px;
    align-self: center;
}
.role-label { font-size: 16px; font-weight: 600; }
.role-desc { font-size: 13px; color: #5f6368; }

/* ===== Tabs ===== */
.tabs {
    display: flex;
    background: white;
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow-x: auto;
}
.tab {
    flex: 1;
    padding: 10px 12px;
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 500;
    color: #5f6368;
    cursor: pointer;
    border-radius: 6px;
    white-space: nowrap;
    font-family: inherit;
}
.tab.active {
    background: #1a73e8;
    color: white;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Match card ===== */
.match-card {
    background: white;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border-left: 3px solid #e0e0e0;
}
.match-card.live { border-left-color: #f44336; background: #fff5f5; }
.match-card.played { border-left-color: #4caf50; opacity: 0.85; }
.match-court {
    display: inline-block;
    background: #1a73e8;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 6px;
}
.match-card.live .match-court { background: #f44336; }
.match-discipline {
    display: inline-block;
    background: #f0f0f0;
    color: #5f6368;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}
.match-teams {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    margin-top: 8px;
    font-size: 14px;
}
.match-team { font-weight: 500; }
.match-team.winner { color: #1a73e8; }
.match-score {
    font-variant-numeric: tabular-nums;
    color: #5f6368;
    font-size: 13px;
}
.match-meta {
    margin-top: 6px;
    font-size: 12px;
    color: #5f6368;
}

/* ===== Player view ===== */
.player-header {
    background: linear-gradient(135deg, #1a73e8 0%, #4285f4 100%);
    color: white;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
}
.player-header h2 { margin: 0; }
.player-header .player-club { opacity: 0.85; font-size: 14px; }

/* ===== Pool ===== */
.pool-card { margin-bottom: 16px; }
.pool-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.pool-table th, .pool-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
}
.pool-table th { font-weight: 600; color: #5f6368; font-size: 11px; text-transform: uppercase; }
.pool-table tr.qualified { background: #e8f5e9; }

/* ===== Footer ===== */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 8px 16px;
    text-align: center;
    border-top: 1px solid #e0e0e0;
    font-size: 11px;
}

/* ===== Loading / empty states ===== */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: #5f6368;
}
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #1a73e8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .app-title { font-size: 16px; }
    main { padding: 12px; }
    .card { padding: 12px; }
    input.code-input { font-size: 20px; }
}
