/* MU Rivals theme: dark stone with a crimson accent and gold highlights. Shared by every page:
   header/nav, page banner, footer, cards, forms, tables, armory. Page-specific styles live in
   /css/<page>.css. */

/* === TOKENS === */
:root {
    --bg: #0d0d10;
    --bg-2: #141418;
    --panel: #1a1a20;
    --panel-2: #212128;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --text: #e9e3d7;
    --muted: #9c958a;
    --accent: #c8161d;
    --accent-2: #e8382c;
    --accent-soft: rgba(200, 22, 29, 0.14);
    --gold: #e2b65a;
    --primary: var(--gold);          /* kept: the original page scripts/styles use --primary */
    --ok: #3ccf7a;
    --bad: #ef5350;
    --radius: 10px;
    --header-h: 76px;
    --wrap: 1180px;
    --font-head: "Rajdhani", "Segoe UI", system-ui, sans-serif;
    --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
}

/* === BASE === */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; overflow-x: hidden; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    overflow-x: hidden;
}

a { color: var(--gold); }
[hidden] { display: none !important; }   /* component display rules must not override hidden */
img { max-width: 100%; }

h1, h2, h3, h4 {
    font-family: var(--font-head);
    font-weight: 700;
    line-height: 1.15;
    margin: 0;
}

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0 16px;
}

/* === HEADER / NAV === */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    /* Opaque on purpose: a backdrop-filter here would become the containing block of the
       position:fixed mobile menu and trap it inside the header. */
    background: linear-gradient(180deg, #0b0b0d, #121014);
    border-bottom: 1px solid var(--line);
}

.site-header .wrap {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}

.brand img { width: 44px; height: 44px; display: block; }

.brand-name {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.45rem;
    letter-spacing: 0.06em;
    color: #fff;
    line-height: 1;
}

.brand-name b { color: var(--accent-2); font-weight: 700; }

.main-nav {
    flex: 1;
    display: flex;
    justify-content: center;
    gap: 4px;
}

.main-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 12px;
    color: #cfc8bb;
    text-decoration: none;
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 0.98rem;
    letter-spacing: 0.02em;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
    white-space: nowrap;
}

.main-nav a svg { width: 20px; height: 20px; stroke: currentColor; opacity: 0.85; }

.main-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.04); }

.main-nav a.active { color: var(--accent-2); }
.main-nav a.active svg { opacity: 1; }

.header-side {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    font-size: 0.82rem;
    color: var(--muted);
    white-space: nowrap;
}

.status-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #666;
}

.status-pill.online .dot { background: var(--ok); box-shadow: 0 0 8px rgba(60, 207, 122, 0.7); }
.status-pill.offline .dot { background: var(--bad); }
.status-pill b { color: var(--text); font-weight: 600; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s, filter 0.2s, background 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.btn svg { width: 18px; height: 18px; stroke: currentColor; }
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }

.btn-primary {
    background: linear-gradient(180deg, var(--accent-2), var(--accent));
    color: #fff;
    box-shadow: 0 6px 20px rgba(200, 22, 29, 0.35);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    border-color: var(--line-strong);
}

.btn-ghost:hover { border-color: var(--accent-2); color: #fff; }

.btn-lg { padding: 14px 28px; font-size: 1.1rem; }

.nav-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    padding: 0;
    margin: 0;
}

.nav-toggle svg { width: 24px; height: 24px; stroke: currentColor; }

/* === PAGE BANNER (inner pages) === */
.page-banner {
    position: relative;
    padding: 56px 0 40px;
    background:
        linear-gradient(180deg, rgba(13, 13, 16, 0.55) 0%, rgba(13, 13, 16, 0.85) 70%, var(--bg) 100%),
        var(--banner-img, url('/img/site/battle.webp')) center 30% / cover no-repeat;
    border-bottom: 1px solid var(--line);
    text-align: center;
}

.page-banner h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
}

.page-banner p { margin: 8px 0 0; color: #c9c1b3; }

.divider {
    width: 220px;
    max-width: 60%;
    height: 12px;
    margin: 14px auto 0;
    background:
        linear-gradient(90deg, transparent, var(--accent) 30%, var(--accent) 70%, transparent) center / 100% 1px no-repeat;
    position: relative;
}

.divider::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;
    height: 10px;
    background: var(--accent-2);
    transform: translate(-50%, -50%) rotate(45deg);
    box-shadow: 0 0 10px rgba(232, 56, 44, 0.6);
}

/* === MAIN / CARD === */
main {
    flex: 1;
    width: 100%;
}

.page-body { padding: 36px 0 64px; }

.container {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    padding: 32px;
    background: linear-gradient(180deg, var(--panel), var(--bg-2));
    border: 1px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.stats-body .container,
.armory-body .container { max-width: 960px; }

/* The banner carries the page title; the card's own heading would repeat it. */
.page-body .container > h2:first-child { display: none; }

/* === FORMS === */
.form-group { margin-bottom: 1.1rem; }

label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--muted);
    text-transform: uppercase;
}

input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--line-strong);
    color: #fff;
    border-radius: 8px;
    font: inherit;
    transition: border-color 0.2s, background 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--accent-2);
    background: rgba(0, 0, 0, 0.5);
}

form button,
button[type="submit"] {
    width: 100%;
    margin-top: 1rem;
    padding: 14px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(180deg, var(--accent-2), var(--accent));
    color: #fff;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: filter 0.2s, transform 0.15s;
}

form button:hover,
button[type="submit"]:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* === MESSAGES === */
#message {
    margin-top: 1.4rem;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    display: none;
    font-size: 0.92rem;
}

.success { background: rgba(60, 207, 122, 0.12); color: var(--ok); border: 1px solid rgba(60, 207, 122, 0.5); }
.error { background: rgba(239, 83, 80, 0.12); color: var(--bad); border: 1px solid rgba(239, 83, 80, 0.5); }

.warning-box {
    background: var(--accent-soft);
    border-left: 3px solid var(--accent-2);
    padding: 10px 12px;
    font-size: 0.8rem;
    margin-top: 10px;
    color: #f0c9c4;
    border-radius: 0 6px 6px 0;
}

.spinner-loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.form-links {
    margin-top: 1.4rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--muted);
}

/* === TABLES (ranking) === */
table { width: 100%; border-collapse: collapse; }

th {
    text-align: left;
    color: var(--gold);
    text-transform: uppercase;
    font-family: var(--font-head);
    font-size: 0.9rem;
    letter-spacing: 0.06em;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line-strong);
}

td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
}

tbody tr { transition: background 0.2s; }
tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

.master-level { text-align: center; }
td.master-level { color: var(--accent-2); font-weight: 700; }

.char-name { font-weight: 700; color: #fff; }
.char-class { color: var(--muted); font-style: italic; font-size: 0.9rem; }

.rank-number {
    width: 48px;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--muted);
}

tbody tr:nth-child(1) .rank-number { color: #ffd34d; }
tbody tr:nth-child(2) .rank-number { color: #d5dbe3; }
tbody tr:nth-child(3) .rank-number { color: #d9935a; }
tbody tr:nth-child(1) .char-name { color: #ffd34d; text-shadow: 0 0 10px rgba(255, 211, 77, 0.35); }

.reset-badge {
    background: rgba(226, 182, 90, 0.12);
    color: var(--gold);
    border: 1px solid rgba(226, 182, 90, 0.4);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 10px;
}

.table-loader { text-align: center; padding: 20px; color: var(--muted); }

/* === SERVER STATUS (inner pages) === */
.server-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 0.88rem;
    color: var(--muted);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #666;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.online { background: var(--ok); box-shadow: 0 0 8px rgba(60, 207, 122, 0.6); animation: pulse 2s infinite; }
.status-dot.offline { background: var(--bad); }

@keyframes pulse { 50% { opacity: 0.5; } }

/* === ARMORY === */
.armory-search {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 1.8rem;
}

.armory-search input { flex: 1 1 auto; width: auto; min-width: 0; max-width: 320px; }

.armory-search button {
    flex: 0 0 auto;
    width: auto;
    margin-top: 0;
    padding: 12px 22px;
}

.armory-content { display: flex; gap: 1.5rem; align-items: flex-start; }

.armory-char {
    flex: 0 0 240px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.armory-char-image { width: 100%; max-width: 200px; height: auto; opacity: 0.9; }
.armory-char-name { color: var(--gold); font-family: var(--font-head); font-size: 1.4rem; font-weight: 700; margin-top: 0.5rem; }
.armory-char-class { color: var(--muted); font-style: italic; font-size: 0.9rem; margin-bottom: 0.8rem; }
.armory-char-stats { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; }
.armory-char-stats b { color: #fff; }

.armory-equip { flex: 1; min-height: 360px; display: flex; align-items: center; justify-content: center; }

.armory-doll {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 12px;
    width: 100%;
}

.armory-slot {
    position: relative;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.armory-slot.filled { border-color: rgba(226, 182, 90, 0.45); background: rgba(226, 182, 90, 0.07); cursor: help; }
.armory-slot img { max-width: 86%; max-height: 86%; object-fit: contain; image-rendering: pixelated; }
.armory-slot img.img-missing { visibility: hidden; }
.armory-slot .slot-label { color: #5b564f; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px; }

.armory-slot .badge { position: absolute; font-size: 0.6rem; font-weight: bold; padding: 1px 4px; border-radius: 4px; line-height: 1.2; }
.armory-slot .badge.exc { top: 3px; left: 3px; background: rgba(46, 204, 113, 0.85); color: #07210f; }
.armory-slot .badge.anc { top: 3px; right: 3px; background: rgba(255, 215, 0, 0.9); color: #2a2100; }
.armory-slot .badge.sock { bottom: 3px; right: 3px; background: rgba(155, 89, 182, 0.9); color: #fff; }

.armory-message { text-align: center; color: var(--muted); padding: 1rem; }
.armory-message.error { color: var(--bad); }

.item-tooltip {
    display: none;
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    max-width: 320px;
    padding: 10px 13px;
    background: rgba(14, 14, 16, 0.96);
    border: 1px solid rgba(226, 182, 90, 0.4);
    border-top: 3px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75);
    font-size: 0.8rem;
    line-height: 1.55;
    color: #cfcfcf;
}

.item-tooltip .tip-head { color: var(--gold); font-weight: bold; margin-bottom: 5px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.item-tooltip .tip-line.opt { color: #4aa3ff; }
.item-tooltip .tip-line.exc { color: #2ecc71; }
.item-tooltip .tip-line.skill { color: #fff; }
.item-tooltip .tip-line.sock { color: #b18bd8; }

/* === FOOTER === */
.site-footer {
    margin-top: auto;
    border-top: 1px solid var(--line);
    background: linear-gradient(180deg, #111114, #0a0a0c);
    padding: 40px 0 28px;
    color: var(--muted);
    font-size: 0.9rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 32px;
}

.footer-grid h4 {
    color: var(--text);
    font-size: 1.05rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer-grid a { color: var(--muted); text-decoration: none; }
.footer-grid a:hover { color: #fff; }
.footer-about p { margin: 12px 0 0; max-width: 360px; }

.footer-legal {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    font-size: 0.78rem;
    color: #6d675f;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
}

.footer-legal a { color: #6d675f; }

/* === LANGUAGE SWITCH === */
.lang-switch { position: relative; }

.lang-current {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: auto;
    margin: 0;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 0.92rem;
    letter-spacing: 0.04em;
    text-transform: none;
    box-shadow: none;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.lang-current:hover,
.lang-switch.open .lang-current { border-color: var(--gold); background: rgba(226, 182, 90, 0.08); transform: none; box-shadow: none; }

.lang-current svg { width: 14px; height: 14px; stroke: currentColor; transition: transform 0.2s; }
.lang-switch.open .lang-current svg { transform: rotate(180deg); }

.lang-flag {
    display: block;
    width: 22px;
    height: 16px;
    border-radius: 3px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
}

.lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 200;
    min-width: 200px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

.lang-switch.open .lang-menu { opacity: 1; visibility: visible; transform: none; }

.lang-menu button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 9px 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #cfc8bb;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.95rem;
    letter-spacing: 0;
    text-transform: none;
    text-align: left;
    box-shadow: none;
    cursor: pointer;
}

.lang-menu button:hover { background: rgba(255, 255, 255, 0.06); color: #fff; transform: none; box-shadow: none; }
.lang-menu button.active { color: var(--gold); background: rgba(226, 182, 90, 0.1); }

/* Rajdhani has no Vietnamese letters (ế, ộ, ữ...): Vietnamese headings use Chakra Petch. */
html[lang^="vi"] { --font-head: "Chakra Petch", "Segoe UI", system-ui, sans-serif; }

/* === RESPONSIVE === */
/* The header fits itself to the width and the language (site.js): when the menu does not fit,
   it drops in steps the status pill (fit-1), the play button (fit-2) and the account button's
   label (fit-3), then switches to the mobile menu (collapsed). */
.site-header.fit-1 .status-pill,
.site-header.fit-2 .play-btn { display: none; }
.site-header.fit-3 .account-btn { padding: 9px 11px; }
.site-header.fit-3 .account-btn span { display: none; }

@media (max-width: 1100px) {
    .main-nav a { padding: 8px 8px; font-size: 0.92rem; }
}

@media (max-width: 900px) {
    :root { --header-h: 64px; }
    .brand-name { font-size: 1.25rem; }
    .brand img { width: 38px; height: 38px; }

    .footer-grid { grid-template-columns: 1fr 1fr; }
    .footer-about { grid-column: 1 / -1; }
}

.site-header.collapsed .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
.site-header.collapsed .header-side .btn,
.site-header.collapsed .status-pill { display: none; }

.site-header.collapsed .main-nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    bottom: 0;
    flex-direction: column;
    justify-content: flex-start;
    gap: 2px;
    padding: 12px 16px 24px;
    background: rgba(10, 10, 12, 0.98);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
}

.site-header.collapsed .main-nav.open { transform: none; }

.site-header.collapsed .main-nav a {
    flex-direction: row;
    gap: 14px;
    padding: 14px 12px;
    font-size: 1.15rem;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
}

.site-header.collapsed .main-nav .nav-cta { display: flex; margin-top: 16px; border: none; justify-content: center; }

.site-header.collapsed .header-side { margin-left: auto; }

.site-header:not(.collapsed) .main-nav .nav-cta,
.site-header:not(.collapsed) .main-nav .nav-mobile-only { display: none; }

.account-btn { padding: 9px 16px; }

@media (max-width: 640px) {
    .armory-content { flex-direction: column; }
    .armory-char { flex: none; width: 100%; }
}

@media (max-width: 480px) {
    body { font-size: 14px; }
    .container { padding: 22px 16px; }
    th, td { padding: 9px 7px; font-size: 0.85rem; }
    .page-banner { padding: 40px 0 28px; }
    .footer-grid { grid-template-columns: 1fr; }
}
