:root {
  color-scheme: dark;
  font-family: "Tajawal", "Cairo", system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  color: #ffffff;
  background: #080910;
  --panel: rgba(8, 10, 18, 0.50);
  --line: rgba(255, 255, 255, 0.16);
  --muted: rgba(255, 255, 255, 0.72);
  --blue: #68dcff;
  --pink: #ff6fae;
  --green: #77f5ba;
  --dark-square: rgba(24, 29, 42, 0.95);
  --light-square: rgba(240, 224, 190, 0.80);
}

* {
  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.76)),
    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(1480px, 100%);
  min-height: 100vh;
  margin-inline: auto;
  padding: clamp(10px, 1.5vw, 18px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: clamp(10px, 1.6vw, 16px);
}

.topbar,
.board-panel,
.score-panel,
.rules-card,
.hint-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
}

.topbar {
  min-height: 50px;
  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: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #ff4d8d, #7c5cff 56%, #00d4ff);
  color: #ffffff;
  font-size: 1.35rem;
  font-weight: 950;
}

.top-actions {
  gap: 8px;
}

.top-actions a,
.game-actions button,
.mode {
  min-height: 38px;
  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(170px, 0.54fr) minmax(520px, 1.65fr) minmax(150px, 0.38fr);
  align-items: center;
  gap: clamp(12px, 2vw, 22px);
}

.side-panel {
  display: grid;
  align-content: center;
  gap: 12px;
}

.kicker,
.subtitle {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.kicker {
  color: var(--green);
}

h1 {
  margin: 0;
  font-size: clamp(2.7rem, 6vw, 5.4rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.subtitle {
  max-width: 22rem;
  font-size: 1rem;
  line-height: 1.55;
}

.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));
}

.rules-card,
.hint-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.38;
}

.rules-card strong,
.hint-card strong {
  color: #ffffff;
}

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

.status-card {
  order: 2;
  min-height: 50px;
  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: 66px;
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #ffffff;
  color: #11131d;
}

.board-wrap {
  order: 1;
  width: min(100%, calc(100svh - 115px));
  margin-inline: auto;
  aspect-ratio: 1;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.30);
}

.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 12px;
}

.square {
  position: relative;
  border: 0;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: default;
}

.square.dark {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.06), transparent 55%),
    var(--dark-square);
}

.square.light {
  background: var(--light-square);
}

.square.playable {
  cursor: pointer;
}

.square.selected {
  outline: 4px solid rgba(119, 245, 186, 0.82);
  outline-offset: -4px;
  z-index: 2;
}

.square.target::after {
  content: "";
  width: 30%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(119, 245, 186, 0.72);
  box-shadow: 0 0 26px rgba(119, 245, 186, 0.62);
}

.square.capture-target::after {
  width: 40%;
  background: rgba(255, 219, 110, 0.82);
  box-shadow: 0 0 30px rgba(255, 219, 110, 0.64);
}

.piece {
  width: 74%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.36);
  box-shadow:
    inset 0 8px 14px rgba(255, 255, 255, 0.22),
    inset 0 -10px 20px rgba(0, 0, 0, 0.32),
    0 12px 22px rgba(0, 0, 0, 0.34);
  color: rgba(255, 255, 255, 0.92);
  font-size: clamp(1rem, 3vw, 1.55rem);
  font-weight: 950;
  transition: transform 140ms ease;
}

.playable:hover .piece {
  transform: translateY(-3px);
}

.piece.blue {
  background: linear-gradient(145deg, #6ee6ff, #2376d9);
}

.piece.pink {
  background: linear-gradient(145deg, #ff8fca, #b81865);
}

.piece.king::before {
  content: "★";
}

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

.game-actions button:hover,
.top-actions a:hover,
.mode:hover {
  border-color: rgba(120, 228, 255, 0.52);
  background: rgba(255, 255, 255, 0.14);
}

.score-panel {
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 12px;
  border-radius: 20px;
}

.score-row {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.08);
}

.score-row span {
  color: var(--muted);
  font-weight: 850;
}

.score-row strong {
  font-size: 1.42rem;
}

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

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

  .board-panel {
    order: -1;
  }

  .side-panel,
  .score-panel {
    width: min(700px, 100%);
    margin-inline: auto;
  }

  .side-panel {
    align-content: start;
  }

  h1 {
    font-size: clamp(2.8rem, 14vw, 5rem);
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
  }

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

  .top-actions {
    width: 100%;
  }

  .top-actions a {
    flex: 1;
    justify-content: center;
  }

  .board-panel {
    padding: 10px;
  }

  .board-wrap {
    padding: 6px;
  }

  .game-actions,
  .mode-switch {
    grid-template-columns: 1fr;
  }
}
