@import url('https://fonts.googleapis.com/css2?family=Alexandria:wght@300;400;500;600;700;800&display=swap');

: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);

  --success: #7ab98f;
  --danger: #d87087;
  --gold: #b98b45;
  --closed: #c8b39a;
  --open: #92c7a4;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(circle at top right, #fff2f7 0%, #f9fbfc 30%, #f6f8f9 70%);
  color: var(--text);
  font-family: "Alexandria", "Tahoma", "Arial", sans-serif;
  direction: rtl;
}

body {
  min-height: 100vh;
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 18px auto 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-badge {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--pink-soft), #fff);
  border: 1px solid var(--pink-border);
  box-shadow: var(--shadow);
  font-size: 1.5rem;
}

.brand h1 {
  margin: 0;
  font-size: 2.1rem;
  line-height: 1.2;
  font-weight: 800;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.topbar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.scoreboard {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.score-card {
  min-width: 138px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  text-align: center;
}

.score-label {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.score-card strong {
  display: block;
  font-size: 1.8rem;
  color: var(--text);
  font-weight: 700;
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: linear-gradient(135deg, #fff 0%, #fcf7f9 100%);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-strong);
  border-radius: var(--radius-xl);
  padding: 22px;
  margin-bottom: 18px;
}

.eyebrow {
  display: inline-block;
  background: var(--pink-soft);
  color: #b86f89;
  border: 1px solid var(--pink-border);
  border-radius: 999px;
  padding: 7px 12px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

.hero-card h2 {
  margin: 0 0 10px;
  font-size: 1.35rem;
  line-height: 1.7;
  font-weight: 700;
}

.hero-card p {
  margin: 0;
  line-height: 2;
  color: var(--muted);
  font-size: 0.97rem;
}

.hero-actions {
  flex-shrink: 0;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) 360px;
  gap: 18px;
  align-items: start;
}

.map-card,
.panel {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.map-card {
  padding: 14px;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 4px 14px;
}

.map-toolbar h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.map-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.pill {
  background: var(--pink-soft);
  border: 1px solid var(--pink-border);
  color: #b86f89;
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.map-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 24px;
  background: #fff;
  border: 1px solid var(--line-soft);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6);
}

.map-image {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}

.doors-layer {
  position: absolute;
  inset: 0;
}

.side-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.rules {
  margin: 0;
  padding-right: 20px;
  color: var(--muted);
  line-height: 2;
  font-size: 0.93rem;
}

.message-box,
.fact-box {
  background: linear-gradient(180deg, var(--bg-soft), #fff);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  line-height: 2;
  min-height: 110px;
  font-size: 0.95rem;
}

.fact-box {
  border-right: 5px solid var(--pink);
}

.btn {
  border: 0;
  cursor: pointer;
  border-radius: 16px;
  padding: 13px 20px;
  transition: 0.22s ease;
  font-weight: 600;
}

.btn:focus-visible,
.answer-btn:focus-visible,
.door-marker:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn-primary {
  background: linear-gradient(180deg, var(--pink), #df92ad);
  color: #fff;
  box-shadow: 0 12px 22px rgba(232, 162, 186, 0.26);
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.btn-secondary,
.answer-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.btn-secondary:hover,
.answer-btn:hover {
  border-color: var(--pink-border);
  background: var(--pink-soft);
}

.door-marker {
  position: absolute;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  z-index: 20;
  transition: transform 0.2s ease, opacity 0.25s ease;
}

.door-marker .door-icon {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffd98b, #d8aa58);
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow:
    0 10px 18px rgba(106, 78, 39, 0.18),
    0 0 0 4px rgba(255, 222, 163, 0.28);
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.25s ease;
}

.door-marker .door-icon::before {
  content: "";
  position: absolute;
  inset: 7px;
  background-image: url("https://api.iconify.design/mdi:door.svg?color=%23503408");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

.door-marker:hover .door-icon {
  transform: scale(1.12);
  box-shadow:
    0 14px 24px rgba(106, 78, 39, 0.22),
    0 0 0 5px rgba(255, 222, 163, 0.35);
}

/* بعد استخدام الباب وكان أصله مفتوح */
.door-marker.used-open {
  pointer-events: none;
  opacity: 0.96;
}

.door-marker.used-open .door-icon {
  background: linear-gradient(180deg, #c9ead3, #8cc4a1);
  box-shadow:
    0 10px 18px rgba(76, 126, 93, 0.16),
    0 0 0 4px rgba(161, 218, 180, 0.26);
}

.door-marker.used-open .door-icon::before {
  background-image: url("https://api.iconify.design/mdi:door-open.svg?color=%233d6c4b");
}

/* بعد استخدام الباب وكان أصله مغلق */
.door-marker.used-closed {
  pointer-events: none;
  opacity: 0.92;
}

.door-marker.used-closed .door-icon {
  background: linear-gradient(180deg, #ead9cc, #c8b39a);
  box-shadow:
    0 10px 18px rgba(112, 89, 66, 0.16),
    0 0 0 4px rgba(216, 196, 177, 0.22);
  filter: grayscale(0.08);
}

.door-marker.used-closed .door-icon::before {
  background-image: url("https://api.iconify.design/mdi:door-closed-lock.svg?color=%23624a34");
}

.door-marker.locked-final {
  animation: finalLockPulse 1.2s ease infinite;
}

.door-marker.locked-final .door-icon {
  background: linear-gradient(180deg, #efb3c3, #d87087);
}

.door-marker.locked-final .door-icon::before {
  background-image: url("https://api.iconify.design/mdi:door-closed-lock.svg?color=%23702b3d");
}

.door-name-tag {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 50%;
  transform: translateX(50%);
  background: #fff;
  border: 1px solid var(--line-soft);
  color: var(--text);
  box-shadow: var(--shadow);
  border-radius: 12px;
  padding: 7px 10px;
  font-size: 0.78rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: 0.18s ease;
}

.door-marker:hover .door-name-tag {
  opacity: 1;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 999;
  background: rgba(40, 54, 66, 0.24);
  backdrop-filter: blur(6px);
  padding: 16px;
}

.modal-card {
  width: min(720px, 100%);
  background: linear-gradient(180deg, #fff, #fffcfd);
  border: 1px solid var(--line-soft);
  border-radius: 28px;
  box-shadow: 0 20px 60px rgba(49, 72, 89, 0.14);
  padding: 26px;
  position: relative;
  animation: modalRise 0.35s ease;
}

.close-btn {
  position: absolute;
  left: 14px;
  top: 12px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.5rem;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 700;
}

.modal-subtitle {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 2;
  font-size: 0.95rem;
}

.modal-note {
  background: var(--pink-soft);
  border: 1px solid var(--pink-border);
  color: #a05e76;
  border-radius: 16px;
  padding: 12px 14px;
  margin: 14px 0;
  line-height: 1.9;
  font-size: 0.92rem;
}

.question-box {
  background: linear-gradient(180deg, #fcfeff, #fff);
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  padding: 16px;
  margin-top: 16px;
}

.question-box h4 {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 700;
}

.question-box p {
  margin: 0;
  line-height: 1.9;
  font-size: 0.95rem;
}

.answers-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.answer-btn {
  width: 100%;
  text-align: right;
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 0.94rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.result-success {
  color: #51876b;
  font-weight: 700;
}

.result-fail {
  color: #c15f79;
  font-weight: 700;
}

.raid-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff3f7;
  border: 1px solid var(--pink-border);
  color: #b86f89;
  padding: 8px 12px;
  border-radius: 999px;
  margin: 10px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.end-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 16px;
  background: rgba(250, 251, 252, 0.86);
  backdrop-filter: blur(8px);
}

.end-card {
  width: min(720px, 100%);
  text-align: center;
  background: linear-gradient(180deg, #fff, #fff8fb);
  border: 1px solid var(--pink-border);
  border-radius: 32px;
  box-shadow: var(--shadow-strong);
  padding: 34px;
  animation: endCardPop 0.65s ease;
}

.end-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: var(--pink-soft);
  border: 1px solid var(--pink-border);
  font-size: 2rem;
  animation: iconFloat 1.8s ease-in-out infinite;
}

.end-card h2 {
  margin: 0 0 12px;
  font-size: 1.4rem;
  font-weight: 800;
}

.end-card p {
  color: var(--muted);
  line-height: 2;
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.global-overlay {
  position: absolute;
  inset: 0;
  background: rgba(232, 162, 186, 0.24);
  z-index: 8;
  animation: overlayFadeIn 0.8s ease;
}

.hidden {
  display: none !important;
}

.shake {
  animation: shakeAnim 0.75s ease;
}

.flash-pink {
  animation: flashPink 1.1s ease;
}

@keyframes shakeAnim {
  0% { transform: translate(0, 0) scale(1); }
  20% { transform: translate(-4px, 2px) scale(1.01); }
  40% { transform: translate(5px, -2px) scale(1.01); }
  60% { transform: translate(-5px, 1px) scale(1.01); }
  80% { transform: translate(4px, -1px) scale(1.005); }
  100% { transform: translate(0, 0) scale(1); }
}

@keyframes flashPink {
  0% { box-shadow: 0 0 0 rgba(232, 162, 186, 0); }
  50% { box-shadow: 0 0 100px rgba(232, 162, 186, 0.55) inset; }
  100% { box-shadow: 0 0 0 rgba(232, 162, 186, 0); }
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalRise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes endCardPop {
  0% {
    opacity: 0;
    transform: scale(0.92) translateY(18px);
  }
  60% {
    opacity: 1;
    transform: scale(1.02) translateY(-4px);
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

@keyframes iconFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes finalLockPulse {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.08);
  }
}

@media (max-width: 1180px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .side-column {
    order: 2;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 18px, 100%);
    margin: 10px auto 20px;
  }

  .brand h1 {
    font-size: 1.5rem;
  }

  .hero-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .score-card {
    min-width: 110px;
  }

  .door-marker {
    width: 30px;
    height: 30px;
  }

  .topbar-actions {
    align-items: stretch;
    width: 100%;
  }
}