@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@600;700&family=Rajdhani:wght@500;600;700&display=swap');

:root {
    --bg-0: #05070d;
    --bg-1: #0b1220;
    --bg-2: #121c2e;
    --panel: rgba(12, 20, 36, 0.82);
    --panel-solid: #101a2c;
    --line: rgba(102, 192, 244, 0.22);
    --line-strong: rgba(102, 192, 244, 0.45);
    --text: #e8f1f8;
    --muted: #8ba3b8;
    --accent: #66c0f4;
    --accent-2: #1a9fff;
    --cyan: #3de0c5;
    --gold: #ffc857;
    --danger: #ff5d6c;
    --ok: #3ddc97;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    --font: 'Rajdhani', 'Segoe UI', sans-serif;
    --display: 'Orbitron', 'Rajdhani', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-0);
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(1200px 700px at 12% -10%, rgba(26, 159, 255, 0.22), transparent 55%),
        radial-gradient(900px 600px at 110% 10%, rgba(61, 224, 197, 0.14), transparent 50%),
        radial-gradient(800px 500px at 50% 110%, rgba(255, 109, 53, 0.08), transparent 50%),
        linear-gradient(180deg, #070b14 0%, #0b1220 45%, #05070d 100%);
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(102, 192, 244, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(102, 192, 244, 0.04) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center, #000 40%, transparent 80%);
}

.container {
    max-width: 620px;
    margin: 0 auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
    position: relative;
    backdrop-filter: blur(18px);
}

.container::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), var(--cyan), transparent);
    z-index: 2;
}

body.page-admin .container {
    max-width: 1200px;
}

.header {
    background:
        linear-gradient(180deg, rgba(26, 159, 255, 0.18), transparent 70%),
        linear-gradient(135deg, #10203a 0%, #0c1628 100%);
    color: white;
    padding: 36px 28px 28px;
    text-align: center;
    position: relative;
}

.page-home .header {
    padding-top: 58px;
}

.header h1 {
    font-family: var(--display);
    font-size: 2.1em;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
    text-shadow: 0 0 24px rgba(102, 192, 244, 0.45);
}

.header p {
    opacity: 0.85;
    font-size: 1.15em;
    color: var(--muted);
    font-weight: 600;
}

.content {
    padding: 36px 32px 40px;
}

.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.92em;
    color: var(--accent);
}

.form-group select,
.form-group input,
.form-group textarea,
input[type="password"],
input[type="text"],
select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 16px;
    font-family: var(--font);
    font-weight: 600;
    color: var(--text);
    background: rgba(5, 10, 18, 0.72);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus,
input[type="password"]:focus,
input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(102, 192, 244, 0.18), 0 0 22px rgba(26, 159, 255, 0.2);
    background: rgba(8, 16, 28, 0.92);
}

.btn,
.login-container button:not(.language-btn),
button[type="submit"]:not(.language-btn) {
    background: linear-gradient(135deg, #1a9fff 0%, #1070c4 55%, #0d5aa3 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 15px 30px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    width: 100%;
    box-shadow: 0 10px 24px rgba(16, 112, 196, 0.35);
}

.page-admin .btn {
    width: auto;
    padding: 10px 18px;
    font-size: 14px;
    margin: 5px;
    letter-spacing: 0.04em;
}

.btn:hover,
.login-container button:not(.language-btn):hover,
button[type="submit"]:not(.language-btn):hover {
    transform: translateY(-2px);
    filter: brightness(1.08);
    box-shadow: 0 14px 30px rgba(26, 159, 255, 0.45);
}

.btn:disabled,
.btn-get-code:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

.btn-danger {
    background: linear-gradient(135deg, #e54858 0%, #b42334 100%);
    box-shadow: 0 8px 20px rgba(180, 35, 52, 0.35);
}

.btn-success {
    background: linear-gradient(135deg, #2ecc8a 0%, #1a9b64 100%);
    box-shadow: 0 8px 20px rgba(26, 155, 100, 0.35);
}

.btn-warning {
    background: linear-gradient(135deg, #ffc857 0%, #e0a800 100%);
    color: #1a1404;
    box-shadow: 0 8px 20px rgba(224, 168, 0, 0.3);
}

.game-info,
.code-game-info {
    background: linear-gradient(180deg, rgba(26, 159, 255, 0.1), rgba(8, 14, 24, 0.6));
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px 20px;
    margin: 18px 0;
    display: none;
}

.game-info h3,
.code-game-info h3 {
    color: var(--text);
    margin-bottom: 10px;
    font-family: var(--display);
    font-size: 1.05em;
    letter-spacing: 0.04em;
}

.game-info p,
.code-game-info p {
    color: var(--muted);
    margin-bottom: 8px;
}

.tabs,
.code-tabs {
    display: flex;
    margin: 18px 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: rgba(5, 10, 18, 0.55);
}

.tab,
.code-tab {
    flex: 1;
    padding: 14px 10px;
    text-align: center;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-family: var(--font);
    font-size: 15px;
    color: var(--muted);
    transition: all 0.25s ease;
}

.tab.active,
.code-tab.active {
    background: linear-gradient(180deg, rgba(26, 159, 255, 0.35), rgba(26, 159, 255, 0.08));
    color: white;
    box-shadow: inset 0 -2px 0 var(--accent);
}

.tab:hover,
.code-tab:hover {
    color: var(--text);
}

.result,
.code-result {
    margin-top: 20px;
    padding: 18px;
    border-radius: 12px;
    text-align: center;
    font-weight: 700;
    display: none;
    letter-spacing: 0.04em;
}

.result.success,
.code-result.success {
    background: rgba(61, 220, 151, 0.12);
    color: #9af0c8;
    border: 1px solid rgba(61, 220, 151, 0.35);
    box-shadow: 0 0 24px rgba(61, 220, 151, 0.12);
    font-family: var(--display);
    font-size: 1.2em;
    letter-spacing: 0.08em;
}

.result.error,
.code-result.error {
    background: rgba(255, 93, 108, 0.12);
    color: #ffb3bb;
    border: 1px solid rgba(255, 93, 108, 0.35);
}

.result small {
    display: block;
    margin-top: 8px;
    opacity: 0.8;
    font-size: 0.9em;
}

.timer {
    background: linear-gradient(135deg, rgba(26, 159, 255, 0.28), rgba(13, 90, 163, 0.35));
    color: white;
    padding: 18px;
    border-radius: 14px;
    margin: 20px 0;
    text-align: center;
    border: 1px solid var(--line-strong);
    box-shadow: 0 0 28px rgba(26, 159, 255, 0.18);
}

.timer-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.timer-icon {
    font-size: 2em;
}

.timer-text {
    text-align: left;
}

.timer-label {
    font-size: 0.95em;
    opacity: 0.9;
    margin-bottom: 5px;
}

.timer-time {
    font-size: 1.9em;
    font-weight: 700;
    font-family: var(--display);
    letter-spacing: 0.12em;
    text-shadow: 0 0 16px rgba(102, 192, 244, 0.6);
}

.timers {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 20px 0;
}

.timers.hidden {
    display: none;
}

.timers .timer {
    margin: 0;
}

.language-switcher {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 1000;
}

.page-login .language-switcher {
    position: static;
    margin-bottom: 18px;
    text-align: center;
}

.language-btn {
    background: rgba(8, 16, 28, 0.55);
    color: var(--text);
    border: 1px solid var(--line);
    padding: 7px 12px;
    margin: 0 2px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font);
    font-weight: 700;
    width: auto;
    letter-spacing: 0;
    text-transform: none;
    box-shadow: none;
    transition: all 0.2s ease;
}

.language-btn:hover {
    background: rgba(26, 159, 255, 0.2);
    transform: translateY(-1px);
}

.language-btn.active {
    background: rgba(26, 159, 255, 0.35);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 12px rgba(102, 192, 244, 0.25);
}

[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .language-switcher {
    right: auto;
    left: 18px;
}

[dir="rtl"] .form-group {
    text-align: right;
}

[dir="rtl"] .tabs {
    flex-direction: row-reverse;
}

[dir="rtl"] .timer-text {
    text-align: right;
}

.game-autocomplete {
    position: relative;
}

.game-autocomplete input {
    width: 100%;
    padding-right: 44px;
}

.game-autocomplete input::-ms-clear,
.game-autocomplete input::-webkit-search-cancel-button {
    display: none;
    width: 0;
    height: 0;
}

.game-search-clear {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: rgba(102, 192, 244, 0.12);
    color: var(--text);
    font-size: 20px;
    line-height: 1;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    z-index: 3;
    box-shadow: none;
    text-transform: none;
    letter-spacing: 0;
}

.game-search-clear:hover {
    background: rgba(255, 93, 108, 0.28);
    color: #fff;
    transform: translateY(-50%);
    filter: none;
}

.game-search-clear[hidden] {
    display: none !important;
}

[dir="rtl"] .game-autocomplete input {
    padding-right: 16px;
    padding-left: 44px;
}

[dir="rtl"] .game-search-clear {
    right: auto;
    left: 8px;
}

.game-suggestions {
    display: none;
    position: absolute;
    top: calc(100% - 2px);
    left: 0;
    right: 0;
    background: #0d1626;
    border: 1px solid var(--accent);
    border-top: none;
    border-radius: 0 0 12px 12px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
}

.game-suggestions.open {
    display: block;
}

.game-suggestion-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    transition: background 0.15s ease;
    color: var(--text);
}

.game-suggestion-item:last-child {
    border-bottom: none;
}

.game-suggestion-item:hover,
.game-suggestion-item.active {
    background: rgba(26, 159, 255, 0.18);
    color: var(--accent);
}

.game-suggestion-empty {
    padding: 12px 15px;
    color: var(--danger);
    font-size: 0.95em;
}

.login-container {
    background: var(--panel);
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

body.page-login {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.login-container h1 {
    margin: 0 0 12px;
    text-align: center;
    color: var(--text);
    font-family: var(--display);
    font-size: 1.45em;
    letter-spacing: 0.04em;
}

.login-container p {
    margin: 0 0 28px;
    text-align: center;
    color: var(--muted);
    font-weight: 600;
}

.login-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.92em;
}

.login-container input[type="password"] {
    margin-bottom: 20px;
}

.login-container .error,
.error {
    background: rgba(255, 93, 108, 0.12);
    color: #ffb3bb;
    border: 1px solid rgba(255, 93, 108, 0.35);
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
}

.back-link,
.logout-btn {
    position: absolute;
    top: 18px;
    color: white;
    text-decoration: none;
    background: rgba(8, 16, 28, 0.45);
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    font-weight: 700;
    font-size: 13px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.back-link {
    left: 18px;
}

.logout-btn {
    right: 18px;
}

.back-link:hover,
.logout-btn:hover {
    background: rgba(26, 159, 255, 0.25);
    border-color: var(--accent);
}

.section {
    margin-bottom: 40px;
}

.section h2 {
    color: var(--text);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent);
    font-family: var(--display);
    font-size: 1.15em;
    letter-spacing: 0.06em;
}

.status-pending,
.status-approved,
.status-rejected {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.85em;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.status-pending {
    background: rgba(255, 200, 87, 0.2);
    color: var(--gold);
}

.status-approved {
    background: rgba(61, 220, 151, 0.2);
    color: var(--ok);
}

.status-rejected {
    background: rgba(255, 93, 108, 0.2);
    color: var(--danger);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

th {
    background: rgba(26, 159, 255, 0.1);
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.85em;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--panel-solid);
    margin: 5% auto;
    padding: 24px;
    border-radius: 16px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.close {
    color: var(--muted);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: var(--text);
}

.hidden {
    display: none;
}

.nav {
    display: flex;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--line);
    gap: 4px;
}

.nav-item {
    padding: 12px 18px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.03em;
}

.nav-item.active {
    border-bottom-color: var(--accent);
    color: var(--accent);
}

.nav-item:hover {
    background: rgba(26, 159, 255, 0.08);
    color: var(--text);
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.12);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.codes-panel {
    max-width: 600px;
}

.codes-badge,
.partner-badge {
    display: inline-block;
    color: #081018;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 20px;
    letter-spacing: 0.08em;
}

.codes-badge {
    background: linear-gradient(135deg, var(--ok) 0%, #1a9b64 100%);
    color: #062214;
}

.partner-badge {
    background: linear-gradient(135deg, #ffd76a 0%, #ffc857 100%);
}

.btn-get-code {
    width: 100%;
    padding: 15px 30px;
    font-size: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.stats-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 20px;
    background: rgba(8, 14, 24, 0.55);
}

.stats-card h3 {
    margin: 0 0 12px;
    color: var(--text);
    font-size: 1.1em;
    font-family: var(--display);
}

.stats-card .meta {
    color: var(--muted);
    font-size: 0.95em;
    margin-bottom: 16px;
}

.stats-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stats-metric {
    background: rgba(5, 10, 18, 0.7);
    border-radius: 10px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-metric .label {
    font-size: 0.85em;
    color: var(--muted);
    margin-bottom: 4px;
}

.stats-metric .value {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--accent);
    font-family: var(--display);
}

.stats-card .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.page-partner .header {
    padding: 70px 20px 30px;
}

.page-partner .header h1 {
    font-size: 1.7em;
}

@media (max-width: 768px) {
    body.page-admin {
        padding: 10px;
    }

    body.page-admin .container {
        overflow: visible;
    }

    body.page-admin .content {
        padding: 16px;
    }

    body.page-admin .header h1 {
        font-size: 1.25em;
    }

    body.page-admin .back-link,
    body.page-admin .logout-btn {
        position: static;
        display: inline-block;
        margin: 4px;
    }

    .nav {
        flex-wrap: wrap;
    }

    .nav-item {
        flex: 1 1 auto;
        min-width: calc(50% - 4px);
        text-align: center;
        font-size: 13px;
        padding: 10px 8px;
    }

    .admin-table {
        border: 0;
    }

    .admin-table thead {
        display: none;
    }

    .admin-table tbody tr {
        display: block;
        margin-bottom: 16px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: rgba(8, 14, 24, 0.65);
        overflow: hidden;
    }

    .admin-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 10px 14px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        text-align: right;
    }

    .admin-table td:last-child {
        border-bottom: none;
    }

    .admin-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--muted);
        text-align: left;
        flex-shrink: 0;
        max-width: 45%;
    }

    .admin-table td.actions-cell {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-table td.actions-cell::before {
        margin-bottom: 6px;
    }

    .admin-table td.actions-cell .btn {
        width: 100%;
        margin: 4px 0;
    }
}

@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    .header h1 {
        font-size: 1.45em;
    }

    .content {
        padding: 24px 18px 28px;
    }

    .page-partner .header {
        padding: 60px 15px 25px;
    }

    .language-btn {
        font-size: 11px;
        padding: 5px 8px;
    }

    .logout-btn {
        font-size: 12px;
        padding: 5px 10px;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 28px 20px;
    }

    .login-container h1 {
        font-size: 1.25em;
    }
}

.user-search-box {
    max-width: 420px;
}

.user-row {
    cursor: pointer;
}

.user-row:hover td {
    background: rgba(26, 159, 255, 0.08);
}

.user-row.selected td {
    background: rgba(26, 159, 255, 0.16);
}

.user-stats-panel {
    margin-top: 28px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(8, 14, 24, 0.55);
}

.user-stats-panel h3 {
    margin-bottom: 8px;
    font-family: var(--display);
    font-size: 1.05em;
}

.user-stats-panel .meta {
    color: var(--muted);
    margin-bottom: 16px;
}

.user-stats-panel .stats-card-actions {
    margin-bottom: 16px;
}
