@import url('https://fonts.googleapis.com/css2?family=Lilita+One&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: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 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('/common/assets/background_main.png');
    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: 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: clamp(14px, 4.5vw, 32px);
    color: white;
    text-shadow: 0px 2px 0px black;
    margin: 0;
    flex-grow: 1;
    text-align: center;
    padding: 0 5px;
    white-space: nowrap;
}

.top-bar::after {
    content: "";
    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;
    width: 100%;
    gap: 5vh;
}

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

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

.section-title {
    font-family: var(--font-heading);
    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: clamp(16px, 3vw, 24px);
    color: #e0e0e0;
    text-decoration: underline;
    cursor: pointer;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
    transition: color 0.2s;
    white-space: nowrap;
    margin-top: 40px;
}

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

/* Input Area */
.input-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    width: 100%;
    flex-wrap: wrap;
}

.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: clamp(14px, 5vw, 24px);
    color: #333;
    text-align: center;
    outline: none;
    text-transform: uppercase;
}

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

.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: 30px;
    height: 30px;
}

/* 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;
}

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

.back-icon:hover {
    transform: rotate(180deg) scale(1.1);
}

.avatar-content {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    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: 90%;
    height: auto;
    margin-bottom: -5px;
    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;
    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;
    inset: 0;
    z-index: 1;
}

#preview-img {
    position: relative;
    z-index: 2;
    width: 90%;
    margin-bottom: -5px;
}

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

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

.ready-btn {
    font-family: var(--font-heading);
    font-size: clamp(20px, 3vw, 32px);
    color: white;
    background: #24db2a;
    border: clamp(2px, 0.4vw, 3px) solid black;
    border-radius: 50px;
    padding: clamp(8px, 1.5vh, 12px) clamp(30px, 5vw, 60px);
    cursor: pointer;
    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 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 clamp(4px, 0.8vw, 6px) 0px 0px black;
    opacity: 0.7;
}

/* Waiting Text */
.waiting-text {
    font-family: var(--font-heading);
    font-size: 24px;
    color: #e0e0e0;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
    margin-top: 10px;
    animation: pulse 2s infinite;
}

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

/* Countdown Overlay */
#countdown-overlay {
    position: fixed;
    top: 0;
    left: 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('/common/assets/background_main.png');
    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: 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: 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);
}

/* Media Queries (Simplified for brevity but maintaining structure) */
@media (max-width: 800px) {
    .lobby-container {
        justify-content: flex-start;
        padding-top: 8vh;
    }
    .avatar-content {
        flex-direction: column;
    }
    .avatar-preview-container {
        padding-left: 0;
    }
    .avatar-step-container {
        justify-content: flex-start;
    }
    .avatar-grid {
        gap: 12px;
    }
    .avatar-option {
         width: clamp(80px, 20vh, 140px);
         height: clamp(80px, 20vh, 140px);
    }
}
