:root{
  --bg: #f6f8f9;
  --bg-soft: #fbfcfc;
  --card: #ffffff;
  --card-2: #fcfafa;

  --text: #243444;
  --muted: #7c8b95;

  --pink: #e8a2ba;
  --pink-soft: #f8e8ee;
  --pink-border: #efc9d6;

  --line: #d9e3e8;
  --line-soft: #e8eef1;

  --shadow: 0 12px 30px rgba(49, 72, 89, 0.06);
  --shadow-strong: 0 16px 40px rgba(49, 72, 89, 0.10);

  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;

  --ring: 0 0 0 4px rgba(232,162,186,.18);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Tajawal", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(215, 231, 236, .70), transparent 26%),
    radial-gradient(circle at top right, rgba(244, 226, 233, .45), transparent 20%),
    linear-gradient(180deg, #f8fbfc, var(--bg));
  color: var(--text);
}

body {
  position: relative;
  overflow-x: hidden;
}

.bg-orbs::before,
.bg-orbs::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  z-index: 0;
  pointer-events: none;
}

.bg-orbs::before {
  width: 260px;
  height: 260px;
  top: 0;
  left: 0;
  background: rgba(208, 226, 232, .45);
}

.bg-orbs::after {
  width: 260px;
  height: 260px;
  top: 0;
  right: 0;
  background: rgba(244, 222, 231, .35);
}

.hero,
.container,
.modal,
.final-screen {
  position: relative;
  z-index: 1;
}

.hero {
  max-width: 1320px;
  margin: 0 auto;
  padding: 32px 20px 16px;
  display: grid;
  grid-template-columns: 1.5fr 0.9fr;
  gap: 22px;
  align-items: stretch;
}

.hero-content,
.hero-card,
.top-panel,
.game-section,
.modal-content,
.final-content {
  background: rgba(255,255,255,.86);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow);
}

.hero-content {
  border-radius: var(--radius-xl);
  padding: 36px 34px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  color: #c96d8d;
  border: 1px solid #c96d8d;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
}

.badge.success {
  background: var(--pink-soft);
  color: #a1627b;
  border-color: var(--pink-border);
}

.hero-content h1 {
  font-size: clamp(30px, 4vw, 54px);
  margin: 18px 0 16px;
  line-height: 1.3;
  color: #1f6d79;
  font-weight: 800;
}

.hero-content p {
  color: var(--muted);
  line-height: 2;
  font-size: 17px;
  margin: 0;
  max-width: 760px;
  font-weight: 500;
}

.hero-actions {
  display: flex;
  gap: 14px;
  margin-top: 30px;
  flex-wrap: wrap;
}

.hero-card {
  border-radius: var(--radius-xl);
  padding: 20px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.mini-stat {
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  padding: 24px 20px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.mini-stat span {
  display: block;
  color: #96a4ac;
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 500;
}

.mini-stat strong {
  font-size: 20px;
  color: var(--text);
  font-weight: 800;
}

.hero-characters {
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  padding: 18px 16px;
}

.characters-title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 800;
  color: #1f6d79;
  text-align: center;
}

.characters-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.character-card {
  background: linear-gradient(180deg, #ffffff, #fbfcfc);
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  padding: 14px 10px;
  text-align: center;
  transition: 0.25s ease;
}

.character-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(49, 72, 89, 0.08);
}

.character-card img {
  width: 100%;
  max-width: 95px;
  height: 120px;
  object-fit: contain;
  display: block;
  margin: 0 auto 10px;
}

.character-card span {
  display: block;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 20px 40px;
}

.top-panel {
  border-radius: var(--radius-xl);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  flex: 1;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  padding: 18px 16px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-card .label {
  display: block;
  color: #9aa7af;
  font-size: 14px;
  margin-bottom: 8px;
  font-weight: 500;
}

.stat-card strong {
  font-size: 22px;
  color: var(--text);
  font-weight: 800;
}

.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line);
  outline: none;
  border-radius: 18px;
  padding: 14px 22px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.25s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #ffffff;
  color: var(--text);
  min-height: 54px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(49, 72, 89, 0.08);
}

.btn:focus-visible,
.map-point:focus-visible,
.modal-close:focus-visible,
.card:focus-visible {
  box-shadow: var(--ring);
}

.btn.primary {
  background: linear-gradient(180deg, #ffffff, #fcfcfc);
  color: #c96d8d;
  border: 2px solid #efc9d6;
}

.btn.primary:hover {
  background: #fffafb;
}

.btn.secondary {
  background: #ffffff;
  color: #c96d8d;
  border: 1px solid #c96d8d;
}

.btn.ghost {
  background: #ffffff;
  color: #1f6d79;
  border: 1px solid #1f6d79;
}

.mode-btn.active {
  background: #fff4f8;
  border-color: #c96d8d;
  box-shadow: 0 10px 22px rgba(201, 109, 141, 0.10);
}

.game-section {
  margin-top: 20px;
  border-radius: var(--radius-xl);
  padding: 20px;
}

.board-head {
  margin-bottom: 18px;
}

.board-head h2 {
  margin: 0 0 8px;
  color: #1f6d79;
  font-size: 28px;
  font-weight: 800;
}

.board-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.9;
  font-weight: 500;
}

.board-layout {
  display: grid;
  grid-template-columns: 1fr 70px 1fr;
  gap: 20px;
  align-items: start;
}

.board-side {
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  padding: 16px;
}

.side-title {
  text-align: center;
  margin-bottom: 14px;
  font-weight: 800;
  color: #c96d8d;
  font-size: 16px;
}

.board-divider {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-divider span {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  padding: 14px 8px;
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  color: #1f6d79;
  font-weight: 800;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.side-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

/* مهم: هذا اللي رجّع حجم الكرت طبيعي مثل قبل */
.card {
  aspect-ratio: 1 / 1.06;
  perspective: 1000px;
  cursor: pointer;
  position: relative;
  outline: none;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 22px;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(.2,.8,.2,1);
}

.card.flipped .card-inner,
.card.matched .card-inner,
.card.preview .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid #dfe8ec;
  background: #ffffff;
}

.card-front {
  background:
    radial-gradient(circle at top, rgba(222, 231, 235, .55), transparent 48%),
    linear-gradient(180deg, #ffffff, #fbfcfc);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-front::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 18px;
  border: 1px dashed #d7e4e9;
}

.card-front-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.card-front-content i {
  font-size: 28px;
  color: #5f95a2;
  margin-bottom: 12px;
}

.card-front-content span {
  display: block;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.card-back {
  transform: rotateY(180deg);
  background: #ffffff;
}

.card-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.card:hover .card-back img {
  transform: scale(1.02);
}

.card.matched {
  pointer-events: none;
}

.card.matched .card-face {
  border-color: #ead3dc;
  box-shadow: 0 0 0 1px #f2dce4, 0 12px 24px rgba(232,162,186,.12);
}

.card.disabled {
  pointer-events: none;
}

.modal,
.final-screen {
  position: fixed;
  inset: 0;
}

.hidden {
  display: none !important;
}

.modal-backdrop,
.final-overlay {
  position: absolute;
  inset: 0;
  background: rgba(36, 52, 68, .18);
  backdrop-filter: blur(6px);
}

.modal {
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  position: relative;
  width: min(980px, 100%);
  background: #ffffff;
  border-radius: 28px;
  box-shadow: var(--shadow-strong);
  padding: 28px;
}

.modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #7d8b94;
  cursor: pointer;
  font-size: 18px;
}

.modal-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  align-items: center;
}

.modal-image-wrap {
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  min-height: 280px;
  background: #fff;
}

.modal-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.modal-badge {
  display: inline-block;
  color: #a1627b;
  background: var(--pink-soft);
  border: 1px solid var(--pink-border);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  margin-bottom: 12px;
}

.modal-text h2 {
  margin: 0 0 12px;
  font-size: 32px;
  color: var(--text);
  font-weight: 800;
}

.modal-text p {
  color: var(--text);
  line-height: 1.9;
  font-size: 16px;
  font-weight: 500;
}

.final-screen {
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.final-content {
  position: relative;
  width: min(1200px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #ffffff;
  border-radius: 30px;
  padding: 26px;
  box-shadow: var(--shadow-strong);
}

.final-header h2 {
  margin: 14px 0 10px;
  font-size: clamp(24px, 3vw, 38px);
  color: var(--text);
  font-weight: 800;
}

.final-header p {
  color: var(--muted);
  line-height: 1.9;
  font-weight: 500;
}

.final-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.final-stats > div {
  background: #ffffff;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  padding: 14px 18px;
  min-width: 160px;
}

.final-stats span {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.final-stats strong {
  font-size: 24px;
  color: var(--text);
  font-weight: 800;
}

.aqsa-explorer {
  margin-top: 28px;
  background: linear-gradient(180deg, #ffffff, #fbfcfc);
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  padding: 20px;
}

.aqsa-explorer-head h3 {
  margin: 0 0 10px;
  color: #1f6d79;
  font-size: 24px;
  font-weight: 800;
}

.aqsa-explorer-head p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.9;
  font-weight: 500;
}

.aqsa-map-wrapper {
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  background: #f7fafb;
}

.aqsa-map {
  position: relative;
  width: 100%;
  line-height: 0;
}

.aqsa-map img {
  width: 100%;
  height: auto;
  display: block;
}

.map-point {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #c96d8d;
  box-shadow:
    0 0 0 4px rgba(201, 109, 141, 0.18),
    0 8px 16px rgba(36, 52, 68, 0.16);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  z-index: 2;
}

.map-point::after {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 1px solid rgba(201, 109, 141, 0.35);
  animation: pulsePoint 1.8s infinite;
}

.map-point:hover {
  transform: translate(-50%, -50%) scale(1.08);
  background: #1f6d79;
  box-shadow:
    0 0 0 4px rgba(31, 109, 121, 0.16),
    0 10px 18px rgba(36, 52, 68, 0.20);
}

.map-point span {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 50%;
  transform: translateX(50%);
  background: rgba(36, 52, 68, 0.92);
  color: #fff;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.map-point:hover span,
.map-point:focus-visible span {
  opacity: 1;
  transform: translateX(50%) translateY(-2px);
}

.final-actions {
  display: flex;
  justify-content: center;
  margin-top: 22px;
}

@keyframes pulsePoint {
  0% {
    transform: scale(0.9);
    opacity: 0.9;
  }
  70% {
    transform: scale(1.35);
    opacity: 0;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

@media (max-width: 1100px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .modal-layout {
    grid-template-columns: 1fr;
  }

  .side-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .board-layout {
    grid-template-columns: 1fr;
  }

  .board-divider {
    min-height: auto;
  }

  .board-divider span {
    writing-mode: initial;
    text-orientation: initial;
    width: fit-content;
    margin: 0 auto;
  }

  .side-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .hero-content,
  .hero-card,
  .top-panel,
  .game-section,
  .final-content,
  .modal-content,
  .board-side {
    border-radius: 22px;
  }

  .hero-content {
    padding: 24px;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .hero-actions,
  .controls {
    width: 100%;
  }

  .hero-actions .btn,
  .controls .btn {
    flex: 1;
  }

  .modal-content,
  .final-content {
    padding: 18px;
  }

  .modal-text h2 {
    font-size: 25px;
  }

  .characters-list {
    grid-template-columns: 1fr 1fr;
  }

  .character-card img {
    max-width: 80px;
    height: 100px;
  }

  .map-point {
    width: 18px;
    height: 18px;
  }

  .map-point span {
    font-size: 12px;
    padding: 5px 8px;
  }

  .side-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .card {
    aspect-ratio: 1 / 0.95;
  }

  .card-front-content i {
    font-size: 22px;
    margin-bottom: 8px;
  }

  .card-front-content span {
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .hero {
    padding: 20px 14px 10px;
  }

  .container {
    padding: 10px 14px 28px;
  }

  .hero-content h1 {
    font-size: 28px;
  }

  .hero-card {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .hero-characters {
    grid-column: 1 / -1;
  }

  .mini-stat {
    min-height: auto;
    padding: 14px 10px;
  }

  .mini-stat span {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .mini-stat strong {
    font-size: 14px;
    line-height: 1.5;
  }

  .stats {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .stat-card {
    min-height: auto;
    padding: 12px 8px;
  }

  .stat-card .label {
    font-size: 11px;
    margin-bottom: 4px;
  }

  .stat-card strong {
    font-size: 14px;
  }

  .controls {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .controls .btn {
    width: 100%;
    min-height: 46px;
    padding: 10px 8px;
    font-size: 12px;
  }

  .characters-list {
    grid-template-columns: 1fr;
  }

  .aqsa-explorer {
    padding: 14px;
  }

  .map-point {
    width: 16px;
    height: 16px;
    border-width: 2px;
  }

  .board-side {
    padding: 12px;
  }

  .side-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .card {
    aspect-ratio: 1 / 0.88;
  }

  .card-face,
  .card-inner {
    border-radius: 16px;
  }

  .card-front::before {
    inset: 8px;
    border-radius: 12px;
  }

  .card-front-content i {
    font-size: 18px;
  }

  .card-front-content span {
    font-size: 11px;
  }

  .board-head h2 {
    font-size: 22px;
  }

  .board-head p {
    font-size: 14px;
  }
}