* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Version badge (bottom-left) */
#version-badge {
    position: fixed;
    left: 10px;
    bottom: 10px;
    padding: 6px 10px;
    background: rgba(32,33,36,0.7);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    border-radius: 6px;
    z-index: 1000;
    pointer-events: none;
}

body {
    background-color: #f0f2f5;
    height: 100vh;
    overflow: hidden;
    touch-action: manipulation;
}

/* Invert filter applied to the whole game screen during waiting state */
.invert-colors {
    filter: invert(1) hue-rotate(180deg);
}

.container {
    max-width: 100%;
    height: 100vh;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.screen {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    text-align: center;
}

/* Decorative collage background for the configuration screen */
#config-screen {
    overflow: hidden;
}

#config-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image: url('collage-time.svg');
    background-size: cover;
    background-position: center;
    opacity: 0.25;
}

/* Ensure foreground content sits above the decorative background */
#config-screen > * {
    position: relative;
    z-index: 1;
}

.hidden {
    display: none !important;
}

/* Treat \n characters in textContent as line breaks */
.nl-preline {
    white-space: pre-line;
}

h1 {
    color: #1a73e8;
    margin-bottom: 20px;
    font-size: 2.5rem;
}

h2 {
    color: #202124;
    margin-bottom: 30px;
    font-size: 1.8rem;
    line-height: 1.4;
}

button {
    background-color: #1a73e8;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    margin: 10px;
    transition: background-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

button:active {
    background-color: #1557b0;
}

#players-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* children will enable */
}

#waiting-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: #202124;
    background: rgba(255,255,255,0.85);
    padding: 20px 32px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    pointer-events: none;
    z-index: 5;
}

.player {
    position: absolute;
    transform: translate(-50%, -50%);
    min-width: 0;
    margin: 0;
    padding: 8px;
    border-radius: 12px;
    background: transparent;
    box-shadow: none;
    text-align: center;
}

.player-button {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background-color: #e8f0fe;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #1a73e8;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s, background-color 0.2s;
}

.player-button:active {
    transform: scale(0.95);
    filter: brightness(0.9);
}

.player-button.active {
    transform: scale(0.95);
    filter: brightness(0.9);
    outline: 6px solid #ff9800;
    outline-offset: 4px;
}

.hold-feedback {
    font-size: 0.9rem;
    margin-top: 10px;
    color: #5f6368;
}

.score {
    font-size: 1.2rem;
    color: #5f6368;
    margin-top: 15px;
}

/* Center container */
#center-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    max-width: 720px;
}

#timer {
    font-size: 3rem;
    font-weight: bold;
    color: #1a73e8;
    margin: 20px 0;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#result {
    margin-top: 30px;
    padding: 20px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#result-text {
    margin-bottom: 20px;
    color: #202124;
    font-size: 1.3rem;
}

#result-table-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px 0 16px;
}

#result-table {
    border-collapse: collapse;
    font-size: 0.95rem;
    color: #202124;
    min-width: 320px;
}

#result-table th,
#result-table td {
    border-bottom: 1px solid #e0e0e0;
    padding: 6px 10px;
    text-align: left;
}

#result-table th {
    font-weight: 700;
    color: #5f6368;
}

#result-table tr:last-child td {
    border-bottom: none;
}

.instructions {
    margin-top: 30px;
    text-align: left;
    background-color: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.instructions h3 {
    color: #1a73e8;
    margin-bottom: 10px;
}

.instructions p {
    margin: 8px 0;
    color: #5f6368;
}

/* Config screen */
.config {
    margin: 20px auto 0;
    padding: 16px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-width: 520px;
}

.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.config-row label {
    font-weight: 600;
    color: #202124;
}

.config-row select {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #dadce0;
    border-radius: 8px;
    font-size: 1rem;
    background: #fff;
}

.names-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    flex: 1;
}

.player-name-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-color-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    flex-shrink: 0;
    outline: 3px solid;
    outline-offset: 2px;
}

.names-grid input[type="text"] {
    padding: 10px 12px;
    border: 2px solid #dadce0;
    border-radius: 8px;
    font-size: 1rem;
    flex: 1;
    min-width: 0;
}

/* ── Auth Screen ─────────────────────────────────────── */

#auth-screen,
#unlock-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    margin: 20px auto 0;
    padding: 24px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-width: 400px;
    width: 100%;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.auth-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 10px 16px;
    font-size: 1rem;
    font-weight: 600;
    color: #5f6368;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin: 0;
    border-radius: 0;
    transition: color 0.2s, border-color 0.2s;
}

.auth-tab.active {
    color: #1a73e8;
    border-bottom-color: #1a73e8;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
    padding: 12px 14px;
    border: 2px solid #dadce0;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    border-color: #1a73e8;
}

.auth-form button {
    margin: 4px 0 0;
}

.auth-error {
    background: #fce8e6;
    color: #c5221f;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 12px;
}

/* ── User Badge (top-right) ──────────────────────────── */

#user-badge {
    position: fixed;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    background: rgba(32,33,36,0.85);
    color: #fff;
    font-size: 13px;
    line-height: 1;
    border-radius: 6px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
}

#user-badge.hidden {
    display: none !important;
}

#logout-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
    margin: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
    line-height: 1;
    border-radius: 4px;
}

#logout-btn:hover,
#logout-btn:active {
    opacity: 1;
    background: rgba(255,255,255,0.15);
}

/* iPad specific optimizations */
@media (max-width: 1024px) {
    h1 {
        font-size: 2.2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .player {
        padding: 8px;
    }
    
    .player-button {
        width: 110px;
        height: 110px;
        font-size: 1rem;
    }
}
