:root {
    --primary: #1a56db;
    --primary-hover: #1e40af;
    --secondary: #6b7280;
    --danger: #dc2626;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);

    /* Title and label colors (overridable via Color Palette) */
    --title-color: var(--text);
    --title-bg: rgba(255, 255, 255, 0.85);
    --subtitle-color: var(--text);
    --label-color: var(--text);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: block;
}

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

/* Title bar — semi-transparent background so titles stay readable
   over any background image.
   Color and background are themeable via --title-color / --title-bg. */
h1 {
    margin-bottom: 1.5rem;
    font-size: 1.75rem;
    color: var(--title-color);
    background: var(--title-bg);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Section titles (h2) inside form sections */
h2 {
    font-size: 1.25rem;
    color: var(--subtitle-color);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

/* Subtitle text (e.g. lookup-screen instructions) — needs a
   background to be readable over a background image */
.subtitle {
    color: var(--subtitle-color);
    background: var(--title-bg);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

/* Loading */
#loading-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

#loading-screen.active {
    display: flex;
}

.loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error */
.error-box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.error-box h2 {
    color: var(--danger);
    border: none;
}

/* Mode selector */
.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

/* Forms */
.form-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

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

.form-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.9375rem;
    color: var(--label-color);
}

input, select, textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

textarea {
    resize: vertical;
}

.hint {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Member display */
.member-display {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.member-name {
    font-weight: 600;
    font-size: 1.0625rem;
}

.member-details {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Player rows */
.player-row {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: grid;
    grid-template-columns: 1fr 140px auto;
    gap: 0.5rem;
    align-items: start;
}

.player-row .player-info {
    grid-column: 1 / -1;
}

.player-row .player-info .member-name {
    font-size: 0.9375rem;
}

.player-row .player-info .member-details {
    font-size: 0.8125rem;
}

.player-row .btn-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0 0.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.625rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s, opacity 0.15s;
    text-decoration: none;
    font-family: inherit;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-large {
    width: 100%;
    padding: 1rem;
    font-size: 1.0625rem;
}

/* Form actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
}

.form-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
    font-size: 0.9375rem;
}

/* Confirmation */
.confirmation-box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.confirmation-box h1 {
    color: #059669;
    margin-bottom: 1rem;
}

.change-code-box {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.change-code {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.25rem;
    color: var(--primary);
    margin: 0.5rem 0;
    font-family: 'Courier New', monospace;
}

.confirmation-details {
    text-align: left;
    margin: 1rem 0;
}

.confirmation-details dl {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 0.5rem;
}

.confirmation-details dt {
    font-weight: 500;
    color: var(--text-muted);
}

.confirmation-details dd {
    color: var(--text);
}

/* Responsive */
@media (max-width: 600px) {
    .player-row {
        grid-template-columns: 1fr;
    }
    
    .player-row .btn-remove {
        justify-self: end;
    }
    
    .form-actions {
        flex-direction: column-reverse;
    }
    
    .btn {
        width: 100%;
    }
}

/* Background overlay (theme-controlled)
   Sits above the body background image but below all content.
   Uses a white overlay: 0% = no white, 100% = fully white. */
#background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0);
    pointer-events: none;
    z-index: 0;
    transition: background 0.3s;
}

/* Ensure all content sits above the overlay */
#app > .screen {
    position: relative;
    z-index: 1;
}

/* Company logo */
.app-logo {
    max-height: 80px;
    max-width: 200px;
    width: auto;
    height: auto;
    margin: 0 auto 1rem;
    display: block;
    object-fit: contain;
}
