/* ------------------------------------------------------------------------------------------
   TOURNO DZ design tokens. Every colour, radius, shadow and font of the dashboard comes from here
   (the mobile app has the same values in mobile/src/theme.js). One brand theme: dark.
   ------------------------------------------------------------------------------------------ */
@font-face { font-family: "Tajawal"; font-weight: 400; src: url("fonts/Tajawal-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Tajawal"; font-weight: 500 600; src: url("fonts/Tajawal-Medium.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Tajawal"; font-weight: 700; src: url("fonts/Tajawal-Bold.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Tajawal"; font-weight: 800 900; src: url("fonts/Tajawal-ExtraBold.ttf") format("truetype"); font-display: swap; }

:root {
  color-scheme: dark;
  /* official brand colours */
  --brand-green: #b6ff3b;      /* neon pistachio: primary buttons, active items */
  --brand-orange: #ff7f22;     /* secondary highlights, competition */
  --brand-black: #1a1a1a;
  --brand-white: #ffffff;
  --surface: #101c19;          /* page background */
  --surface-2: #1c2925;        /* cards */
  /* what they are used for (names used by the rest of this file) */
  --green: var(--brand-green);
  --green-dark: #9bdf2a;       /* hover of the green */
  --gradient: linear-gradient(135deg, #b6ff3b, #ff7f22);   /* brand gradient: pistachio -> orange */
  --on-green: var(--brand-black);
  --orange: var(--brand-orange);
  --bg: var(--surface);
  --card: var(--surface-2);
  --text: var(--brand-white);
  --muted: #9db2aa;
  --line: #2c3d37;
  --danger: #ff5c4d;
  --warn: var(--brand-orange);
  --yellow-card: #ffd60a;      /* football meanings: never follow the brand colours */
  --red-card: #e5322d;
  /* sizes */
  --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-pill: 999px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px;
  --shadow-card: 0 3px 10px rgba(0, 0, 0, .3);
  --font: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); line-height: 1.6;
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--gradient); color: var(--on-green);
}
.topbar a { color: var(--on-green); text-decoration: none; }
.brand { font-weight: 800; font-size: 1.25rem; letter-spacing: .04em; }
#userbox { display: flex; gap: 12px; align-items: center; font-size: .9rem; }
.container { max-width: 960px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: .2em 0 .6em; }
h2 { font-size: 1.15rem; margin: 1.2em 0 .5em; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow-card);
}
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; flex: 1 1 150px; }
.field > span { color: var(--muted); }
textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); width: 100%; resize: vertical; line-height: 1.6;
}
input, select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); width: 100%;
}
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
input[type=checkbox] { width: auto; }
.ltr { direction: ltr; text-align: right; }
button, .btn {
  font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: 9px 16px;
  background: var(--gradient); color: var(--on-green); font-weight: 700; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { filter: brightness(1.06) saturate(1.05); }
button:disabled { opacity: .55; cursor: wait; }
button.secondary { background: transparent; color: var(--green); border: 1px solid var(--green); }
button.secondary:hover { background: color-mix(in srgb, var(--green) 14%, transparent); filter: none; }
button.small { padding: 4px 10px; font-size: .85rem; }
.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--line); margin: 12px 0 16px; overflow-x: auto; overflow-y: hidden; }
.tabs a {
  padding: 8px 14px; text-decoration: none; color: var(--muted); font-weight: 600;
  border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap;
}
.tabs a.active { color: var(--green); border-bottom-color: var(--orange); }
.badge {
  display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: .78rem;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.badge.ongoing { color: var(--green); border-color: var(--green); }
.badge.finished { color: var(--warn); border-color: var(--warn); }
.badge.paused { color: var(--danger); border-color: var(--danger); }
.muted { color: var(--muted); font-size: .9rem; }
.match { display: grid; grid-template-columns: 96px 1fr auto 1fr auto; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.match:first-child { border-top: 0; }
.match .team { font-weight: 600; }
.match .home { text-align: start; }
.match .away { text-align: end; }
/* RTL on purpose: the home team is on the right, so its goals must be on the right too */
.score { font-weight: 800; font-size: 1.1rem; min-width: 64px; text-align: center; white-space: nowrap; }
.match-extra { grid-column: 1 / -1; text-align: center; font-size: 0.9em; line-height: 1.7; }
.match-referee { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; font-size: 0.9em; border-top: 1px dashed var(--line); padding-top: 6px; }
.match-referee select { width: auto; max-width: 200px; }
.result-form { grid-column: 1 / -1; background: var(--bg); padding: 10px; border-radius: 8px; }
.result-form input { width: 70px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 6px 8px; text-align: center; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
td.name, th.name { text-align: start; }
tr.qualify td { background: color-mix(in srgb, var(--green) 12%, transparent); }
.day { font-weight: 700; margin: 18px 0 4px; color: var(--green); }
.players { margin: 8px 0 0; padding: 0; list-style: none; font-size: .9rem; }
.players li { padding: 2px 0; border-top: 1px dashed var(--line); }
.error { color: var(--danger); }
.map { height: 300px; border-radius: 10px; border: 1px solid var(--line); z-index: 0; }
.venue { display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--line); }
.venue:first-child { border-top: 0; }
.ok { color: var(--green); }
.won { font-weight: 800; color: var(--green); }
.lost { color: var(--muted); text-decoration: line-through; }
#toasts { position: fixed; bottom: 16px; left: 16px; right: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--brand-black); color: var(--brand-white); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; max-width: 520px; pointer-events: auto; }
.toast.err { background: var(--danger); color: var(--brand-black); }
.center { max-width: 420px; margin: 40px auto; }
@media (max-width: 640px) {
  .match { grid-template-columns: 1fr auto 1fr; }
  .match .time { grid-column: 1 / -1; }
  .match .actions { grid-column: 1 / -1; }
}
.invite { border-color: var(--green); border-width: 2px; }
.invite .code { font-family: Consolas, monospace; font-size: 2rem; font-weight: 800; letter-spacing: .15em; text-align: center; padding: 10px; background: var(--bg); border-radius: 10px; margin: 8px 0; user-select: all; }
.captain { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
details > summary { cursor: pointer; }
.card:has(> table) { overflow-x: auto; }
.venue .match-extra { flex-basis: 100%; }

/* ---------------------------------------------------------------- landing page, sign-up, dashboard */
.btn.big, button.big, .btn-ghost.big { padding: 14px 28px; font-size: 1.1rem; border-radius: var(--radius-pill); }
.btn-ghost { display: inline-block; text-decoration: none; font-weight: 700; color: var(--green); border: 1px solid var(--green); border-radius: var(--radius-pill); padding: 9px 16px; background: transparent; }
.btn-ghost:hover { background: color-mix(in srgb, var(--green) 14%, transparent); }
.btn-ghost.small { padding: 4px 14px; font-size: .85rem; color: var(--on-green); border-color: var(--on-green); }
.hero {
  text-align: center; padding: 56px 16px 48px; margin: 8px 0 24px; border-radius: 24px; border: 1px solid var(--line);
  background: radial-gradient(circle at 80% 0%, rgba(182, 255, 59, .16), transparent 55%), linear-gradient(160deg, #1e302a, #131f1c);
}
.hero-tag { display: inline-block; color: var(--green); border: 1px solid var(--green); border-radius: 99px; padding: 2px 14px; font-size: .85rem; margin-bottom: 14px; }
.hero-title { font-size: clamp(2.2rem, 7vw, 3.6rem); line-height: 1.15; margin: 0 0 14px; font-weight: 900; }
.hero-title span { color: var(--green); }
.hero-text { max-width: 560px; margin: 0 auto 26px; color: var(--muted); font-size: 1.05rem; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.steps { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; }
.step p { margin: 4px 0 0; }
.step-n { width: 34px; height: 34px; border-radius: 10px; background: var(--gradient); color: var(--on-green); font-weight: 900; display: grid; place-items: center; margin-bottom: 8px; }
.cta-band { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin: 28px 0; padding: 20px; border-radius: var(--radius-lg); border: 1px solid var(--green); background: color-mix(in srgb, var(--green) 9%, var(--card)); }
.form-page { max-width: 640px; margin: 24px auto; }
.dash-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); margin: 12px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px; text-align: center; }
.stat-n { font-size: 2rem; font-weight: 900; color: var(--green); line-height: 1.2; }
.card.empty { text-align: center; padding: 28px; }

/* small SVG icons, and the WhatsApp icon-only button */
.ic { display: inline-flex; vertical-align: middle; line-height: 0; }
.ic-label { display: inline-flex; align-items: center; }
.wa-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; color: #25d366; border: 1px solid #25d366; text-decoration: none; background: transparent; }
.wa-btn:hover { background: #25d366; color: #fff; }

/* the two doors of the front page */
.choices { display: grid; gap: 28px; grid-template-columns: repeat(3, 1fr); max-width: 900px; margin: 0 auto; }
@media (max-width: 720px) { .choices { grid-template-columns: 1fr; gap: 18px; } }
.choice { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 26px 18px; text-decoration: none; color: var(--text); border-radius: var(--radius-lg); background: var(--card); border: 1px solid var(--line); transition: transform .15s, border-color .15s; }
.choice:hover { transform: translateY(-3px); border-color: var(--orange); }
.choice strong { font-size: 1.25rem; }
.choice-icon { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--gradient); color: var(--on-green); }
.center-text { text-align: center; }

/* calendar planning of a new tournament */
.daychips { display: flex; flex-wrap: wrap; gap: 8px; }
.daychip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius-pill); cursor: pointer; background: var(--bg); }
.daychip:has(input:checked) { background: var(--gradient); color: var(--on-green); border-color: transparent; font-weight: 700; }
.daychip input { accent-color: var(--orange); }
.estimate { margin-top: 14px; padding: 14px 16px; border: 1px solid var(--green); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--green) 8%, var(--card)); display: grid; gap: 4px; }
.estimate-big { font-weight: 800; font-size: 1.05rem; color: var(--green); }
.estimate ul { margin: 4px 0 0; padding-inline-start: 18px; font-size: .88rem; }
[hidden] { display: none !important; }

/* scorers of a match: small goal chips side by side, and a round "+" to add a goal */
.goal-team { margin-top: 10px; }
.goal-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.goal-chips { display: contents; }
.goal-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--green); }
.goal-chip select { width: auto; max-width: 170px; padding: 3px 4px; font-size: .85rem; border: 0; background: transparent; color: var(--text); }
.chip-x { background: transparent; color: var(--muted); padding: 0 6px; font-size: 1.1rem; line-height: 1; border-radius: 50%; }
.chip-x:hover { background: transparent; color: var(--danger); filter: none; }
.plus-goal { width: 30px; height: 30px; padding: 0; border-radius: 50%; font-size: 1.3rem; line-height: 1; display: inline-grid; place-items: center; }

/* cards of a match: a coloured card mark, chips side by side and two round "+" buttons (yellow / red) */
.card-mark { display: inline-block; width: 11px; height: 15px; border-radius: 2px; transform: rotate(-6deg); flex: none; }
.card-mark.yellow { background: var(--yellow-card); }
.card-mark.red { background: var(--red-card); }
.card-chip.yellow { border-color: color-mix(in srgb, var(--yellow-card) 55%, transparent); }
.card-chip.red { border-color: color-mix(in srgb, var(--red-card) 70%, transparent); }
.plus-card { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; background: var(--card); color: var(--text); border: 1px solid var(--line); font-size: 1.05rem; line-height: 1; }
.plus-card:hover { background: var(--card); filter: none; border-color: var(--green); }

/* excluding a team: a red button above "edit"; an excluded team is faded, reddish and cannot be used */
.team-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.exclude-btn { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.exclude-btn:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); filter: none; }
.badge.out { color: var(--danger); border-color: var(--danger); font-weight: 700; }
.team-out { opacity: .55; pointer-events: none; user-select: none; background: color-mix(in srgb, var(--danger) 9%, var(--card)); border: 1px dashed color-mix(in srgb, var(--danger) 55%, transparent); }

/* photos of the tournament */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-top: 10px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-x { position: absolute; top: 6px; left: 6px; width: 28px; height: 28px; padding: 0; border-radius: 50%; background: rgba(0, 0, 0, .65); color: #fff; font-size: 1.1rem; line-height: 1; display: grid; place-items: center; }
.photo-x:hover { background: var(--danger); filter: none; }

/* postponed / cancelled matches */
.match-cancelled { opacity: .65; }
.danger-btn { color: var(--danger) !important; border-color: var(--danger) !important; }
button.danger-btn:not(.secondary) { background: transparent; border: 1px solid var(--danger); }
.radio-line { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; }
.radio-line input { width: auto; accent-color: var(--orange); }
.extra-form { margin-top: 8px; }

/* pop-up window (edit a match): it scrolls by itself and the page behind stays still */
body.modal-open { overflow: hidden; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .65); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow: hidden; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); width: min(720px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head strong { font-size: 1.05rem; }
.modal-x { width: 34px; height: 34px; padding: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.5rem; line-height: 1; display: grid; place-items: center; border: 1px solid var(--line); }
.modal-x:hover { background: var(--danger); color: var(--brand-black); filter: none; }
.modal-body { overflow-y: auto; padding: 14px 16px 18px; overscroll-behavior: contain; }
.modal-form { background: transparent; padding: 0; }

/* header of a tournament page: the name and the lines under it sit on a picture */
.t-hero { background: linear-gradient(rgba(0, 0, 0, .72), rgba(0, 0, 0, .1) 62%), url("img/organizer-cover.jpg") center 80% / cover no-repeat; border-radius: var(--radius-lg); padding: 16px 20px; margin: 10px 0 14px; color: #fff; aspect-ratio: 2.8 / 1; min-height: 210px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: flex-start; }
.t-hero h1 { margin: 0 0 6px; color: #fff; text-shadow: 0 1px 4px rgba(0, 0, 0, .85); }
.t-hero p, .t-hero .muted { color: #fff; font-weight: 600; text-shadow: 0 1px 4px rgba(0, 0, 0, .85); margin: 4px 0; }

/* the drop-down lists open on a white background: the names must be dark, not white */
select option, select optgroup { background: #fff; color: #111; }

/* a text box that starts as one line and grows with the text */
textarea.auto-grow { resize: none; overflow: hidden; min-height: 0; line-height: 1.5; }

/* the category next to the tournament name: small and thin, so the name stays big */
.cat-tag { font-size: .55em; font-weight: 300; opacity: .85; margin-inline-start: .5em; }
h1 .cat-tag { font-size: .5em; }

/* player rows: small round icon buttons (edit = pencil, delete = red minus) and the age line */
.icon-btn { width: 32px; height: 32px; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; background: transparent; color: var(--green); border: 1.5px solid var(--green); cursor: pointer; }
.icon-btn:hover { background: var(--green); color: var(--brand-black); filter: none; }
.icon-btn.danger { color: var(--danger); border-color: var(--danger); }
.icon-btn.danger:hover { background: var(--danger); color: var(--brand-black); }
.icon-btn .ic { display: inline-grid; place-items: center; }
.player-age { font-size: .8rem; color: var(--muted); }
.player-age.bad { color: var(--danger); font-weight: 700; }

.modal button.danger-btn:not(.secondary) { background: var(--danger); color: var(--brand-black); border: 0; }

/* the delete button in the corner of a tournament card (dashboard home) */
.tcard { position: relative; }
.tcard-del { position: absolute; top: 10px; inset-inline-start: 10px; }
.tcard > strong { padding-inline-start: 38px; }

/* tournament cards of the dashboard: same hover as the three doors of the front page (they rise and the border turns orange) */
.tcard { transition: transform .15s, border-color .15s; }
.tcard:hover { transform: translateY(-3px); border-color: var(--orange); }

/* the long collapsible boxes of the tournament page (about, max players, fee, admins...): same hover as the doors / tournament cards.
   An OPEN box does not move (the organizer may be typing in it): only its border turns orange. */
details.card { transition: transform .15s, border-color .15s; }
details.card:hover { border-color: var(--orange); }
details.card:not([open]):hover { transform: translateY(-3px); }
