@font-face {
    font-family: "Speda";
    src:
        local("Speda"),
        local("Speda Regular"),
        url("assets/fonts/Speda.woff2") format("woff2"),
        url("assets/fonts/Speda.ttf") format("truetype");
    font-display: swap;
}

:root {
    --page-bg: #2a243e;
    --panel-border: #0c111a;
    --text: #f3f5fb;
    --muted: #a6adbf;
    --field-bg: #232935;
    --field-border: #2f3646;
    --field-focus: #8a63f5;
    --button-a: #6f46e8;
    --button-b: #8f63ff;
    --success-bg: rgba(16, 185, 129, 0.16);
    --success-text: #9ff2cf;
    --error-bg: rgba(239, 68, 68, 0.16);
    --error-text: #ffc8c8;
    --loader-bg: rgba(11, 12, 19, 0.9);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: "Speda", "Noto Sans Arabic", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 50% -15%, #4b3a7f 0%, var(--page-bg) 34%, #262136 100%);
    overflow-x: hidden;
    direction: rtl;
    text-align: right;
}

body:not(.is-ready) {
    overflow: hidden;
}

input,
button,
select,
textarea {
    font-family: inherit;
}

.page-loader {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: var(--loader-bg);
    display: grid;
    place-items: center;
    gap: 12px;
    text-align: center;
    transition: opacity 0.45s ease, visibility 0.45s ease;
}

.loader-ring {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: 4px solid rgba(161, 130, 255, 0.25);
    border-top-color: #8a63f5;
    animation: spin 0.85s linear infinite;
}

.page-loader p {
    margin: 0;
    font-size: 0.95rem;
    color: #d8ccff;
}

body.is-ready .page-loader {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.bg-shape {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(60px);
}

.bg-shape-1 {
    width: 320px;
    height: 320px;
    top: -80px;
    left: -60px;
    background: rgba(126, 87, 255, 0.55);
}

.bg-shape-2 {
    width: 300px;
    height: 300px;
    right: -80px;
    bottom: -80px;
    background: rgba(103, 58, 183, 0.4);
}

.page-wrap {
    min-height: 100vh;
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: 16px;
    position: relative;
    z-index: 1;
}

.panel {
    width: 100%;
    min-height: calc(100vh - 32px);
    background:
        radial-gradient(circle at 15% 0%, rgba(126, 87, 255, 0.23), transparent 32%),
        radial-gradient(circle at 85% 0%, rgba(141, 104, 255, 0.2), transparent 32%),
        linear-gradient(125deg, #1d2230 0%, #171b25 60%, #121722 100%);
    border: 1px solid var(--panel-border);
    border-radius: 38px;
    box-shadow:
        0 22px 45px rgba(0, 0, 0, 0.44),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    padding: 32px 34px;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

body.is-ready .panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.back-link {
    display: inline-block;
    margin-bottom: 10px;
    text-decoration: none;
    color: #d6c8ff;
    border: 1px solid #5b46a7;
    background: rgba(94, 70, 173, 0.22);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.82rem;
    transition: background 0.2s ease, transform 0.2s ease;
}

.back-link:hover {
    background: rgba(109, 80, 200, 0.34);
    transform: translateY(-1px);
}

.eyebrow {
    margin: 0;
    color: #9b87ce;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
}

h1 {
    margin: 10px 0 8px;
    font-family: inherit;
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    line-height: 1.15;
}

.subtext {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 0.98rem;
}

.alert {
    border-radius: 14px;
    padding: 11px 13px;
    margin-bottom: 14px;
    font-size: 0.93rem;
}

.alert ul {
    margin: 0;
    padding-left: 18px;
}

.alert.success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.alert.error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.entry-form {
    margin-top: 12px;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #d9def0;
    font-size: 0.93rem;
}

.field-group.full {
    grid-column: 1 / -1;
}

.field-group input[type="text"] {
    width: 100%;
    height: 54px;
    border: 1px solid var(--field-border);
    border-radius: 12px;
    background: linear-gradient(90deg, #242a37 0%, #1f2431 100%);
    color: #f4f7ff;
    font-size: 1rem;
    padding: 0 16px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field-group input[type="text"]::placeholder {
    color: #8f96ab;
}

.field-group input[type="text"]:focus {
    border-color: var(--field-focus);
    box-shadow: 0 0 0 3px rgba(138, 99, 245, 0.2);
}

.upload-card {
    display: grid;
    grid-template-columns: 142px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    border: 1px solid #313a4f;
    border-radius: 14px;
    background: linear-gradient(130deg, rgba(38, 45, 62, 0.95), rgba(28, 33, 46, 0.95));
    padding: 12px;
}

.preview-box {
    width: 142px;
    height: 142px;
    border-radius: 12px;
    border: 1px dashed #5a4b8f;
    background: linear-gradient(135deg, rgba(143, 99, 255, 0.14), rgba(43, 52, 71, 0.2));
    display: grid;
    place-items: center;
    overflow: hidden;
    position: relative;
}

#previewImage {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

#previewImage.show {
    display: block;
}

#previewPlaceholder {
    font-size: 0.8rem;
    color: #b9b2d5;
    text-align: center;
    width: 80%;
}

.upload-actions {
    display: grid;
    gap: 10px;
}

.hidden-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.choose-image-btn {
    border: 1px solid #5b46a7;
    border-radius: 12px;
    padding: 11px 14px;
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 600;
    color: #f3edff;
    background: linear-gradient(135deg, rgba(102, 67, 214, 0.86), rgba(74, 44, 167, 0.9));
    box-shadow: 0 8px 16px rgba(80, 48, 182, 0.35);
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.choose-image-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.file-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
    word-break: break-all;
}

.submit-btn {
    margin-top: 18px;
    border: none;
    border-radius: 999px;
    padding: 14px 30px;
    font-family: inherit;
    font-size: 1.12rem;
    font-weight: 600;
    color: #f8f8ff;
    background: linear-gradient(135deg, var(--button-a), var(--button-b));
    box-shadow: 0 10px 22px rgba(105, 70, 224, 0.45);
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.submit-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.quick-links {
    margin-top: 16px;
}

.view-players-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: 1px solid #2d5f78;
    background: linear-gradient(135deg, #203a48, #132833);
    color: #d9f8ff;
    border-radius: 999px;
    padding: 12px 18px;
    font-weight: 700;
    font-size: 0.92rem;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.view-players-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.list-head {
    margin-top: 30px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}

.list-head h2 {
    margin: 0;
    font-family: inherit;
    font-size: 1.3rem;
}

.list-head span {
    color: var(--muted);
    font-size: 0.86rem;
}

.site-list {
    display: grid;
    gap: 10px;
    max-height: 290px;
    overflow: auto;
    padding-right: 6px;
}

.site-list::-webkit-scrollbar {
    width: 8px;
}

.site-list::-webkit-scrollbar-thumb {
    background: rgba(143, 99, 255, 0.45);
    border-radius: 8px;
}

.player-item {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    border-radius: 12px;
    border: 1px solid #2a3242;
    background: #1f2533;
    padding: 11px 12px;
    animation: itemIn 0.45s ease both;
}

.player-item img {
    width: 74px;
    height: 74px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid #3a4358;
}

.player-item h3 {
    margin: 0 0 5px;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
}

.player-item p {
    margin: 0;
    color: #c7cee4;
    font-size: 0.9rem;
}

.player-item p + p {
    margin-top: 3px;
}

.player-item small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.82rem;
}

.empty {
    margin: 0;
    color: var(--muted);
    padding: 12px;
    border: 1px dashed #374156;
    border-radius: 12px;
}

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

@keyframes itemIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 720px) {
    .panel {
        min-height: calc(100vh - 20px);
        padding: 24px 18px;
        border-radius: 26px;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .upload-card {
        grid-template-columns: 1fr;
    }

    .preview-box {
        width: 100%;
        height: 170px;
    }

    .list-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .submit-btn {
        width: 100%;
    }

    .player-item {
        grid-template-columns: 60px minmax(0, 1fr);
    }

    .player-item img {
        width: 60px;
        height: 60px;
    }
}
