*{
  box-sizing:border-box;
}

html, body{
  margin:0;
  padding:0;
  width:100%;
  min-height:100%;
}

body{
 
  text-align:center;
  background:url("assets/khaimg/background.webp") center/cover no-repeat fixed;
  color:#4a2340;
}


@font-face {
  font-family: 'NotoArabic';
  src: url('fonts/NotoSansArabic-Regular.ttf');
}

body{
  font-family:'NotoArabic','Baloo Bhaijaan 2', sans-serif;
}

body{
  direction: rtl;
} 

#wordText {
  direction: rtl;
  unicode-bidi: plaintext;
  white-space: nowrap;
  font-feature-settings: "liga" 1;
}

.highlight-letter{
  color:#e53935;
  font-weight:700;

}


.container{
  min-height:100svh;
  max-width:1360px;
  margin:0 auto;
  padding:18px 24px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:12px;
}

.main-title{
  margin:0 auto 8px;
  font-size:28px;
  line-height:1.2;
  background:#ffffff;
  padding:8px 18px;
  border-radius:14px;
  display:inline-block;
  box-shadow:0 4px 12px rgba(0,0,0,.08);
}

.card{
  width:100%;
  background:rgba(255,255,255,.95);
  border-radius:30px;
  padding:22px 26px;
  box-shadow:0 10px 24px rgba(0,0,0,.08);
}

.screen-card{
  max-width:860px;
  margin:0 auto;
}

.game-card{
  max-width:1220px;
  margin:0 auto;
  min-height:560px;
  padding:26px 26px 20px;
  display:flex;
  align-items:center;
}

.hidden{
  display:none !important;
}

h2{
  margin:0 0 8px;
  font-size:34px;
  line-height:1.25;
}

h3{
  margin:8px 0;
}

p{
  margin:8px 0;
  font-size:27px;
  line-height:1.5;
}

.instruction-text{
  max-width:700px;
  margin:8px auto 0;
}

.instruction-status{
  margin-top:12px;
  font-size:22px;
  color:#7a3c62;
}

input{
  width:min(340px, 90%);
  height:58px;
  font-size:28px;
  font-family:'Baloo Bhaijaan 2', cursive;
  text-align:center;
  border:3px solid #e9a8c8;
  border-radius:18px;
  padding:8px 16px;
  background:#fff;
  outline:none;
}

input:focus{
  border-color:#d86fa7;
  box-shadow:0 0 0 4px rgba(242,139,183,.15);
}

button{
  min-width:130px;
  min-height:56px;
  font-size:28px;
  font-family:'Baloo Bhaijaan 2', cursive;
  border:none;
  border-radius:18px;
  padding:10px 22px;
  cursor:pointer;
  color:#fff;
  background:#f28bb7;
  box-shadow:0 6px 12px rgba(0,0,0,.14);
  transition:transform .2s ease, background .2s ease, opacity .2s ease;
}

button:hover{
  transform:translateY(-2px) scale(1.02);
  background:#ea74a8;
}

button:disabled{
  opacity:.55;
  cursor:not-allowed;
  transform:none;
  background:#caa3b7;
}

.action-row{
  margin-top:18px;
}

.start-btn{
  min-width:170px;
}

.instruction-buttons{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:18px;
  flex-wrap:wrap;
  margin-top:18px;
}

.game-layout{
  width:100%;
  display:grid;
  grid-template-columns:220px 1fr;
  gap:34px;
  align-items:center;
}

.sidebar-wrap{
  display:flex;
  flex-direction:column;
  gap:14px;
  background:linear-gradient(180deg,#ffd6e8 0%, #ffc0dd 50%, #ffb1d6 100%);
  border:4px solid #ef94bc;
  border-radius:30px;
  padding:14px 12px;
  box-shadow:
    0 12px 24px rgba(0,0,0,.08),
    inset 0 2px 0 rgba(255,255,255,.55);
}

.game-badge,
.info-box{
  background:#fff8fc;
  color:#8a2d5d;
  border:3px solid #f1a4c7;
  border-radius:20px;
  box-shadow:0 4px 10px rgba(0,0,0,.05);
}

.game-badge{
  padding:14px 10px;
  font-size:22px;
  line-height:1.5;
  font-weight:700;
  background:#fffdfd;
}

.info-box{
  padding:16px 14px;
  font-size:21px;
  line-height:1.4;
  font-weight:700;
}

.welcome-box{
  font-size:23px;
  background:#fff;
}

.stats-line{
  text-align:center;
}

.play-area{
  min-width:0;
  display:grid;
  grid-template-rows:auto auto auto;
  gap:40px;
  align-content:center;
  justify-items:center;
}

.question-row{
  width:100%;
  display:grid;
  grid-template-columns:260px 1fr;
  gap:34px;
  align-items:center;
  justify-content:center;
  max-width:760px;
}

.sprite-frame{
  width:260px;
  height:260px;
  overflow:hidden;
  border:4px solid #ff33ff;
  border-radius:24px;
  position:relative;
  background:#fff;
  justify-self:center;
  box-shadow:0 8px 18px rgba(0,0,0,.07);
}

.sprite{
  position:absolute;
  width:1280px;
  height:512px;
  background:url("assets/khaimg/atlaskha.webp");
  background-size:1280px 512px;
  background-repeat:no-repeat;
  transform-origin:top left;
}

.word-audio-wrap{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  min-width:0;
  width:100%;
}

.word-line{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:14px;
  width:100%;
}

.word-box{
  font-size:58px;
  background:#ecdd8a;
  padding:10px 24px;
  border-radius:22px;
  min-width:300px;
  height:108px;
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
  box-shadow:0 8px 18px rgba(0,0,0,.08);
}

#wordText{
  position:relative;
  z-index:2;
  line-height:1;
}

.listen-btn{
  width:58px;
  min-width:58px;
  height:58px;
  border-radius:50%;
  padding:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:28px;
  background:#8ec5ff;
  color:#fff;
  box-shadow:0 4px 10px rgba(0,0,0,.12);
}

.listen-btn:hover{
  background:#6fb4fb;
}

.highlight-letter{
  color:#e53935;
  font-weight:700;
}

.choices{
  width:100%;
  max-width:760px;
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  justify-content:center;
  gap:18px;
  margin-top:10px;
}

.choices button{
  width:120px;
  height:60px;
  font-size:38px;
  border-radius:18px;

  display:flex;
  align-items:center;
  justify-content:center;

  background:linear-gradient(180deg,#f08ab6,#e36aa0);
  color:white;

  border:none;

  box-shadow:
  0 6px 0 #c6538a,
  0 10px 16px rgba(0,0,0,0.15);

  cursor:pointer;

  transition:
  transform 0.15s ease,
  box-shadow 0.15s ease;
}


.choices button:hover{
  transform:translateY(-3px);
}

.choices button:active{
  transform:translateY(3px);

  box-shadow:
  0 2px 0 #c6538a,
  0 4px 8px rgba(0,0,0,0.15);
}


#feedback{
  width:100%;
  max-width:760px;
  height:34px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:24px;
  font-weight:700;
  margin:0;
}

.stars-layer{
  position:absolute;
  inset:0;
  pointer-events:none;
  overflow:visible;
  z-index:5;
}

.star{
  position:absolute;
  font-size:24px;
  animation:starFloat 900ms ease-out forwards;
  opacity:0;
}

@keyframes starFloat{
  0%{
    transform:translate(-50%, -50%) scale(.35);
    opacity:0;
  }
  20%{
    opacity:1;
  }
  100%{
    transform:translate(calc(-50% + var(--moveX)), calc(-50% + var(--moveY))) scale(1.15);
    opacity:0;
  }
}

.result-layout{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:20px;
  margin:14px 0;
  flex-wrap:wrap;
}

.medal-box{
  display:flex;
  align-items:center;
  justify-content:center;
}

.medal{
  font-size:84px;
}

.result-info{
  text-align:right;
  font-size:24px;
  line-height:1.8;
}

@media (max-width: 1100px){
  .game-layout{
    grid-template-columns:200px 1fr;
    gap:22px;
  }

  .question-row{
    grid-template-columns:220px 1fr;
    gap:22px;
    max-width:680px;
  }

  .sprite-frame{
    width:220px;
    height:220px;
  }

  .word-box{
    min-width:250px;
    height:94px;
    font-size:46px;
  }

  .choices{
    max-width:680px;
    grid-template-columns:repeat(4, minmax(90px, 1fr));
  }

  .choices button{
    width:100%;
    height:54px;
    font-size:32px;
  }
}

@media (max-width: 980px){
  .container{
    min-height:auto;
    justify-content:flex-start;
    padding:12px;
  }

  .game-card{
    display:block;
    min-height:auto;
    padding:14px;
  }

  .game-layout{
    grid-template-columns:1fr;
    gap:18px;
  }

  .sidebar-wrap{
    width:100%;
    max-width:560px;
    margin:0 auto;
  }

  .play-area{
    gap:16px;
    align-content:start;
  }

  .question-row{
    grid-template-columns:1fr;
    gap:18px;
    max-width:none;
  }

  .word-audio-wrap,
  .word-line{
    justify-content:center;
  }

  .choices{
    max-width:none;
    grid-template-columns:repeat(2,1fr);
    justify-content:center;
  }

  #feedback{
    max-width:none;
  }
}

@media (max-width: 768px){

  body{
    background-attachment:scroll;
  }

  .game-layout{
    display:flex;
    flex-direction:column;
    gap:22px;
  }

  /* ترتيب العناصر */
  .play-area{
    order:1;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:22px;
  }

  .question-row{
    order:1;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:18px;
  }

  .sprite-frame{
    order:1;
    width:240px;
    height:240px;
  }

  .word-line{
    order:2;
    justify-content:center;
  }

  .word-box{
    font-size:52px;
    min-width:260px;
    height:100px;
  }

  .listen-btn{
    width:60px;
    height:60px;
    font-size:28px;
  }

  .choices{
    order:3;
    grid-template-columns:repeat(4, 1fr);
    gap:16px;
  }

  .choices button{
    height:70px;
    font-size:42px;
  }

  #feedback{
    order:4;
    font-size:24px;
  }

  /* نقل مربعات القائمة للأسفل */
  .sidebar-wrap{
    order:2;
    width:100%;
    max-width:420px;
    margin:0 auto;
  }

  .game-badge{
    display:none; /* اختياري لإزالة العنوان الكبير من الأعلى */
  }

}

@media (max-width: 480px){
  .container{
    padding:10px;
    gap:8px;
  }

  .main-title{
    font-size:18px;
    padding:7px 14px;
  }

  input{
    height:54px;
  }

  button{
    min-height:52px;
    padding:8px 16px;
  }

  .instruction-buttons{
    flex-direction:column;
    gap:10px;
  }

  .word-line{
    flex-direction:row;
    gap:10px;
  }

  .word-box{
    min-width:180px;
    font-size:60px;
  }

  .choices{
    grid-template-columns:repeat(2, 1fr);
  }

  .medal{
    font-size:72px;
  }
}


/* =========================
   iPad / Tablet Layout
========================= */
@media (min-width: 769px) and (max-width: 1100px){

  .game-layout{
    display:flex;
    flex-direction:column;
    gap:28px;
  }

  .play-area{
    order:1;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:28px;
  }

  .question-row{
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:22px;
  }

  .sprite-frame{
    width:320px;
    height:320px;
  }

  .word-box{
    font-size:64px;
    min-width:340px;
    height:120px;
  }

  .listen-btn{
    width:70px;
    height:70px;
    font-size:32px;
  }

  .choices{
    grid-template-columns:repeat(2, 140px);
    gap:20px;
  }

  .choices button{
    height:80px;
    font-size:46px;
  }

  .sidebar-wrap{
    order:2;
    width:100%;
    max-width:600px;
    margin:0 auto;
  }

  .game-badge{
    display:none;
  }

}