@import url("https://fonts.googleapis.com/css2?family=Noto+Kufi+Arabic:wght@400;500;600;700;800&family=Tajawal:wght@400;500;700;800;900&display=swap");

:root {
  color-scheme: dark;
  --bg: #041014;
  --bg-soft: #081b22;
  --surface: rgba(8, 27, 34, .76);
  --surface-strong: rgba(8, 27, 34, .94);
  --line: rgba(255, 255, 255, .11);
  --text: #f5fbfc;
  --muted: #8fa7ad;
  --green: #20e89b;
  --green-rgb: 32, 232, 155;
  --blue: #19b5ff;
  --blue-rgb: 25, 181, 255;
  --gold: #ffc94d;
  --danger: #ff5c6c;
  --shadow: 0 22px 70px rgba(0, 0, 0, .35);
  --radius: 24px;
  font-family: "Tajawal", "Segoe UI", Tahoma, sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #e9f3f4;
  --bg-soft: #f6fbfb;
  --surface: rgba(255, 255, 255, .78);
  --surface-strong: rgba(255, 255, 255, .96);
  --line: rgba(5, 35, 42, .12);
  --text: #08262d;
  --muted: #577078;
  --shadow: 0 22px 70px rgba(8, 46, 54, .14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  transition: color .35s ease, background .35s ease;
}

.noscript-message {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  padding: 24px;
  place-items: center;
  color: #fff;
  font-size: 18px;
  text-align: center;
  background: #041014;
}

button, input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(var(--blue-rgb), .55);
  outline-offset: 3px;
}

/* طبقة الملعب ثابتة لتمنح الصفحة عمقًا دون التأثير في قابلية قراءة البطاقات. */
.stadium-bg {
  position: fixed;
  inset: 0;
  z-index: -3;
  background: url("assets/stadium-bg.png") center top / cover no-repeat;
  filter: saturate(.78);
  opacity: .34;
  transform: scale(1.03);
}

.stadium-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(3, 13, 18, .28), var(--bg) 72%),
    radial-gradient(circle at 50% 28%, transparent 0 16%, var(--bg) 72%);
  transition: background .35s ease;
}

[data-theme="light"] .stadium-bg {
  opacity: .18;
}

.crowd-lights {
  position: fixed;
  inset: 30vh 0 auto;
  z-index: -2;
  height: 34vh;
  pointer-events: none;
  opacity: .38;
  background-image:
    radial-gradient(circle, rgba(var(--blue-rgb), .8) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(var(--green-rgb), .65) 0 1px, transparent 1.5px);
  background-size: 31px 22px, 43px 29px;
  animation: crowdPulse 3.4s ease-in-out infinite alternate;
  mask-image: linear-gradient(transparent, #000 32%, transparent);
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 22px;
  background: #041014;
  transition: opacity .55s ease, visibility .55s ease;
}

.loading-screen.done {
  opacity: 0;
  visibility: hidden;
}

.loading-screen p {
  color: #bed0d4;
  letter-spacing: .04em;
}

.loader-ball {
  font-size: 58px;
  filter: drop-shadow(0 0 22px rgba(var(--green-rgb), .45));
  animation: loaderBounce 1s cubic-bezier(.3, .7, .4, 1) infinite;
}

/* شريط الأدوات الزجاجي يبقى قريبًا أثناء التنقل بين الأدوار الطويلة. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 82px;
  padding: 14px clamp(18px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(4, 16, 20, .68);
  backdrop-filter: blur(20px) saturate(140%);
}

[data-theme="light"] .topbar {
  background: rgba(242, 250, 250, .76);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  padding: 3px;
  overflow: hidden;
  border: 1px solid rgba(var(--green-rgb), .42);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 0 25px rgba(var(--green-rgb), .16);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  object-fit: cover;
}

.brand small, .brand strong {
  display: block;
}

.brand small {
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 10px;
}

.brand strong {
  font-family: "Noto Kufi Arabic", sans-serif;
  font-size: 15px;
}

.actions, .export-actions, .modal-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.icon-btn, .reset-btn, .secondary-btn, .save-btn, .danger-btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  cursor: pointer;
  background: rgba(255, 255, 255, .055);
  transition: transform .2s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease;
}

.icon-btn:hover, .secondary-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--blue-rgb), .42);
  background: rgba(var(--blue-rgb), .1);
}

.icon-btn {
  width: 42px;
  padding: 0;
  font-size: 18px;
}

.icon-btn.active {
  color: var(--green);
  border-color: rgba(var(--green-rgb), .45);
  background: rgba(var(--green-rgb), .11);
}

.reset-btn {
  padding: 0 18px;
  color: #ffc2c8;
  border-color: rgba(255, 92, 108, .25);
}

.reset-btn:hover {
  color: #fff;
  border-color: rgba(255, 92, 108, .5);
  background: rgba(255, 92, 108, .16);
}

main {
  width: min(100%, 1800px);
  margin-inline: auto;
}

.hero {
  display: flex;
  min-height: 465px;
  padding: 88px 22px 68px;
  align-items: center;
  flex-direction: column;
  text-align: center;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
}

.eyebrow span {
  width: 34px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--green));
}

.eyebrow span:last-child {
  transform: scaleX(-1);
}

.hero h1 {
  max-width: 900px;
  margin: 24px 0 14px;
  font-family: "Noto Kufi Arabic", sans-serif;
  font-size: clamp(40px, 6.2vw, 82px);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -.045em;
  text-shadow: 0 8px 50px rgba(0, 0, 0, .5);
}

.hero h1 em {
  color: transparent;
  font-style: normal;
  background: linear-gradient(110deg, var(--green), #9affd9 48%, var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
}

.hero > p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(16px, 1.6vw, 20px);
  line-height: 1.8;
}

.progress-wrap {
  width: min(520px, 92vw);
  margin-top: 38px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.progress-label strong {
  color: var(--text);
  font-weight: 600;
}

.progress-track {
  height: 7px;
  padding: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(255, 255, 255, .04);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
  box-shadow: 0 0 18px rgba(var(--green-rgb), .55);
  transition: width .7s cubic-bezier(.2, .9, .2, 1);
}

.tournament-shell {
  margin: 0 clamp(10px, 2.4vw, 38px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(150deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .018));
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px 24px;
  border-bottom: 1px solid var(--line);
}

.section-kicker, .champion-kicker {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
}

.section-head h2 {
  margin: 5px 0 0;
  font-family: "Noto Kufi Arabic", sans-serif;
  font-size: 25px;
}

.secondary-btn {
  padding: 0 15px;
  color: var(--muted);
  font-size: 13px;
}

.bracket-path {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.6vw, 26px);
  padding: 19px 20px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, .08);
  direction: ltr;
}

.bracket-path div {
  display: flex;
  min-width: 70px;
  align-items: center;
  gap: 7px;
  flex-direction: column;
  direction: rtl;
  text-align: center;
}

.bracket-path strong {
  color: var(--green);
  font-family: "Noto Kufi Arabic", sans-serif;
  font-size: 19px;
  line-height: 1;
}

.bracket-path span {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.bracket-path i {
  color: rgba(var(--blue-rgb), .6);
  font-size: 18px;
  font-style: normal;
}

.bracket-path .path-final strong {
  color: var(--gold);
}

/* تظهر أعمدة الأدوار الخمسة كاملة على الشاشات الواسعة. */
.bracket-viewport {
  position: relative;
  padding: 30px 18px 40px;
  direction: ltr;
  overflow-x: hidden;
  overscroll-behavior-inline: contain;
  scrollbar-color: rgba(var(--green-rgb), .4) transparent;
}

.bracket {
  position: relative;
  display: grid;
  width: 100%;
  min-width: 100%;
  grid-template-columns: repeat(9, minmax(118px, 1fr));
  gap: clamp(8px, 1vw, 18px);
  isolation: isolate;
}

.bracket-lines {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.connector {
  fill: none;
  stroke: rgba(var(--blue-rgb), .28);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 5px rgba(var(--blue-rgb), .2));
  transition: stroke .4s ease;
}

.connector.active {
  stroke: rgba(var(--green-rgb), .72);
  stroke-dasharray: 5 5;
  animation: lineFlow 1.5s linear infinite;
}

.round {
  position: relative;
  display: flex;
  width: auto;
  min-width: 0;
  flex-direction: column;
  direction: rtl;
}

.round-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 0 4px;
}

.round-head h3 {
  margin: 0;
  font-family: "Noto Kufi Arabic", sans-serif;
  font-size: clamp(10px, .9vw, 15px);
}

.round-head span {
  display: grid;
  min-width: 34px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(var(--green-rgb), .25);
  border-radius: 99px;
  color: var(--green);
  font-size: 11px;
  background: rgba(var(--green-rgb), .06);
}

.round-matches {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-around;
  gap: 16px;
}

.side-center .round-head h3 {
  color: var(--gold);
}

.side-center .round-head span {
  color: var(--gold);
  border-color: rgba(255, 201, 77, .35);
  background: rgba(255, 201, 77, .08);
}

.side-center .match-card {
  border-color: rgba(255, 201, 77, .35);
  box-shadow: 0 18px 45px rgba(255, 201, 77, .08);
}

.side-center {
  z-index: 3;
}

.side-center .round-matches {
  justify-content: center;
  gap: 24px;
}

.final-emblem {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-direction: column;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  filter: drop-shadow(0 0 28px rgba(255, 201, 77, .14));
}

.final-emblem img {
  display: block;
  width: clamp(105px, 8vw, 145px);
  height: auto;
  border-radius: 26px;
  box-shadow: 0 0 40px rgba(255, 201, 77, .14);
}

/* حالات المباراة توضح الفائز بصريًا مع إبقاء النتيجة المقروءة. */
.match-card {
  position: relative;
  min-height: 188px;
  padding: 14px;
  overflow: hidden;
  border: 1px solid rgba(var(--blue-rgb), .2);
  border-radius: 22px;
  background:
    radial-gradient(circle at 100% 0, rgba(var(--blue-rgb), .1), transparent 40%),
    linear-gradient(145deg, var(--surface-strong), var(--surface));
  box-shadow:
    0 16px 38px rgba(0, 0, 0, .18),
    inset 0 1px 0 rgba(255, 255, 255, .08);
  backdrop-filter: blur(14px);
  transition: transform .28s ease, border-color .28s ease, box-shadow .28s ease, opacity .28s ease;
}

.match-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--green), var(--blue), transparent);
  opacity: .72;
}

.match-card::after {
  content: "";
  position: absolute;
  top: -28px;
  right: -28px;
  width: 70px;
  height: 70px;
  border: 1px solid rgba(var(--green-rgb), .13);
  border-radius: 50%;
  pointer-events: none;
}

.match-card:hover {
  z-index: 2;
  transform: translateY(-5px) scale(1.01);
  border-color: rgba(var(--green-rgb), .42);
  box-shadow: 0 22px 48px rgba(0, 0, 0, .24), 0 0 30px rgba(var(--blue-rgb), .1);
}

.match-card.completed {
  border-color: rgba(var(--green-rgb), .25);
}

.match-number {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .05em;
}

.match-number > span:first-child {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(255, 255, 255, .035);
}

.saved-label {
  color: var(--green);
}

.team-row {
  display: grid;
  min-height: 56px;
  grid-template-columns: 32px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 14px;
  transition: opacity .35s ease, background .35s ease, transform .35s ease;
}

.match-number + .team-row {
  margin-bottom: 3px;
}

.versus + .team-row {
  margin-top: 3px;
}

.team-row.winner {
  color: #fff;
  background: linear-gradient(90deg, rgba(var(--green-rgb), .17), transparent);
  transform: translateX(-2px);
  border-color: rgba(var(--green-rgb), .16);
}

[data-theme="light"] .team-row.winner {
  color: var(--text);
}

.team-row.loser {
  opacity: .4;
  filter: grayscale(.65);
}

.flag-frame {
  position: relative;
  width: 32px;
  height: 32px;
  padding: 3px;
  overflow: hidden;
  border: 1px solid rgba(var(--blue-rgb), .42);
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(var(--blue-rgb), .28), rgba(var(--green-rgb), .16));
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, .06),
    0 0 16px rgba(var(--blue-rgb), .2);
  animation: flagFloat 3.2s ease-in-out infinite;
}

.flag-frame img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  animation: flagWave 2.4s ease-in-out infinite;
  transform-origin: 20% 50%;
}

.team-row:nth-of-type(even) .flag-frame,
.team-row:nth-of-type(even) .flag-frame img {
  animation-delay: -.9s;
}

.team-name {
  display: block;
  overflow: visible;
  font-size: clamp(9px, .7vw, 11px);
  font-weight: 700;
  line-height: 1.45;
  text-wrap: balance;
  text-overflow: clip;
  white-space: normal;
  word-break: normal;
}

.score-input {
  width: 40px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(var(--green-rgb), .32);
  border-radius: 13px;
  color: var(--text);
  font-size: 17px;
  font-weight: 900;
  text-align: center;
  background:
    linear-gradient(145deg, rgba(var(--green-rgb), .08), rgba(var(--blue-rgb), .06)),
    rgba(0, 0, 0, .2);
  box-shadow: inset 0 0 18px rgba(var(--green-rgb), .045);
  appearance: textfield;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.score-input::-webkit-inner-spin-button {
  appearance: none;
}

.score-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(var(--green-rgb), .13), 0 0 20px rgba(var(--green-rgb), .12);
}

.score-input:disabled {
  color: var(--text);
  opacity: 1;
  cursor: default;
}

.versus {
  position: absolute;
  top: 101px;
  left: 40px;
  z-index: 2;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 9px;
  background: var(--surface-strong);
  box-shadow: 0 0 0 3px var(--surface);
}

.save-btn {
  width: 100%;
  min-height: 36px;
  margin-top: 10px;
  border-color: rgba(var(--green-rgb), .28);
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  background: linear-gradient(90deg, rgba(var(--green-rgb), .11), rgba(var(--blue-rgb), .07));
}

.save-btn:hover:not(:disabled) {
  color: #03150e;
  background: var(--green);
  box-shadow: 0 0 18px rgba(var(--green-rgb), .25);
}

.save-btn:disabled {
  color: var(--muted);
  cursor: default;
  border-color: var(--line);
  background: rgba(255, 255, 255, .025);
}

.team-placeholder {
  display: flex;
  min-height: 93px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.team-arrival {
  animation: teamArrival .75s cubic-bezier(.18, .9, .25, 1);
}

/* بطاقة البطل مستقلة عن ازدحام المخطط وتتحول إلى اللون الذهبي عند الحسم. */
.champion-section {
  padding: 70px clamp(16px, 4vw, 70px);
}

.champion-card {
  position: relative;
  max-width: 760px;
  min-height: 390px;
  margin-inline: auto;
  padding: 48px 24px;
  overflow: hidden;
  border: 1px solid rgba(255, 201, 77, .22);
  border-radius: 34px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 25%, rgba(255, 201, 77, .16), transparent 35%),
    linear-gradient(145deg, rgba(255, 255, 255, .065), rgba(255, 255, 255, .02));
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.champion-card::before {
  content: "";
  position: absolute;
  inset: -50%;
  background: conic-gradient(transparent, rgba(255, 201, 77, .16), transparent 20%);
  animation: trophySweep 8s linear infinite;
}

.champion-card > * {
  position: relative;
}

.trophy {
  font-size: 88px;
  line-height: 1;
  filter: grayscale(.65) drop-shadow(0 0 5px transparent);
  opacity: .32;
  transition: filter .5s ease, opacity .5s ease;
}

.champion-card.revealed .trophy {
  opacity: 1;
  filter: drop-shadow(0 0 28px rgba(255, 201, 77, .75));
  animation: trophyWin 2.1s ease-in-out infinite;
}

.champion-card .champion-kicker {
  display: block;
  margin-top: 18px;
  color: var(--gold);
}

.champion-card h2 {
  margin: 8px 0 23px;
  font-family: "Noto Kufi Arabic", sans-serif;
  font-size: clamp(24px, 4vw, 36px);
}

.champion-placeholder {
  color: var(--muted);
}

.champion-winner {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 12px 26px;
  border: 1px solid rgba(255, 201, 77, .28);
  border-radius: 99px;
  color: var(--gold);
  font-family: "Noto Kufi Arabic", sans-serif;
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 800;
  background: rgba(255, 201, 77, .08);
  box-shadow: 0 0 36px rgba(255, 201, 77, .12);
}

.champion-winner .flag-frame {
  width: 48px;
  height: 48px;
  border-color: rgba(255, 201, 77, .5);
}

footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 10px 20px 36px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  padding: 20px;
  place-items: center;
  background: rgba(0, 5, 8, .76);
  backdrop-filter: blur(10px);
  animation: fadeIn .22s ease;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: min(520px, 100%);
  padding: 34px;
  border: 1px solid rgba(var(--blue-rgb), .25);
  border-radius: 27px;
  text-align: center;
  background: var(--surface-strong);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .5);
  animation: modalIn .35s cubic-bezier(.2, .85, .25, 1);
}

.modal.compact {
  max-width: 440px;
}

.modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  background: rgba(255, 255, 255, .05);
}

.modal-icon {
  margin-bottom: 13px;
  font-size: 42px;
}

.modal-icon.danger {
  color: var(--danger);
  font-size: 48px;
}

.modal > span {
  color: var(--green);
  font-size: 12px;
}

.modal h2 {
  margin: 7px 0 22px;
  font-family: "Noto Kufi Arabic", sans-serif;
  font-size: 22px;
}

.modal p {
  margin: -10px 0 25px;
  color: var(--muted);
}

.penalty-teams {
  display: block;
}

.penalty-form {
  display: grid;
  gap: 18px;
}

.penalty-score-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
}

.penalty-team {
  display: flex;
  min-width: 0;
  padding: 18px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  align-items: center;
  gap: 10px;
  flex-direction: column;
  background: rgba(255, 255, 255, .035);
}

.penalty-team strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.penalty-team .flag-frame {
  width: 45px;
  height: 45px;
}

.penalty-input {
  width: 76px;
  height: 52px;
  border: 1px solid rgba(var(--green-rgb), .35);
  border-radius: 14px;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  background: rgba(0, 0, 0, .22);
  appearance: textfield;
}

.penalty-input::-webkit-inner-spin-button {
  appearance: none;
}

.penalty-separator {
  color: var(--muted);
  font-size: 22px;
}

.penalty-hint {
  margin: -5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.penalty-submit {
  min-height: 44px;
  margin-top: 0;
  font-size: 13px;
}

.danger-btn {
  padding: 0 18px;
  border-color: transparent;
  color: #fff;
  background: var(--danger);
}

.toast {
  position: fixed;
  right: 50%;
  bottom: 26px;
  z-index: 300;
  padding: 12px 19px;
  border: 1px solid rgba(var(--green-rgb), .3);
  border-radius: 13px;
  color: var(--text);
  pointer-events: none;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(50%, 18px);
  transition: opacity .25s ease, transform .25s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(50%, 0);
}

.rolling-ball {
  position: fixed;
  right: -70px;
  bottom: 46px;
  z-index: 250;
  font-size: 42px;
  pointer-events: none;
  opacity: 0;
}

.rolling-ball.play {
  animation: ballRoll 1.25s cubic-bezier(.15, .8, .3, 1);
}

#confettiCanvas {
  position: fixed;
  inset: 0;
  z-index: 120;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@keyframes loaderBounce {
  0%, 100% { transform: translateY(0) rotate(0); }
  45% { transform: translateY(-30px) rotate(95deg); }
  55% { transform: translateY(-30px) rotate(105deg); }
}

@keyframes crowdPulse {
  from { opacity: .2; transform: translateY(3px); }
  to { opacity: .48; transform: translateY(-2px); }
}

@keyframes lineFlow {
  to { stroke-dashoffset: -20; }
}

@keyframes teamArrival {
  0% { opacity: 0; transform: translateX(-42px) scale(.94); }
  70% { opacity: 1; transform: translateX(5px) scale(1.01); }
  100% { transform: translateX(0) scale(1); }
}

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

@keyframes trophyWin {
  0%, 100% { transform: translateY(0) rotate(-2deg) scale(1); }
  50% { transform: translateY(-9px) rotate(2deg) scale(1.05); }
}

@keyframes fadeIn {
  from { opacity: 0; }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(24px) scale(.96); }
}

@keyframes ballRoll {
  0% { right: -70px; opacity: 0; transform: rotate(0); }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { right: calc(100vw + 70px); opacity: 0; transform: rotate(-900deg); }
}

@keyframes flagFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-3px) rotate(2deg); }
}

@keyframes flagWave {
  0%, 100% { transform: perspective(50px) rotateY(-5deg) scaleX(.98); }
  50% { transform: perspective(50px) rotateY(10deg) scaleX(1.04); }
}

@media (max-width: 1500px) {
  .bracket-viewport {
    overflow-x: auto;
  }

  .bracket {
    width: 1800px;
    grid-template-columns: repeat(9, 184px);
    gap: 18px;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: relative;
    align-items: flex-start;
    padding: 13px 16px;
  }

  .brand small {
    display: none;
  }

  .actions {
    justify-content: flex-end;
  }

  .reset-btn {
    min-height: 38px;
    padding: 0 12px;
    font-size: 11px;
  }

  .icon-btn {
    width: 38px;
    min-height: 38px;
  }

  .hero {
    min-height: 390px;
    padding-top: 62px;
  }

  .hero h1 {
    font-size: clamp(34px, 12vw, 54px);
  }

  .section-head {
    align-items: stretch;
    padding: 23px 20px;
    flex-direction: column;
  }

  .export-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .secondary-btn {
    padding-inline: 8px;
    font-size: 11px;
  }

  .bracket-viewport {
    padding: 22px 18px 32px;
    overflow-x: auto;
  }

  .bracket {
    width: 2122px;
    grid-template-columns: repeat(9, 210px);
    gap: 29px;
  }

  .round {
    width: auto;
  }

  .match-card {
    min-height: 188px;
  }

  .bracket-path {
    gap: 5px;
    padding-inline: 8px;
  }

  .bracket-path div {
    min-width: 43px;
  }

  .bracket-path span {
    font-size: 8px;
  }

  .bracket-path i {
    font-size: 12px;
  }

  .penalty-score-grid {
    gap: 7px;
  }

  .modal {
    padding: 28px 20px;
  }

  footer {
    align-items: center;
    flex-direction: column;
    gap: 4px;
  }

  footer p {
    margin: 0;
  }
}

/* احترام تفضيل تقليل الحركة لإتاحة أفضل. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .topbar, .hero, .export-actions, footer, .champion-section {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .tournament-shell {
    margin: 0;
    border: 0;
    box-shadow: none;
  }
}
