:root {
    --navy-950: #060f1f;
    --navy-900: #0a1730;
    --navy-800: #0f2342;
    --navy-700: #142a4d;
    --navy-600: #1b3760;
    --border: #1f3a66;
    --border-strong: #2a4a7a;
    --text: #e6ecf5;
    --text-muted: #8fa3bf;
    --text-dim: #6f83a0;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --success-hover: #16a34a;
    --danger: #ef4444;
    --danger-bg: #4a1a1a;
    --danger-border: #8a2a2a;
    --success-bg: #143a24;
    --success-border: #2a6a4a;
}

* {
    box-sizing: border-box;
}

html, body {
    font-family: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--navy-950);
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

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

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

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

.muted {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    text-decoration: none;
    min-height: 40px;
    line-height: 1.2;
}

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

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    min-height: 32px;
}

.btn-lg {
    padding: 0.75rem 1.75rem;
    font-size: 1.05rem;
    min-height: 48px;
}

.btn-primary {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #ffffff;
}

.btn-success {
    background-color: var(--success);
    border-color: var(--success);
    color: #06210f;
}

.btn-success:hover:not(:disabled) {
    background-color: var(--success-hover);
    border-color: var(--success-hover);
    color: #06210f;
}

.btn-secondary {
    background-color: var(--navy-600);
    border-color: var(--navy-600);
    color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--border-strong);
    border-color: var(--border-strong);
    color: #ffffff;
}

.btn-outline-primary {
    background: transparent;
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-primary:hover:not(:disabled) {
    background-color: var(--accent);
    color: #ffffff;
}

.btn-outline-secondary {
    background: transparent;
    border-color: var(--border-strong);
    color: var(--text-muted);
}

.btn-outline-secondary:hover:not(:disabled) {
    background-color: var(--border-strong);
    color: #ffffff;
}

.btn-outline-danger {
    background: transparent;
    border-color: var(--danger-border);
    color: #ff8a8a;
}

.btn-outline-danger:hover:not(:disabled) {
    background-color: var(--danger-border);
    color: #ffffff;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: #c9d6e8;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    background-color: var(--navy-800);
    border: 1px solid var(--border-strong);
    color: var(--text);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    font-size: 1rem;
    min-height: 44px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238fa3bf' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.radio-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    color: var(--text);
    cursor: pointer;
}

.radio-option input[type="radio"] {
    accent-color: var(--accent);
    width: 1.1rem;
    height: 1.1rem;
}

.player-input-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Alerts */
.alert {
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.alert-danger {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: #ffb3b3;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: #b3ffd1;
}

/* Home */
.home {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem 0 3rem;
}

.home-header {
    text-align: center;
    padding: 2rem 0 1rem;
}

.home-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
}

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

.new-game-btn {
    border-radius: 999px;
}

.game-section {
    margin-top: 2rem;
}

.game-section h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.game-list {
    display: grid;
    gap: 0.75rem;
}

.game-card {
    display: block;
    background: var(--navy-700);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.game-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    color: inherit;
}

.game-card.completed {
    opacity: 0.85;
}

.game-card-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 0.35rem;
}

.game-card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: #b8c7dd;
    flex-wrap: wrap;
}

.game-card-meta.muted {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--navy-600);
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.empty-state {
    background: var(--navy-700);
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
}

.page-narrow {
    max-width: 640px;
    margin: 0 auto;
    padding: 1rem 0 3rem;
}

/* Game page */
.game-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 0 3rem;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.game-header h1 {
    margin-bottom: 0.25rem;
}

.game-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Scoreboard */
.scoreboard-wrapper {
    overflow-x: auto;
    background: var(--navy-700);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 2rem;
}

.scoreboard {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.scoreboard th,
.scoreboard td {
    padding: 0.6rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.scoreboard tbody tr:last-child th,
.scoreboard tbody tr:last-child td {
    border-bottom: none;
}

.scoreboard thead th {
    background: var(--navy-800);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
}

.scoreboard .player-col {
    text-align: left;
    min-width: 140px;
    position: sticky;
    left: 0;
    background: var(--navy-700);
    z-index: 1;
}

.scoreboard thead .player-col {
    background: var(--navy-800);
}

.scoreboard .round-col.current {
    background: rgba(59, 130, 246, 0.12);
}

.scoreboard .total-col {
    font-weight: 700;
    color: #ffffff;
    background: var(--navy-800);
    font-variant-numeric: tabular-nums;
}

.player-dot {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.player-name {
    color: #ffffff;
    font-weight: 600;
}

.round-label {
    color: #ffffff;
}

.round-cards {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
}

.score-cell {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text);
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    min-width: 2.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.score-cell:hover:not(:disabled) {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.15);
}

.score-cell.empty {
    color: #4a5f80;
}

.score-cell:disabled {
    cursor: default;
}

/* Score entry */
.score-entry {
    background: var(--navy-700);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.score-entry h2 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.entry-row {
    margin-bottom: 1rem;
}

.entry-row label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: #c9d6e8;
    font-size: 0.9rem;
}

.player-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.player-chip {
    background: var(--navy-800);
    border: 2px solid var(--border-strong);
    color: var(--text);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.95rem;
    min-height: 44px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.player-chip:hover {
    border-color: var(--accent);
}

.player-chip.selected {
    border-color: var(--chip-color, var(--accent));
    background: rgba(59, 130, 246, 0.2);
    color: #ffffff;
}

.entry-summary {
    margin: 1rem 0;
    color: #b8c7dd;
}

/* Dialogs */
.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.dialog {
    background: var(--navy-700);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.dialog h2 {
    margin-bottom: 0.5rem;
}

.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.color-swatch {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
}

.color-swatch.selected {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px var(--accent);
}

/* Responsive */
@media (max-width: 640px) {
    .home-header h1 {
        font-size: 2rem;
    }

    .game-header {
        flex-direction: column;
    }

    .scoreboard .player-col {
        min-width: 110px;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
    }
}

a {
    color: #7fb3ff;
}

h1, h2, h3 {
    color: #ffffff;
}

.muted {
    color: #8fa3bf;
}

.home {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem 0 3rem;
}

.home-header {
    text-align: center;
    padding: 2rem 0 1rem;
}

.home-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: #8fa3bf;
    margin-bottom: 1.5rem;
}

.new-game-btn {
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
    border-radius: 999px;
}

.game-section {
    margin-top: 2rem;
}

.game-section h2 {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8fa3bf;
    margin-bottom: 0.75rem;
}

.game-list {
    display: grid;
    gap: 0.75rem;
}

.game-card {
    display: block;
    background: #142a4d;
    border: 1px solid #1f3a66;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.game-card:hover {
    border-color: #3a6bb5;
    transform: translateY(-1px);
    color: inherit;
}

.game-card.completed {
    opacity: 0.85;
}

.game-card-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 0.35rem;
}

.game-card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: #b8c7dd;
}

.game-card-meta.muted {
    color: #6f83a0;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.empty-state {
    background: #142a4d;
    border: 1px dashed #2a4a7a;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
}

.page-narrow {
    max-width: 640px;
    margin: 0 auto;
    padding: 1rem 0 3rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: #c9d6e8;
}

.form-control {
    background-color: #0f2342;
    border: 1px solid #2a4a7a;
    color: #e6ecf5;
}

.form-control:focus {
    background-color: #0f2342;
    color: #e6ecf5;
    border-color: #4a7bc8;
    box-shadow: 0 0 0 0.2rem rgba(74, 123, 200, 0.25);
}

.radio-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: normal;
    color: #e6ecf5;
}

.player-input-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

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

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.game-header h1 {
    margin-bottom: 0.25rem;
}

.game-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.scoreboard-wrapper {
    overflow-x: auto;
    background: #142a4d;
    border: 1px solid #1f3a66;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.scoreboard {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.scoreboard th,
.scoreboard td {
    padding: 0.6rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid #1f3a66;
}

.scoreboard thead th {
    background: #0f2342;
    color: #b8c7dd;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
}

.scoreboard .player-col {
    text-align: left;
    min-width: 140px;
    position: sticky;
    left: 0;
    background: #142a4d;
    z-index: 1;
}

.scoreboard thead .player-col {
    background: #0f2342;
}

.scoreboard .round-col.current {
    background: rgba(74, 123, 200, 0.15);
}

.scoreboard .total-col {
    font-weight: 700;
    color: #ffffff;
    background: #0f2342;
}

.player-dot {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.player-name {
    color: #ffffff;
    font-weight: 600;
}

.round-label {
    color: #ffffff;
}

.round-cards {
    font-size: 0.7rem;
    color: #6f83a0;
    text-transform: none;
    letter-spacing: 0;
}

.score-cell {
    background: transparent;
    border: 1px solid transparent;
    color: #e6ecf5;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    min-width: 2.5rem;
    cursor: pointer;
    font-size: 1rem;
}

.score-cell:hover:not(:disabled) {
    border-color: #4a7bc8;
    background: rgba(74, 123, 200, 0.15);
}

.score-cell.empty {
    color: #4a5f80;
}

.score-cell:disabled {
    cursor: default;
}

.score-entry {
    background: #142a4d;
    border: 1px solid #1f3a66;
    border-radius: 12px;
    padding: 1.5rem;
}

.score-entry h2 {
    margin-bottom: 1rem;
}

.entry-row {
    margin-bottom: 1rem;
}

.entry-row label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: #c9d6e8;
}

.player-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.player-chip {
    background: #0f2342;
    border: 2px solid #2a4a7a;
    color: #e6ecf5;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.95rem;
    min-height: 44px;
}

.player-chip.selected {
    border-color: var(--chip-color, #4a7bc8);
    background: rgba(74, 123, 200, 0.2);
    color: #ffffff;
}

.entry-summary {
    margin: 1rem 0;
    color: #b8c7dd;
}

.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.dialog {
    background: #142a4d;
    border: 1px solid #2a4a7a;
    border-radius: 12px;
    padding: 1.5rem;
    width: 100%;
    max-width: 420px;
}

.dialog h2 {
    margin-bottom: 0.5rem;
}

.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.color-swatch {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
}

.color-swatch.selected {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px #4a7bc8;
}

.alert {
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.alert-danger {
    background: #4a1a1a;
    border: 1px solid #8a2a2a;
    color: #ffb3b3;
}

.alert-success {
    background: #1a3a2a;
    border: 1px solid #2a6a4a;
    color: #b3ffd1;
}

.btn-primary {
    background-color: #2a6bb5;
    border-color: #2a6bb5;
}

.btn-primary:hover {
    background-color: #3a7bc5;
    border-color: #3a7bc5;
}

.btn-outline-primary {
    color: #7fb3ff;
    border-color: #4a7bc8;
}

.btn-outline-primary:hover {
    background-color: #4a7bc8;
    color: #ffffff;
}

.btn-outline-secondary {
    color: #b8c7dd;
    border-color: #4a5f80;
}

.btn-outline-secondary:hover {
    background-color: #4a5f80;
    color: #ffffff;
}

.btn-outline-danger {
    color: #ff8a8a;
    border-color: #8a2a2a;
}

.btn-outline-danger:hover {
    background-color: #8a2a2a;
    color: #ffffff;
}

.btn-secondary {
    background-color: #2a4a7a;
    border-color: #2a4a7a;
}

@media (max-width: 640px) {
    .home-header h1 {
        font-size: 2rem;
    }

    .game-header {
        flex-direction: column;
    }

    .scoreboard .player-col {
        min-width: 110px;
    }
}

.content {
    padding-top: 1.1rem;
}

.brand-centered {
    display: block;
    width: 100%;
    text-align: center;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--success);
}

.invalid {
    outline: 1px solid var(--danger);
}

.validation-message {
    color: var(--danger);
}

.blazor-error-boundary {
    background: var(--danger-bg);
    padding: 1rem;
    color: #ffb3b3;
    border-radius: 8px;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}
