body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
}

#gameCanvas {
    display: block;
}

#loading-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #111;
    color: white; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 9999;
}

#main-menu-ui {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none; 
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}

#username-input {
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 12px 16px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 18px;
    font-weight: bold;
    width: 280px;
    text-align: center;
    margin-bottom: 20px;
    outline: none;
}

#username-input:focus {
    border-color: #ffffff;
}

#play-btn {
    background-color: #ff8800;
    color: white;
    border: none;
    padding: 14px 48px;
    font-size: 20px;
    font-weight: bold;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    cursor: pointer;
    border-radius: 6px;
}

#play-btn:hover {
    background-color: #ff9911;
}

#play-btn:active {
    background-color: #e67a00;
}

#editor-ui {
    position: fixed;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 1000;
}

#layer-toggles {
    display: flex;
    gap: 5px;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.layer-btn {
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: 2px solid transparent;
    padding: 8px 14px;
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.layer-btn:hover {
    border-color: #ffffff;
    background-color: rgba(0, 0, 0, 0.8);
}

.layer-btn.active {
    border-color: #ffffff;
    background-color: rgba(0, 0, 0, 0.9);
}

.danger-btn {
    background-color: #ff4444;
    border: 2px solid transparent;
}

.danger-btn:hover {
    border-color: #ffffff;
    background-color: #ff5555;
}

#palette {
    display: flex;
    gap: 4px;
    justify-content: flex-start;
}

.tile-btn {
    width: 64px;
    height: 64px;
    outline: 2px solid transparent; 
    cursor: pointer;
    background-color: rgba(0, 0, 0, 0.4); 
    background-repeat: no-repeat;
    transition: outline-color 0.1s;
}

.tile-btn:hover, .tile-btn.selected {
    outline-color: #ffffff;
    z-index: 1;
}

.eraser-btn {
    background-color: rgba(0, 0, 0, 0.6);
}

#leaderboard-ui {
    position: fixed;
    top: 10px;
    right: 10px;
    flex-direction: column;
    gap: 4px;
    z-index: 1000;
    width: 220px;
}

#leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 14px;
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
}

#leaderboard-header:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

#leaderboard-toggle {
    font-size: 10px;
}

#leaderboard-list {
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 10px 14px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    color: #ffffff;
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 2px;
}

#role-list-ui {
    position: fixed;
    top: 240px;
    right: 10px;
    flex-direction: column;
    gap: 4px;
    z-index: 1000;
    width: 220px;
}

#role-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 14px;
    font-weight: bold;
    font-size: 13px;
    cursor: pointer;
}

#role-list-header:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

#role-list-toggle {
    font-size: 10px;
}

#role-list-items {
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 10px 14px;
    max-height: 250px;
    overflow-y: auto;
}

.role-list-entry {
    display: flex;
    justify-content: space-between;
    color: #ffffff;
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 3px;
    cursor: default;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.1s;
}

.role-list-entry:hover {
    background: rgba(255, 255, 255, 0.12);
}

.role-list-entry.town {
    color: #55ee77;
}

.role-list-entry.mafia {
    color: #ff5555;
}

#role-tooltip {
    position: fixed;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 8px 12px;
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
    max-width: 240px;
    line-height: 1.4;
}

#bottom-ui {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    display: none;
    z-index: 1000;
}

#health-bar-bg {
    width: 100%;
    height: 18px;
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 9px;
    box-sizing: border-box;
    padding: 2px;
}

#health-bar-fill {
    width: 100%;
    height: 100%;
    background-color: #ff4444;
    border-radius: 5px;
    transition: width 0.2s ease-out;
}

#chat-ui {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    padding: 12px 20px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    z-index: 2000;
    display: none;
}

#chat-input {
    background: transparent;
    color: #ffffff;
    border: none;
    outline: none;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 16px;
    font-weight: bold;
    width: 400px;
    text-align: center;
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#chat-log-ui {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 360px;
    height: 240px;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    z-index: 1500;
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    box-sizing: border-box;
}

#chat-log-messages {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: min-content;
}

#chat-log-ui::-webkit-scrollbar {
    width: 6px;
}
#chat-log-ui::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}
#chat-log-ui::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}
#chat-log-ui::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.chat-log-line {
    background-color: transparent;
    color: white;
    padding: 2px 0;
    margin-top: 2px;
    font-weight: bold;
    font-size: 14px;
    word-wrap: break-word;
    text-shadow: 1px 1px 0 #000;
}

.sys-msg { 
    color: #ffeb3b; 
}

#will-ui {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.15);
    z-index: 2000;
    display: none;
    flex-direction: column;
    width: 400px;
    height: 300px;
    border-radius: 8px;
    overflow: hidden;
}

#will-header {
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 10px;
    font-weight: bold;
    text-align: center;
}

#will-input {
    flex: 1;
    background: transparent;
    color: white;
    border: none;
    padding: 10px;
    resize: none;
    outline: none;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    font-size: 16px;
}
