* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  font-family: serif;
  direction: rtl;
}

.card-wrap {
  position: relative;
  width: 100%;
  max-width: var(--card-max, 480px);
  line-height: 0;
}

.card-wrap img {
  width: 100%;
  height: auto;
  display: block;
}

.card-wrap input {
  position: absolute;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 4px;
  outline: none;
  font-family: serif;
  font-weight: bold;
  text-align: center;
  direction: rtl;
  padding: 0;
  visibility: hidden;
  color: var(--clr);
  -webkit-text-fill-color: var(--clr);
}

.card-wrap input::placeholder {
  color: var(--clr);
  -webkit-text-fill-color: var(--clr);
  opacity: 1;
}

/* معاينة الكتابة الحية: النص ينرسم بنفس كود الصورة النهائية */
.card-wrap .live-text {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1; /* فوق إطار الكتابة عشان الإطار ما يغطي أطراف الحروف */
}
.card-wrap.live input {
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--clr);
}

.card-wrap input:focus {
  border-color: rgba(255, 255, 255, 0.8);
}

#create {
  display: block;
  width: 100%;
  max-width: var(--card-max, 480px);
  padding: 15px;
  background: var(--btn, #c0663a);
  color: #fff;
  font-size: clamp(14px, 3.5vw, 18px);
  font-weight: bold;
  font-family: inherit;
  border: none;
  cursor: pointer;
  text-align: center;
  line-height: normal;
  transition: background 0.2s;
}
#create:hover { background: var(--btn-hover, #a8522a); }
#create:active { opacity: 0.88; }
#create:disabled { opacity: 0.5; cursor: not-allowed; }

#errMsg {
  color: #c0392b;
  font-size: 13px;
  font-family: inherit;
  padding: 8px 0;
  min-height: 28px;
  text-align: center;
  width: 100%;
  max-width: var(--card-max, 480px);
  line-height: normal;
}

/* زر التبرع (يظهر لو حطيت رابط الجمعية) */
.donate-btn {
  display: block;
  width: 100%;
  max-width: var(--card-max, 480px);
  padding: 13px 15px;
  margin-bottom: 16px;
  background: #fff;
  color: var(--btn, #c0663a);
  border: 2px solid var(--btn, #c0663a);
  font-size: clamp(14px, 3.5vw, 18px);
  font-weight: bold;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  line-height: normal;
}
.donate-btn:active { opacity: 0.85; }

/* بعد إنشاء البطاقة */
.result {
  width: 100%;
  max-width: var(--card-max, 480px);
  padding: 4px 16px 28px;
  text-align: center;
  line-height: normal;
  scroll-margin-top: 12px;
}
.result-title { font-size: 21px; font-weight: bold; margin: 6px 0 8px; }
.result-hint {
  font-family: system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: #555;
  margin-bottom: 14px;
}
.result-img {
  display: block;
  width: 72%;
  max-width: 340px;
  margin: 0 auto 16px;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  -webkit-touch-callout: default;
}
.result-actions { display: flex; flex-direction: column; gap: 8px; }
.result-actions button {
  width: 100%;
  padding: 13px;
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  border: 2px solid var(--btn, #c0663a);
  background: #fff;
  color: var(--btn, #c0663a);
  cursor: pointer;
  line-height: normal;
}
.landscape .result-img { width: 100%; max-width: 100%; }
.result-actions .share-btn { background: var(--btn, #c0663a); color: #fff; }
.result-actions button[hidden] { display: none; }

body.not-found {
  justify-content: center;
  font-family: system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  color: #333;
  text-align: center;
  padding: 24px 16px;
}
body.not-found main { max-width: 420px; }
body.not-found .icon { font-size: 44px; margin-bottom: 12px; }
body.not-found h1 { font-size: 22px; margin-bottom: 8px; line-height: 1.5; }
body.not-found p { color: #666; font-size: 15px; line-height: 1.7; }
body.not-found .when { margin-top: 8px; color: #8a5a2b; font-weight: 600; }
