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

.screen {
  display: none;
  min-height: 100vh;
}

.screen.screen-active {
  display: block;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.lang-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.lang-selector select {
  padding: 6px 12px;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  font-size: 14px;
  cursor: pointer;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  background: white;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

h1 {
  color: #2563eb;
  text-align: center;
  margin-bottom: 30px;
  font-size: 32px;
}

.instructions {
  margin-bottom: 24px;
  text-align: left;
}

.instructions h2 {
  font-size: 18px;
  color: #1f2937;
  margin-bottom: 12px;
}

.instructions ul {
  padding-left: 24px;
  line-height: 1.8;
  color: #4b5563;
}

.settings {
  margin-bottom: 24px;
  padding: 16px;
  background: #f8fafc;
  border-radius: 8px;
}

.setting-group {
  margin-bottom: 16px;
}

.setting-group:last-of-type {
  margin-bottom: 16px;
}

.setting-label {
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 8px;
}

.radio-group,
.checkbox-group {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.radio-group label,
.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #4b5563;
  cursor: pointer;
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-row label {
  font-size: 14px;
  color: #6b7280;
  font-weight: 600;
  min-width: 140px;
}

.setting-row input[type="range"] {
  width: 120px;
  accent-color: #2563eb;
}

#max-digit {
  width: 140px;
}

#speed-value,
#max-digit-value {
  font-weight: 700;
  color: #2563eb;
  min-width: 24px;
}

.game-description {
  text-align: center;
  color: #6b7280;
  margin-bottom: 20px;
  font-size: 16px;
}

.falling-score {
  text-align: center;
  margin-bottom: 20px;
  font-size: 24px;
  font-weight: 700;
}

.score-label {
  color: #6b7280;
  margin-right: 8px;
}

.score-value {
  color: #2563eb;
  min-width: 40px;
  display: inline-block;
}

.score-sep {
  margin: 0 12px;
  color: #94a3b8;
}

.falling-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-bottom: 24px;
}

.max-digit-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.max-digit-control label {
  font-size: 14px;
  color: #6b7280;
  font-weight: 600;
}

.max-digit-control input[type="range"] {
  width: 80px;
  accent-color: #2563eb;
}

.max-digit-control input[type="range"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#max-digit-value {
  font-weight: 700;
  color: #2563eb;
  min-width: 20px;
}

.start-btn {
  background: #2563eb;
  color: white;
  border: none;
  padding: 15px 40px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.start-btn:hover:not(:disabled) {
  background: #1d4ed8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.start-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.stop-btn {
  background: #f59e0b;
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.stop-btn:hover:not(:disabled) {
  background: #d97706;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.stop-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.restart-btn {
  background: #ef4444;
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.restart-btn:hover {
  background: #dc2626;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.falling-game-area {
  position: relative;
  min-height: 400px;
  background: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 50%, #bae6fd 100%);
  border-radius: 12px;
  border: 2px solid #0ea5e9;
  overflow: hidden;
  transition: background 0.2s;
}

.falling-game-area.game-area-error {
  background: #fecaca !important;
  border-color: #dc2626;
}

@keyframes levelCompleteBlink {
  0%, 100% { background-color: #ffffff; }
  50% { background-color: #fef08a; }
}

#game-container.level-complete-blink {
  animation: levelCompleteBlink 0.5s ease-in-out infinite;
}

.falling-game-area.level-complete-blink {
  animation: levelCompleteBlink 0.5s ease-in-out infinite;
}

.falling-card {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px;
  background: white;
  border: 2px solid #2563eb;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: top 0.05s linear;
}

.falling-card img {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

.bottom-cards {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  background: #f8fafc;
  border-top: 2px solid #e2e8f0;
}

.bottom-card {
  padding: 8px;
  background: white;
  border: 2px solid #94a3b8;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.bottom-card img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  display: block;
}

.bottom-card:hover {
  background: #eff6ff;
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.2);
}

.bottom-card:active {
  transform: translateY(0);
}

.bottom-card-clicked {
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

.nav-section {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 2px solid #e2e8f0;
}

.link-btn {
  background: #6b7280;
  color: white;
  border: none;
  padding: 15px 40px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.link-btn:hover {
  background: #4b5563;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
}

@media (max-width: 768px) {
  .container {
    padding: 20px;
  }

  h1 {
    font-size: 24px;
  }

  .falling-game-area {
    min-height: 350px;
  }

  .falling-card img {
    width: 60px;
    height: 60px;
  }

  .bottom-card img {
    width: 50px;
    height: 50px;
  }
}
