:root {
    --bg: #f7f7f7;
    --fg: #222;
    --muted: #666;
    --accent: #2b6cb0;
    --accent-hover: #2c5282;
    --border: #ddd;
    --card: #fff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.site-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

.main-nav a {
    margin-left: 1rem;
    color: var(--fg);
    text-decoration: none;
}

.main-nav a:hover {
    color: var(--accent);
}

main {
    padding: 2rem 0;
}

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--card);
    padding: 1.5rem 0;
    margin-top: 2rem;
    color: var(--muted);
    font-size: 0.875rem;
}

h1, h2, h3 {
    margin-top: 0;
}

.subtitle {
    color: var(--muted);
    margin-top: -0.5rem;
    margin-bottom: 1.5rem;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-form input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
}

.search-form select {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    background: var(--card);
}

.search-form button {
    padding: 0.6rem 1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.search-form button:hover {
    background: var(--accent-hover);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card .value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-card .label {
    color: var(--muted);
    font-size: 0.875rem;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.results-table th,
.results-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.results-table th {
    background: #eef2f7;
    font-weight: 600;
}

.results-table tr:last-child td {
    border-bottom: none;
}

.results-table a {
    color: var(--accent);
    text-decoration: none;
}

.results-table a:hover {
    text-decoration: underline;
}

.results-table .num {
    text-align: right;
}

.player-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.player-table th,
.player-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.player-table th {
    background: #eef2f7;
    font-weight: 600;
}

.player-table tr:last-child td {
    border-bottom: none;
}

.player-table a {
    color: var(--accent);
    text-decoration: none;
}

.player-table a:hover {
    text-decoration: underline;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
}

.pagination a {
    padding: 0.5rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--accent);
}

.pagination a:hover {
    background: #eef2f7;
}

.pagination .disabled {
    color: var(--muted);
    pointer-events: none;
}

.player-detail {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.player-detail dt {
    font-weight: 600;
    color: var(--muted);
    margin-top: 1rem;
}

.player-detail dd {
    margin: 0.25rem 0 0;
    font-size: 1.125rem;
}

.deceased {
    color: #c53030;
    font-weight: 600;
}

.empty {
    color: var(--muted);
    font-style: italic;
}

/* ALT tournament navigation */
.stage-nav,
.tournament-views {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.stage-nav a,
.tournament-views a {
    padding: 0.4rem 0.8rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--accent);
}

.stage-nav a:hover,
.tournament-views a:hover {
    background: #eef2f7;
}

.stage-nav a.active,
.tournament-views a.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.flag {
    color: var(--muted);
    font-size: 0.8rem;
    margin-left: 0.25rem;
}

/* Match header */
.match-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.match-header .team {
    text-align: center;
}

.match-header .team a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

.match-header .score {
    font-size: 1.125rem;
    margin-top: 0.25rem;
}

.match-header .vs {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--muted);
}

/* Board protocol */
.board-protocol th,
.board-protocol td {
    font-size: 0.875rem;
}

/* Board deal */
.board-deal {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto 1.5rem;
}

.board-deal .hand {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    box-shadow: var(--shadow);
}

.board-deal .hand h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.board-deal .north {
    grid-column: 2;
    grid-row: 1;
}

.board-deal .west {
    grid-column: 1;
    grid-row: 2;
}

.board-deal .east {
    grid-column: 3;
    grid-row: 2;
}

.board-deal .south {
    grid-column: 2;
    grid-row: 2;
}

.board-deal .suit {
    font-family: "Courier New", Courier, monospace;
    font-size: 1.125rem;
    line-height: 1.4;
}

.board-deal .suit.spades { color: #000; }
.board-deal .suit.hearts { color: #c53030; }
.board-deal .suit.diamonds { color: #c53030; }
.board-deal .suit.clubs { color: #276749; }

/* Cross table */
.cross-table {
    font-size: 0.8rem;
    table-layout: fixed;
}

.cross-table th,
.cross-table td {
    padding: 0.3rem;
    text-align: center;
}

.cross-table th:first-child,
.cross-table td:first-child {
    text-align: left;
    width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cross-table .rotated span {
    display: block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    max-height: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cross-table .diag {
    background: #f0f0f0;
}

.cross-cell.empty {
    background: #fafafa;
}

.cross-cell small {
    display: block;
    color: var(--muted);
    font-size: 0.7rem;
}

.player-list {
    list-style: none;
    padding: 0;
}

.player-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}

.bbo-nick {
    color: var(--muted);
    font-size: 0.875rem;
    margin-left: 0.25rem;
}

.team-totals {
    font-weight: 600;
    margin-bottom: 1rem;
}

.lin-bidding,
.lin-play {
    border-collapse: collapse;
    background: #fff;
    font-size: 12px;
}

.lin-bidding th,
.lin-bidding td,
.lin-play th,
.lin-play td {
    border: 1px solid #999;
    padding: 2px 6px;
    text-align: center;
    min-width: 36px;
}

.lin-bidding th,
.lin-play th {
    background: #e0e0e0;
    font-weight: bold;
}

.lin-bidding td small {
    color: #666;
    font-size: 10px;
}

.lin-bid-anns {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.lin-bid-ann {
    display: inline-block;
    background: #fdebd0;
    border: 1px solid #e0c0a0;
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 11px;
}

.hover-cell {
    cursor: help;
    text-decoration: underline dotted;
}

/* ALT match protocol */
.match-hint {
    text-align: center;
    color: #555;
    font-size: 0.85rem;
    margin-top: 1rem;
}

.deal-suit {
    white-space: nowrap;
}

.deal-suit img {
    height: 12px;
    width: auto;
    vertical-align: middle;
}
