/*
 * Title screen and game-mode menus.
 *
 * The background is a separate layer so it can be blurred and darkened
 * without affecting the menu readability or the original image file.
 */

.title-screen {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #080706;
    font-family: Georgia, 'Times New Roman', serif;
    color: #f0e6d2;
    opacity: 1;
    transition: opacity 420ms ease;
}

.title-screen--leaving {
    opacity: 0;
    pointer-events: none;
}

.title-background {
    position: absolute;
    inset: -28px;
    background-image: url('../assets/title-screen.png');
    background-size: cover;
    background-position: center;
    filter: blur(4px) brightness(0.78) saturate(0.95);
    transform: scale(1.04);
}

.title-vignette {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at center, rgba(8, 7, 6, 0.04) 0%, rgba(8, 7, 6, 0.4) 70%, rgba(4, 3, 2, 0.82) 100%),
        linear-gradient(180deg, rgba(8, 7, 6, 0.16) 0%, rgba(8, 7, 6, 0.04) 45%, rgba(8, 7, 6, 0.62) 100%);
}

.title-content {
    position: relative;
    z-index: 1;
    width: min(94vw, 1120px);
    max-height: 100dvh;
    padding: 32px;
    overflow-y: auto;
    scrollbar-width: thin;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 26px;
    box-sizing: border-box;
}

.title-header {
    text-align: center;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.85);
}

.title-kicker {
    margin: 0 0 8px;
    color: #b98a5a;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.34em;
    text-transform: uppercase;
}

.title-header h1 {
    margin: 0;
    color: #f0d3a3;
    font-size: clamp(48px, 7vw, 86px);
    font-weight: 600;
    letter-spacing: 0.16em;
    line-height: 1;
}

.title-tagline {
    margin: 14px 0 0;
    color: #d8c7a8;
    font-size: clamp(14px, 1.5vw, 19px);
    font-style: italic;
    letter-spacing: 0.03em;
}

.title-menu {
    width: min(560px, 94vw);
    max-height: min(58dvh, 520px);
    overflow-y: auto;
    scrollbar-width: thin;
    padding: 26px 30px 24px;
    box-sizing: border-box;
    background: rgba(14, 12, 10, 0.82);
    border: 1px solid rgba(185, 138, 90, 0.55);
    border-radius: 14px;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.7),
        inset 0 0 0 1px rgba(255, 240, 210, 0.04);
}

.title-screen-page {
    display: none;
}

.title-screen-page--active {
    display: block;
    animation: title-page-in 220ms ease both;
}

@keyframes title-page-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.title-menu h2 {
    margin: 0 0 6px;
    color: #f0d3a3;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.title-menu-copy {
    margin: 0 0 18px;
    color: #b8aa96;
    font-size: 13px;
    line-height: 1.55;
}

.title-menu-button {
    display: block;
    width: 100%;
    margin: 9px 0;
    padding: 13px 16px;
    box-sizing: border-box;
    background: linear-gradient(180deg, rgba(58, 43, 29, 0.7), rgba(30, 23, 17, 0.85));
    border: 1px solid #6b5638;
    border-radius: 7px;
    color: #f0e6d2;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 17px;
    text-align: left;
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease, color 160ms ease;
}

.title-menu-button:hover,
.title-menu-button:focus-visible {
    background: linear-gradient(180deg, rgba(78, 57, 36, 0.9), rgba(44, 33, 23, 0.95));
    border-color: #d4a574;
    color: #ffe9c4;
    transform: translateX(2px);
    outline: none;
}

.title-menu-button--primary {
    border-color: #b98a5a;
    background: linear-gradient(180deg, rgba(92, 66, 40, 0.95), rgba(49, 35, 23, 0.98));
    font-weight: bold;
    letter-spacing: 0.03em;
}

.title-menu-button:disabled,
.title-menu-button[aria-disabled='true'] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    border-color: #4a3b2a;
    color: #8f8170;
}

.title-menu-back {
    display: inline-block;
    margin-top: 10px;
    padding: 4px 0;
    background: transparent;
    border: 0;
    color: #b8aa96;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 13px;
    cursor: pointer;
}

.title-menu-back:hover,
.title-menu-back:focus-visible {
    color: #f0d3a3;
    outline: none;
}

.title-notice {
    margin: 14px 0 0;
    padding: 10px 12px;
    border: 1px solid rgba(139, 107, 67, 0.55);
    border-radius: 6px;
    background: rgba(30, 24, 18, 0.7);
    color: #bfae94;
    font-size: 12px;
    line-height: 1.5;
}

.title-status {
    min-height: 18px;
    margin: 12px 0 0;
    color: #d4a574;
    font-size: 12px;
    letter-spacing: 0.05em;
    text-align: center;
}

.title-footer {
    position: absolute;
    right: 24px;
    bottom: 16px;
    left: 24px;
    color: rgba(216, 199, 168, 0.55);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-align: center;
    text-transform: uppercase;
}

/* Historical curriculum picker */
.title-topic-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 8px;
    max-height: min(48dvh, 430px);
    margin: 16px 0 12px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.title-topic-button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-height: 52px;
    padding: 9px 12px;
    border: 1px solid rgba(185, 138, 90, 0.45);
    border-radius: 8px;
    background: rgba(40, 31, 23, 0.86);
    color: #f0e6d2;
    font-family: Georgia, serif;
    text-align: left;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.title-topic-button:hover,
.title-topic-button:focus-visible {
    border-color: #d9a65a;
    background: rgba(66, 49, 33, 0.95);
}

.title-topic-button:active {
    transform: translateY(1px);
}

.title-topic-label {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
}

.title-topic-meta {
    color: #b6a68c;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

@media (max-width: 640px) {
    .title-content {
        padding: 20px 16px;
        gap: 18px;
        justify-content: flex-start;
    }

    .title-menu {
        padding: 22px 20px 18px;
        max-height: none;
        overflow-y: visible;
    }

    .title-header h1 {
        letter-spacing: 0.1em;
    }

    .title-topic-list {
        grid-template-columns: 1fr;
        max-height: none;
    }
}

@media (max-height: 680px) and (min-width: 641px) {
    .title-content {
        padding: 18px 24px;
        gap: 16px;
    }

    .title-header h1 {
        font-size: clamp(38px, 6vw, 58px);
    }

    .title-tagline {
        margin-top: 8px;
    }

    .title-menu {
        max-height: calc(100dvh - 190px);
        padding: 20px 26px 18px;
    }
}

/* Lobby setup and local lobby shell */
.title-screen [hidden] {
    display: none !important;
}

.title-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 12px 0;
    color: #cbb894;
    font-size: 12px;
    letter-spacing: 0.04em;
}

.title-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #6b5638;
    border-radius: 6px;
    background: rgba(9, 8, 7, 0.8);
    color: #f0e6d2;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 15px;
}

.title-input:focus {
    outline: none;
    border-color: #d4a574;
    box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.25);
}

.title-code-input {
    font-family: 'Courier New', monospace;
    font-size: 20px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}

.lobby-code-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0;
    padding: 10px 12px;
    border: 1px solid rgba(185, 138, 90, 0.55);
    border-radius: 7px;
    background: rgba(9, 8, 7, 0.7);
}

.lobby-code-label {
    color: #b8aa96;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.lobby-code-value {
    color: #f0d3a3;
    font-family: 'Courier New', monospace;
    font-size: 22px;
    letter-spacing: 0.22em;
}

.lobby-copy {
    margin-left: auto;
    padding: 5px 9px;
    border: 1px solid #6b5638;
    border-radius: 5px;
    background: transparent;
    color: #d8c7a8;
    font-family: Georgia, serif;
    font-size: 12px;
    cursor: pointer;
}

.lobby-copy:hover,
.lobby-copy:focus-visible {
    border-color: #d4a574;
    color: #ffe9c4;
    outline: none;
}

.lobby-participants {
    margin: 12px 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lobby-participant {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(107, 86, 56, 0.55);
    border-radius: 6px;
    background: rgba(9, 8, 7, 0.45);
}

.lobby-participant-name {
    color: #f0e6d2;
    font-size: 14px;
}

.lobby-pill {
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(185, 138, 90, 0.22);
    color: #e8c89a;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.lobby-pill--late {
    background: rgba(122, 154, 122, 0.25);
    color: #b8d4b8;
}

.lobby-pill--reconnecting {
    background: rgba(196, 151, 77, 0.22);
    color: #e8c89a;
}

.title-menu-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.title-menu-row .title-menu-button {
    margin: 0;
}
