* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #111;
    color: white;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: #000;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.hidden {
    display: none !important;
}

/* Overlays & Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    overflow-y: auto;
    padding: 40px 0;
}

h1 {
    font-size: 3rem;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

#role-display {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px black;
}

#role-text.crewmate { color: #00ff00; }
#role-text.impostor { color: #ff0000; }
#role-text.ghost { color: #aaaaaa; }

#tasks-container {
    position: absolute;
    top: 50px;
    left: 15px;
    background: rgba(0,0,0,0.5);
    padding: 8px;
    border-radius: 8px;
    pointer-events: auto;
    max-width: 40%;
}

#tasks-list {
    list-style-type: none;
    margin-top: 5px;
}

.task-item {
    font-size: 0.9rem;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.task-item.done {
    color: #00ff00;
    text-decoration: line-through;
}

#action-buttons {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    pointer-events: auto;
    width: 180px;
}

.action-btn {
    width: 75px;
    height: 75px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-weight: bold;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.action-btn:hover:not(:disabled) {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.2);
}

.action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: #555;
}

#btn-kill { border-color: #ff3333; }
#btn-kill:hover:not(:disabled) { background: rgba(255, 51, 51, 0.3); }

/* Buttons */
.primary-btn, .secondary-btn {
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.2s;
}

.primary-btn {
    background-color: #4CAF50;
    color: white;
}
.primary-btn:hover { background-color: #45a049; }

.secondary-btn {
    background-color: #f44336;
    color: white;
}
.secondary-btn:hover { background-color: #da190b; }

/* Join Screen */
.join-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background: #222;
    padding: 40px;
    border-radius: 12px;
    border: 2px solid #444;
    width: 90%;
    max-width: 600px;
}

.join-options {
    display: flex;
    width: 100%;
    gap: 30px;
}

.option-block {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #333;
    padding: 20px;
    border-radius: 10px;
}

.option-block h3 {
    font-size: 1.2rem;
    color: #aaa;
}

#input-max-players, #input-room-code, #input-name {
    padding: 10px;
    font-size: 1.1rem;
    border-radius: 6px;
    border: 1px solid #555;
    background: #111;
    color: white;
    text-align: center;
}

#input-name { width: 100%; }

/* Browser */
.browser-container {
    background: #222;
    padding: 30px;
    border-radius: 12px;
    border: 2px solid #444;
    width: 90%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
}

.room-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    touch-action: pan-y;
}

.room-item {
    display: grid;
    grid-template-columns: 1fr 100px;
    padding: 15px;
    background: #333;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}

.room-item:hover:not(.header) { background: #444; }
.room-item.header { background: transparent; color: #888; font-weight: bold; cursor: default; }

/* Settings */
.icon-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
    background: rgba(0,0,0,0.6);
    border: 2px solid #555;
    border-radius: 50%;
    cursor: pointer;
    z-index: 300;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.device-options { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.device-btn { padding: 12px; font-size: 1.1rem; background: #444; color: white; border: 2px solid transparent; border-radius: 8px; cursor: pointer; text-align: left; }
.device-btn.active { border-color: #4CAF50; background: #2e4d2f; }

/* Customization Picker */
.color-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.color-option { aspect-ratio: 1; border-radius: 8px; cursor: pointer; border: 3px solid transparent; }
.color-option.selected { border-color: white; }
.color-option.taken { opacity: 0.3; cursor: not-allowed; filter: grayscale(1); }

.accessory-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.accessory-option { aspect-ratio: 1; background: #333; border-radius: 6px; cursor: pointer; display: flex; justify-content: center; align-items: center; font-size: 1.5rem; border: 2px solid transparent; }
.accessory-option.selected { border-color: #4CAF50; background: #2e4d2f; }

/* Mobile Only */
.mobile-only { display: none; }
.force-show-joystick { display: block !important; }

#joystick-container {
    position: absolute;
    bottom: 40px;
    left: 40px;
    width: 120px;
    height: 120px;
    z-index: 60;
    pointer-events: auto;
    touch-action: none;
}

#joystick-base {
    position: relative;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
}

#joystick-stick {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

#minimap-container {
    top: 15px !important;
    right: 70px !important;
    width: 140px !important;
    height: 100px !important;
}

#chat-container {
    width: 280px !important;
    height: 300px !important;
    bottom: 110px !important;
    right: 15px !important;
}

@media (max-width: 900px), (pointer: coarse) {
    .mobile-only { display: block; }
    .screen { justify-content: flex-start; padding-top: 40px; }
    h1 { font-size: 1.8rem; }
    .join-options { flex-direction: column; gap: 15px; }
    .join-box { padding: 15px; width: 95%; }
    .option-block { padding: 15px; }
    .lobby-customization { width: 220px !important; padding: 10px !important; }
    #action-buttons { bottom: 15px; right: 15px; width: 160px; }
    .action-btn { width: 65px; height: 65px; border-radius: 50%; font-size: 0.8rem; }
    #tasks-container { max-width: 50%; font-size: 0.8rem; }
    #chat-container { width: 90% !important; left: 5% !important; bottom: 150px !important; height: 250px !important; }
    #minimap-container { width: 120px !important; height: 90px !important; top: 10px !important; right: 65px !important; }
}

/* Modals */
.modal { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 200; overflow-y: auto; }
.modal-content { background: #333; padding: 40px; border-radius: 12px; text-align: center; border: 2px solid #555; max-width: 90%; }

/* Meeting UI Overhaul */
.meeting-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vote-player {
    display: flex;
    align-items: center;
    background: #333;
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    border: 2px solid transparent;
    position: relative;
    transition: all 0.2s;
    text-align: left;
}

.vote-player:hover:not(.dead) {
    background: #444;
    transform: translateX(5px);
}

.vote-player.selected {
    border-color: #4CAF50;
    background: #2e4d2f;
}

.vote-player.dead {
    opacity: 0.5;
    cursor: not-allowed;
    background: #222;
}

.vote-player::after {
    content: "💬";
    position: absolute;
    right: 15px;
    opacity: 0.3;
}

.vote-player.voted::after {
    content: "✅";
    opacity: 1;
}

.color-badge {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 15px;
    border: 2px solid white;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

/* Ejection Animation */
@keyframes driftAway {
    0% { transform: rotate(0deg) scale(1.5) translate(0, 0); }
    100% { transform: rotate(1080deg) scale(0.1) translate(400px, 400px); }
}

.starfield {
    background: radial-gradient(white, rgba(255,255,255,0) 2px),
                radial-gradient(white, rgba(255,255,255,0) 1px),
                radial-gradient(white, rgba(255,255,255,0) 1.5px);
    background-size: 550px 550px, 350px 350px, 250px 250px;
    background-position: 0 0, 40px 60px, 130px 270px;
    animation: starMove 10s linear infinite;
    width: 100%;
    height: 100%;
}

@keyframes starMove {
    from { background-position: 0 0, 40px 60px, 130px 270px; }
    to { background-position: -550px 0, -350px 60px, -250px 270px; }
}

.ejecting-character-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ejecting-character {
    animation: driftAway 5s linear forwards;
}
