:root {
  color-scheme: dark;
  font-family: "Tajawal", "Cairo", system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  color: #ffffff;
  background: #080910;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(4, 5, 12, 0.28), rgba(4, 5, 12, 0.72)),
    linear-gradient(90deg, rgba(3, 24, 31, 0.82), rgba(36, 9, 31, 0.54)),
    url("/assets/salfa-desktop.png") center bottom / cover fixed,
    #080910;
}

button,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin-inline: auto;
  padding: clamp(16px, 3vw, 34px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: clamp(18px, 4vw, 42px);
}

.topbar,
.board-panel,
.score-panel {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(8, 10, 18, 0.48);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
}

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 18px;
}

.brand,
.top-actions,
.top-actions a {
  display: inline-flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 950;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #ff4d8d, #7c5cff 56%, #00d4ff);
  color: #ffffff;
  font-weight: 950;
  letter-spacing: 0;
}

.top-actions {
  gap: 8px;
}

.top-actions a,
.game-actions button,
.mode {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  cursor: pointer;
  font-weight: 850;
}

.top-actions a {
  justify-content: center;
  padding-inline: 14px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(310px, 1fr) minmax(160px, 0.42fr);
  align-items: center;
  gap: clamp(16px, 3vw, 30px);
}

.hero-copy {
  display: grid;
  align-content: center;
  gap: 16px;
}

.kicker,
.subtitle {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.kicker {
  color: #78e4ff;
}

h1 {
  margin: 0;
  font-size: clamp(2.7rem, 8vw, 6.4rem);
  line-height: 0.9;
  letter-spacing: 0;
  text-wrap: balance;
}

.subtitle {
  max-width: 28rem;
  font-size: 1.08rem;
  line-height: 1.65;
}

.mode-switch {
  width: min(100%, 360px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
}

.mode {
  padding-inline: 10px;
}

.mode.is-active {
  border-color: rgba(120, 228, 255, 0.56);
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.24), rgba(255, 77, 141, 0.22));
}

.board-panel {
  width: min(100%, 470px);
  margin-inline: auto;
  display: grid;
  gap: 14px;
  padding: clamp(14px, 3vw, 22px);
  border-radius: 22px;
}

.status-card {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 900;
}

.status-card strong {
  min-width: 44px;
  min-height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #ffffff;
  color: #11131d;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  aspect-ratio: 1;
}

.cell {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.05)),
    rgba(7, 9, 16, 0.72);
  color: #ffffff;
  cursor: pointer;
  font-size: clamp(2.5rem, 8vw, 5.1rem);
  font-weight: 950;
  line-height: 1;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.cell:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: rgba(120, 228, 255, 0.52);
  background:
    linear-gradient(145deg, rgba(120, 228, 255, 0.18), rgba(255, 77, 141, 0.12)),
    rgba(7, 9, 16, 0.82);
}

.cell:disabled {
  cursor: default;
}

.cell.mark-x {
  color: #78e4ff;
  text-shadow: 0 0 26px rgba(0, 212, 255, 0.52);
}

.cell.mark-o {
  color: #ff8ec0;
  text-shadow: 0 0 26px rgba(255, 77, 141, 0.46);
}

.cell.is-win {
  border-color: rgba(255, 214, 102, 0.86);
  background:
    linear-gradient(145deg, rgba(255, 214, 102, 0.22), rgba(255, 255, 255, 0.08)),
    rgba(7, 9, 16, 0.82);
}

.game-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.game-actions button {
  padding-inline: 12px;
}

.top-actions a:hover,
.game-actions button:hover,
.mode:hover {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.16);
}

.top-actions a:focus-visible,
.game-actions button:focus-visible,
.mode:focus-visible,
.cell:focus-visible {
  outline: 3px solid rgba(120, 228, 255, 0.48);
  outline-offset: 3px;
}

.score-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
}

.score-panel div {
  min-height: 76px;
  display: grid;
  place-items: center;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.score-panel span {
  color: rgba(255, 255, 255, 0.68);
  font-weight: 850;
}

.score-panel strong {
  font-size: 2rem;
  line-height: 1;
}

@media (max-width: 920px) {
  body {
    background-attachment: scroll;
  }

  .game-layout {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .hero-copy {
    text-align: center;
    justify-items: center;
  }

  .score-panel {
    width: min(100%, 470px);
    margin-inline: auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: clamp(2.4rem, 16vw, 4.2rem);
  }

  .board {
    gap: 8px;
  }

  .cell {
    border-radius: 12px;
  }

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