#chat-left .tab{text-decoration:none;display:inline-block;padding:4px;margin:2px;border-radius:2px;cursor:pointer;background:rgba(255,255,255,0.1);color:rgba(255,255,255,0.75);text-overflow:ellipsis;overflow:hidden;max-width:80%;vertical-align:top}
#chat-left .tab:hover:not(.selected):not(.disabled){background:rgba(255,255,255,0.2)}
#chat-left .tab.selected{background:rgba(255,255,255,0.4);color:#fff}
#chat-left .tab.disabled{opacity:0.25;cursor:default}

/* Notification dot (its own element) */
.tab-notification{position:fixed;width:8px;height:8px;background:#e53935;border-radius:50%;pointer-events:none;z-index:1000}

#battles #chat-left .tab{background:rgba(0,0,0,0.25);color:#fff}
#battles #chat-left .tab:hover:not(.selected):not(.disabled){background:rgba(0,0,0,0.1)}
#battles #chat-left .tab.selected{background:rgba(0,0,0,0.5);color:#fff}

#chat-container{display:flex}

#chat-channels{margin:2px;text-align:right;min-height:4px;overflow:hidden}

#chat-messages{margin:0 4px;overflow-y:auto;padding:0 4px;user-select:text;-moz-user-select:text;flex:1}

.chat-line{margin-bottom:2px}
div#chat-messages > div:last-child .chat-line:last-child{margin:0}
.chat-line text span{display:inline-block;background:#acc2d8;border-radius:2px;color:#000;padding:2px 4px;margin:1px}
.chat-line text span.green{color:#fff;background:#4cd06a;cursor:pointer}
.chat-line a,#motd a{color:#437ba5;cursor:pointer;text-decoration:none}
#battles .chat-line a{color:#63bcff}
.chat-line a.yt{display:inline-block;background:#d41515;border-radius:2px;padding:2px;margin:2px}
.chat-line .error a{color:#fff;text-decoration:underline}
.chat-line .upload{display:inline-block;background:rgba(0,0,0,0.4);border-radius:2px;padding:2px;margin:2px}
.chat-line .upload img{max-width:64px;cursor:zoom-in}
.chat-line img{vertical-align:top;border-radius:2px}
.chat-line .emoji,#top-bar .emoji{width:24px;height:24px;vertical-align:middle;margin:1px}
.chat-line .mon{margin:2px}

.chat-message,.chat-system{display:inline-block;border-radius:2px;padding:3px 4px;word-wrap:break-word;overflow:hidden;vertical-align:top}
.chat-message{background:rgba(0,0,0,0.4);padding:2px;max-width:100%;color:#fff}
#battles .chat-message{background:rgba(0,0,0,0.1);color:#000}
.chat-system{background:rgba(0,0,0,0.1);color:#fff}
#battles .chat-system{background:rgba(0,0,0,0.5)}
.chat-system.error{background:#d83b3b;color:#fff}
.chat-system.success{background:#3bd84e;color:#fff}

.chat-message > div{display:flex;align-items:start}
.chat-message > div > span,#chat-right .nametag{border-radius:2px;padding:2px 8px;display:inline-block;cursor:pointer;color:#000;text-decoration:none;height:22px;white-space:nowrap}
.chat-message text{padding:2px 2px 2px 4px}

.nametag a{color:inherit}
.nametag.light,.nametag.light a{color:#fff !important}
.nametag .emoji{width:14px;height:14px}

#chat-input{background:rgba(0,0,0,0.4);border-radius:2px;height:32px;margin:4px;padding:4px;border:0;width:calc(100% - 8px);color:#fff}
#battles #chat-input{background:#fff;color:#000;border:1px solid rgba(0,0,0,0.2)}

#chat-left,#chat-right{float:left}
#chat-left{position:relative;flex:1;display:flex;flex-direction:column;max-width:calc(100% - 150px)}
#chat-right{width:150px;padding:2px;border-left:1px solid rgba(0,0,0,0.1)}
#chat-right.collapsed{display:none}
#chat-right .nametag{display:block;text-overflow:ellipsis;overflow:hidden;vertical-align:top;margin:2px 2px 4px 2px;padding-left:12px;width:calc(100% - 4px)}

#chat-scrolldown{display:none;position:absolute;left:calc(50% - 16px);bottom:40px;width:32px;height:32px;background:rgba(0,0,0,0.5);border-radius:16px;cursor:pointer;transition:0.5s opacity;opacity:0}
#chat-scrolldown div{position:absolute;left:13px;top:14px;border:solid #fff;border-width:0 1px 1px 0;padding:2px;transform:rotate(45deg)}

#userlist{height:100%;overflow-y:auto;overflow-x:hidden}
#userlist > div{position:relative}
#userlist .status{position:absolute;bottom:-2px;width:12px;height:12px;background:#54c554;border:1px solid #fff;border-radius:50%}
#userlist .status.away{background:#c5a254}
#userlist .status.busy{background:#c55454}

#fullscreen .widget.chat{display:none;background:#232323;z-index:5 !important;box-shadow:1px 1px 8px rgba(0,0,0,0.5)}
#fullscreen .widget.chat.show{display:block}

.chat-popup{display:flex;flex-direction:column;cursor:pointer;position:absolute;left:50%;top:-84px;width:500px;height:80px;background:#232323;border-radius:2px;color:#fff;padding:8px;transform:translateX(-50%);transition:0.5s bottom,0.5s top,0.5s opacity;box-shadow:1px 1px 8px rgba(0,0,0,0.5);z-index:910000}
.chat-popup.on-screen{top:8px}
.chat-popup p{margin:0 0 4px 0;color:#808080}
.chat-popup div{text-overflow:ellipsis;overflow:hidden}

/** chat "back" button on mobile */
#chat-toggle-btn {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.75);
    padding: 0 8px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 12px;
}

#chat-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

#chat-toggle-btn:active {
    background: rgba(255, 255, 255, 0.4);
    color: #fff;
}

/** "back" button inline with the chat input */

#chat-input-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 4px;
}

#chat-input-row #chat-toggle-btn {
    position: static;
    width: auto;
    height: 32px;
    line-height: 32px;
}

#chat-input-row #chat-input {
    flex: 1;
    margin: 0;
    width: auto;
}

@media (pointer: coarse) {
    #chat-toggle-btn {
        display: block;
    }
}

/* ==================
   Battle Log
   ================== */

/* "controls" are the timer and copy button */
.battle-log-controls {
    position: absolute;
    top: 30px;
    right: 8px;
    display: flex;
    gap: 4px;
    align-items: center;
    z-index: 100;
}

.battle-log-timer {
    font-family: monospace;
    font-size: 14px;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 8px;
    border-radius: 4px;
}

.battle-log-copy-btn {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    cursor: pointer;
}

.battle-log-copy-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* Remove nametag background/padding for battle log messages */
.battle-log-message .nametag {
    background: none !important;
    padding: 0 !important;
    margin: 0 4px 0 0 !important;
}

/* Read-only input when battle log tab is selected */
#chat-input.chat-input-readonly {
    opacity: 0.5;
    pointer-events: none;
}

/* Hide close button on battle log tab */
#chat-left .tab[data-tab="#battle-log"] .close-tab {
    display: none;
}

.battle-log-centered {
    display: block !important;
    text-align: center;
    width: 100%;
}

.battle-log-centered > div {
    justify-content: center;
}

#chat-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-line text span.battle-action {
    display: inline;
    background: transparent;
    border-radius: 0;
    color: #e7e7e7;
    padding: 0;
    margin: 0;
    cursor: pointer;
    text-decoration: underline;
}

.chat-line text span.battle-action::before {
    content: "[";
}

.chat-line text span.battle-action::after {
    content: "]";
}

.chat-line text span.battle-action:hover {
    color: #81d4fa;
}

.chat-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 4px;
    padding: 8px;
    color: #fff;
    font-size: 12px;
    z-index: 10000;
    min-width: 150px;
    max-width: 250px;
}

/** Move tooltip */

.move-tooltip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.move-tooltip-name {
    font-weight: bold;
}

.move-tooltip-type {
    padding: 2px 6px;
    border-radius: 2px;
    font-size: 10px;
    text-transform: uppercase;
}

.move-tooltip-priority {
    font-size: 10px;
    color: #aaa;
}

.move-tooltip-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    font-size: 11px;
    color: #aaa;
}

.move-tooltip-desc {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 11px;
    color: #ccc;
    max-height: 80px;
    overflow-y: auto;
    line-height: 1.4;
    width: 0;
    min-width: 100%;
    box-sizing: border-box;
}

.move-tooltip-desc::-webkit-scrollbar {
    width: 4px;
}

.move-tooltip-desc::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.move-tooltip-desc::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

/** Mon tooltip */

.mon-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
}

.mon-tooltip-name {
    font-weight: bold;
}

.mon-tooltip-homeregion {
    margin-bottom: 2px;
    font-size: 10px;
    color: #888;
}

/* Shares homeregion font/color, just nudged up toward the Spe bar */
.mon-tooltip-speedtip {
    display: block;
    margin-top: -3px;
    margin-bottom: 6px;
}

.mon-tooltip-types {
    display: flex;
    gap: 4px;
    align-items: center;
}

.mon-tooltip-stats {
    margin-bottom: 6px;
}

.mon-stat-row {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    margin-bottom: 2px;
}

.mon-stat-label {
    width: 24px;
    color: #aaa;
}

.mon-stat-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.mon-stat-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.2s;
}

.mon-stat-value {
    width: 24px;
    text-align: right;
    color: #fff;
    font-size: 9px;
}

/** This lets mon boxes exceed the regular tooltip max width of 180px */
.mon-tooltip {
    min-width: 150px; // No max width
}

/** Abilities */

.mon-tooltip-abilities {
    font-size: 11px;
    color: #aaa;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    width: 0;
    min-width: 100%;
}

/** We want the ability names to wrap at the whole word and keep the comma */
.ability-item {
    white-space: nowrap;
}

.tooltip-link {
    color: #4fc3f7;
    cursor: pointer;
    text-decoration: underline;
}

.tooltip-link:hover {
    color: #81d4fa;
}

.mon-tooltip-abilities .battle-action {
    color: #4fc3f7;
    cursor: pointer;
    text-decoration: underline;
}

.mon-tooltip-abilities .battle-action:hover {
    color: #81d4fa;
}

.ability-tooltip-name {
    font-weight: bold;
    margin-bottom: 4px;
}

.ability-tooltip-desc {
    font-size: 11px;
    color: #ccc;
    max-height: 80px;
    overflow-y: auto;
    line-height: 1.4;
}

/** Item tooltip */
.item-tooltip-name {
    font-weight: bold;
    margin-bottom: 4px;
}

.item-tooltip-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.item-tooltip-icon {
    image-rendering: pixelated;
}

.item-tooltip-name {
    font-weight: bold;
}

/** Weather tooltip (it's only a description, so needs a min width) */
.weather-tooltip {
    min-width: 200px;
}

.weather-tooltip-name {
    font-weight: bold;
    margin-bottom: 4px;
}

/** Terrain tooltip */
.terrain-tooltip {
    min-width: 200px;
}

.terrain-tooltip-name {
    font-weight: bold;
    margin-bottom: 4px;
}

/** Owned mon */

.owned-mon-tooltip {
    min-width: 200px;
    max-width: 300px;
}

.owned-mon-header {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.owned-mon-sprite-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    justify-content: flex-end; /* Push to the bottom of the column */
}

.owned-mon-sprite {
    image-rendering: pixelated;
}

.ball-sprite {
    width: 18px;
    height: 18px;
    image-rendering: pixelated;
    cursor: pointer;
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
}

.owned-mon-info {
    flex: 1;
}

.owned-mon-name {
    font-weight: bold;
    font-size: 14px;
}

.owned-mon-species {
    font-size: 11px;
    color: #aaa;
}

.owned-mon-types {
    margin-top: 4px;
}

.owned-mon-level {
    font-size: 11px;
    color: #ccc;
    margin-top: 2px;
}

.shiny-badge {
    color: #ffd700;
    margin-right: 2px;
}

.owned-mon-nature,
.owned-mon-ability,
.owned-mon-item,
.owned-mon-moves,
.owned-mon-ivs,
.owned-mon-evs {
    font-size: 11px;
    color: #ccc;
    margin-top: 4px;
}

.owned-mon-moves {
    line-height: 1.4;
}

.owned-mon-stats-grid {
    display: grid;
    grid-template-columns: auto repeat(6, 1fr);
    gap: 0 8px;
    font-family: monospace;
    font-size: 11px;
    text-align: right;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.owned-mon-stats-grid .label {
    text-align: left;
}

.owned-mon-stats-grid .header {
    color: #888;
}

.nature-tooltip {
    min-width: 100px;
}

.nature-tooltip-name {
    font-weight: bold;
    margin-bottom: 4px;
}

.nature-tooltip-effect {
    font-size: 11px;
    color: #ccc;
}

/** Types as clickable badges */

.type-tooltip {
    min-width: 150px;
    max-width: 300px;
}

.type-tooltip-header {
    margin-bottom: 8px;
    text-align: center;
}

.type-tooltip-row {
    margin-bottom: 4px;
    font-size: 11px;
}

.type-tooltip-label {
    color: #aaa;
    display: block;
    margin-bottom: 2px;
}

.type-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 2px;
    font-size: 10px;
    color: #fff;
    text-transform: uppercase;
    cursor: pointer;
}

.type-badge:hover {
    filter: brightness(1.2);
}

.type-tooltip-section {
    margin-top: 8px;
    padding-top: 2px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.type-tooltip-section-title {
    font-weight: bold;
    font-size: 11px;
    color: #aaa;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.type-tooltip-row {
    margin: 4px 0;
}

.type-tooltip-label {
    display: block;
    font-size: 11px;
    color: #ccc;
    margin-bottom: 2px;
}

.type-tooltip-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}
