/* ===========================
   GENERAL BODY
=========================== */
html, body {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    color: #333;
    height: 100%;
    width: 100%;
    background: #f4f4f7;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* default: top-aligned for portrait/mobile */
    box-sizing: border-box;
    overflow-y: auto;
}

/* ===========================
   LOGIN (DEFAULT PORTRAIT/MOBILE)
=========================== */
.login-box {
    background: #ffffff;
    width: 95vw;           /* keep original width scaling */
    max-width: 850px;      /* keep original max width */
    min-height: 45vh;      /* reasonable minimum height */
    max-height: 60vh;      /* cap height */
    border-radius: 12px;
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 2rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
    margin-top: 1rem;
    overflow-y: auto;      /* scroll if content exceeds max-height */
}

/* login logo */
.login-box img.logo {
    width: 60%;
    max-height: 35%;
    margin-bottom: 2rem;
    object-fit: contain;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

/* login form */
.login-box form {
    width: 90%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    flex: 1;
    box-sizing: border-box;
    position: relative;
}

/* input container */
.input-container {
    width: 100%;
    max-width: 450px;
    margin-bottom: 1.5rem;
    position: relative;
}

.input-container i {
    position: absolute;
    top: 50%;
    left: 1rem;
    transform: translateY(-50%);
    color: #888;
    font-size: 1.2rem;
    pointer-events: none;
}

.input-container input {
    width: 100%;
    padding: 1.25rem 1rem 1.25rem 3rem;
    font-size: 1.25rem;
    border-radius: 12px;
    box-sizing: border-box;
}

/* login button */
.login-box button {
    width: 100%;
    max-width: 350px;
    padding: 0.8rem 1.2rem;
    border-radius: 6px;
    margin-top: 1rem;
    border: none;
    background: #007bff;
    color: #fff;
    font-weight: 500;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.login-box button:hover {
    background: #0056b3;
}

/* ===========================
   LOGIN LAYOUT ADJUSTMENTS
=========================== */

/* LANDSCAPE SMALL DEVICES (tablet/phones) */
@media (orientation: landscape) and (max-width: 1023px) {
    html, body {
        align-items: flex-start;
    }

    .login-box {
        flex-direction: row;
        width: 60vw;
        max-width: 600px;
        min-height: 20vh;
        max-height: 60vh;
        height: auto;
        padding: 0.5rem 1rem;
        border-radius: 12px;
        overflow: hidden;
        align-items: flex-start;
    }

    .login-box img.logo {
        width: 30%;
        max-height: 100%;
        margin-right: 1rem;
        margin-top: 0;
        object-fit: contain;
    }

    .login-box form {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        gap: 0.15rem;
        height: auto;
        padding-left: 0.5rem;
        padding-top: 0.3rem;
    }

    .input-container input {
        padding: 0.65rem 0.8rem 0.65rem 2.5rem;
        font-size: 1rem;
        margin-top: 0.1rem;
    }

    .login-box button {
        max-width: 140px;
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
        align-self: flex-start;
        margin-top: 0.1rem;
    }
}

/* DESKTOP */
@media (min-width: 1024px) {
    html, body {
        align-items: center;
    }

    .login-box {
        flex-direction: row;
        width: 70vw;
        max-width: 1000px;
        min-height: 60vh;
        padding: 3rem 4rem;
        margin-top: 0;
        overflow: visible; /* no scroll for desktop */
    }

    .login-box img.logo {
        width: 40%;
        max-height: 80%;
        margin-right: 3rem;
        margin-bottom: 0;
    }

    .login-box form {
        flex: 1;
        width: 100%;
        justify-content: center;
        align-items: flex-start;
    }

    .input-container {
        margin-bottom: 1.5rem;
    }

    .login-box button {
        max-width: 300px;
        padding: 0.8rem 1.2rem;
        font-size: 1.1rem;
    }
}





/* ===========================
   LOBBY
=========================== */
.lobby {
    width: 100%;
    max-width: 1200px;
    height: 100vh;
    margin: 1rem auto 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

/* header / top bar */
.lobby-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    margin-top: 0.5rem;
}

.lobby-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.lobby-top img.logo {
    max-width: 140px;
    height: auto;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 15px;
}

.welcome-text {
    font-size: clamp(14px, 1.2vw, 18px);
    font-weight: 500;
    color: #222;
}

.logout-btn {
    padding: 0.6rem 1.2rem;
    background: #ff4d4f;
    color: #fff;
    font-weight: 600;
    border-radius: 10px;
    text-decoration: none;
    transition: 0.3s ease;
}

.logout-btn:hover {
    background: #d9363e;
}


/* category bar */
.category-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.cat-btn {
    flex: 1 1 auto;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid #007bff;
    background: #fff;
    color: #007bff;
    cursor: pointer;
    transition: 0.3s ease;
    text-align: center;
}

.cat-btn.active {
    background: #007bff;
    color: #fff;
}


/* search bar */
.search-bar input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    margin-bottom: 15px;
    border-radius: 10px;
    border: 1px solid #ccc;
    font-size: 1rem;
    outline: none;
    box-sizing: border-box;
}


/* ===========================
   GAME LIST
=========================== */
.game-list-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 25px 0 20px;
    min-height: 0;
}

.game-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    justify-items: center;
}

/* game cards */
.game {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    padding: 20px;
    background: #fff;
    border-radius: 16px;
    text-align: center;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.game:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 12px 25px rgba(0,0,0,0.15);
}

/* game icon */
.game-icon {
    width: 100%;
    height: 200px;
    object-fit: contain;
    background: #fff;
    border-radius: 12px;
    margin-bottom: 16px;
    padding: 12px;
    box-sizing: border-box;
}

/* game info */
.game-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* game title */
.game-title {
    font-size: clamp(22px, 3vw, 28px);
    font-weight: 800;
    line-height: 1.2;
    padding: 8px 16px;
    border-radius: 10px;
    background: linear-gradient(135deg, #1E90FF 0%, #DAA520 50%, #1E90FF 100%);
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.6);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: 0.3s ease;
    user-select: none;
}

.game-title:hover {
    background: linear-gradient(135deg, #1E90FF 0%, #DAA520 50%, #1E90FF 100%);
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}


/* ===========================
   DESKTOP MODE
=========================== */
@media (min-width: 1024px) {
     .game-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 25px;
        justify-items: center;
        width: 100%;
    }

    .game {
        width: 100%;
        max-width: 350px; /* safe max-width to prevent overlap */
    }
}


/* ===========================
   PORTRAIT MODE
=========================== */
@media (orientation: portrait) {
    .game-list {
        grid-template-columns: 1fr !important;
    }

    .game {
        max-width: 500px;
    }

    .play-btn {
        display: none;
    }
}


/* ===========================
   RESPONSIVE BREAKPOINTS
=========================== */
@media (max-width: 900px) {
    .game-list {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }

    .game {
        max-width: 320px;
    }
}

@media (max-width: 600px) {
    .lobby-top {
        flex-direction: column;
        align-items: center;
    }

    .game-list {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .game-icon {
        height: 140px;
    }

    .game-title {
        font-size: 1.2rem;
    }

    .logout-btn,
    .cat-btn {
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }
}


/* ===========================
   LANDSCAPE LOW HEIGHT OPTIMIZATIONS
=========================== */
@media (orientation: landscape) and (max-height: 600px) {
    .lobby-header {
        padding: 5px 10px;
        margin-top: 0;
    }

    .lobby-top img.logo {
        max-width: 60px;
        height: auto;
    }

    .user-box {
        gap: 8px;
    }

    .logout-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    .search-bar input {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
        margin-bottom: 8px;
    }

    .game-list-wrapper {
        padding-top: 50px;
    }

    .game {
        padding: 10px;
        max-width: 300px;
    }

    .game-icon {
        height: 100px;
        padding: 6px;
        margin-bottom: 10px;
    }

    .game-title {
        font-size: clamp(16px, 2.2vw, 20px);
        padding: 4px 8px;
    }
}
