body {
    margin: 0;
    overflow: hidden;
    font-family: 'Roboto', "Microsoft YaHei", "SimHei", sans-serif; /* Base font for readability */
    background-color: #000;
    color: #f0e6d2;
    user-select: none;
}

#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* --- Top Bar --- */
#top-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px 0;
    background: linear-gradient(to bottom, rgba(9, 20, 40, 0.95), rgba(9, 20, 40, 0));
    pointer-events: auto;
    border-bottom: 1px solid rgba(200, 170, 110, 0.3);
}

.team-info {
    font-family: 'Cinzel', "Microsoft YaHei", serif; /* LoL-like header font */
    font-size: clamp(16px, 2.5vw, 28px);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0,0,0,0.8);
    letter-spacing: 1px;
}

.blue-team { color: #0acbe6; text-shadow: 0 0 10px rgba(10, 203, 230, 0.5); }
.red-team { color: #e84057; text-shadow: 0 0 10px rgba(232, 64, 87, 0.5); }

#score-board {
    font-family: 'Cinzel', serif;
    font-size: clamp(24px, 4vw, 48px);
    color: #f0e6d2;
    font-weight: bold;
    text-shadow: 0 0 10px #c8aa6e;
    padding: 0 40px;
}

#game-status {
    background: -webkit-linear-gradient(#c8aa6e, #785a28);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.8));
}

/* --- Message Area --- */
#message-area {
    text-align: center;
    font-family: 'Cinzel', "Microsoft YaHei", serif;
    font-size: clamp(32px, 5vw, 56px);
    font-weight: bold;
    color: #ff4444;
    text-shadow: 0 0 10px #000, 0 0 20px #ff0000;
    margin-top: 50px;
    height: auto; /* Changed from fixed height to fit button */
    min-height: 80px;
    pointer-events: none;
    letter-spacing: 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 20; /* Ensure it's on top */
}

.victory-button {
    pointer-events: auto;
    background: linear-gradient(to bottom, #1e2328, #091428);
    border: 2px solid #c8aa6e;
    color: #f0e6d2;
    font-family: 'Cinzel', "Microsoft YaHei", serif;
    font-size: 20px;
    padding: 10px 30px;
    cursor: pointer;
    text-shadow: 0 0 5px #000;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    transition: all 0.2s;
    margin-top: 10px;
}

.victory-button:hover {
    background: linear-gradient(to bottom, #2a3038, #111c30);
    border-color: #f0e6d2;
    box-shadow: 0 0 15px #c8aa6e;
    transform: scale(1.05);
}

/* --- Bottom HUD --- */
#bottom-hud {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 15px;
    background: linear-gradient(to top, #091428 0%, rgba(9, 20, 40, 0.9) 60%, transparent 100%);
    border-top: 2px solid #785a28;
    pointer-events: auto;
    height: 140px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.5);
}

.hud-section {
    margin: 0 15px;
    display: flex;
    align-items: center;
}

/* Player Stats (Left) */
.player-stats {
    border-right: 1px solid rgba(200, 170, 110, 0.3);
    padding-right: 25px;
}

.portrait-frame {
    width: 90px;
    height: 90px;
    border: 3px solid #c8aa6e;
    border-radius: 50%;
    position: relative;
    background: #000;
    margin-right: 15px;
    /* overflow: hidden; Removed to allow badge to overlap */
    box-shadow: 0 0 15px rgba(200, 170, 110, 0.3);
}

.portrait-img {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: background-image 0.3s;
    border-radius: 50%;
}

.level-badge {
    position: absolute;
    bottom: -5px;
    right: -5px;
    background: #091428;
    border: 2px solid #c8aa6e;
    color: #f0e6d2;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    text-align: center;
    line-height: 26px;
    font-size: 14px;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    box-shadow: 0 0 5px #000;
    z-index: 1;
}

.stats-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.player-name {
    font-size: clamp(14px, 1.5vw, 20px);
    color: #f0e6d2;
    font-weight: bold;
    font-family: 'Cinzel', "Microsoft YaHei", serif;
    margin-bottom: 4px;
    text-shadow: 0 0 5px #000;
}

.kda {
    font-size: 14px;
    color: #a09b8c;
    font-family: 'Roboto', sans-serif;
    letter-spacing: 1px;
}

/* Skills Panel (Center) */
.skills-panel {
    display: flex;
    gap: 15px;
}

.skill-slot {
    position: relative;
    width: 70px;
    height: 70px;
}

.skill-button {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e2328 0%, #091428 100%);
    border: 2px solid #785a28;
    padding: 0;
    cursor: pointer;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    box-shadow: inset 0 0 10px #000;
}

.skill-button:hover {
    border-color: #c8aa6e;
    box-shadow: 0 0 15px rgba(200, 170, 110, 0.4);
}

.skill-button.active {
    border-color: #0acbe6;
    box-shadow: 0 0 15px #0acbe6, inset 0 0 10px #0acbe6;
}

.skill-icon {
    font-size: 36px;
    filter: drop-shadow(0 0 2px #000);
}

.cooldown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    color: #f0e6d2;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    font-weight: bold;
    opacity: 0;
    pointer-events: none;
    font-family: 'Cinzel', serif;
    text-shadow: 0 0 5px #000;
}

.skill-button:disabled .cooldown-overlay {
    opacity: 1;
}

.key-bind {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #c8aa6e;
    background: #091428;
    padding: 2px 6px;
    border: 1px solid #463714;
    border-radius: 4px;
    font-family: 'Roboto', sans-serif;
    font-weight: bold;
    z-index: 10;
}

/* Tooltip */
.tooltip {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(9, 20, 40, 0.95);
    border: 2px solid #c8aa6e;
    padding: 12px;
    width: 220px;
    display: none;
    z-index: 100;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
}

.skill-slot:hover .tooltip {
    display: block;
}

.tt-title {
    color: #c8aa6e;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 8px;
    border-bottom: 1px solid #463714;
    padding-bottom: 4px;
    font-family: 'Cinzel', "Microsoft YaHei", serif;
}

.tt-desc {
    font-size: 13px;
    color: #a09b8c;
    font-family: 'Roboto', "Microsoft YaHei", sans-serif;
    line-height: 1.4;
}

/* System Panel (Right) */
.system-panel {
    border-left: 1px solid rgba(200, 170, 110, 0.3);
    padding-left: 25px;
}

.inventory-slot {
    width: 45px;
    height: 45px;
    position: relative;
}

.inventory-slot:hover .tooltip {
    display: block;
}

.system-tooltip {
    width: auto;
    min-width: 80px;
    bottom: 60px;
    padding: 8px 12px;
    text-align: center;
    white-space: nowrap;
}

.system-tooltip .tt-title {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
    font-size: 14px;
}

.item-button {
    width: 100%;
    height: 100%;
    background: #1e2328;
    border: 1px solid #785a28;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.item-button:hover {
    border-color: #c8aa6e;
    box-shadow: 0 0 10px rgba(200, 170, 110, 0.3);
}

.item-icon {
    font-size: 24px;
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

/* --- Lobby Overlay --- */
#lobby-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(9, 20, 40, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.lobby-container {
    display: flex;
    gap: 20px;
    align-items: stretch;
}

.lobby-box {
    background: #091428;
    border: 2px solid #c8aa6e;
    padding: 40px;
    text-align: center;
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
    width: 400px;
}

.room-list-panel {
    background: #091428;
    border: 2px solid #c8aa6e;
    padding: 20px;
    width: 250px;
    box-shadow: 0 0 20px #c8aa6e;
    display: flex;
    flex-direction: column;
}

.room-list-panel h3 {
    color: #c8aa6e;
    margin-top: 0;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
    font-family: 'Cinzel', "Microsoft YaHei", serif;
}

#room-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
    max-height: 300px;
}

#room-list li {
    background: #1e2328;
    margin-bottom: 5px;
    padding: 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    color: #f0e6d2;
    border: 1px solid #444;
    transition: all 0.2s;
}

#room-list li:hover {
    border-color: #c8aa6e;
    background: #2a3038;
}

#room-list li span.status {
    font-size: 0.8em;
    color: #888;
}

#room-list li.full {
    opacity: 0.6;
    cursor: not-allowed;
}

.lobby-title {
    font-family: 'Cinzel', "Microsoft YaHei", serif;
    color: #c8aa6e;
    font-size: clamp(24px, 3vw, 36px);
    margin-bottom: 30px;
    text-shadow: 0 0 10px #c8aa6e;
}

.lobby-input-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#room-id-input {
    background: #1e2328;
    border: 1px solid #785a28;
    color: #f0e6d2;
    padding: 10px;
    font-size: 18px;
    text-align: center;
    font-family: 'Roboto', sans-serif;
}

#room-id-input:focus {
    outline: none;
    border-color: #c8aa6e;
    box-shadow: 0 0 10px rgba(200, 170, 110, 0.3);
}

.lobby-btn {
    background: linear-gradient(to bottom, #1e2328, #091428);
    border: 2px solid #c8aa6e;
    color: #f0e6d2;
    font-family: 'Cinzel', serif;
    font-size: 20px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.lobby-btn:hover {
    background: linear-gradient(to bottom, #2a3038, #111c30);
    box-shadow: 0 0 15px #c8aa6e;
}

#lobby-status {
    margin-top: 20px;
    color: #a09b8c;
    font-size: 14px;
    min-height: 20px;
}

/* --- Skill Draft Notification --- */
#skill-draft-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-in-out;
}

#skill-draft-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.draft-title {
    font-family: 'Cinzel', "Microsoft YaHei", serif;
    font-size: clamp(32px, 4vw, 48px);
    color: #c8aa6e;
    text-shadow: 0 0 20px #c8aa6e;
    margin-bottom: 40px;
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.5s ease-out;
}

#skill-draft-overlay.visible .draft-title {
    transform: translateY(0);
    opacity: 1;
}

.draft-cards {
    display: flex;
    gap: 40px;
}

.draft-card {
    width: 150px;
    height: 220px;
    background: linear-gradient(135deg, #1e2328 0%, #091428 100%);
    border: 2px solid #785a28;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#skill-draft-overlay.visible .draft-card {
    transform: scale(1);
    opacity: 1;
}

#skill-draft-overlay.visible .draft-card:nth-child(1) {
    transition-delay: 0.3s;
}

#skill-draft-overlay.visible .draft-card:nth-child(2) {
    transition-delay: 0.6s;
}

.draft-card-icon {
    font-size: 64px;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 10px rgba(200, 170, 110, 0.5));
}

.draft-card-name {
    font-family: 'Cinzel', "Microsoft YaHei", serif;
    font-size: clamp(16px, 2vw, 24px);
    color: #f0e6d2;
    font-weight: bold;
    text-shadow: 0 0 5px #000;
}

.draft-card.rare {
    border-color: #0acbe6;
    box-shadow: 0 0 30px rgba(10, 203, 230, 0.3);
}

/* --- Mobile Adaptation --- */
@media (max-width: 768px) {
    /* Top Bar */
    #top-bar {
        padding: 10px 15px;
    }
    
    /* Font sizes handled by clamp() */
    
    #score-board {
        padding: 0 10px;
    }

    /* Message Area */
    #message-area {
        margin-top: 80px;
    }

    /* Bottom HUD */
    #bottom-hud {
        height: 100px;
        padding-bottom: 10px;
    }

    .hud-section {
        margin: 0 5px;
    }

    /* Player Stats */
    .player-stats {
        padding-right: 10px;
    }

    .portrait-frame {
        width: 50px;
        height: 50px;
        margin-right: 8px;
        border-width: 2px;
    }

    /* Skills */
    .skills-panel {
        gap: 8px;
    }

    .skill-slot {
        width: 50px;
        height: 50px;
    }

    .skill-icon {
        font-size: 24px;
    }

    .key-bind {
        display: none; /* Hide keyboard shortcuts on mobile */
    }

    .cooldown-overlay {
        font-size: 20px;
    }

    /* System Panel */
    .system-panel {
        padding-left: 10px;
        flex-direction: column;
        gap: 5px;
        border-left: none;
    }

    .inventory-slot {
        width: 30px;
        height: 30px;
    }

    .item-icon {
        font-size: 16px;
    }

    /* Lobby */
    .lobby-container {
        flex-direction: column;
        width: 90%;
        max-height: 90vh;
        overflow-y: auto;
    }

    .lobby-box {
        width: auto;
        padding: 20px;
    }

    .room-list-panel {
        width: auto;
        max-height: 200px;
    }

    /* Draft Overlay */
    .draft-cards {
        gap: 15px;
    }

    .draft-card {
        width: 110px;
        height: 160px;
    }

    .draft-card-icon {
        font-size: 48px;
    }
}

/* --- Chat/Emote System --- */
#chat-container {
    position: absolute;
    bottom: 160px; /* Above HUD */
    right: 20px;
    width: 300px;
    pointer-events: none; /* Let clicks pass through empty areas */
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    z-index: 50;
}

#chat-messages {
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
    pointer-events: none;
}

.chat-bubble {
    background: rgba(9, 20, 40, 0.8);
    border: 1px solid #c8aa6e;
    color: #f0e6d2;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    max-width: 80%;
    align-self: flex-start; /* Default left (opponent) */
    animation: fadeIn 0.3s ease-out;
    pointer-events: auto;
}

.chat-bubble.self {
    align-self: flex-end;
    background: rgba(10, 203, 230, 0.2);
    border-color: #0acbe6;
}

.chat-bubble.opponent {
    align-self: flex-start;
    background: rgba(232, 64, 87, 0.2);
    border-color: #e84057;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#emote-panel {
    background: rgba(9, 20, 40, 0.95);
    border: 2px solid #785a28;
    padding: 10px;
    border-radius: 8px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    pointer-events: auto;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease-out;
    pointer-events: none; /* Hidden by default */
}

#emote-panel.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.emote-btn {
    background: #1e2328;
    border: 1px solid #444;
    color: #fff;
    font-size: 20px;
    padding: 5px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.1s;
}

.emote-btn:hover {
    background: #2a3038;
    border-color: #c8aa6e;
    transform: scale(1.1);
}

#toggle-chat-btn {
    background: #1e2328;
    border: 2px solid #c8aa6e;
    color: #f0e6d2;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    pointer-events: auto;
    margin-top: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    transition: all 0.2s;
}

#toggle-chat-btn:hover {
    background: #2a3038;
    box-shadow: 0 0 15px #c8aa6e;
}

/* Mobile adjustments for chat */
@media (max-width: 768px) {
    #chat-container {
        bottom: 120px;
        right: 10px;
        width: 200px;
    }
    
    #emote-panel {
        grid-template-columns: repeat(4, 1fr);
    }
}
/* --- English Font Adjustments --- */
body.lang-en .lobby-title { font-size: clamp(22px, 2.8vw, 32px); }
body.lang-en .team-info { font-size: clamp(14px, 2.2vw, 24px); }
body.lang-en #score-board { font-size: clamp(22px, 3.5vw, 42px); }
body.lang-en #message-area { font-size: clamp(28px, 4.5vw, 48px); }
body.lang-en .player-name { font-size: clamp(13px, 1.4vw, 18px); }
body.lang-en .lobby-btn { font-size: clamp(16px, 1.8vw, 18px); }
body.lang-en .draft-title { font-size: clamp(28px, 3.5vw, 42px); }
body.lang-en .draft-card-name { font-size: clamp(14px, 1.8vw, 20px); }

/* --- Rules Modal --- */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #091428;
    border: 2px solid #c8aa6e;
    padding: 40px;
    width: 500px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 0 40px rgba(0,0,0,0.9), inset 0 0 20px rgba(0,0,0,0.5);
    position: relative;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 5px; left: 5px; right: 5px; bottom: 5px;
    border: 1px solid rgba(200, 170, 110, 0.3);
    pointer-events: none;
}

.modal-title {
    font-family: 'Cinzel', "Microsoft YaHei", serif;
    color: #c8aa6e;
    font-size: 32px;
    margin-top: 0;
    margin-bottom: 20px;
    text-shadow: 0 0 10px #c8aa6e;
    border-bottom: 1px solid #444;
    padding-bottom: 15px;
}

.rules-body {
    color: #f0e6d2;
    font-family: 'Roboto', "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.8;
    text-align: left;
    margin-bottom: 30px;
}

.rules-body p {
    margin: 0;
}

/* Mobile adjustments for modal */
@media (max-width: 768px) {
    .modal-content {
        padding: 20px;
        width: 85%;
    }
    
    .modal-title {
        font-size: 24px;
    }
    
    .rules-body {
        font-size: 14px;
    }
}
