/* ============================================================================
   Reliquary — base + components
   ========================================================================== */

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

/* The [hidden] attribute must always win — component display rules
   (flex/grid/inline-flex) otherwise override it and "hidden" UI leaks. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 50% -10%, rgba(74, 144, 217, 0.06), transparent 60%),
        var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

/* World location art behind every page, on a fixed viewport-sized layer
   (background-attachment: fixed tears/seams on some zoom levels and mobile).
   The scrim on top keeps panels readable. play.php opts out via .bare-bg. */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(180deg, rgba(14, 14, 18, 0.42) 0%, rgba(14, 14, 18, 0.55) 45%, rgba(14, 14, 18, 0.8) 100%),
        url('../img/world-bg.jpg') center / cover no-repeat,
        var(--bg);
}
body.bare-bg::before { content: none; }

a { color: inherit; text-decoration: none; }

h1, h2, h3 { margin: 0 0 var(--space-3); font-weight: 600; line-height: 1.2; }

/* Mono numerals — stats read like an instrument panel. */
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* --- Layout --------------------------------------------------------------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(6px);
}

.brand {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: 0.18em;
    color: var(--text);
}

.topnav { display: flex; align-items: center; gap: var(--space-5); }
.topnav a { color: var(--text-muted); font-size: 0.95rem; transition: color var(--dur) var(--ease-out); }
.topnav a:hover { color: var(--text); }
.game-nav { flex: 1; margin-left: var(--space-6); }

/* Wallet chips */
.wallet { display: inline-flex; gap: var(--space-3); }
.coin { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 0.9rem; }
.coin::before { content: ""; width: 10px; height: 10px; border-radius: 50%; }
.coin.gold::before { background: var(--sodium); box-shadow: 0 0 8px rgba(242, 169, 59, 0.5); }
.coin.dust::before { background: var(--azure); box-shadow: 0 0 8px rgba(74, 144, 217, 0.5); }
.coin .num { color: var(--text); font-weight: 600; }

.main {
    flex: 1 0 auto;
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding: var(--space-7) var(--space-5);
}

.footer {
    flex-shrink: 0;
    padding: var(--space-5) var(--space-6);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* --- Panels / cards ------------------------------------------------------- */
.panel {
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
}

.auth-wrap {
    max-width: 420px;
    margin: var(--space-6) auto;
}

/* Реликварий: тёплый тёмный ларец с двойной золотой рамкой вместо
   нейтральной панели — форма входа как часть мира, не как веб-форма. */
.auth-card {
    position: relative;
    padding: var(--space-7);
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(242, 169, 59, 0.08), transparent 55%),
        linear-gradient(180deg, rgba(31, 27, 21, 0.96), rgba(16, 14, 12, 0.97));
    border: 1px solid rgba(242, 169, 59, 0.30);
    box-shadow: var(--shadow-2), inset 0 0 46px rgba(0, 0, 0, 0.35);
}
.auth-card::before {
    content: '';
    position: absolute; inset: 9px;
    border: 1px solid rgba(242, 169, 59, 0.14);
    border-radius: calc(var(--radius-lg) - 7px);
    pointer-events: none;
}
.auth-card h1 {
    font-family: var(--font-display);
    font-size: 2.1rem;
    letter-spacing: 0.05em;
    text-align: center;
    margin-bottom: var(--space-2);
    color: var(--bone);
}
.auth-card h1::after {
    content: '✦';
    display: block;
    margin-top: var(--space-2);
    font-size: 0.75rem;
    line-height: 1;
    color: rgba(242, 169, 59, 0.85);
    background: linear-gradient(90deg, transparent, rgba(242, 169, 59, 0.45), transparent) center / 170px 1px no-repeat;
}
.auth-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: var(--space-6);
    font-size: 0.95rem;
}

/* --- Forms ---------------------------------------------------------------- */
.field { margin-bottom: var(--space-4); }
.field label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.input {
    width: 100%;
    padding: 0.7rem 0.85rem;
    font: inherit;
    color: var(--text);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.input::placeholder { color: rgba(138, 138, 150, 0.6); }
.input:focus {
    outline: none;
    border-color: rgba(242, 169, 59, 0.65);
    box-shadow: 0 0 0 3px rgba(242, 169, 59, 0.18);
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;
    padding: 0.72rem 1rem;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: var(--radius);
    transition: transform var(--dur-fast) var(--ease-out), background var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Primary action — RPG-плашка: тёмная кованая сталь в литой золотой раме,
   ромбы-заклёпки по краям, гравированный текст и пробегающий блик.
   Рама — металлический градиент через background-clip: border-box. */
.btn-primary {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    border: 1px solid transparent;
    background:
        radial-gradient(130% 120% at 50% -20%, rgba(255, 216, 140, 0.18), transparent 55%),
        linear-gradient(180deg, #3d2f1a 0%, #261b0e 52%, #170f07 100%) padding-box,
        linear-gradient(180deg, #f3cc79 0%, #8a6222 38%, #5c3f13 55%, #a87c2c 78%, #f0c874 100%) border-box;
    color: #f4d488;
    font-family: var(--font-display);
    font-size: 1.08em;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85), 0 0 14px rgba(242, 169, 59, 0.35);
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.6),
        inset 0 0 0 2px rgba(244, 202, 116, 0.22),
        inset 0 10px 16px -10px rgba(255, 221, 150, 0.28),
        inset 0 -8px 14px -10px rgba(0, 0, 0, 0.8),
        0 4px 14px rgba(0, 0, 0, 0.5);
    transition:
        color var(--dur) var(--ease-out),
        box-shadow var(--dur) var(--ease-out),
        transform var(--dur-fast) var(--ease-out);
}

/* Ромбы-заклёпки слева и справа от надписи. */
.btn-primary::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(circle 3.5px at 14px 50%, #f7d488 0 1.6px, #5c3f13 2.2px, transparent 3.2px),
        radial-gradient(circle 3.5px at calc(100% - 14px) 50%, #f7d488 0 1.6px, #5c3f13 2.2px, transparent 3.2px);
    pointer-events: none;
}

/* Блик, пробегающий по пластине при наведении. */
.btn-primary::after {
    content: '';
    position: absolute; top: -20%; bottom: -20%; left: -60%; width: 45%;
    background: linear-gradient(105deg, transparent, rgba(255, 233, 175, 0.30), transparent);
    transform: skewX(-20deg);
    transition: left 0.55s var(--ease-out);
    pointer-events: none;
}

.btn-primary:hover {
    color: #ffe9b0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85), 0 0 18px rgba(255, 200, 100, 0.6);
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.6),
        inset 0 0 0 2px rgba(255, 219, 140, 0.38),
        inset 0 10px 16px -10px rgba(255, 228, 165, 0.4),
        inset 0 -8px 14px -10px rgba(0, 0, 0, 0.8),
        0 4px 18px rgba(0, 0, 0, 0.5),
        0 0 22px rgba(242, 169, 59, 0.3);
}
.btn-primary:hover::after { left: 120%; }

.btn-primary:active {
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.7),
        inset 0 0 0 2px rgba(244, 202, 116, 0.2),
        inset 0 4px 12px rgba(0, 0, 0, 0.6),
        0 2px 8px rgba(0, 0, 0, 0.5);
}
.btn-primary:disabled:hover::after { left: -60%; }

.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--text-muted); }

.btn-twitch { background: var(--twitch); color: #fff; font-weight: 600; }
.btn-twitch:hover { background: color-mix(in srgb, var(--twitch) 88%, white); }

/* Keyboard focus is always visible (quality floor). */
:focus-visible { outline: 2px solid var(--sodium); outline-offset: 2px; }

/* --- Divider "или" -------------------------------------------------------- */
.divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-5) 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* --- Alerts (voice of the interface) ------------------------------------- */
.alert {
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: var(--space-4);
    border: 1px solid transparent;
}
.alert-error { background: rgba(255, 92, 122, 0.10); border-color: rgba(255, 92, 122, 0.35); color: #ffb3c1; }
.alert-info  { background: rgba(74, 144, 217, 0.10); border-color: rgba(74, 144, 217, 0.30); color: #bcd9f6; }
.alert-ok    { background: rgba(87, 194, 138, 0.10); border-color: rgba(87, 194, 138, 0.30); color: #b6e8cd; }

/* --- Auth meta links ------------------------------------------------------ */
.auth-meta { margin-top: var(--space-5); text-align: center; font-size: 0.9rem; color: var(--text-muted); }
.auth-meta a { color: #eeb85e; }
.auth-meta a:hover { text-decoration: underline; }

/* --- Recovery code -------------------------------------------------------- */
.recovery-box {
    margin: var(--space-4) 0;
    padding: var(--space-4);
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed var(--rarity-legendary);
    border-radius: var(--radius);
}
.recovery-code {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    letter-spacing: 0.12em;
    color: var(--rarity-legendary);
    word-break: break-all;
}

/* --- Landing hero --------------------------------------------------------- */
.hero { text-align: center; padding: var(--space-8) 0; }
.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 4rem);
    letter-spacing: 0.04em;
}
.hero p { color: var(--text-muted); max-width: 40ch; margin: 0 auto var(--space-6); font-size: 1.05rem; }
.hero-actions { display: flex; gap: var(--space-3); justify-content: center; flex-wrap: wrap; }
.hero-actions .btn { width: auto; padding-inline: var(--space-6); }

/* --- Dashboard tiles ------------------------------------------------------ */
.greet { margin-bottom: var(--space-6); }
.greet .name { font-family: var(--font-display); font-size: 2rem; }

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-4);
}
.tile {
    position: relative;
    padding: var(--space-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: transform var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.tile:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.tile h3 { font-size: 1.1rem; margin-bottom: var(--space-1); }
.tile p { margin: 0; color: var(--text-muted); font-size: 0.85rem; }
.tile.tile-primary { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow-1); }
.tile.tile-primary h3 { color: var(--accent); }
.tile.locked { opacity: 0.55; }
.tile .soon {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    padding: 2px 8px;
}

/* --- Badges --------------------------------------------------------------- */
.badge {
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em;
    padding: 2px 9px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong);
    color: var(--text-muted);
}
.badge.ok { color: var(--ok); border-color: rgba(87, 194, 138, 0.4); }
.badge.warn { color: var(--sodium); border-color: rgba(242, 169, 59, 0.4); }

/* --- Page head / filters -------------------------------------------------- */
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-3);
}
.page-head h1 { margin: 0; }
.filters { display: flex; align-items: center; gap: var(--space-4); }
.filters .input { padding: 0.45rem 0.7rem; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-muted); cursor: pointer; }
.muted-line { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 var(--space-5); }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 560px) {
    .topbar { padding: var(--space-3) var(--space-4); flex-wrap: wrap; gap: var(--space-2); }
    .game-nav { order: 3; margin-left: 0; width: 100%; gap: var(--space-4); }
    .main { padding: var(--space-5) var(--space-4); }
    .auth-card { padding: var(--space-5); }
}
