/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-card: rgba(22, 33, 62, 0.85);
    --bg-card-hover: rgba(30, 45, 80, 0.95);
    --accent-primary: #00d2ff;
    --accent-secondary: #7b2ff7;
    --accent-gradient: linear-gradient(135deg, #00d2ff 0%, #7b2ff7 100%);
    --accent-gradient-hover: linear-gradient(135deg, #00e5ff 0%, #9b4dff 100%);
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b80;
    --border-color: rgba(123, 47, 247, 0.25);
    --border-glow: rgba(0, 210, 255, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(0, 210, 255, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition-fast: 0.2s ease;
    --transition-med: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    min-height: 100vh;
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(123, 47, 247, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 210, 255, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(123, 47, 247, 0.05) 0%, transparent 50%),
        var(--bg-primary);
    padding: 20px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

/* ===== Buttons ===== */
button, .btn {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 12px 28px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-med);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-med);
    z-index: 0;
}

button:hover::before {
    opacity: 1;
}

button {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: var(--shadow-md), 0 0 20px rgba(0, 210, 255, 0.1);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

button:disabled::before {
    display: none;
}

/* ===== Inputs ===== */
input[type="text"],
input[type="number"],
input[type="float"],
select {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    padding: 12px 18px;
    background: rgba(15, 15, 15, 0.8);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition-med);
    width: 100%;
}

input:focus,
select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.15), var(--shadow-sm);
}

input::placeholder {
    color: var(--text-muted);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a0a0b8' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
}

label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: block;
}

/* ===== Links ===== */
a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: #fff;
    text-decoration: underline;
}

/* ===== Footer ===== */
footer {
    width: 100%;
    text-align: center;
    padding: 20px;
    margin-top: auto;
}

#AppInfo {
    padding: 16px;
    border-top: 1px solid rgba(123, 47, 247, 0.15);
}

#AppInfo p {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ===================================================
   INDEX PAGE - Home / Create & Join
   =================================================== */
#createRoomButton {
    font-size: 1.1rem;
    padding: 16px 40px;
    margin-bottom: 30px;
}

#joinRoomForm {
    display: flex !important;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-md);
}

#joinRoomForm input[type="text"] {
    width: 240px;
    flex: none;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 600;
    text-align: center;
}

#LogoutBtn {
    background: transparent;
    border: 1px solid rgba(255, 80, 80, 0.4);
    color: #ff6b6b;
    font-size: 0.82rem;
    padding: 10px 20px;
}

#LogoutBtn::before {
    background: linear-gradient(135deg, #ff4757, #c0392b);
}

#LogoutBtn:hover {
    color: #fff;
    border-color: transparent;
}

/* ===================================================
   LOGIN / REGISTER PAGE
   =================================================== */
#createuser {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    backdrop-filter: blur(16px);
}

#createuser h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 32px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#create-user-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#create-user-form label {
    text-align: left;
}

#registerButton {
    margin-top: 8px;
}

/* ===================================================
   ROOM PAGE - Lobby
   =================================================== */
body > h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 24px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    letter-spacing: -0.5px;
}

#gameContainer {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

/* ===== Room Panel ===== */
#Room {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 36px;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
}

#gameCode {
    text-align: center;
}

#gameCode p {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: 12px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
    padding: 12px 24px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    display: inline-block;
}

#playersList {
    width: 100%;
    text-align: center;
}

#playersList h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#playersUl {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

#playersUl p {
    background: rgba(15, 15, 15, 0.6);
    border: 1px solid var(--border-color);
    padding: 10px 22px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all var(--transition-med);
}

#playersUl p#master {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 0 0 12px rgba(0, 210, 255, 0.2);
}

#playersUl p:hover {
    border-color: var(--accent-secondary);
    transform: translateY(-2px);
}

/* ===== Game Params (Master) ===== */
#GameParam {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 380px;
    padding: 24px;
    background: rgba(15, 15, 15, 0.5);
    border: 1px solid rgba(123, 47, 247, 0.15);
    border-radius: var(--radius-md);
}

#Room > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

#Room > div > button {
    width: 100%;
    max-width: 380px;
}

#SetBTN {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

#SetBTN::before {
    background: var(--accent-gradient);
}

#SetBTN:hover {
    color: #fff;
    border-color: transparent;
}

#StartBTN {
    font-size: 1.1rem;
    padding: 16px 40px;
}

/* ===== Game Params (Player View) ===== */
#GameParamPlayerView {
    padding: 20px 28px;
    background: rgba(15, 15, 15, 0.5);
    border: 1px solid rgba(123, 47, 247, 0.15);
    border-radius: var(--radius-md);
    text-align: center;
}

#GameParamPlayerView p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 2;
}

#leaveRoomBtn {
    background: transparent;
    border: 1px solid rgba(255, 80, 80, 0.3);
    color: #ff6b6b;
    font-size: 0.82rem;
    padding: 10px 20px;
    align-self: center;
}

#leaveRoomBtn::before {
    background: linear-gradient(135deg, #ff4757, #c0392b);
}

#leaveRoomBtn:hover {
    color: #fff;
    border-color: transparent;
}

/* ===================================================
   GAME VIEW - Photosphere + Map Overlay
   =================================================== */
#Game {
    position: fixed;
    inset: 0;
    z-index: 1000;
    width: 100vw !important;
    height: 100vh !important;
    background: #000;
}

/* Photosphere takes full background */
#GameView {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    inset: 0;
    z-index: 1;
}

/* Map panel - small on the right, expands on hover */
#GuessMAP {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 10;
    width: 220px;
    height: 220px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    background: var(--bg-secondary);
    transition:
        width var(--transition-slow),
        height var(--transition-slow),
        border-color var(--transition-med),
        box-shadow var(--transition-med);
    display: flex;
    flex-direction: column;
    opacity: 0.75;
}

#GuessMAP:hover {
    width: 520px;
    height: 520px;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 210, 255, 0.2);
    opacity: 1;
}

#bluemapImport {
    flex: 1;
    overflow: hidden;
    position: relative;
}

#bluemapImport object {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    inset: 0;
    border: none;
}

#guessBTN {
    flex-shrink: 0;
    width: 100%;
    border-radius: 0;
    padding: 10px 16px;
    font-size: 0.85rem;
    background: var(--accent-gradient);
    letter-spacing: 1px;
    z-index: 11;
}

#GuessMAP:hover #guessBTN {
    padding: 14px 20px;
    font-size: 1rem;
}

/* ===================================================
   WAITING FOR PLAYERS
   =================================================== */
#WaitingForPlayer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(15, 15, 15, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
}

#WaitingForPlayer p {
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--text-secondary);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.03); }
}

/* ===================================================
   ROUND RESULT
   =================================================== */
#RoundResult {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 36px;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

#roundResultTablx {
    width: 100%;
    max-width: 600px;
}

#roundResultTablx tr {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(123, 47, 247, 0.1);
    transition: background var(--transition-fast);
}

#roundResultTablx tr:hover {
    background: rgba(0, 210, 255, 0.05);
}

#roundResultTablx tr:first-child {
    border-top: 1px solid rgba(123, 47, 247, 0.1);
}

#roundResultTablx td {
    font-size: 0.95rem;
}

#roundResultTablx td:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

#roundResultTablx td:nth-child(2) {
    color: var(--accent-primary);
    font-weight: 700;
}

#roundResultTablx td:nth-child(3) {
    color: var(--text-muted);
    font-size: 0.85rem;
}

#roundResultMap {
    width: 100%;
    max-width: 600px;
    height: 400px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

#roundResultMap object {
    width: 100% !important;
    height: 100% !important;
    border: none;
}

#NextRoundBTN {
    font-size: 1rem;
    padding: 14px 36px;
}

/* ===================================================
   GAME RESULT
   =================================================== */
#GameResult {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px 36px;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
}

#GameResultTablx {
    width: 100%;
    max-width: 500px;
}

#GameResultTablx tr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(123, 47, 247, 0.1);
    transition: background var(--transition-fast);
}

#GameResultTablx tr:hover {
    background: rgba(0, 210, 255, 0.05);
}

#GameResultTablx tr:first-child {
    border-top: 1px solid rgba(123, 47, 247, 0.1);
}

#GameResultTablx tr:first-child td:first-child {
    color: var(--accent-primary);
    font-size: 1.15rem;
}

#GameResultTablx tr:first-child td:nth-child(2) {
    font-size: 1.3rem;
}

#GameResultTablx td:first-child {
    font-weight: 600;
    font-size: 1rem;
}

#GameResultTablx td:nth-child(2) {
    font-weight: 800;
    font-size: 1.1rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#BackToLobbyBTN {
    font-size: 1rem;
    padding: 14px 36px;
}

/* ===================================================
   WAITING - fix initial display 
   =================================================== */
/* The JS toggles display, but we want the default hidden */
#WaitingForPlayer {
    display: none;
}

/* When shown by JS via style.display = "block" or "flex" */
#WaitingForPlayer[style*="block"],
#WaitingForPlayer[style*="flex"] {
    display: flex !important;
}

/* ===================================================
   Responsive
   =================================================== */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    body > h1 {
        font-size: 1.4rem;
    }

    #Room {
        padding: 24px 16px;
    }

    #gameCode p {
        font-size: 1.8rem;
        letter-spacing: 8px;
    }

    #joinRoomForm {
        flex-direction: column;
        width: 100%;
    }

    #joinRoomForm input[type="text"] {
        width: 100%;
    }

    #GuessMAP {
        width: 160px;
        height: 160px;
        bottom: 12px;
        right: 12px;
    }

    #GuessMAP:hover {
        width: 300px;
        height: 340px;
    }

    #RoundResult,
    #GameResult {
        padding: 24px 16px;
    }

    #roundResultMap {
        height: 260px;
    }
}

@media (max-width: 480px) {
    #GuessMAP {
        width: 130px;
        height: 130px;
        bottom: 8px;
        right: 8px;
    }

    #GuessMAP:hover {
        width: calc(100vw - 24px);
        height: 320px;
        right: 12px;
        bottom: 12px;
    }
}
