/* Local Fonts - Turkish character support */
@font-face {
    font-family: 'Lilita One';
    src: url('../assets/fonts/FeduGamesLilitaOne-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --primary-color: #6c5ce7;
    --secondary-color: #a29bfe;
    --accent-color: #2ed573;
    --text-color: #ffffff;
    --input-bg: rgba(255, 255, 255, 0.1);
    --font-heading: 'Lilita One', cursive, sans-serif;
}

* {
    box-sizing: border-box;
}

body.join-screen {
    margin: 0;
    padding: 0;
    font-family: var(--font-heading);
    color: var(--text-color);
    background-color: #3f00ab;
    height: 100vh;
    height: 100svh;
    width: 100vw;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    overscroll-behavior: none;
}

/* Background Layers */
.bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background-size: cover;
    background-position: center;
}

.bg-main {
    background-image: url('https://cdn.fedu.ai/futureeducation/multiplayerGames/assets/common/assets/background_main.webp');
    opacity: 0.2;
    mix-blend-mode: overlay;
}

.bg-glow {
    position: absolute;
    top: 48%;
    left: 42%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 1000px;
    z-index: -1;
    pointer-events: none;
    opacity: 0.55;
    /* Use game1 asset for now */
    content: url('/common/assets/background_glow.svg');
}

.join-screen .bg-light {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(
        ellipse at 40% 45%,
        rgba(120, 0, 255, 0.7) 0%,
        rgba(120, 0, 255, 0.35) 35%,
        rgba(63, 0, 171, 0) 65%
    );
    opacity: 0.85;
}

/* Top Bar */
.top-bar {
    width: 100%;
    height: calc(55px + env(safe-area-inset-top));
    background-color: #3f00ab;
    box-shadow: 0px 8px 0px 0px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 20;
    padding: 0 max(24px, env(safe-area-inset-right), env(safe-area-inset-left));
    padding-top: env(safe-area-inset-top);
}

.top-bar-logo {
    display: flex;
    align-items: center;
    gap: 3.5px;
    height: 24px;
    height: clamp(18px, 4vw, 24px);
    flex-shrink: 0;
}

.top-bar-logo img {
    height: 100%;
    width: auto !important;
    max-width: none;
    flex-shrink: 0;
    object-fit: contain;
}

.top-bar-title {
    font-family: var(--font-heading);
    font-size: 32px;
    font-size: clamp(14px, 4.5vw, 32px);
    color: white;
    text-shadow: 0px 3px 0px black;
    -webkit-text-stroke: 0.15em black;
    paint-order: stroke fill;
    margin: 0;
    flex-grow: 1;
    text-align: center;
    padding: 0 5px;
    white-space: nowrap;
}

.top-bar::after {
    content: "";
    width: 80px;
    width: clamp(50px, 12vw, 80px);
    flex-shrink: 0;
}

/* Main Content */
.lobby-container {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    width: 100%;
    max-width: 800px;
    padding: 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 0;
    /* Fixed height to prevent layout shift between steps */
    min-height: 280px;
}

.game-title {
    font-family: var(--font-heading);
    font-size: 60px;
    font-size: clamp(30px, 8vw, 60px);
    margin: 0;
    text-align: center;
    line-height: 1.1;
    color: white;
    text-shadow: 0 0.08em 0px black;
    -webkit-text-stroke: 0.08em black;
    paint-order: stroke fill;
}

/* Input Container & Titles */
.input-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 24px;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 48px;
    font-size: clamp(32px, 6vw, 48px);
    color: white;
    margin: 0;
    text-shadow: 0 4px 0 black;
    letter-spacing: 1px;
}

.back-link {
    font-family: var(--font-heading);
    font-size: 24px;
    font-size: clamp(16px, 3vw, 24px);
    color: #e0e0e0;
    text-decoration: underline;
    text-decoration-color: #e0e0e0;
    text-underline-offset: 0.15em;
    cursor: pointer;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
    -webkit-text-stroke: 0.15em black;
    paint-order: stroke fill;
    transition: color 0.2s;
    white-space: nowrap;
    margin-top: 24px;
    /* Reserve space even when hidden to prevent layout shift */
    min-height: 1.5em;
}

.back-link:hover {
    color: white;
}

/* Input Area */
.input-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
    flex-wrap: wrap;
    /* Offset to visually center with title (button takes extra space on right) */
    padding-left: 76px;
}

.input-box {
    flex: 1;
    width: 100%;
    max-width: 500px;
    height: 60px;
    background: white;
    border: 2px solid black;
    border-radius: 6px;
    box-shadow: 0px 6px 0px 0px black;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
}

.game-id-input {
    width: 100%;
    border: none;
    background: transparent;
    font-family: var(--font-heading);
    font-size: 24px;
    font-size: clamp(14px, 5vw, 24px);
    color: #333;
    text-align: center;
    outline: none;
}

/* Room code should always be uppercase */
.room-code-input {
    text-transform: uppercase;
}

.game-id-input::placeholder {
    color: #c3c3c3;
    font-size: 0.9em;
    text-transform: none;
}

.game-submit-btn {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    background: #24db2a;
    border: 2px solid black;
    border-radius: 6px;
    box-shadow: 0px 6px 0px 0px black;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

.game-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0px 8px 0px 0px black;
}

.game-submit-btn:active {
    transform: translateY(4px);
    box-shadow: 0px 2px 0px 0px black;
}

.game-submit-btn img {
    width: 40px;
        height: 40px;
}

/* Avatar Selection Split Layout */
.avatar-step-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 90vw;
    align-items: center;
    flex-grow: 1;
    justify-content: center;
}

.avatar-header {
    width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 5vh;
    padding: 0 60px;
}

.avatar-header .game-title {
    width: 100%;
    max-width: 100%;
    white-space: nowrap;
    line-height: 1.05;
}

.back-icon {
    position: absolute;
    left: 0;
    width: 48px;
    width: clamp(32px, 5vw, 48px);
    height: 48px;
    height: clamp(32px, 5vw, 48px);
    cursor: pointer;
    transform: scaleX(-1);
    transition: transform 0.2s;
}

.back-icon:hover {
    transform: scaleX(-1) scale(1.1);
}

.avatar-content {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 60px;
    gap: clamp(20px, 5vw, 60px);
    width: 100%;
    max-height: 60vh;
}

.avatar-grid-container {
    display: flex;
    justify-content: flex-end;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    justify-items: center;
    width: fit-content;
}

.avatar-option {
    width: 200px;
    height: 200px;
    max-width: 22vw;
    max-height: 22vw;
    position: relative;
    cursor: pointer;
    border-radius: 20px;
    transition: transform 0.2s;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
    border: 3px solid black;
    box-shadow: 0 3px 0 0 black;
    flex-shrink: 0;
}

.avatar-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 14px;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Helper classes for JS to apply if needed, but component likely applies colors inline or via these classes */
.avatar-option img {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
    pointer-events: none;
}

.avatar-option:hover {
    transform: scale(1.02);
}

.avatar-option.selected {
    border-color: #00ff1a;
    box-shadow: none;
    box-shadow: 0 0 0 4px #00ff1a;
    box-shadow: 0 0 0 clamp(2px, 0.45vmin, 4px) #00ff1a;
    transform: scale(1.05);
}

.avatar-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-left: 140px;
}

.avatar-preview-box {
    width: 200px;
    height: 200px;
    max-width: 25vw;
    max-height: 25vw;
    border-radius: 24px;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    margin-bottom: 10px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
    border: 5px solid black;
    box-shadow: 0 6px 0 0 black;
    flex-shrink: 0;
}

.avatar-bg-preview {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0; inset: 0;
    z-index: 1;
}

#preview-img {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
}

#preview-img.hidden {
    display: none;
}

.preview-name {
    font-family: var(--font-heading);
    font-size: 40px;
    font-size: clamp(24px, 4vw, 40px);
    color: white;
    text-shadow: 0 0.1em 0 black;
    -webkit-text-stroke: 0.08em black;
    paint-order: stroke fill;
    margin-bottom: 30px;
    margin-bottom: clamp(15px, 3vh, 30px);
    text-align: center;
    width: 100%;
}

.ready-btn {
    font-family: var(--font-heading);
    font-size: 32px;
    font-size: clamp(20px, 3vw, 32px);
    color: white;
    background: #24db2a;
    border: 3px solid black;
    border: clamp(2px, 0.4vw, 3px) solid black;
    border-radius: 50px;
    padding: 12px 60px;
    padding: clamp(8px, 1.5vh, 12px) clamp(30px, 5vw, 60px);
    cursor: pointer;
    box-shadow: 0px 6px 0px 0px black;
    box-shadow: 0px clamp(4px, 0.8vw, 6px) 0px 0px black;
    text-transform: capitalize;
    transition: all 0.1s;
    text-shadow: 0 2px 0 black;
    white-space: nowrap;
}

.ready-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0px 8px 0px 0px black;
    box-shadow: 0px clamp(6px, 1vw, 8px) 0px 0px black;
}

.ready-btn:active:not(:disabled) {
    transform: translateY(4px);
    box-shadow: 0px 2px 0px 0px black;
}

.ready-btn.disabled {
    background: #555;
    color: #ccc;
    cursor: not-allowed;
    box-shadow: 0px 6px 0px 0px black;
    box-shadow: 0px clamp(4px, 0.8vw, 6px) 0px 0px black;
    opacity: 0.7;
}

/* Waiting Text */
.waiting-text {
    font-family: var(--font-heading);
    font-size: 24px;
    font-size: clamp(14px, 2.5vmin, 24px);
    color: #e0e0e0;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
        -webkit-text-stroke: 0.1em black;
        paint-order: stroke fill;
    margin-top: 10px;
    animation: pulse 2s infinite;
    white-space: nowrap;
    text-align: center;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Countdown Overlay */
#countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, #4f00d6 0%, #2a0072 100%);
    z-index: 3000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#countdown-overlay::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://cdn.fedu.ai/futureeducation/multiplayerGames/assets/common/assets/background_main.webp');
    background-size: cover;
    background-position: center;
    opacity: 0.1;
    mix-blend-mode: screen;
    pointer-events: none;
    z-index: 1;
}

.countdown-label {
    font-family: var(--font-heading);
    font-size: 48px;
    font-size: clamp(32px, 6vh, 48px);
    color: white;
    margin-bottom: 2vh;
    text-shadow: 0 4px 0 black;
    z-index: 10;
}

.countdown-wheel-container {
    height: 54vh;
    width: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 5;
    mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
}

.countdown-wheel {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.15);
    will-change: transform;
    margin-top: 18vh;
}

.countdown-num {
    height: 18vh;
    font-family: var(--font-heading);
    font-size: 180px;
    font-size: clamp(80px, 18vh, 180px);
    line-height: 18vh;
    color: white;
    text-shadow: 0 0.05em 0 black;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0.3;
    transform: scale(0.6);
}

.countdown-num.go-text {
    letter-spacing: 0.06em;
}

.countdown-num.active {
    opacity: 1 !important;
    transform: scale(1.1);
    text-shadow: 0 0.08em 0 black, 0 0 20px rgba(0, 0, 0, 0.5);
    filter: brightness(1.2);
}

/* Error Modal Overlay */
.error-modal-overlay {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0; inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    /* Above top-bar (z-index: 20) */
    padding: 20px;
}

.error-modal-overlay.visible {
    display: flex;
}

.error-modal {
    background: white;
    border: 2px solid black;
    border-radius: 24px;
    box-shadow: 0px 6px 0px 0px black;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 48px;
    gap: clamp(24px, 4vw, 48px);
    padding: 48px 24px;
    padding: clamp(24px, 5vh, 48px) clamp(16px, 3vw, 24px);
    max-width: 820px;
    max-height: 90vh;
    max-height: 90svh;
    width: 100%;
    overflow: hidden;
    animation: errorModalIn 0.3s ease-out;
    /* Scale down for small landscape screens */
    transform-origin: center center;
}

@keyframes errorModalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.error-modal-character {
    width: 189px;
    width: clamp(100px, 20vw, 189px);
    height: 300px;
    height: clamp(160px, 40vh, 300px);
    flex-shrink: 0;
    object-fit: contain;
}

.error-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    gap: clamp(12px, 3vh, 24px);
    flex: 1;
}

.error-modal-title {
    font-family: var(--font-heading);
    font-size: 48px;
    font-size: clamp(24px, min(6vw, 6vh), 48px);
    color: black;
    text-align: center;
    margin: 0;
    line-height: 1.15;
}

.error-modal-message {
    font-family: 'Playpen Sans', sans-serif;
    font-weight: 500;
    font-size: 24px;
    font-size: clamp(14px, min(3vw, 3vh), 24px);
    color: black;
    text-align: center;
    line-height: 1.4;
    max-width: 535px;
    margin: 0;
}

.error-modal-btn {
    font-family: var(--font-heading);
    font-size: 32px;
    font-size: clamp(20px, min(4vw, 5vh), 32px);
    color: white;
    background: #24db2a;
    border: 2px solid black;
    border-radius: 52px;
    padding: 16px 64px;
    padding: clamp(10px, 2vh, 16px) clamp(40px, 8vw, 64px);
    cursor: pointer;
    box-shadow: 0px 6px 0px 0px black;
    -webkit-text-stroke: 0.18em black;
        paint-order: stroke fill;
        text-shadow: 0 0.06em 0 black;
    transition: all 0.1s;
    white-space: nowrap;
}

.error-modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0px 8px 0px 0px black;
}

.error-modal-btn:active {
    transform: translateY(4px);
    box-shadow: 0px 2px 0px 0px black;
}
/* Media Queries */
@media (max-width: 1024px) {
    .lobby-container {
        justify-content: center;
        min-height: 0;
    }

    .input-row {
        padding-left: 0;
    }

    .game-title {
        font-size: 36px;
        font-size: clamp(24px, 5vw, 36px);
    }

    .avatar-step-container {
        justify-content: flex-start;
        width: 100%;
        max-width: 100%;
        height: 100%;
        min-height: 0;
        padding-top: 16px;
        padding-top: clamp(6px, 1.5vh, 16px);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-y;
    }

    .avatar-header {
        padding: 0 56px;
        padding: 0 clamp(44px, 12vw, 56px);
        margin-bottom: 20px;
        margin-bottom: clamp(10px, 2.4vh, 20px);
        flex-shrink: 0;
    }

    .avatar-header .game-title {
        font-size: 26px;
        font-size: clamp(20px, 5vw, 26px);
        -webkit-text-stroke: 0.06em black;
        text-shadow: 0 0.06em 0 black;
    }

    .avatar-content {
        flex-direction: column;
        gap: 16px;
        gap: clamp(8px, 1.5vh, 16px);
        max-height: none;
        align-items: center;
        width: 100%;
        flex: 0 0 auto;
    }

    .avatar-preview-container {
        order: -1;
        padding-left: 0;
        flex-shrink: 0;
    }

    .avatar-preview-box {
        width: 110px;
        width: clamp(90px, 14vh, 110px);
        height: 110px;
        height: clamp(90px, 14vh, 110px);
        max-width: none;
        max-height: none;
        margin-bottom: 0;
        border-width: 3px;
        border-radius: 10px;
    }

    .preview-name {
        margin-bottom: 0;
        font-size: 28px;
        font-size: clamp(20px, 4vw, 28px);
    }

    .waiting-text {
        margin-top: 2px;
        font-size: 16px;
        font-size: clamp(12px, 3vw, 16px);
        white-space: normal;
        line-height: 1.2;
    }

    .avatar-grid-container {
        background: rgba(0, 0, 0, 0.4);
        border-radius: 24px;
        padding: 12px 16px;
        padding: clamp(8px, 1.8vh, 12px) clamp(10px, 2.6vw, 16px);
        width: fit-content;
        max-width: 100%;
        justify-content: center;
        box-sizing: border-box;
        order: 1;
        flex-shrink: 0;
    }

    .avatar-grid {
        --avatar-cell-size: 24vh;
        gap: 26px;
        gap: clamp(14px, 2.3vw, 26px);
        width: 100%;
        justify-content: center;
        grid-template-columns: repeat(2, var(--avatar-cell-size));
    }

    .avatar-option {
        width: var(--avatar-cell-size);
        height: var(--avatar-cell-size);
        aspect-ratio: auto;
        max-width: 100%;
        max-height: none;
        align-self: center;
        justify-self: center;
    }

    .avatar-option.selected {
        transform: scale(1.03);
    }
}

@media (max-width: 1024px) and (pointer: coarse) {
    .top-bar {
        display: none;
    }

    .error-modal {
        flex-direction: column;
        gap: 16px;
        padding: 24px 16px;
    }

    .error-modal-character {
        width: 100px;
        height: 160px;
    }

    .error-modal-content {
        gap: 12px;
    }

    .error-modal-btn {
        padding: 10px 40px;
    }
}

@media (max-width: 1024px) and (max-height: 700px) {
    .avatar-header {
        margin-bottom: 14px;
        margin-bottom: clamp(8px, 1.8vh, 14px);
    }

    .avatar-header .game-title {
        font-size: 22px;
        font-size: clamp(18px, 4.8vw, 22px);
        -webkit-text-stroke: 0.05em black;
        text-shadow: 0 0.05em 0 black;
    }

    .avatar-content {
        gap: 10px;
        gap: clamp(6px, 1.2vh, 10px);
    }

    .avatar-preview-box {
        width: 92px;
        width: clamp(76px, 12vh, 92px);
        height: 92px;
        height: clamp(76px, 12vh, 92px);
    }

    .preview-name {
        font-size: 24px;
        font-size: clamp(18px, 3.8vw, 24px);
    }

    .waiting-text {
        font-size: 14px;
        font-size: clamp(11px, 2.7vw, 14px);
    }

    .avatar-grid-container {
        padding: 10px 12px;
        padding: clamp(6px, 1.4vh, 10px) clamp(8px, 2.2vw, 12px);
    }

    .avatar-grid {
        --avatar-cell-size: 21vh;
        gap: 14px;
        gap: clamp(10px, 2vw, 14px);
    }

    .avatar-option {
        width: var(--avatar-cell-size);
        height: var(--avatar-cell-size);
        max-width: 100%;
        max-height: none;
    }
}

@media (max-width: 1024px) and (max-height: 500px) and (orientation: landscape) {
    .avatar-step-container {
        padding-top: 4px;
    }

    .avatar-header {
        padding: 0 40px;
        margin-bottom: 8px;
    }

    .avatar-preview-box {
        width: 64px;
        height: 64px;
        border-width: 2px;
    }

    .preview-name {
        font-size: 22px;
        font-size: clamp(16px, 3.8vh, 22px);
    }

    .waiting-text {
        font-size: 12px;
        font-size: clamp(10px, 2.5vh, 12px);
    }

    .avatar-grid-container {
        max-width: 100%;
        padding: 6px 8px;
    }

    .avatar-grid {
        --avatar-cell-size: 18vh;
        gap: 10px;
    }

    .avatar-option {
        width: var(--avatar-cell-size);
        height: var(--avatar-cell-size);
        max-width: 100%;
        max-height: none;
        border-radius: 12px;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .error-modal {
        flex-direction: row;
        gap: 20px;
        padding: 16px 20px;
        max-height: 85vh;
        max-height: 85svh;
    }

    .error-modal-character {
        width: 120px;
        width: clamp(80px, 15vw, 120px);
        height: 180px;
        height: clamp(100px, 30vh, 180px);
    }

    .error-modal-title {
        font-size: 32px;
        font-size: clamp(18px, 4vh, 32px);
    }

    .error-modal-message {
        font-size: 18px;
        font-size: clamp(12px, 2.5vh, 18px);
        line-height: 1.3;
    }

    .error-modal-content {
        gap: 8px;
    }

    .error-modal-btn {
        font-size: 24px;
        font-size: clamp(16px, 4vh, 24px);
        padding: 8px 32px;
        box-shadow: 0px 4px 0px 0px black;
    }
}

/* ─── clamp() progressive enhancement for custom properties ─── */
@media (max-width: 1024px) {
    @supports (width: clamp(1px, 2px, 3px)) {
        .avatar-grid {
            --avatar-cell-size: clamp(92px, 24vh, 150px);
        }
    }
}

@media (max-width: 1024px) and (max-height: 700px) {
    @supports (width: clamp(1px, 2px, 3px)) {
        .avatar-grid {
            --avatar-cell-size: clamp(82px, 21vh, 128px);
        }
    }
}

@media (max-width: 1024px) and (max-height: 500px) and (orientation: landscape) {
    @supports (width: clamp(1px, 2px, 3px)) {
        .avatar-grid {
            --avatar-cell-size: clamp(64px, 18vh, 95px);
        }
    }
}

/* ─── PNG fallback for browsers without WebP support ─── */
.no-webp .bg-main { background-image: url('https://cdn.fedu.ai/futureeducation/multiplayerGames/assets/common/assets/background_main.png'); }
.no-webp #countdown-overlay::before { background-image: url('https://cdn.fedu.ai/futureeducation/multiplayerGames/assets/common/assets/background_main.png'); }
