* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #F3F4F6;
    color: #1F2937;
    -webkit-font-smoothing: antialiased;
}

.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    background-color: #F3F4F6;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex: 1;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ── Setup Screen ────────────────────────────── */
.setup-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px;
}

.setup-title {
    font-size: 28px;
    font-weight: bold;
    color: #1F2937;
    margin-bottom: 24px;
    text-align: center;
}

.setup-label {
    font-size: 16px;
    color: #4B5563;
    margin-bottom: 8px;
}

.setup-input {
    background-color: #fff;
    border: 1px solid #D1D5DB;
    border-radius: 12px;
    padding: 16px;
    font-size: 20px;
    margin-bottom: 24px;
    color: #1F2937;
    text-align: center;
    width: 100%;
    font-family: inherit;
}

/* ── Header ──────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    padding-top: 40px;
    background-color: #fff;
    border-bottom: 1px solid #E5E7EB;
}

.app-title {
    font-size: 14px;
    font-weight: 600;
    color: #6B7280;
    margin-bottom: 4px;
}

.header-title {
    font-size: 24px;
    font-weight: bold;
    color: #1F2937;
}

.reset-text {
    background: none;
    border: none;
    color: #EF4444;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
}

/* ── Main content area ───────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Match display ───────────────────────────── */
.match-container {
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.match-prompt {
    font-size: 16px;
    color: #6B7280;
    margin-bottom: 24px;
}

.doubles-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.doubles-container.hidden {
    display: none;
}

.pair-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.vs-container {
    padding: 0 12px;
}

.vs-text {
    font-size: 20px;
    font-weight: 900;
    color: #EF4444;
    font-style: italic;
}

.player-card {
    width: 64px;
    height: 64px;
    background-color: #3B82F6;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.player-card-text {
    font-size: 32px;
    font-weight: bold;
    color: #fff;
}

/* ── Action buttons ──────────────────────────── */
.actions-container {
    padding: 0 24px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.primary-button {
    background-color: #10B981;
    border-radius: 16px;
    border: none;
    padding: 18px;
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
    width: 100%;
    font-family: inherit;
}

.primary-button:active {
    opacity: 0.85;
}

.secondary-button {
    background-color: #fff;
    border: 2px solid #3B82F6;
    border-radius: 16px;
    padding: 16px;
    color: #3B82F6;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
}

.secondary-button:active {
    opacity: 0.85;
}

/* ── Stats / History panel ───────────────────── */
.stats-container {
    flex: 1;
    background-color: #fff;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 24px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.tab-header {
    display: flex;
    flex-direction: row;
    margin-bottom: 16px;
    border-bottom: 1px solid #E5E7EB;
}

.tab-button {
    flex: 1;
    padding-bottom: 12px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.stats-title {
    font-size: 16px;
    font-weight: bold;
    color: #9CA3AF;
}

.stats-title.active-tab-title {
    color: #374151;
}

.tab-content {
    display: none;
    flex-direction: column;
}

.tab-content.active {
    display: flex;
}

/* ── Stats rows ──────────────────────────────── */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #F3F4F6;
}

.stat-row.inactive {
    opacity: 0.6;
}

.stat-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-header-row {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #D1D5DB;
    margin-bottom: 4px;
}

.stat-h-toggle {
    width: 56px;
    font-size: 12px;
    font-weight: bold;
    color: #6B7280;
}

.stat-h-name {
    flex: 1;
    font-size: 12px;
    font-weight: bold;
    color: #6B7280;
}

.stat-h-count {
    font-size: 12px;
    font-weight: bold;
    color: #6B7280;
}

/* Toggle switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #D1D5DB;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #10B981;
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.stat-player {
    font-size: 16px;
    color: #4B5563;
    font-weight: 500;
}

.stat-player.inactive {
    text-decoration: line-through;
    color: #9CA3AF;
}

.stat-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.stat-count {
    font-size: 16px;
    color: #111827;
    font-weight: bold;
}

.stat-count.inactive {
    text-decoration: line-through;
    color: #9CA3AF;
}

.stat-sub-text {
    font-size: 12px;
    color: #6B7280;
    margin-top: 2px;
}

/* ── History table ───────────────────────────── */
.history-header {
    display: flex;
    flex-direction: row;
    padding: 8px 0;
    border-bottom: 1px solid #D1D5DB;
    margin-bottom: 8px;
}

.h-col-id {
    flex: 0.6;
    font-size: 12px;
    font-weight: bold;
    color: #6B7280;
}

.h-col-time {
    flex: 1.4;
    font-size: 12px;
    font-weight: bold;
    color: #6B7280;
}

.h-col-match {
    flex: 1;
    font-size: 12px;
    font-weight: bold;
    color: #6B7280;
    text-align: center;
}

.history-row {
    display: flex;
    flex-direction: row;
    padding: 12px 0;
    border-bottom: 1px solid #F3F4F6;
    align-items: center;
}

.r-col-id {
    flex: 0.6;
    font-size: 14px;
    font-weight: bold;
    color: #4B5563;
}

.r-col-time {
    flex: 1.4;
    font-size: 13px;
    color: #6B7280;
}

.r-col-match {
    flex: 1;
    font-size: 14px;
    font-weight: bold;
    color: #111827;
    text-align: center;
}

.empty-label {
    text-align: center;
    color: #6B7280;
    padding: 20px 0;
    font-size: 14px;
}