:root {
  --primary: #2d9cdb;
  --success: #27ae60;
  --warning: #f1c40f;
  --purple: #6c3483;
  --orange: #d9822b;
  --danger: #e74c3c;
  --text-dark: #243447;
  --text-muted: #718096;
  --gray-zero: #7f8c8d;
  --surface: #ffffff;
  --soft: #f7f3ff;
  --line: #ead8ff;
  --bg-gradient: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
  --ui-font: Tahoma, "Segoe UI", Arial, sans-serif;
  /* خط النسخ للحروف والكلمات.
     يقرأ SKR-HEAD1.ttf من مجلد fonts إذا أضيف قبل الرفع،
     ثم يستخدم بدائل نسخ عربية من الجهاز. */
  --naskh-font: "Baba Ahmed Naskh", "SKR HEAD1", "SKR-HEAD1", "Traditional Arabic", "Arabic Typesetting", "Sakkal Majalla", "Simplified Arabic", serif;
}

@font-face {
  font-family: "Baba Ahmed Naskh";
  src: local("SKR HEAD1"),
       local("SKR-HEAD1"),
       url("../fonts/SKR-HEAD1.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}


* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--ui-font);
  background: var(--bg-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dark);
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-container {
  width: 100%;
  max-width: 760px;
  height: 100svh;
  max-height: 100svh;
  background: #fcfcfc;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

@media (min-width: 760px) and (min-height: 680px) {
  .app-container {
    width: min(76vw, 880px);
    height: calc(100svh - 42px);
    border: 8px solid #ffffff;
    border-radius: 34px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.25);
  }
}

.brand-strip {
  flex-shrink: 0;
  min-height: 44px;
  padding: 7px 12px;
  background: linear-gradient(90deg, #fff7ec, #f7ecff);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--purple);
  font-weight: 900;
  text-align: center;
}

.brand-pill {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(108, 52, 131, 0.14);
  border-radius: 999px;
  padding: 6px 14px;
  line-height: 1.2;
}

.content-area {
  flex: 1;
  min-height: 0;
  padding: 12px 16px 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: hidden;
}

.screen-center {
  justify-content: center;
}

.hero-card,
.home-hero {
  width: min(100%, 520px);
  background: linear-gradient(180deg, #ffffff 0%, #fbf8ff 100%);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 14px 16px;
  box-shadow: 0 8px 22px rgba(108, 52, 131, 0.08);
  margin-bottom: 12px;
}

.hero-title,
#welcomeText {
  color: var(--primary);
  font-size: clamp(1.55rem, 4vw, 2.35rem);
  font-weight: 950;
  line-height: 1.2;
  margin: 0 0 6px;
}

.hero-subtitle,
.mini-note {
  color: var(--text-muted);
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.6;
}

.name-input {
  width: min(100%, 320px);
  padding: 13px 16px;
  border-radius: 999px;
  border: 2px solid #e2e8f0;
  text-align: center;
  margin: 4px 0 12px;
  font-size: 1.08rem;
  outline: none;
  background: white;
}

.name-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(45, 156, 219, 0.12);
}

.gender-row,
.utility-row,
.status-row,
.resume-container,
.main-actions,
.sound-panel,
.footer-links,
.nav-buttons,
.legend-row {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gender-row {
  gap: 10px;
  margin-bottom: 14px;
}

.gender-btn {
  border: 0;
  min-width: 112px;
  padding: 11px 18px;
  border-radius: 999px;
  background: #edf2f7;
  color: #1a202c;
  font-weight: 900;
}

#btnBoy {
  background: #3498db;
  color: #fff;
}

.main-btn {
  width: min(100%, 350px);
  min-height: 58px;
  border: 0;
  border-radius: 999px;
  color: white;
  background: var(--success);
  box-shadow: 0 6px 0 #168347;
  font-weight: 950;
  font-size: 1.18rem;
  padding: 13px 24px;
  margin: 0;
  transition: transform 0.1s, box-shadow 0.1s;
}

.main-btn:active,
.utility-btn:active,
.nav-btn:active,
.sound-btn:active,
.ghost-danger:active {
  transform: translateY(2px);
}

.letters-btn {
  background: var(--warning);
  color: #243447;
  box-shadow: 0 7px 0 #d4ac0d;
}

.words-btn {
  background: var(--success);
  box-shadow: 0 7px 0 #168347;
}

.start-btn {
  background: var(--purple);
  box-shadow: 0 7px 0 #4b235e;
}

.main-actions {
  flex-direction: column;
  gap: 10px;
  width: min(100%, 380px);
  margin-top: 8px;
}

.status-row {
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.visit-badge,
.audio-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  line-height: 1.2;
  font-weight: 900;
  background: #f6f0ff;
  color: var(--purple);
  border: 1px solid var(--line);
  margin: 0;
}

.utility-row {
  gap: 8px;
  flex-wrap: wrap;
  width: min(100%, 390px);
  margin: 2px 0 8px;
}

.utility-btn,
.sound-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: #5b2c6f;
  font-weight: 950;
  padding: 9px 14px;
  box-shadow: 0 3px 0 rgba(91, 44, 111, 0.18);
  font-size: 0.9rem;
  min-height: 40px;
}

.resume-container {
  width: min(100%, 410px);
  gap: 8px;
  flex-wrap: wrap;
  margin: 2px 0 8px;
}

.secondary-action {
  flex: 1 1 160px;
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-weight: 950;
  padding: 9px 14px;
}

.resume-action {
  background: #8e44ad;
  box-shadow: 0 4px 0 #5b2c6f;
}

.reset-action {
  background: #34495e;
  box-shadow: 0 4px 0 #2c3e50;
}

.ghost-danger {
  background: transparent;
  color: var(--danger);
  border: 2px solid var(--danger);
  box-shadow: none;
  min-height: 46px;
  font-size: 1rem;
  margin-top: 4px;
}

.game-header {
  width: 100%;
  flex-shrink: 0;
}

.nav-buttons {
  width: 100%;
  gap: 6px;
  margin-bottom: 8px;
}

.nav-btn {
  flex: 1;
  min-height: 42px;
  border: 2px solid #d7e3f0;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 3px 0 #c7d4e4;
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text-dark);
}

.nav-text {
  font-size: 0.78rem;
  white-space: nowrap;
}

.btn-shuffle {
  background: #ffd08a;
  border-color: #ffc16b;
  box-shadow: 0 3px 0 #b46d2a;
}

.legend-container {
  width: 100%;
  flex-shrink: 0;
  background: #ffffff;
  border: 1px solid #edf2f7;
  border-radius: 18px;
  padding: 7px 9px;
  margin-bottom: 8px;
}

.legend-row {
  gap: 5px;
  flex-wrap: nowrap;
}

.legend-row + .legend-row {
  margin-top: 5px;
}

.legend-item {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #f7fafc;
  border-radius: 999px;
  padding: 4px 5px;
  font-size: 0.68rem;
  font-weight: 900;
  white-space: nowrap;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.word-title {
  flex-shrink: 0;
  height: clamp(48px, 9svh, 68px);
  max-height: 68px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 6px;
}

.naskh-font,
.letter-font {
  font-family: var(--naskh-font);
  font-weight: 400;
  color: var(--text-dark);
  letter-spacing: 0;
}

.title-naskh {
  font-size: clamp(2.35rem, 7.4vw, 3.75rem);
  line-height: 1.05;
}

.motivational-text {
  color: var(--purple);
  font-size: clamp(0.98rem, 2.8vw, 1.25rem);
  font-weight: 950;
  line-height: 1.4;
}

.sound-panel {
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
  margin-bottom: 8px;
}

.sound-btn {
  background: #eef8ff;
  color: #1f618d;
  border-color: #bde3ff;
  min-height: 36px;
  padding: 7px 13px;
  font-size: 0.84rem;
}

.cards-container {
  width: 100%;
  height: clamp(78px, 14svh, 98px);
  max-height: 104px;
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 8px;
  padding: 9px;
  background: #f4f6f7;
  border-radius: 20px;
  margin-bottom: 9px;
  overflow: hidden;
}

.card {
  touch-action: none;
  width: clamp(48px, 9vw, 58px);
  height: clamp(48px, 9vw, 58px);
  color: white;
  font-size: clamp(2.05rem, 6.6vw, 2.65rem);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  border: 2px solid;
  cursor: grab;
  padding-bottom: 0;
  line-height: 1;
  transition: background-color 0.2s, border-color 0.2s;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1;
}

.card.naskh-font {
  padding-bottom: 5px;
}


.drop-zones {
  width: 100%;
  height: clamp(90px, 16svh, 116px);
  max-height: 120px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  gap: 7px;
  overflow: hidden;
}

.zone {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: white;
  border: 2px dashed #cbd5e0;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px;
  position: relative;
}

.zone-active {
  background: #e1f0fa;
  border-color: var(--primary);
}

.zone-title {
  font-size: 0.78rem;
  font-weight: 950;
  background: #34495e;
  color: white;
  padding: 4px 8px;
  border-radius: 999px;
  margin-bottom: 7px;
  cursor: pointer;
}

.game-hint {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 6px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.footer {
  flex-shrink: 0;
  width: 100%;
  background: #fffdf9;
  border-top: 2px solid #ffe2bb;
  padding: 7px 8px 9px;
  text-align: center;
}

.footer-links {
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.footer-link {
  min-height: 32px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 950;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
}

.academy-link {
  background: #ffe3c6;
  color: #8b5a2b;
  border: 1px solid #ffcd9a;
}

.telegram-link {
  background: #0088cc;
  color: white;
}

.youtube-link {
  background: #ffebee;
  color: #b71c1c;
  border: 1px solid #ffcdd2;
}

.credit-line {
  font-size: 0.7rem;
  color: var(--purple);
  font-weight: 950;
  margin: 2px 0;
  line-height: 1.25;
}

.rights {
  font-size: 0.64rem;
  color: var(--orange);
  font-weight: 800;
  line-height: 1.35;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-content {
  width: min(100%, 390px);
  max-height: 90svh;
  overflow: auto;
  background: white;
  border: 4px solid var(--primary);
  border-radius: 26px;
  padding: 24px 22px;
  text-align: center;
}

.modal-title {
  color: var(--purple);
  font-size: 1.45rem;
  font-weight: 950;
  margin-bottom: 10px;
}

.modal-text {
  font-size: 0.98rem;
  line-height: 1.8;
  font-weight: 800;
  color: #555;
  margin-bottom: 12px;
}

.report-name,
.report-total,
.win-earned,
.win-total {
  font-weight: 950;
  margin-bottom: 10px;
}

.report-score,
.total-score {
  color: var(--danger);
  font-size: 2rem;
}

.win-word {
  margin: 10px 0 15px;
  font-size: 3.4rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.modal-actions .main-btn {
  width: auto;
  min-height: 48px;
  font-size: 0.98rem;
  padding: 11px 17px;
}

.muted-btn {
  background: #7f8c8d;
  box-shadow: 0 6px 0 #566573;
}

.audio-progress {
  width: 100%;
  height: 14px;
  background: #f4f6f7;
  border: 1px solid #e5e8eb;
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 8px;
}

.audio-progress > div {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #27ae60, #8e44ad);
  transition: width 0.2s;
}

.progress-text {
  min-height: 24px;
  font-size: 0.86rem;
  font-weight: 950;
  color: var(--purple);
}

.error-shake {
  animation: shake 0.4s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@media (max-height: 760px) {
  .brand-strip { min-height: 38px; padding: 5px 10px; font-size: 0.78rem; }
  .brand-pill { padding: 5px 10px; }
  .content-area { padding: 9px 13px 7px; }
  .hero-card, .home-hero { padding: 10px 14px; margin-bottom: 8px; border-radius: 20px; }
  .hero-title, #welcomeText { font-size: 1.55rem; margin-bottom: 3px; }
  .hero-subtitle, .mini-note { font-size: 0.78rem; line-height: 1.45; }
  .main-actions { gap: 8px; margin-top: 5px; }
  .main-btn { min-height: 48px; padding: 10px 20px; font-size: 1.02rem; }
  .utility-row, .resume-container { margin-bottom: 6px; }
  .utility-btn, .sound-btn { min-height: 34px; padding: 7px 11px; font-size: 0.78rem; }
  .visit-badge, .audio-status { min-height: 28px; padding: 5px 8px; font-size: 0.7rem; }
  .footer { padding: 5px 6px 6px; }
  .footer-link { min-height: 28px; padding: 5px 8px; font-size: 0.68rem; }
  .credit-line { font-size: 0.62rem; }
  .rights { font-size: 0.57rem; }
  .legend-container { padding: 5px 7px; margin-bottom: 5px; }
  .legend-item { font-size: 0.6rem; padding: 3px 4px; }
  .nav-btn { min-height: 36px; font-size: 1rem; }
  .word-title { height: 44px; margin-bottom: 4px; }
  .sound-panel { margin-bottom: 5px; }
  .cards-container { height: 72px; padding: 7px; margin-bottom: 7px; }
  .drop-zones { height: 86px; }
  .zone-title { font-size: 0.68rem; padding: 3px 6px; }
  .game-hint { font-size: 0.68rem; padding-top: 4px; }
}

@media (max-width: 420px) {
  .app-container { max-width: none; }
  .content-area { padding-inline: 10px; }
  .legend-item { font-size: 0.58rem; gap: 3px; }
  .legend-color { width: 8px; height: 8px; }
  .footer-links { gap: 5px; }
  .footer-link { font-size: 0.64rem; padding: 5px 7px; }
  .rights { display: none; }
}


/* وضع الشاشات القصيرة: يحافظ على اكتمال الواجهة بدون تمرير داخلي */
@media (max-height: 680px) {
  .brand-strip { min-height: 36px; padding: 4px 8px; font-size: 0.86rem; }
  .brand-pill { padding: 4px 10px; }
  .content-area { padding: 8px 12px 6px; }
  .hero-card, .home-hero { padding: 10px 12px; margin-bottom: 8px; border-radius: 22px; }
  .hero-title, #welcomeText { font-size: 1.45rem; margin-bottom: 4px; }
  .hero-subtitle, .mini-note { font-size: 0.8rem; line-height: 1.35; }
  .status-row { margin-top: 4px; gap: 5px; }
  .visit-badge, .audio-status { min-height: 28px; padding: 4px 8px; font-size: 0.68rem; }
  .utility-row { margin-bottom: 6px; }
  .utility-btn, .sound-btn { min-height: 34px; padding: 6px 10px; font-size: 0.78rem; }
  .main-actions { gap: 7px; margin-top: 5px; }
  .main-btn { min-height: 48px; font-size: 1.02rem; padding: 10px 18px; }
  .nav-buttons { gap: 5px; margin-bottom: 5px; }
  .nav-btn { min-height: 36px; font-size: 0.95rem; }
  .nav-text { font-size: 0.62rem; }
  .legend-container { padding: 5px 6px; margin-bottom: 5px; border-radius: 14px; }
  .legend-item { font-size: 0.58rem; padding: 3px 4px; }
  .word-title { height: 42px; margin-bottom: 4px; }
  .sound-panel { margin-bottom: 5px; gap: 6px; }
  .cards-container { height: 72px; padding: 6px; margin-bottom: 6px; gap: 6px; border-radius: 16px; }
  .drop-zones { height: 82px; gap: 5px; }
  .card { width: 46px; height: 46px; font-size: 2.1rem; border-radius: 12px; padding-bottom: 0; line-height: 1; }
  .zone { border-radius: 13px; padding: 4px; }
  .zone-title { font-size: 0.68rem; padding: 3px 6px; margin-bottom: 4px; }
  .game-hint { display: none; }
  .footer { padding: 5px 6px 6px; }
  .footer-links { margin-bottom: 2px; gap: 5px; }
  .footer-link { min-height: 27px; padding: 4px 7px; font-size: 0.66rem; }
  .credit-line { font-size: 0.64rem; }
  .rights { font-size: 0.56rem; line-height: 1.2; }
}

@media (max-height: 590px) {
  .footer-links { display: none; }
  .rights { display: none; }
  .home-hero .hero-subtitle { display: none; }
  .sound-panel { display: none; }
}
