:root {
  --background: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #f1f5fb;
  --brand-cream: #fffde1;
  --brand-yellow: #fff1a8;
  --brand-purple: #6e56cf;
  --brand-purple-dark: #5842b8;
  --brand-red: #c94b54;
  --text: #23262b;
  --muted: #5f6b7a;
  --primary: #0b3a8a;
  --primary-light: #245cb1;
  --border: #d5deeb;
  --success: #15803d;
  --shadow: 0 16px 36px rgba(11, 58, 138, 0.1);
  --brand-shadow: 0 7px 0 var(--primary);

  /* Aliases keep the activity-specific styles readable. */
  --navy: var(--primary);
  --navy-light: var(--primary-light);
  --blue: var(--brand-purple);
  --blue-soft: var(--surface-soft);
  --bg: var(--background);
  --card: var(--surface);
  --warning: #c77700;

  /* צבעי המגרש נשארים ייעודיים להמחשה. */
  --gold: #facc15;
  --yellow-line: #fff7ae;
  --white: #ffffff;
  --success-light: #dcfce7;
  --warning-light: #fef3c7;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    "Noto Sans Hebrew",
    "Montserrat",
    Arial,
    sans-serif;
  color: var(--text);
  background: var(--background);
  line-height: 1.6;
}

html[lang="en"] body {
  font-family:
    "Montserrat",
    "Manrope",
    Arial,
    sans-serif;
}

button,
input {
  font: inherit;
}

button,
.fundamatics-home-link {
  font-family:
    "Manrope",
    "Noto Sans Hebrew",
    Arial,
    sans-serif;
}

#app {
  width: min(1160px, calc(100% - 32px));
  margin: 22px auto 36px;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
  padding: 16px 18px;
  border: 2px solid var(--primary);
  border-radius: 22px;
  background: var(--brand-cream);
  color: var(--text);
  box-shadow:
    var(--brand-shadow),
    var(--shadow);
}

.brand-product-lockup {
  display: flex;
  flex: 1 1 560px;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.fundamatics-brand {
  display: flex;
  width: min(230px, 42vw);
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 18px 7px;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  text-decoration: none;
}

.fundamatics-brand img {
  display: block;
  width: 100%;
  height: auto;
}

.brand-tagline {
  color: var(--brand-yellow);
  font-family: cursive;
  font-size: 0.92rem;
  font-style: italic;
  line-height: 1.15;
}

.brand-divider {
  color: var(--primary);
  font-family: "Montserrat", Arial, sans-serif;
  font-size: 2rem;
  font-weight: 600;
}

.product-identity {
  min-width: 0;
}

.app-header h1 {
  margin: 0 0 2px;
  color: var(--primary);
  font-family: "Montserrat", Arial, sans-serif;
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 800;
  line-height: 1.2;
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.language-option {
  width: auto;
  min-width: 0;
  padding: 7px 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.language-option:hover {
  background: var(--surface-soft);
}

.language-option.is-active,
.language-option.is-active:hover {
  background: var(--primary);
  color: white;
}

.fundamatics-home-link {
  flex: 0 0 auto;
  padding: 10px 18px;
  border: 2px solid var(--brand-purple);
  border-radius: 999px;
  color: var(--brand-purple-dark);
  font-weight: 700;
  text-decoration: none;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.fundamatics-home-link:hover {
  background: var(--brand-purple);
  color: white;
  transform: translateY(-2px);
}

.fundamatics-brand:focus-visible,
.fundamatics-home-link:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(110, 86, 207, 0.35);
  outline-offset: 3px;
}

/* מבנה */

.app-layout {
  width: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 22px;
  align-items: start;
}

.simulation-panel,
.information-panel {
  min-width: 0;
}

.simulation-panel,
.math-card,
.identity-card,
.controls-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.simulation-panel {
  padding: 24px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0 0 4px;
  color: var(--navy);
  font-size: 1.4rem;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.model-badge {
  flex: 0 0 auto;
  padding: 6px 11px;
  color: var(--primary);
  background: var(--brand-cream);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
}

/* מגרש */

.pitch-wrapper {
  position: relative;
  width: 100%;
  overflow: hidden;
  aspect-ratio: 68 / 52.5;
  border-radius: 18px;
  background: #0b6d37;
  border: 4px solid rgba(255, 255, 255, 0.75);
  box-shadow:
    inset 0 0 30px rgba(0, 0, 0, 0.22),
    0 12px 25px rgba(15, 23, 42, 0.18);
}

#footballPitch {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  touch-action: none;
}

.draggable {
  cursor: grab;
}

.draggable:active {
  cursor: grabbing;
}

#shotLine {
  filter:
    drop-shadow(
      0 0 5px rgba(255, 247, 174, 0.7)
    );
}

/* מקרא */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-top: 12px;
  color: #334155;
  font-size: 14px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend-ball,
.legend-target {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.legend-ball {
  background: var(--white);
  border: 2px solid #111827;
}

.legend-target {
  background: var(--gold);
  border: 2px solid #713f12;
}

.legend-line {
  display: inline-block;
  width: 30px;
  height: 5px;
  border-radius: 4px;
  background: var(--yellow-line);
}

.instruction-box {
  margin-top: 14px;
  padding: 16px;
  color: var(--text);
  background: var(--brand-cream);
  border: 1px solid var(--border);
  border-radius: 18px;
  line-height: 1.5;
}

/* פאנל מידע */

.information-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.math-card,
.controls-card {
  padding: 18px;
}

.math-card h2,
.identity-card h2,
.controls-card h2 {
  margin: 0 0 9px;
  color: var(--navy);
  font-size: 18px;
}

.primary-card {
  border-inline-start: 6px solid var(--brand-purple);
}

.main-equation {
  direction: ltr;
  margin: 8px 0;
  text-align: center;
  color: var(--navy);
  font-size: clamp(28px, 4vw, 36px);
  font-weight: 800;
}

#equationExplanation {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  text-align: center;
}

.values-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.value-card {
  min-width: 0;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.value-card span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.value-card strong {
  display: block;
  direction: ltr;
  color: var(--navy);
  font-size: 19px;
}

/* שיפוע וטנגנס */

.identity-card {
  padding: 16px;
  background: var(--surface-soft);
  border-color: var(--border);
}

.identity-card h2 {
  margin-bottom: 5px;
  font-size: 16px;
}

.identity-line {
  direction: ltr;
  display: grid;
  grid-template-columns: 1fr auto 1.5fr;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  padding: 5px 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
}

.identity-result {
  direction: ltr;
  margin-top: 6px;
  padding: 7px;
  color: var(--success);
  background: var(--success-light);
  border: 2px solid #86efac;
  border-radius: 11px;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
}

.identity-result.undefined {
  color: var(--warning);
  background: var(--warning-light);
  border-color: #fcd34d;
}

/* בקרים */

.controls-card label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 11px 0 6px;
  color: var(--text);
  font-weight: 700;
}

.controls-card label strong {
  min-width: 73px;
  padding: 5px 8px;
  color: var(--navy);
  background: var(--surface-soft);
  border-radius: 10px;
  text-align: center;
}

.controls-card input[type="range"] {
  width: 100%;
  height: 6px;
  accent-color: var(--brand-purple);
  cursor: pointer;
}

.target-heading {
  margin-top: 18px !important;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* כפתורים */

.button-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
  max-width: 420px;
  margin: 0 auto 10px;
}

.button-row button {
  min-width: 120px;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    background 0.15s ease;
}

.primary-button {
  color: var(--white);
  background: var(--brand-purple);
}

.secondary-button {
  color: var(--brand-purple-dark);
  background: var(--white);
  border-color: var(--brand-purple) !important;
}

.button-row button:hover {
  transform: translateY(-2px);
  background: var(--brand-purple-dark);
  color: white;
}

footer {
  padding: 28px 16px 0;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

/* שולחן עבודה: כל האפליקציה נשארת בתוך גובה המסך. */

@media (min-width: 651px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  #app {
    display: grid;
    grid-template-rows:
      auto
      minmax(0, 1fr)
      auto;
    gap: 10px;
    height: calc(100dvh - 20px);
    margin: 10px auto;
  }

  .app-header {
    gap: 14px;
    margin-bottom: 0;
    padding: 10px 14px;
    border-radius: 18px;
  }

  .brand-product-lockup {
    flex-basis: 500px;
    gap: 12px;
  }

  .fundamatics-brand {
    width: 190px;
    padding: 7px 14px 5px;
  }

  .brand-tagline {
    font-size: 0.78rem;
  }

  .brand-divider {
    font-size: 1.65rem;
  }

  .app-header h1 {
    font-size: clamp(1.2rem, 2vw, 1.65rem);
  }

  .app-header p {
    font-size: 0.82rem;
    line-height: 1.35;
  }

  .header-actions {
    gap: 8px;
  }

  .language-option {
    padding: 6px 9px;
  }

  .fundamatics-home-link {
    padding: 8px 14px;
    font-size: 0.9rem;
  }

  .app-layout {
    height: 100%;
    min-height: 0;
    gap: 14px;
    align-items: stretch;
  }

  .simulation-panel {
    display: grid;
    grid-template-rows:
      auto
      minmax(0, 1fr)
      auto
      auto;
    min-height: 0;
    padding: 14px;
    border-radius: 20px;
  }

  .section-heading {
    margin-bottom: 7px;
  }

  .section-heading h2 {
    font-size: 1.22rem;
  }

  .section-heading p {
    font-size: 0.86rem;
  }

  .pitch-wrapper {
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
    border-width: 3px;
    border-radius: 15px;
  }

  .legend {
    gap: 6px 14px;
    margin-top: 6px;
    font-size: 0.82rem;
  }

  .instruction-box {
    display: grid;
    grid-template-columns:
      minmax(250px, 360px)
      minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    margin-top: 6px;
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .button-row {
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .button-row button {
    min-width: 0;
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  .information-panel {
    display: grid;
    grid-template-rows:
      auto
      auto
      auto
      minmax(0, 1fr);
    gap: 8px;
    height: 100%;
    min-height: 0;
  }

  .math-card,
  .controls-card {
    padding: 11px 13px;
  }

  .math-card h2,
  .controls-card h2 {
    margin-bottom: 4px;
    font-size: 1rem;
  }

  .main-equation {
    margin: 2px 0;
    font-size: clamp(1.55rem, 3vw, 2rem);
  }

  #equationExplanation {
    font-size: 0.82rem;
    line-height: 1.3;
  }

  .values-grid {
    gap: 7px;
  }

  .value-card {
    padding: 8px 10px;
    border-radius: 14px;
  }

  .value-card span {
    margin-bottom: 1px;
    font-size: 0.75rem;
  }

  .value-card strong {
    font-size: 1.02rem;
  }

  .identity-card {
    padding: 9px 11px;
  }

  .identity-card h2 {
    margin-bottom: 3px;
    font-size: 0.9rem;
  }

  .identity-line {
    margin: 3px 0;
    padding: 3px 7px;
    font-size: 0.82rem;
  }

  .identity-result {
    margin-top: 4px;
    padding: 4px 6px;
    font-size: 0.88rem;
  }

  .controls-card {
    min-height: 0;
  }

  .controls-card label {
    margin: 5px 0 2px;
    font-size: 0.84rem;
  }

  .controls-card label strong {
    min-width: 62px;
    padding: 2px 6px;
  }

  .target-heading {
    margin-top: 8px !important;
    padding-top: 7px;
  }

  footer {
    padding: 0;
    font-size: 0.72rem;
    line-height: 1.2;
  }
}

@media (min-width: 651px) and (max-height: 820px) {
  #app {
    gap: 6px;
    height: calc(100dvh - 8px);
    margin: 4px auto;
  }

  .app-header {
    padding: 6px 10px;
  }

  .fundamatics-brand {
    width: 165px;
    padding-block: 5px 3px;
  }

  .brand-tagline {
    display: none;
  }

  .app-header h1 {
    font-size: 1.2rem;
  }

  .app-layout {
    gap: 10px;
  }

  .simulation-panel {
    padding: 10px;
  }

  .section-heading {
    margin-bottom: 4px;
  }

  .section-heading h2 {
    font-size: 1.05rem;
  }

  .section-heading p,
  .model-badge {
    font-size: 0.76rem;
  }

  .legend {
    margin-top: 3px;
    font-size: 0.74rem;
  }

  .instruction-box {
    margin-top: 3px;
    padding-block: 5px;
    font-size: 0.75rem;
  }

  .button-row button {
    padding-block: 6px;
    font-size: 0.82rem;
  }

  .information-panel {
    gap: 5px;
  }

  .math-card,
  .controls-card {
    padding: 8px 10px;
  }

  .value-card {
    padding-block: 5px;
  }

  .identity-card {
    padding: 6px 9px;
  }

  .identity-line {
    margin: 2px 0;
    padding-block: 2px;
  }

  .controls-card label {
    margin-top: 3px;
  }

  .target-heading {
    margin-top: 5px !important;
    padding-top: 4px;
  }

  footer {
    display: none;
  }
}

/*
  חלונות בינוניים מקבלים משטח עבודה וירטואלי רחב יותר
  שמוקטן כמקשה אחת. כך כל הבקרים נשארים גלויים בלי
  להפוך את הפריסה לעמוד ארוך.
*/

@media (min-width: 721px) and (max-width: 850px) {
  #app {
    position: fixed;
    top: 5.333px;
    left: 0;
    width: 100%;
    height: calc(133.333dvh - 10.667px);
    margin: 0;
    zoom: 0.75;
  }

  .brand-product-lockup {
    flex: 1 1 auto;
    gap: 7px;
  }

  .fundamatics-brand {
    width: 145px;
  }

  .brand-divider {
    font-size: 1.25rem;
  }

  .app-header h1 {
    font-size: 1rem;
  }

  .app-header p,
  .fundamatics-home-link {
    display: none;
  }

  .header-actions {
    flex: 0 0 auto;
  }
}

@media (min-width: 651px) and (max-width: 720px) {
  #app {
    position: fixed;
    top: 6.061px;
    left: 0;
    width: 100%;
    height: calc(151.515dvh - 12.121px);
    margin: 0;
    zoom: 0.66;
  }

  .brand-product-lockup {
    flex: 1 1 auto;
    gap: 6px;
  }

  .fundamatics-brand {
    width: 135px;
  }

  .brand-divider {
    font-size: 1.15rem;
  }

  .app-header h1 {
    font-size: 0.95rem;
  }

  .app-header p,
  .fundamatics-home-link {
    display: none;
  }

  .header-actions {
    flex: 0 0 auto;
  }
}

/* טאבלט */

@media (max-width: 650px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-product-lockup {
    flex-basis: auto;
  }

  .header-actions {
    justify-content: space-between;
  }

  .fundamatics-home-link {
    align-self: flex-start;
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .information-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .primary-card,
  .controls-card {
    grid-column: 1 / -1;
  }
}

/* נייד */

@media (max-width: 650px) {
  #app {
    width: min(100% - 16px, 1160px);
    margin: 10px auto 24px;
  }

  .app-header {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    border-radius: 18px;
  }

  .brand-product-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .fundamatics-brand {
    width: min(220px, 100%);
  }

  .brand-divider {
    display: none;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .language-switcher {
    align-self: flex-start;
  }

  .fundamatics-home-link {
    align-self: stretch;
    text-align: center;
  }

  .app-layout {
    width: 100%;
  }

  .simulation-panel {
    padding: 16px;
    border-radius: 18px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .information-panel {
    display: flex;
  }

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

  .button-row {
    grid-template-columns: 1fr;
  }

  .button-row button {
    width: 100%;
  }

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

  .legend {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .button-row button {
    transition: none;
  }

  .fundamatics-home-link {
    transition: none;
  }
}
