/* ---------------------------------------------------------------- tokens */
:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --bg-soft: #eaeef2;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #dfe5ec;
  --line-soft: #eaeff4;
  --text: #10202b;
  --text-2: #5b6b7a;
  --muted: #7c8b9a;
  --brand: #0f766e;
  --brand-2: #12a594;
  --brand-ink: #ffffff;
  --ok: #0f7b45;
  --ok-bg: #e2f6ea;
  --warn: #9a6100;
  --warn-bg: #fdf1dc;
  --bad: #a52222;
  --bad-bg: #fceaea;
  --neutral: #4b5c6b;
  --neutral-bg: #eaeff4;
  --shadow: 0 1px 2px rgb(16 32 43 / .06), 0 8px 24px -12px rgb(16 32 43 / .18);
  --radius: 16px;
}
:root[data-theme="dark"], :root:not([data-theme="light"]) {
  --bg: #0b1116;
  --bg-soft: #0e161d;
  --panel: #131c24;
  --panel-2: #182129;
  --line: #253039;
  --line-soft: #1d2830;
  --text: #e8eef3;
  --text-2: #a3b1bd;
  --muted: #7d8d9a;
  --brand: #2dd4bf;
  --brand-2: #14b8a6;
  --brand-ink: #04211d;
  --ok: #52d18b;
  --ok-bg: #0f2b1e;
  --warn: #f0b352;
  --warn-bg: #2c2213;
  --bad: #f08585;
  --bad-bg: #2e1717;
  --neutral: #9fb0bd;
  --neutral-bg: #1c262e;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 10px 30px -14px rgb(0 0 0 / .7);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6f8; --bg-soft: #eaeef2; --panel: #fff; --panel-2: #f8fafc;
    --line: #dfe5ec; --line-soft: #eaeff4; --text: #10202b; --text-2: #5b6b7a; --muted: #7c8b9a;
    --brand: #0f766e; --brand-2: #12a594; --brand-ink: #fff;
    --ok: #0f7b45; --ok-bg: #e2f6ea; --warn: #9a6100; --warn-bg: #fdf1dc;
    --bad: #a52222; --bad-bg: #fceaea; --neutral: #4b5c6b; --neutral-bg: #eaeff4;
    --shadow: 0 1px 2px rgb(16 32 43 / .06), 0 8px 24px -12px rgb(16 32 43 / .18);
  }
}

* { box-sizing: border-box; }
/* Author `display` rules outrank the UA sheet's [hidden] rule, so restate it. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Kufi Arabic", "Noto Sans Arabic", "Dubai", Tahoma, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* --------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px clamp(14px, 4vw, 28px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; font-size: 15px; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-mark rect { fill: var(--brand); stroke: none; }
.topnav { display: flex; align-items: center; gap: 6px; }
.navlink { color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 600; padding: 7px 12px; border-radius: 999px; }
.navlink:hover { background: var(--panel); color: var(--text); }
.iconbtn {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text-2); cursor: pointer;
}
.iconbtn:hover { color: var(--text); border-color: var(--brand); }
.iconbtn svg { width: 18px; height: 18px; }

/* ----------------------------------------------------------------- page */
.wrap { flex: 1; width: 100%; max-width: 780px; margin: 0 auto; padding: clamp(18px, 4vw, 34px) clamp(14px, 4vw, 24px) 60px; }

.hero { text-align: center; margin-bottom: 22px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(26px, 6vw, 40px); line-height: 1.25; letter-spacing: -.01em; }
.hero .year { color: var(--brand); }
.hero .sub { margin: 0; color: var(--text-2); font-size: clamp(14px, 3.4vw, 17px); }

/* ----------------------------------------------------------- search box */
.searchcard { position: sticky; top: 57px; z-index: 15; padding: 10px 0 12px; background: linear-gradient(var(--bg) 78%, transparent); }
.searchbox {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 14px;
  padding: 0 14px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.searchbox:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent); }
.sicon { width: 20px; height: 20px; flex: none; color: var(--muted); }
#q {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; font-size: clamp(16px, 4vw, 18px); padding: 15px 0; font-family: inherit;
}
#q::placeholder { color: var(--muted); }
#q::-webkit-search-cancel-button { display: none; }
.clearbtn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; display: grid; place-items: center; border-radius: 8px; }
.clearbtn:hover { color: var(--text); background: var(--panel-2); }
.clearbtn svg { width: 16px; height: 16px; }
.spin { display: block; width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hint { margin: 9px 4px 0; font-size: 13px; color: var(--muted); }
.hint b { color: var(--text-2); }

/* --------------------------------------------------------------- status */
.status { margin: 14px 0 0; padding: 14px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--text-2); font-size: 15px; }
.status.err { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 32%, transparent); color: var(--bad); }
.status.info { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.status b { color: inherit; }

/* -------------------------------------------------------------- results */
.results { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.reshead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--muted); padding: 0 4px; }

.row {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px 14px;
  width: 100%; text-align: start; font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 15px; cursor: pointer;
  transition: border-color .12s, transform .12s, background .12s;
}
.row:hover { border-color: var(--brand); background: var(--panel-2); }
.row:active { transform: scale(.995); }
.row .rname { font-weight: 600; font-size: 15.5px; line-height: 1.45; min-width: 0; overflow-wrap: anywhere; }
.row .rseat { font-size: 12.5px; color: var(--muted); grid-column: 1; }
.row .rdeg { grid-row: 1 / span 2; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--brand); }
.row .rbadge { grid-row: 1 / span 2; }
.row mark { background: color-mix(in srgb, var(--brand) 26%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

.badge { display: inline-block; font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.neutral { background: var(--neutral-bg); color: var(--neutral); }

.morebtn {
  border: 1px dashed var(--line); background: transparent; color: var(--text-2); font: inherit; font-weight: 600;
  padding: 12px; border-radius: 12px; cursor: pointer;
}
.morebtn:hover { border-color: var(--brand); color: var(--brand); }

/* ----------------------------------------------------------------- card */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(16px, 4vw, 24px); }
.backbtn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--brand); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; padding: 0 0 12px; }
.backbtn svg { width: 16px; height: 16px; }
.card-head { border-bottom: 1px solid var(--line-soft); padding-bottom: 14px; margin-bottom: 16px; }
.card-head .name { margin: 0 0 4px; font-size: clamp(19px, 4.6vw, 25px); line-height: 1.4; overflow-wrap: anywhere; }
.seatline { color: var(--text-2); font-size: 14px; }
.seatline b { font-variant-numeric: tabular-nums; letter-spacing: .04em; color: var(--text); }

.scoregrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.scorebox { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 14px 10px; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 92px; }
.scoreval { font-size: clamp(24px, 6.5vw, 32px); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--brand); }
.scoreval small { font-size: .5em; font-weight: 600; color: var(--muted); }
.scorelabel { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.statusbox .badge { font-size: 13px; padding: 6px 12px; }

.note { margin: 14px 0 0; padding: 11px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 13.5px; }
.rankrow { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.rankmain { font-size: 15px; }
.rankmain b { font-variant-numeric: tabular-nums; color: var(--brand); font-size: 18px; }
.rankbar { height: 8px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; margin: 10px 0 6px; }
.rankfill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand-2), var(--brand)); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.muted { color: var(--muted); font-size: 13px; }

.dist { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.dist-title { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.dist-chart { display: flex; align-items: flex-end; gap: 2px; height: 64px; direction: ltr; }
.dist-chart i { flex: 1; background: var(--bg-soft); border-radius: 2px 2px 0 0; min-height: 2px; }
.dist-chart i.hit { background: var(--brand); }
.dist-axis { display: flex; justify-content: space-between; direction: ltr; font-size: 11px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

.cardactions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.btn { flex: 1; min-width: 130px; border: 0; border-radius: 11px; padding: 12px 16px; font: inherit; font-weight: 700; font-size: 14.5px; cursor: pointer; background: var(--brand); color: var(--brand-ink); }
.btn:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; color: var(--text-2); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }

/* --------------------------------------------------------------- stats */
.stats { margin-top: 26px; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center; }
.stat .v { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--brand); }
.stat .k { font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------------- table */
.toplist { display: flex; flex-direction: column; gap: 6px; }
.toprow { display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; width: 100%; text-align: start; font: inherit; color: var(--text); cursor: pointer; }
.toprow:hover { border-color: var(--brand); }
.toprow .n { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; }
.toprow.gold .n { color: #d99b00; }
.toprow .d { font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- footer */
.foot { border-top: 1px solid var(--line); padding: 20px clamp(14px, 4vw, 28px) 30px; text-align: center; color: var(--muted); font-size: 12.5px; }
.foot p { margin: 3px 0; }

@media (max-width: 430px) {
  .scoregrid { grid-template-columns: 1fr 1fr; }
  .statusbox { grid-column: span 2; }
  .row { grid-template-columns: 1fr auto; }
  .row .rbadge { grid-row: 3; grid-column: 1 / -1; justify-self: start; }
}

@media print {
  .topbar, .searchcard, .foot, .cardactions, .backbtn, .hero, .stats, #status { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #999; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
