/* Chat, tip cards and announcements (loaded last). Markup/logic: js/chat.js */

/* Announcement types share one colour variable (--tc) */
[data-type="info"]   { --tc: var(--accent); }
[data-type="event"]  { --tc: #a78bfa; }
[data-type="update"] { --tc: #34d399; }
[data-type="promo"]  { --tc: var(--gold); }
[data-type="warn"]   { --tc: #f87171; }

/* --- Top announcement bar ------------------------------------------------------------------------ */
.announce {
    --tc: var(--accent);
    position: relative;
    gap: 10px;
    padding: 8px 46px 8px 16px;
    color: var(--text);
    font-weight: 600;
    background:
        linear-gradient(90deg, transparent, color-mix(in srgb, var(--tc) 20%, var(--bg2)) 18%, color-mix(in srgb, var(--tc) 20%, var(--bg2)) 82%, transparent),
        var(--bg2);
    border-bottom: 1px solid color-mix(in srgb, var(--tc) 38%, transparent);
}

.announce .an-ic { display: grid; place-items: center; color: var(--tc); }
.announce .an-ic .ic { width: 18px; height: 18px; }

.announce .an-label {
    flex: none;
    padding: 2px 9px;
    border-radius: 99px;
    background: var(--tc);
    color: #0a0f1f;
    font-size: 10.5px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.announce .an-text { min-width: 0; text-wrap: balance; }

.announce .an-x {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.announce .an-x:hover { background: color-mix(in srgb, var(--tc) 22%, transparent); color: var(--text); }
.announce .an-x .ic { width: 14px; height: 14px; }

@media (max-width: 640px) {
    .announce { padding-left: 12px; font-size: 12.5px; }
    .announce .an-ic { display: none; }
}

/* --- Rain: time bar ------------------------------------------------------------------------------- */
.rain { position: relative; overflow: hidden; }
.rain-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .08); }
.rain-bar i { display: block; height: 100%; background: var(--green); box-shadow: 0 0 8px var(--green); }

/* --- Pinned announcement in the chat -------------------------------------------------------------- */
.chat-pin {
    --tc: var(--accent);
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 0 12px 6px;
    padding: 8px 6px 8px 10px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--tc) 42%, transparent);
    background: linear-gradient(100deg, color-mix(in srgb, var(--tc) 16%, var(--panel)), var(--panel) 80%);
    cursor: pointer;
}

.chat-pin[hidden] { display: none; }
.chat-pin .cp-ic { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; background: color-mix(in srgb, var(--tc) 22%, transparent); color: var(--tc); }
.chat-pin .cp-ic .ic { width: 14px; height: 14px; }
.chat-pin > div { flex: 1; min-width: 0; }
.chat-pin b { display: block; color: var(--tc); font-size: 10.5px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.chat-pin p { margin: 1px 0 0; font-size: 12.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.chat-pin.open p { -webkit-line-clamp: unset; display: block; }
.chat-pin .cp-x { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.chat-pin .cp-x:hover { color: var(--text); background: rgba(255, 255, 255, .08); }
.chat-pin .cp-x .ic { width: 13px; height: 13px; }

/* --- Messages: grouped lines, mentions ------------------------------------------------------------- */
.chat-msgs { gap: 10px; scroll-behavior: auto; }

.msg > img { border-radius: 8px; image-rendering: pixelated; cursor: pointer; }
.msg > div { min-width: 0; flex: 1; }

.msg.cont { margin-top: -7px; padding-left: 39px; }
.msg.cont > img, .msg.cont .nm { display: none; }

.msg.mention {
    margin-inline: -6px;
    padding: 4px 6px;
    border-radius: 8px;
    border-left: 2px solid var(--gold);
    background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 16%, transparent), transparent);
}
.msg.mention.cont { padding-left: 45px; }

.at { color: var(--accent2); font-weight: 700; cursor: pointer; }
.at:hover { text-decoration: underline; }
.at.me { padding: 0 4px; border-radius: 5px; background: color-mix(in srgb, var(--gold) 24%, transparent); color: var(--gold); }

.msg-del { top: 2px; right: 2px; }

/* --- Cards: tips, announcements, system lines ------------------------------------------------------- */
.msg.card {
    display: block;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line2);
    background: var(--panel);
}

.msg.card.sys {
    padding: 2px 6px;
    border: 0;
    background: none;
    text-align: center;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
}

/* Tips */
.tip-card {
    border-color: color-mix(in srgb, var(--gold) 32%, transparent);
    background: linear-gradient(110deg, color-mix(in srgb, var(--gold) 14%, var(--panel)), var(--panel) 75%);
}

.tip-card.mine {
    border-color: var(--gold);
    background: linear-gradient(110deg, color-mix(in srgb, var(--gold) 28%, var(--panel)), color-mix(in srgb, var(--gold) 6%, var(--panel)) 80%);
    box-shadow: 0 0 18px color-mix(in srgb, var(--gold) 22%, transparent);
}

.tip-card.big {
    border-color: var(--gold);
    background:
        linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .13) 50%, transparent 70%) 0 0 / 250% 100% no-repeat,
        linear-gradient(110deg, color-mix(in srgb, var(--gold) 26%, var(--panel)), var(--panel) 80%);
    animation: tipShine 3.2s ease-in-out 2;
}

@keyframes tipShine { from { background-position: 150% 0, 0 0; } to { background-position: -50% 0, 0 0; } }
.reduce-motion .tip-card.big { animation: none; }
@media (prefers-reduced-motion: reduce) { .tip-card.big { animation: none; } }

.tc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tc-label { display: inline-flex; align-items: center; gap: 6px; color: var(--gold); font-size: 10.5px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.tc-label .ic { width: 14px; height: 14px; }
.tc-amt { font-size: 14px; font-weight: 800; }

.tc-flow { display: flex; align-items: center; gap: 6px; margin-top: 8px; min-width: 0; }
.tc-flow img, .tc-anon { flex: none; width: 22px; height: 22px; border-radius: 6px; image-rendering: pixelated; }
.tc-anon { display: grid; place-items: center; background: var(--panel3); color: var(--muted); font-style: normal; font-weight: 800; font-size: 12px; }
.tc-flow b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-size: 12px; }
.tc-arrow { flex: none; display: grid; place-items: center; color: var(--gold); }
.tc-arrow .ic { width: 14px; height: 14px; }

/* Announcements */
.ann-card {
    --tc: var(--accent);
    border-color: color-mix(in srgb, var(--tc) 45%, transparent);
    background: linear-gradient(120deg, color-mix(in srgb, var(--tc) 16%, var(--panel)), var(--panel) 80%);
}

.ac-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.ac-head b { color: var(--tc); font-size: 10.5px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.ac-ic { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; background: color-mix(in srgb, var(--tc) 22%, transparent); color: var(--tc); }
.ac-ic .ic { width: 13px; height: 13px; }
.ann-card p { margin: 0; font-size: 13px; line-height: 1.4; color: var(--text); }

/* --- "N new messages" pill and character counter ----------------------------------------------------- */
.chat-new {
    position: absolute;
    left: 50%;
    bottom: 68px;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px 6px 9px;
    border: 0;
    border-radius: 99px;
    background: var(--accent);
    color: var(--on-accent, #fff);
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
    cursor: pointer;
}

.chat-new[hidden] { display: none; }
.chat-new .ic { width: 14px; height: 14px; }

.chat-count { position: absolute; right: 66px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 700; color: var(--muted); pointer-events: none; font-variant-numeric: tabular-nums; }
.chat-count[hidden] { display: none; }
.chat-count.low { color: #fca5a5; }
.chat-form:has(.chat-count:not([hidden])) input { padding-right: 38px; }

/* --- Player card ---------------------------------------------------------------------------------------- */
.user-card {
    position: absolute;
    z-index: 60;
    width: 250px;
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid var(--line2);
    background: var(--panel2);
    box-shadow: 0 16px 40px rgba(0, 0, 0, .55);
    animation: slideIn .15s ease-out;
}

.uc-head { display: flex; align-items: center; gap: 10px; }
.uc-head img { flex: none; width: 40px; height: 40px; border-radius: 10px; image-rendering: pixelated; }
.uc-head > div { flex: 1; min-width: 0; display: grid; gap: 1px; justify-items: start; }
.uc-head b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--text); }
.uc-head .badge { height: 16px; font-size: 9px; padding: 0 5px; }
.uc-head small { font-size: 11px; }
.uc-x { align-self: flex-start; display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; }
.uc-x:hover { color: var(--text); background: rgba(255, 255, 255, .08); }
.uc-x .ic { width: 13px; height: 13px; }
.uc-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.uc-label .ic { width: 13px; height: 13px; color: var(--gold); }
.uc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.uc-actions { display: flex; gap: 6px; }

/* Admin: type picker next to the announcement text */
.ann-type { flex: none; width: auto; min-width: 118px; }
form.ann { display: grid; gap: 8px; }

/* --- Player profile window (js/profile.js). Only theme variables, so it follows the active colour theme. ------- */
.modal.pf-modal { width: min(540px, 100%); }
.pf-modal .modal-head h3 { display: flex; align-items: center; gap: 10px; text-transform: none; font-size: 16px; font-weight: 600; }
.pf-modal .modal-head h3 .ic { width: 17px; height: 17px; color: var(--muted); }
.pf-modal .modal-body { gap: 14px; }
.pf-loading { padding: 40px 0; text-align: center; }

.pf-head { display: flex; align-items: center; gap: 16px; }
.pf-av { flex: none; width: 76px; height: 76px; border-radius: 50%; object-fit: cover; image-rendering: pixelated; background: var(--panel2); border: 1px solid var(--line2); }
.pf-id { min-width: 0; display: grid; gap: 4px; }
.pf-name { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.pf-name b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 22px; font-weight: 700; color: var(--text); }
.pf-lvl { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px 0 6px; border-radius: 7px; background: var(--panel3); color: var(--muted); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pf-lvl .ic { width: 14px; height: 14px; color: var(--accent2); }

.pf-actions { display: grid; grid-template-columns: repeat(3, 1fr); border-radius: 12px; overflow: hidden; background: var(--panel2); border: 1px solid var(--line); }
.pf-actions button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.pf-actions button + button { border-left: 1px solid var(--line); }
.pf-actions button:hover { background: var(--panel3); }
.pf-actions button .ic { width: 16px; height: 16px; flex: none; }
.pf-actions button.danger { color: var(--red); }
.pf-actions button.danger:hover { background: color-mix(in srgb, var(--red) 14%, transparent); }
.pf-me { margin: 0; font-size: 13px; }

.pf-panel { display: grid; gap: 10px; padding: 12px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); animation: slideIn .15s ease-out; }
.pf-panel[hidden] { display: none; }
.pf-panel textarea { resize: none; width: 100%; }
.pf-row { display: flex; justify-content: flex-end; gap: 8px; }
.pf-reasons { display: flex; flex-wrap: wrap; gap: 6px; }
.pf-reasons label { cursor: pointer; }
.pf-reasons input { position: absolute; opacity: 0; pointer-events: none; }
.pf-reasons span { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel3); color: var(--muted); font-size: 12.5px; font-weight: 700; transition: .15s; }
.pf-reasons input:checked + span { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 18%, var(--panel3)); }
.pf-reasons input:focus-visible + span { outline: 2px solid var(--accent2); outline-offset: 2px; }

.pf-level > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 8px; }
.pf-level .muted { font-size: 13px; font-variant-numeric: tabular-nums; }
.pf-bar { height: 8px; border-radius: 999px; overflow: hidden; background: var(--panel3); }
.pf-bar i { display: block; height: 100%; min-width: 4px; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent2)); box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 55%, transparent); transition: width .5s ease-out; }

.pf-sec { border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); }
.pf-sec > summary { display: flex; align-items: center; gap: 10px; padding: 14px 16px; cursor: pointer; list-style: none; font-size: 14px; font-weight: 700; color: var(--text); user-select: none; }
.pf-sec > summary::-webkit-details-marker { display: none; }
.pf-sec > summary > .ic { width: 16px; height: 16px; color: var(--muted); flex: none; }
.pf-sec > summary > span { flex: 1; }
.pf-sec > summary > .pf-chev { transition: transform .2s; }
.pf-sec[open] > summary > .pf-chev { transform: rotate(180deg); }
.pf-sec > summary:focus-visible { outline: 2px solid var(--accent2); outline-offset: -2px; border-radius: 12px; }
.pf-sec-body { padding: 0 12px 12px; }

.pf-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pf-stat { display: grid; gap: 6px; padding: 14px 8px; border-radius: 10px; background: var(--bg2); text-align: center; min-width: 0; }
.pf-stat small, .pf-game small { color: var(--muted); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.pf-stat b { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }

.pf-luckies { display: grid; gap: 6px; }
.pf-lucky { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg2); font-size: 13px; }
.pf-lg { font-weight: 700; }
.pf-lucky .chip { justify-self: end; }
.pf-lp { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pf-lp i { display: inline-flex; color: var(--dim); }
.pf-lp .ic { width: 12px; height: 12px; }
.pf-lucky small { justify-self: end; }
.pf-empty { margin: 6px 0; text-align: center; font-size: 13px; }

.pf-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.pf-game { display: grid; gap: 6px; align-content: center; padding: 12px 6px; min-height: 66px; border-radius: 10px; background: var(--bg2); text-align: center; min-width: 0; }
.pf-game small { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-game b { font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
.pf-game.zero { opacity: .5; }

.pf-private { display: grid; justify-items: center; gap: 6px; padding: 30px 10px; text-align: center; }
.pf-private .ic { width: 28px; height: 28px; color: var(--muted); }
.pf-private p { margin: 0; font-size: 13px; }

.msg .nm, .msg > img, .msg .at { cursor: pointer; }

@media (max-width: 520px) {
  .pf-av { width: 64px; height: 64px; }
  .pf-name b { font-size: 19px; }
  .pf-actions button { font-size: 13px; gap: 6px; }
  .pf-games { grid-template-columns: repeat(3, 1fr); }
}
