:root {
  --primary: #ff6b6b;
  --secondary: #4ecdc4;
  --accent: #ffd166;
  --peach: #ff9a8b;
  --mint: #95e1d3;
  --light-bg: #f9f7f7;
  --text-dark: #2c3e50;
  --text-light: #ffffff;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: var(--light-bg);
  color: var(--text-dark);
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path fill="%23FFD166" opacity="0.15" d="M50,10 C65,10 77,22 77,37 C77,52 65,64 50,64 C35,64 23,52 23,37 C23,22 35,10 50,10 Z"/><path fill="%234ECDC4" opacity="0.15" d="M50,70 C65,70 77,82 77,97 C77,112 65,124 50,124 C35,124 23,112 23,97 C23,82 35,70 50,70 Z"/>');
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  flex: 1;
  width: 100%;
}

header {
  text-align: center;
  padding: 25px 0;
  background: linear-gradient(135deg, var(--primary), var(--peach));
  color: var(--text-light);
  border-radius: 20px;
  margin-bottom: 30px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
  background: var(--accent);
}

.header-content {
  position: relative;
  z-index: 1;
}

header h1 {
  font-size: 2.8rem;
  margin-bottom: 15px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header p {
  font-size: 1.3rem;
  max-width: 800px;
  margin: 0 auto;
  opacity: 0.95;
}

.arabic-decoration {
  font-family: "Traditional Arabic", "Scheherazade", serif;
  font-size: 2.2rem;
  color: var(--accent);
  margin: 15px 0;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.main-content {
  display: flex;
  flex-wrap: wrap;
  gap: 25px;
  margin-bottom: 30px;
  align-items: stretch;
}

.sidebar {
  flex: 1;
  min-width: 280px;
  background: white;
  border-radius: 20px;
  padding: 25px;
  box-shadow: var(--shadow);
  border: 2px solid var(--mint);
  display: flex;
  flex-direction: column;
  min-height: 600px;
}

.content {
  flex: 3;
  min-width: 300px;
  background: white;
  border-radius: 20px;
  padding: 25px;
  box-shadow: var(--shadow);
  border: 2px solid var(--mint);
  display: flex;
  flex-direction: column;
  min-height: 600px;
}

.section-title {
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title i {
  color: var(--accent);
}

.operation-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 25px;
}

.operation-btn {
  padding: 15px 10px;
  border: none;
  border-radius: 15px;
  background: var(--secondary);
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 6px rgba(78, 205, 196, 0.2);
  min-height: 100px;
  text-align: center;
  line-height: 1.4;
}

.operation-btn i {
  font-size: 1.8rem;
  margin-bottom: 5px;
}

.operation-btn:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 15px rgba(78, 205, 196, 0.3);
}

.operation-btn.active {
  background: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(255, 107, 107, 0.3);
}

.theme-selector {
  margin: 25px 0;
}

.theme-btn {
  display: inline-block;
  padding: 12px 18px;
  margin: 8px;
  background: #f0f0f0;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.theme-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.theme-btn.active {
  background: var(--accent);
  color: white;
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(255, 209, 102, 0.3);
}

.learning-area {
  text-align: center;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex: 1;
}

.question-container {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  margin: 20px 0;
  padding: 20px 15px;
  background: #f5f5f5;
  border-radius: 20px;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 15px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 800px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#question-text {
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  line-height: 1.4;
}

.number-display {
  display: inline-block;
  min-width: 50px;
  text-align: center;
  font-weight: bold;
  color: var(--primary);
  font-size: 2rem;
}

.visual-operation {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  margin: 25px 0;
  padding: 25px;
  background: #f9f9f9;
  border-radius: 20px;
  width: 100%;
  max-width: 800px;
  min-height: 280px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
  overflow: auto;
  flex: 1;
}

.item {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 3rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: var(--transition);
  position: relative;
  animation: pop-in 0.5s ease-out;
}

@keyframes pop-in {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  70% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.item:hover {
  transform: scale(1.1);
}

.animal {
  background: linear-gradient(135deg, var(--secondary), #6ce5de);
}
.fruit {
  background: linear-gradient(135deg, var(--primary), var(--peach));
}
.object {
  background: linear-gradient(135deg, #2196f3, #42a5f5);
}

.group-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 15px;
  padding: 20px;
  border: 2px dashed var(--accent);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.group-label {
  font-size: 1rem;
  margin-bottom: 10px;
  font-weight: bold;
  color: var(--primary);
  background: rgba(255, 209, 102, 0.1);
  padding: 5px 12px;
  border-radius: 10px;
}

.answer-input {
  width: 160px;
  padding: 20px;
  font-size: 2rem;
  text-align: center;
  border: 3px solid #ddd;
  border-radius: 15px;
  margin: 25px;
  transition: var(--transition);
  font-weight: bold;
}

.answer-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 15px rgba(255, 209, 102, 0.5);
  transform: scale(1.05);
}

.controls {
  margin: 25px 0;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  padding: 18px 30px;
  border: none;
  border-radius: 15px;
  background: var(--primary);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 6px rgba(255, 107, 107, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.btn:hover {
  background: var(--peach);
  transform: translateY(-5px);
  box-shadow: 0 8px 15px rgba(255, 107, 107, 0.3);
}

.feedback {
  font-size: 1.5rem;
  margin: 20px 0;
  min-height: 60px;
  padding: 20px;
  border-radius: 15px;
  width: 100%;
  max-width: 600px;
  animation: fadeIn 0.5s ease-in;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.correct {
  color: var(--secondary);
  background: #e8f5e9;
  border: 2px solid var(--secondary);
}

.incorrect {
  color: #f44336;
  background: #ffebee;
  border: 2px solid #f44336;
}

.score-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin: 25px 0;
  padding: 20px;
  background: #f5f5f5;
  border-radius: 15px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.star {
  font-size: 2.5rem;
  color: #ddd;
  transition: var(--transition);
}

.star.filled {
  color: var(--accent);
  text-shadow: 0 0 10px rgba(255, 209, 102, 0.7);
  animation: star-pop 0.5s ease-out;
}

@keyframes star-pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

.islamic-pattern {
  height: 50px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60"><path fill="%23FF6B6B" opacity="0.2" d="M30,10 C40,10 47,17 47,27 C47,37 40,44 30,44 C20,44 13,37 13,27 C13,17 20,10 30,10 Z"/><path fill="%234ECDC4" opacity="0.2" d="M30,50 C40,50 47,57 47,67 C47,77 40,84 30,84 C20,84 13,77 13,67 C13,57 20,50 30,50 Z"/>');
  margin: 25px 0;
  opacity: 0.7;
}

.wisdom-quote {
  font-style: italic;
  text-align: center;
  margin: 25px 0;
  padding: 20px;
  background: #f5f5f5;
  border-radius: 15px;
  border-left: 5px solid var(--accent);
  font-size: 1.1rem;
  line-height: 1.6;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

footer {
  text-align: center;
  padding: 20px;
  background: var(--primary);
  color: white;
  border-radius: 15px;
  margin-top: 30px;
  box-shadow: var(--shadow);
}

footer p {
  margin: 5px 0;
}

footer i {
  color: var(--accent);
}

.operation-symbol {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: bold;
  color: var(--primary);
  margin: 0 15px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
  display: inline-block;
}

.equals-symbol {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: bold;
  color: var(--primary);
  margin: 0 15px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
  display: inline-block;
}

.question-mark {
  width: clamp(60px, 8vw, 90px);
  height: clamp(60px, 8vw, 90px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  font-weight: bold;
  font-size: clamp(2.2rem, 4vw, 3rem);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.game-link-container {
  margin: 25px 0;
  text-align: center;
  margin-top: auto;
}

.game-link-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 15px;
  background: linear-gradient(135deg, var(--secondary), #6ce5de);
  color: white;
  text-decoration: none;
  border-radius: 15px;
  font-size: 1.2rem;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
  border: 2px solid #3dbdb4;
  gap: 8px;
  min-height: 100px;
}

.game-link-btn:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(78, 205, 196, 0.4);
  background: linear-gradient(135deg, #3dbdb4, var(--secondary));
}

.game-link-btn:active {
  transform: translateY(-2px);
}

.game-link-btn i {
  font-size: 2rem;
  margin-bottom: 5px;
}

.game-link-desc {
  font-size: 0.9rem;
  opacity: 0.9;
  font-weight: normal;
}

@media (min-width: 1024px) {
  .main-content {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 30px;
    align-items: stretch;
  }

  .sidebar,
  .content {
    min-height: 650px;
  }

  .content {
    min-height: 650px;
  }

  .visual-operation {
    min-height: 320px;
    max-height: 400px;
    overflow-y: auto;
  }

  .item {
    width: 80px;
    height: 80px;
    font-size: 2.8rem;
  }

  .question-container {
    min-height: 140px;
  }
}

@media (max-width: 1023px) and (min-width: 768px) {
  .main-content {
    grid-template-columns: 270px 1fr;
    gap: 20px;
  }

  .sidebar,
  .content {
    min-height: 620px;
  }

  .item {
    width: 70px;
    height: 70px;
    font-size: 2.5rem;
  }

  .question-container {
    font-size: 1.8rem;
    min-height: 130px;
  }

  .game-link-btn {
    min-height: 90px;
    padding: 15px 10px;
  }

  .operation-symbol,
  .equals-symbol {
    font-size: 2.5rem;
  }
}

@media (max-width: 767px) {
  .main-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  .sidebar,
  .content {
    width: 100%;
    margin: 0;
    min-height: auto;
  }

  .operation-selector {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .operation-btn {
    min-height: 85px;
    padding: 12px 8px;
    font-size: 0.95rem;
  }

  .operation-btn i {
    font-size: 1.5rem;
  }

  .game-link-btn {
    min-height: 80px;
    padding: 15px;
    font-size: 1.1rem;
  }

  .game-link-btn i {
    font-size: 1.8rem;
  }

  .game-link-desc {
    font-size: 0.85rem;
  }

  .question-container {
    font-size: 1.6rem;
    padding: 15px 10px;
    min-height: 110px;
  }

  .operation-symbol,
  .equals-symbol {
    font-size: 2.2rem;
  }

  .item {
    width: 65px;
    height: 65px;
    font-size: 2.2rem;
  }
}

@media (max-width: 576px) {
  .container {
    padding: 10px;
  }

  header {
    padding: 20px 15px;
  }

  header h1 {
    font-size: 1.8rem;
  }

  header p {
    font-size: 1rem;
  }

  .arabic-decoration {
    font-size: 1.6rem;
  }

  .main-content {
    gap: 15px;
  }

  .sidebar,
  .content {
    padding: 20px 15px;
    border-radius: 15px;
  }

  .section-title {
    font-size: 1.3rem;
    margin-bottom: 15px;
  }

  .operation-selector {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .operation-btn {
    min-height: 75px;
    padding: 10px;
    font-size: 0.9rem;
  }

  .operation-btn i {
    font-size: 1.3rem;
  }

  .theme-btn {
    padding: 10px 12px;
    font-size: 0.9rem;
    margin: 5px;
  }

  .visual-operation {
    padding: 15px;
    min-height: 220px;
    gap: 10px;
  }

  .item {
    width: 55px;
    height: 55px;
    font-size: 2rem;
  }

  .group-container {
    padding: 10px;
    margin: 5px;
  }

  .operation-symbol,
  .equals-symbol {
    font-size: 2rem;
    margin: 0 8px;
  }

  .question-mark {
    width: 55px;
    height: 55px;
    font-size: 2rem;
  }

  .question-container {
    font-size: 1.4rem;
    padding: 15px 8px;
    min-height: 100px;
    gap: 8px;
  }

  .answer-input {
    width: 140px;
    padding: 15px;
    font-size: 1.8rem;
    margin: 20px 0;
  }

  .btn {
    padding: 14px 20px;
    font-size: 1rem;
    width: 100%;
    max-width: 300px;
    justify-content: center;
  }

  .controls {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .feedback {
    font-size: 1.2rem;
    padding: 15px;
    min-height: 50px;
  }

  .game-link-btn {
    min-height: 70px;
    padding: 12px;
    font-size: 1rem;
  }

  .game-link-btn i {
    font-size: 1.5rem;
  }

  .game-link-desc {
    font-size: 0.8rem;
  }
}

@media (max-width: 360px) {
  header h1 {
    font-size: 1.6rem;
  }

  .arabic-decoration {
    font-size: 1.4rem;
  }

  .item {
    width: 50px;
    height: 50px;
    font-size: 1.8rem;
  }

  .operation-btn {
    font-size: 0.85rem;
    min-height: 70px;
  }

  .question-container {
    font-size: 1.2rem;
    padding: 12px 5px;
    min-height: 90px;
  }

  .operation-symbol,
  .equals-symbol {
    font-size: 1.8rem;
    margin: 0 5px;
  }

  .question-mark {
    width: 45px;
    height: 45px;
    font-size: 1.8rem;
  }
}

input[type="number"] {
  font-size: 1.8rem !important;
  padding: 15px !important;
}

.visual-operation::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.visual-operation::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.visual-operation::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

.visual-operation::-webkit-scrollbar-thumb:hover {
  background: var(--peach);
}

@media (max-width: 576px) {
  .theme-btn,
  .operation-btn,
  .btn {
    min-height: 44px;
  }

  input,
  button,
  a {
    font-size: 16px !important;
  }
}

@media (max-width: 576px) {
  .question-container {
    white-space: normal;
    overflow-x: hidden;
  }

  #question-text {
    white-space: normal;
  }
}

.sidebar {
  justify-content: flex-start;
}

.wisdom-quote,
.score-container {
  margin-bottom: 20px;
}
