:root {
    color-scheme: dark;
    --bg: #080d14;
    --surface: rgba(15, 24, 35, .86);
    --surface-strong: #121e2b;
    --surface-2: rgba(23, 35, 49, .88);
    --border: rgba(145, 177, 204, .17);
    --border-strong: rgba(101, 214, 193, .35);
    --text: #eef7fb;
    --muted: #9eb1bd;
    --accent: #61d6c1;
    --accent-2: #9ce9d9;
    --gold: #e6bd68;
    --danger: #ef7a72;
    --success: #74d39a;
    --shadow: 0 24px 80px rgba(0, 0, 0, .38);
    --radius-xl: 24px;
    --radius-lg: 17px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: "Cairo", system-ui, sans-serif;
    background:
        radial-gradient(circle at 8% 5%, rgba(97, 214, 193, .12), transparent 26rem),
        radial-gradient(circle at 94% 18%, rgba(230, 189, 104, .09), transparent 28rem),
        linear-gradient(145deg, #080d14 0%, #0d1721 46%, #081019 100%);
    color: var(--text);
}
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .34;
    background-image:
        linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
    background-size: 38px 38px;
    mask-image: linear-gradient(to bottom, black, transparent 86%);
}
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.mouse-glow {
    --x: 50vw;
    --y: 50vh;
    position: fixed;
    z-index: 0;
    left: 0;
    top: 0;
    width: 520px;
    height: 520px;
    border-radius: 50%;
    pointer-events: none;
    transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50%));
    background: radial-gradient(circle, rgba(97,214,193,.19) 0%, rgba(97,214,193,.08) 32%, transparent 70%);
    filter: blur(18px);
    opacity: 0;
    transition: opacity .35s ease;
    will-change: transform;
}
body.mouse-active .mouse-glow { opacity: 1; }
.ambient {
    position: fixed;
    z-index: 0;
    border-radius: 50%;
    filter: blur(70px);
    pointer-events: none;
    opacity: .19;
}
.ambient-one { width: 330px; height: 330px; background: var(--accent); top: 18%; right: -140px; }
.ambient-two { width: 280px; height: 280px; background: var(--gold); bottom: 5%; left: -120px; opacity: .11; }

.page-shell {
    position: relative;
    z-index: 1;
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 38px 0 68px;
}
.hero-card, .panel {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    background: linear-gradient(145deg, rgba(18,30,43,.93), rgba(10,18,28,.88));
    box-shadow: var(--shadow);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(18px);
}
.hero-card::after, .panel::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(115deg, rgba(255,255,255,.045), transparent 25%, transparent 72%, rgba(97,214,193,.025));
}
.hero-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 26px;
    padding: 34px 38px;
    margin-bottom: 22px;
    border-color: rgba(97,214,193,.23);
}
.hero-card > * { position: relative; z-index: 1; }
.eyebrow, .section-kicker {
    display: inline-block;
    color: var(--accent-2);
    font-weight: 800;
    font-size: .92rem;
    letter-spacing: .08em;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
    margin: 7px 0 9px;
    font-size: clamp(1.9rem, 4vw, 3.15rem);
    line-height: 1.28;
    background: linear-gradient(90deg, #fff 10%, #c9f7ed 65%, #e8ca87);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero-card p { margin-bottom: 0; color: var(--muted); max-width: 730px; line-height: 1.9; font-size: 1.05rem; }
.hero-badge {
    width: 108px;
    height: 108px;
    flex: 0 0 108px;
    display: grid;
    place-items: center;
    border-radius: 28px;
    border: 1px solid rgba(230,189,104,.3);
    background: radial-gradient(circle at 35% 25%, rgba(230,189,104,.22), rgba(97,214,193,.08));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 18px 35px rgba(0,0,0,.28);
}
.hero-badge span { font-size: 4.2rem; filter: drop-shadow(0 10px 20px rgba(97,214,193,.22)); }
.panel { padding: 29px; margin-bottom: 22px; }
.panel > * { position: relative; z-index: 1; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.panel-heading h2 { margin: 5px 0 0; font-size: 1.7rem; }
.hint, .counter {
    color: var(--muted);
    font-size: .98rem;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.025);
    padding: 8px 12px;
    border-radius: 999px;
}
.form-grid { display: grid; gap: 18px; }
.top-grid { grid-template-columns: 1.3fr .7fr; }
.field { display: grid; gap: 8px; font-weight: 700; }
.field > span { color: #d9e8ee; font-size: 1.05rem; }
input, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(7,14,22,.65);
    color: var(--text);
    padding: 15px 16px;
    font-size: 1.05rem;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease, background .2s ease;
}
input:hover, select:hover { border-color: rgba(156,233,217,.28); }
input:focus, select:focus {
    border-color: var(--accent);
    background: rgba(11,22,32,.96);
    box-shadow: 0 0 0 4px rgba(97,214,193,.11), 0 0 28px rgba(97,214,193,.08);
}
.units-header { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 29px 0 15px; }
.units-header h3 { margin-bottom: 5px; }
.units-header p { color: var(--muted); font-size: .98rem; margin-bottom: 0; }
.text-button, .delete-button {
    border: 1px solid transparent;
    border-radius: 11px;
    cursor: pointer;
    padding: 9px 14px;
    transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.text-button { background: rgba(97,214,193,.08); color: var(--accent-2); border-color: rgba(97,214,193,.13); }
.text-button:hover { transform: translateY(-1px); background: rgba(97,214,193,.13); border-color: rgba(97,214,193,.28); }
.units-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.unit-card {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: space-between;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, rgba(26,40,54,.72), rgba(13,23,33,.8));
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.unit-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    box-shadow: 0 13px 28px rgba(0,0,0,.19), inset 0 1px 0 rgba(255,255,255,.035);
}
.unit-meta { display: grid; gap: 4px; }
.unit-meta strong { font-size: 1.08rem; }
.unit-meta span { color: var(--muted); font-size: .9rem; }
.unit-card input { width: 150px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.live-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; margin: 23px 0; }
.live-summary > div {
    padding: 17px;
    border-radius: var(--radius-lg);
    background: rgba(7,14,22,.58);
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}
.live-summary span { display: block; color: var(--muted); font-size: .92rem; margin-bottom: 7px; }
.live-summary strong { font-size: 1.55rem; font-variant-numeric: tabular-nums; }
.total-preview {
    border-color: rgba(230,189,104,.34) !important;
    background: linear-gradient(145deg, rgba(230,189,104,.11), rgba(97,214,193,.06)) !important;
}
.total-preview strong { color: #f4d990; }
.primary-button {
    width: 100%;
    border: 1px solid rgba(156,233,217,.28);
    border-radius: 15px;
    cursor: pointer;
    padding: 17px 20px;
    font-size: 1.12rem;
    background: linear-gradient(135deg, #62d9c4, #2fae9c);
    color: #061410;
    font-weight: 800;
    box-shadow: 0 14px 32px rgba(47,174,156,.19), inset 0 1px 0 rgba(255,255,255,.28);
    transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 18px 38px rgba(47,174,156,.27); filter: brightness(1.04); }
.primary-button:active { transform: translateY(0); }
.alert { padding: 14px 18px; border-radius: 14px; margin-bottom: 18px; border: 1px solid; backdrop-filter: blur(12px); }
.alert-success { color: #dff8e8; border-color: rgba(116,211,154,.42); background: rgba(116,211,154,.09); }
.alert-error { color: #ffe1de; border-color: rgba(239,122,114,.42); background: rgba(239,122,114,.09); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; min-width: 920px; background: rgba(6,13,20,.38); }
th, td { padding: 14px 13px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-size: .9rem; background: rgba(255,255,255,.025); }
td { font-size: 1rem; }
tbody tr { transition: background .18s ease; }
tbody tr:hover { background: rgba(97,214,193,.045); }
tbody tr:last-child td { border-bottom: 0; }
.player-name { font-weight: 800; color: #f5fbfd; }
.total-value { color: #f0d17f; }
.rank { display: inline-grid; place-items: center; min-width: 35px; height: 35px; border-radius: 50%; background: #273542; font-weight: 800; border: 1px solid rgba(255,255,255,.07); }
.rank-1 { background: linear-gradient(145deg, #d3a943, #8e6517); color: #fff8dd; box-shadow: 0 8px 18px rgba(211,169,67,.19); }
.rank-2 { background: linear-gradient(145deg, #8494a0, #4b5963); color: white; }
.rank-3 { background: linear-gradient(145deg, #a56a44, #683c24); color: white; }
.delete-button { color: #ffd8d4; background: rgba(239,122,114,.08); border-color: rgba(239,122,114,.14); }
.delete-button:hover { transform: translateY(-1px); background: rgba(239,122,114,.14); border-color: rgba(239,122,114,.3); }
.empty-state { text-align: center; color: var(--muted); padding: 36px; }

@media (pointer: coarse), (prefers-reduced-motion: reduce) {
    .mouse-glow { display: none; }
    *, *::before, *::after { scroll-behavior: auto !important; }
}
@media (max-width: 760px) {
    .page-shell { width: min(100% - 20px, 1180px); padding-top: 18px; }
    .hero-card, .panel { border-radius: 18px; padding: 21px; }
    .hero-card { align-items: flex-start; }
    .hero-badge { width: 74px; height: 74px; flex-basis: 74px; border-radius: 20px; }
    .hero-badge span { font-size: 2.8rem; }
    .panel-heading, .units-header { align-items: flex-start; flex-direction: column; }
    .top-grid, .units-grid, .live-summary { grid-template-columns: 1fr; }
    .unit-card input { width: 118px; }
}
@media (max-width: 480px) {
    .hero-card { padding: 21px 18px; }
    .hero-badge { display: none; }
    .unit-card { align-items: stretch; flex-direction: column; }
    .unit-card input { width: 100%; }
}

/* بطاقات الوحدات المطورة */
.unit-identity {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}
.unit-icon {
    width: 50px;
    height: 50px;
    flex: 0 0 50px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    font-size: 1.65rem;
    background: rgba(97,214,193,.075);
    border: 1px solid rgba(97,214,193,.15);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.045);
    transition: transform .2s ease, background .2s ease, border-color .2s ease;
}
.unit-card.is-filled {
    border-color: rgba(230,189,104,.55);
    background: linear-gradient(145deg, rgba(230,189,104,.13), rgba(20,40,46,.88));
    box-shadow: 0 14px 34px rgba(230,189,104,.09), inset 0 1px 0 rgba(255,255,255,.05);
}
.unit-card.is-filled .unit-icon {
    transform: scale(1.05);
    background: rgba(230,189,104,.14);
    border-color: rgba(230,189,104,.34);
}
.unit-card.is-filled input {
    border-color: rgba(230,189,104,.55);
    box-shadow: 0 0 0 4px rgba(230,189,104,.07);
}
.unit-meta strong { font-size: 1.16rem; }
.unit-meta span { font-size: .96rem; line-height: 1.65; }
@media (max-width: 480px) {
    .unit-identity { width: 100%; }
    .unit-icon { width: 46px; height: 46px; flex-basis: 46px; }
}
