/* Fraction Builder - Gaming Styles */
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700;800&display=swap");

:root {
  --primary: #28c76f;
  --primary-dark: #1f9d57;
  --secondary: #00d4bd;
  --accent: #ff9f43;
  --success: #28c76f;
  --danger: #ea5455;
  --bg-gradient-start: #81fbb8;
  --bg-gradient-end: #28c76f;
  --card-bg: rgba(255, 255, 255, 0.98);
  --text-dark: #2d3748;
  --text-light: #718096;
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.15);
  --shadow-xl: 0 30px 80px rgba(0, 0, 0, 0.2);
}

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

body {
  font-family: "Poppins", "Segoe UI", sans-serif;
  background: linear-gradient(
    135deg,
    var(--bg-gradient-start) 0%,
    var(--bg-gradient-end) 100%
  );
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 50%
  );
  animation: rotate 30s linear infinite;
  pointer-events: none;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Container */
#game-container {
  background: var(--card-bg);
  border-radius: 32px;
  padding: 40px;
  max-width: 1400px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
}

/* Header */
.game-header {
  text-align: center;
  margin-bottom: 40px;
}

.game-icon {
  font-size: 100px;
  animation: bounce 2s ease-in-out infinite;
  display: inline-block;
  filter: drop-shadow(0 10px 20px rgba(40, 199, 111, 0.3));
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-15px);
  }
}

.game-title {
  font-size: 3.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 20px 0 10px;
  letter-spacing: -1px;
}

.game-subtitle {
  font-size: 1.3rem;
  color: var(--text-light);
  font-weight: 500;
}

/* Skills */
.skills-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 25px 0;
}

.skill-badge {
  background: linear-gradient(
    135deg,
    rgba(40, 199, 111, 0.2) 0%,
    rgba(0, 212, 189, 0.2) 100%
  );
  color: var(--primary);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid var(--primary);
  text-transform: capitalize;
  transition: all 0.3s ease;
}

.skill-badge:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(40, 199, 111, 0.3);
}

/* Buttons */
.btn {
  padding: 18px 40px;
  font-size: 1.2rem;
  font-weight: 700;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s ease;
}

.btn:hover::before {
  left: 100%;
}

.btn-primary {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
  color: white;
  box-shadow: 0 8px 25px rgba(40, 199, 111, 0.4);
}

.btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 35px rgba(40, 199, 111, 0.5);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary) 0%, #00b4a0 100%);
  color: white;
  box-shadow: 0 8px 25px rgba(0, 212, 189, 0.4);
}

.btn-secondary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 35px rgba(0, 212, 189, 0.5);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, #ff8510 100%);
  color: white;
  box-shadow: 0 8px 25px rgba(255, 159, 67, 0.4);
}

.btn-accent:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(255, 159, 67, 0.5);
}

/* Game Screens */
.game-screen {
  display: none;
}

#welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.welcome-content {
  text-align: center;
  max-width: 700px;
}

.welcome-text {
  font-size: 1.2rem;
  color: var(--text-dark);
  line-height: 1.8;
  margin-bottom: 30px;
}

.mode-buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Build Mode Screen */
#build-screen {
  display: none;
}

.build-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 20px;
  background: linear-gradient(
    135deg,
    rgba(40, 199, 111, 0.1) 0%,
    rgba(0, 212, 189, 0.1) 100%
  );
  border-radius: 20px;
}

.level-info {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.score-display {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--secondary);
}

.build-content {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 30px;
  margin-bottom: 30px;
}

/* Target Section */
.target-section {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.8) 0%,
    rgba(248, 250, 252, 0.8) 100%
  );
  padding: 30px;
  border-radius: 24px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.target-fraction {
  font-size: 4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin: 20px 0;
}

.target-visual-container {
  margin-top: 30px;
}

.target-bar-container {
  width: 100%;
  height: 60px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 30px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

#target-visual {
  height: 100%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border-radius: 30px;
  transition: width 0.5s ease;
  box-shadow: 0 0 20px rgba(40, 199, 111, 0.5);
}

/* Construction Section */
.construction-section {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.8) 0%,
    rgba(248, 250, 252, 0.8) 100%
  );
  padding: 30px;
  border-radius: 24px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.current-fraction-display {
  text-align: center;
  margin-bottom: 20px;
}

.current-fraction-label {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 10px;
}

#current-fraction {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
}

#construction-zone {
  min-height: 100px;
  background: white;
  border: 3px dashed rgba(40, 199, 111, 0.3);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 25px;
  transition: all 0.3s ease;
}

#construction-zone:empty::after {
  content: "Drag blocks here or click blocks from inventory";
  width: 100%;
  text-align: center;
  color: var(--text-light);
  font-size: 1.1rem;
}

#construction-zone.shake {
  animation: shake 0.5s ease;
}

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

/* Inventory */
.inventory-section {
  margin-bottom: 25px;
}

#block-inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  padding: 20px;
  background: white;
  border-radius: 20px;
  min-height: 120px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
}

.fraction-block {
  height: 60px;
  min-width: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

.fraction-block::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), transparent);
  pointer-events: none;
}

.fraction-block:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.fraction-block.dragging {
  opacity: 0.5;
  transform: scale(0.9);
}

.fraction-block.constructed {
  cursor: pointer;
}

.fraction-block.constructed:hover::after {
  content: "✕";
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(234, 84, 85, 0.9);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.block-label {
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 1;
}

/* Build Actions */
.build-actions {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

/* Feedback Messages */
.feedback-message {
  padding: 20px;
  border-radius: 16px;
  font-size: 1.1rem;
  margin-top: 20px;
  text-align: center;
  animation: slideDown 0.4s ease;
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.success-message {
  background: linear-gradient(
    135deg,
    rgba(40, 199, 111, 0.2) 0%,
    rgba(40, 199, 111, 0.1) 100%
  );
  color: #1f9d57;
  border-left: 5px solid var(--success);
}

.error-message {
  background: linear-gradient(
    135deg,
    rgba(234, 84, 85, 0.2) 0%,
    rgba(234, 84, 85, 0.1) 100%
  );
  color: #c53030;
  border-left: 5px solid var(--danger);
}

.hint-message {
  background: linear-gradient(
    135deg,
    rgba(255, 159, 67, 0.2) 0%,
    rgba(255, 159, 67, 0.1) 100%
  );
  color: #c05621;
  border-left: 5px solid var(--accent);
}

/* Compare Mode Screen */
#compare-screen {
  display: none;
}

.compare-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 20px;
  background: linear-gradient(
    135deg,
    rgba(40, 199, 111, 0.1) 0%,
    rgba(0, 212, 189, 0.1) 100%
  );
  border-radius: 20px;
}

.compare-content {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 40px;
  align-items: center;
  margin-bottom: 30px;
}

.fraction-display {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.8) 0%,
    rgba(248, 250, 252, 0.8) 100%
  );
  padding: 40px;
  border-radius: 24px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.fraction-label {
  font-size: 5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 30px;
}

.visual-container {
  width: 100%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fraction-bar {
  height: 80px;
  border-radius: 40px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  transition: all 0.5s ease;
}

.fraction-circle {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  transition: all 0.5s ease;
}

.comparison-operators {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.compare-btn {
  width: 80px;
  height: 80px;
  font-size: 2.5rem;
  font-weight: 700;
  background: white;
  color: var(--text-dark);
  border: 4px solid rgba(40, 199, 111, 0.3);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.compare-btn:hover:not(:disabled) {
  border-color: var(--primary);
  transform: scale(1.1);
  box-shadow: 0 8px 25px rgba(40, 199, 111, 0.3);
  background: linear-gradient(
    135deg,
    rgba(40, 199, 111, 0.1) 0%,
    rgba(0, 212, 189, 0.1) 100%
  );
}

.compare-btn.correct {
  background: linear-gradient(135deg, #d1fae5 0%, #6ee7b7 100%);
  border-color: var(--success);
  border-width: 5px;
  animation: correctPulse 0.5s ease;
}

.compare-btn.wrong {
  background: linear-gradient(135deg, #fee2e2 0%, #fca5a5 100%);
  border-color: var(--danger);
  border-width: 5px;
  animation: wrongShake 0.5s ease;
}

@keyframes correctPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.15);
  }
}

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

.compare-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Results Screen */
#results-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 35px;
  text-align: center;
}

.results-icon {
  font-size: 120px;
  animation: bounce 1s ease infinite;
}

.results-title {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 25px;
  width: 100%;
  margin: 30px 0;
}

.stat-card {
  background: linear-gradient(
    135deg,
    rgba(40, 199, 111, 0.1) 0%,
    rgba(0, 212, 189, 0.1) 100%
  );
  padding: 30px;
  border-radius: 20px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.12);
}

.stat-value {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 1rem;
  color: var(--text-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 10px;
}

.performance-msg {
  font-size: 1.5rem;
  font-weight: 700;
  padding: 20px 40px;
  border-radius: 16px;
  margin: 20px 0;
}

.performance-msg.perfect {
  background: linear-gradient(
    135deg,
    rgba(40, 199, 111, 0.2) 0%,
    rgba(40, 199, 111, 0.1) 100%
  );
  color: #1f9d57;
}

.performance-msg.excellent {
  background: linear-gradient(
    135deg,
    rgba(0, 212, 189, 0.2) 0%,
    rgba(0, 212, 189, 0.1) 100%
  );
  color: #00867a;
}

.performance-msg.good {
  background: linear-gradient(
    135deg,
    rgba(255, 159, 67, 0.2) 0%,
    rgba(255, 159, 67, 0.1) 100%
  );
  color: #c05621;
}

.performance-msg.try-again {
  background: linear-gradient(
    135deg,
    rgba(234, 84, 85, 0.2) 0%,
    rgba(234, 84, 85, 0.1) 100%
  );
  color: #c53030;
}

.results-actions {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .build-content {
    grid-template-columns: 1fr;
  }

  .compare-content {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .comparison-operators {
    flex-direction: row;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  #game-container {
    padding: 25px;
  }

  .game-title {
    font-size: 2.5rem;
  }

  .game-icon {
    font-size: 70px;
  }

  .target-fraction,
  .fraction-label {
    font-size: 3rem;
  }

  .btn {
    width: 100%;
  }

  .mode-buttons,
  .build-actions,
  .compare-actions,
  .results-actions {
    flex-direction: column;
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}
