:root {
  --primary-color: #2962ff;
  --secondary-color: #0039cb;
  --success-color: #2e7d32;
  --error-color: #d32f2f;
  --box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  --border-radius: 16px;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: "Tajawal", Arial, sans-serif;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  margin: 0;
  padding: 0;
  direction: rtl;
  min-height: 100vh;
  transition: background 1s ease;
  position: relative;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  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"><text x="30" y="50" font-family="Arial" font-size="80" fill="rgba(255,255,255,0.05)">؟</text></svg>');
  background-repeat: repeat;
  z-index: -1;
}

.container {
  max-width: 800px;
  margin: 30px auto;
  padding: 20px;
  perspective: 1000px;
}

.header-container {
  position: relative;
  margin-bottom: 40px;
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
}

.header-container:hover {
  transform: translateY(-5px);
}

.number-circle {
  background: linear-gradient(145deg, #ffffff, #f0f0f0);
  border-radius: 50%;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: bold;
  position: absolute;
  right: -15px;
  top: -15px;
  box-shadow: var(--box-shadow);
  color: var(--primary-color);
  z-index: 2;
  border: 5px solid white;
}

.header {
  background: linear-gradient(145deg, #ffffff, #f0f0f0);
  border-radius: var(--border-radius);
  padding: 30px;
  text-align: center;
  box-shadow: var(--box-shadow);
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.header::before {
  content: "";
  position: absolute;
  top: -20px;
  left: -20px;
  right: -20px;
  bottom: -20px;
  background: linear-gradient(
    45deg,
    transparent 40%,
    rgba(41, 98, 255, 0.1) 45%,
    rgba(41, 98, 255, 0.1) 55%,
    transparent 60%
  );
  transform: rotate(-45deg);
  z-index: -1;
}

.title {
  font-size: 60px;
  font-weight: bold;
  margin: 0;
  color: var(--primary-color);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
  letter-spacing: 2px;
}

.clues-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.clue {
  background: linear-gradient(145deg, #ffffff, #f0f0f0);
  border-radius: var(--border-radius);
  padding: 25px;
  font-size: 24px;
  font-weight: bold;
  box-shadow: var(--box-shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
  color: #333;
  display: flex;
  align-items: center;
  min-height: 120px;
}

.clue::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  background-color: rgba(41, 98, 255, 0.2);
  border-radius: 50%;
  top: 15px;
  right: 15px;
}

.clue:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.answer-container {
  display: flex;
  justify-content: center;
  margin-top: 40px;
  position: relative;
  perspective: 1000px;
}

.answer-input {
  padding: 18px 25px;
  font-size: 22px;
  border-radius: var(--border-radius) 0 0 var(--border-radius);
  border: none;
  width: 70%;
  text-align: right;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
  background-color: rgba(255, 255, 255, 0.95);
  transition: all 0.3s ease;
  font-family: "Tajawal", Arial, sans-serif;
}

.answer-input:focus {
  outline: none;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1),
    0 0 0 3px rgba(41, 98, 255, 0.3);
}

.submit-btn {
  padding: 18px 35px;
  font-size: 22px;
  background: linear-gradient(
    145deg,
    var(--primary-color),
    var(--secondary-color)
  );
  color: white;
  border: none;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  cursor: pointer;
  box-shadow: var(--box-shadow);
  transition: all 0.3s ease;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  font-family: "Tajawal", Arial, sans-serif;
  font-weight: bold;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

.submit-btn::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0));
  top: 0;
  left: 0;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.submit-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.submit-btn:hover::before {
  transform: translateY(0);
}

.submit-btn:active {
  transform: translateY(1px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.shake {
  animation: shake 0.5s;
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-10px);
  }
  40% {
    transform: translateX(10px);
  }
  60% {
    transform: translateX(-10px);
  }
  80% {
    transform: translateX(10px);
  }
  100% {
    transform: translateX(0);
  }
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
  z-index: 1000;
  perspective: 1000px;
}

.modal-content {
  background: linear-gradient(145deg, #ffffff, #f0f0f0);
  padding: 50px;
  border-radius: var(--border-radius);
  text-align: center;
  max-width: 80%;
  animation: zoomIn 0.7s cubic-bezier(0.17, 0.67, 0.83, 0.67);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}

.modal-content::before {
  content: "";
  position: absolute;
  top: -100px;
  left: -100px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(46, 125, 50, 0.2), transparent 70%);
}

.modal-content::after {
  content: "";
  position: absolute;
  bottom: -100px;
  right: -100px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(46, 125, 50, 0.2), transparent 70%);
}

@keyframes zoomIn {
  from {
    transform: scale(0) rotate(-10deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.congrats-title {
  font-size: 48px;
  background: linear-gradient(145deg, var(--success-color), #1b5e20);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 20px;
  position: relative;
  display: inline-block;
}

.congrats-title::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(
    to right,
    transparent,
    var(--success-color),
    transparent
  );
}

.congrats-message {
  font-size: 24px;
  margin-bottom: 30px;
  color: #333;
}

.congrats-icon {
  font-size: 60px;
  margin-bottom: 20px;
  display: inline-block;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.continue-btn {
  padding: 15px 30px;
  font-size: 20px;
  background: linear-gradient(145deg, var(--success-color), #1b5e20);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  box-shadow: var(--box-shadow);
  transition: all 0.3s ease;
  font-family: "Tajawal", Arial, sans-serif;
  font-weight: bold;
  margin-top: 10px;
}

.continue-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  background-color: #f00;
  border-radius: 50%;
  z-index: 2000;
}

.correct-body {
  background: linear-gradient(135deg, var(--success-color), #1b5e20);
}

.wrong-body {
  background: linear-gradient(135deg, var(--error-color), #b71c1c);
}

.rainbow-body {
  background: linear-gradient(
    135deg,
    #ff0000,
    #ff7f00,
    #ffff00,
    #00ff00,
    #0000ff,
    #4b0082,
    #9400d3
  );
  background-size: 1400% 1400%;
  animation: rainbow 10s ease infinite;
}

@keyframes rainbow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.hidden {
  display: none;
}

.game-level {
  transition: transform 0.5s ease, opacity 0.5s ease;
  transform-origin: center;
}

.fade-out {
  opacity: 0;
  transform: translateY(-50px);
}

.fade-in {
  animation: fadeIn 1s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.final-modal-content {
  background: linear-gradient(145deg, #ffffff, #f0f0f0);
  padding: 50px;
  border-radius: var(--border-radius);
  text-align: center;
  max-width: 80%;
  animation: zoomIn 0.7s cubic-bezier(0.17, 0.67, 0.83, 0.67);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
  background-size: 400% 400%;
  animation: gradient 3s ease infinite;
}

.final-modal-content::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    45deg,
    rgba(255, 0, 0, 0.1),
    rgba(255, 165, 0, 0.1),
    rgba(255, 255, 0, 0.1),
    rgba(0, 128, 0, 0.1),
    rgba(0, 0, 255, 0.1),
    rgba(75, 0, 130, 0.1),
    rgba(238, 130, 238, 0.1)
  );
  opacity: 0.6;
  z-index: -1;
}

@keyframes gradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.rainbow-text {
  font-size: 48px;
  background: linear-gradient(
    to right,
    #ff0000,
    #ff7f00,
    #ffff00,
    #00ff00,
    #0000ff,
    #4b0082,
    #9400d3
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 20px;
  position: relative;
  display: inline-block;
  animation: rainbow-shift 5s linear infinite;
  background-size: 200% auto;
}

@keyframes rainbow-shift {
  0% {
    background-position: 0% center;
  }
  100% {
    background-position: 200% center;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .title {
    font-size: 40px;
  }

  .clues-container {
    grid-template-columns: 1fr;
  }

  .clue {
    font-size: 20px;
    padding: 20px;
  }

  .answer-input,
  .submit-btn {
    font-size: 18px;
    padding: 15px;
  }

  .modal-content {
    padding: 30px;
  }

  .congrats-title {
    font-size: 36px;
  }
}
.home-button {
  position: absolute;
  top: 20px;
  left: 20px;
  display: inline-block;
  padding: 15px 30px;
  background: linear-gradient(135deg, #722afe, #2b86c5);
  color: white;
  font-size: 24px;
  text-decoration: none;
  border-radius: 50px;
  font-weight: bold;
  text-align: center;
  overflow: hidden;
  z-index: 1;
  box-shadow: 0 5px 15px rgba(43, 134, 197, 0.4);
  transition: all 0.3s ease;
}

.home-button:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #2b86c5, #722afe);
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s ease;
  border-radius: 50px;
}

.home-button:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(114, 42, 254, 0.6);
}

.home-button:hover:before {
  opacity: 1;
}

.home-button:active {
  transform: translateY(0);
  box-shadow: 0 5px 15px rgba(43, 134, 197, 0.4);
}

.home-button .icon {
  display: inline-block;
  margin-right: 10px;
  transition: transform 0.3s ease;
}

.home-button:hover .icon {
  transform: rotate(10deg);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(114, 42, 254, 0.7);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(114, 42, 254, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(114, 42, 254, 0);
  }
}

.home-button:hover {
  animation: pulse 1.5s infinite;
}
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .title {
    font-size: 40px;
  }

  .clues-container {
    grid-template-columns: 1fr;
  }

  .clue {
    font-size: 20px;
    padding: 20px;
  }

  .answer-input,
  .submit-btn {
    font-size: 18px;
    padding: 15px;
  }

  .modal-content {
    padding: 30px;
  }

  .congrats-title {
    font-size: 36px;
  }

  /* Home button repositioned to top of webpage for mobile */
  .home-button {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    font-size: 16px;
    z-index: 1000;
    width: auto;
    display: inline-block;
  }

  .home-button:hover {
    transform: translateX(-50%);
    animation: none;
  }

  /* Add space at top of container to accommodate the fixed home button */
  .container {
    margin-top: 60px;
  }
}

/* Additional styles for smaller mobile screens */
@media (max-width: 480px) {
  .title {
    font-size: 32px;
  }

  .header {
    padding: 20px 15px;
  }

  .number-circle {
    width: 60px;
    height: 60px;
    font-size: 30px;
    right: -10px;
    top: -10px;
  }

  .clue {
    min-height: 100px;
    font-size: 18px;
    padding: 15px;
  }

  .answer-container {
    flex-direction: column;
  }

  .answer-input {
    width: 100%;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
  }

  .submit-btn {
    width: 100%;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
  }

  /* Even smaller home button for small screens */
  .home-button {
    padding: 6px 12px;
    font-size: 14px;
  }

  .modal-content,
  .final-modal-content {
    padding: 20px;
    max-width: 90%;
  }

  .congrats-title,
  .rainbow-text {
    font-size: 28px;
  }

  .congrats-message {
    font-size: 18px;
  }
}

/* For very small screens */
@media (max-width: 360px) {
  .title {
    font-size: 28px;
  }

  .clue {
    font-size: 16px;
    padding: 12px;
  }

  /* Even smaller home button for tiny screens */
  .home-button {
    padding: 5px 10px;
    font-size: 12px;
  }

  .congrats-title,
  .rainbow-text {
    font-size: 24px;
  }
}
