:root {
  --bg1: #fffaf0;
  --bg2: #eff8ff;
  --panel: rgba(255, 255, 255, 0.85);
  --ink: #1f325c;
  --primary: #6c63ff;
  --primary-strong: #5549d9;
  --secondary: #ff8a5b;
  --mint: #5ee7c6;
  --yellow: #ffd866;
  --green: #4ecb71;
  --red: #ff5d73;
  --shadow: rgba(66, 83, 143, 0.18);
  --gray: #eef2ff;
  --danger: #ff5c6b;
  --success: #2ac38b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Fredoka", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 202, 120, 0.35), transparent 25%),
    radial-gradient(circle at bottom right, rgba(120, 162, 255, 0.28), transparent 30%),
    linear-gradient(135deg, var(--bg1), var(--bg2));
}

button,
input {
  font: inherit;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.header {
  text-align: center;
  margin-bottom: 20px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.header-nav-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.65);
  padding: 10px 14px;
  border-radius: 16px;
  box-shadow: 0 8px 18px var(--shadow);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  transition: transform 0.2s ease, background 0.2s ease;
}

.back-link:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.9);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  text-align: center;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  margin: 10px 0 8px;
}

.tagline {
  text-align: center;
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.35rem);
  color: rgba(31, 50, 92, 0.8);
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.card {
  background: var(--panel);
  border: 3px solid rgba(118, 137, 255, 0.18);
  border-radius: 28px;
  box-shadow: 0 20px 40px var(--shadow);
  padding: 22px 18px;
  backdrop-filter: blur(8px);
}

.card h1 {
  text-align: center;
}

#screen-welcome {
  max-width: 900px;
  margin: 0 auto;
}

#screen-welcome .card {
  width: 100%;
  padding: 28px 22px;
}

h1,
h2,
h3 {
  margin: 0 0 12px;
}

.subtitle {
  text-align: center;
  margin: 0 0 22px;
  font-size: 1.08rem;
  line-height: 1.5;
  color: rgba(31, 50, 92, 0.8);
}

.field {
  display: block;
  margin-bottom: 18px;
  font-weight: 600;
}

.field span {
  display: block;
  margin-bottom: 8px;
}

.field input {
  width: 100%;
  border: 3px solid rgba(108, 99, 255, 0.15);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 1.05rem;
  color: var(--ink);
}

.mode-label {
  font-weight: 700;
  margin: 10px 0 14px;
}

.mode-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.mode-btn {
  background: linear-gradient(180deg, #fff7d6, #f5ecff);
  border: 3px solid transparent;
  border-radius: 20px;
  padding: 18px 14px;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 18px rgba(98, 114, 199, 0.12);
}

.mode-btn:hover,
.mode-btn:focus-visible {
  transform: translateY(-2px);
}

.mode-btn.selected {
  border-color: var(--primary);
  background: linear-gradient(180deg, #f5efff, #eaf9ff);
  box-shadow: 0 12px 22px rgba(108, 99, 255, 0.18);
}

.mode-icon {
  display: block;
  font-size: 2rem;
  margin-bottom: 10px;
}

.mode-title {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.mode-desc {
  display: block;
  line-height: 1.3;
  font-size: 0.9rem;
  color: rgba(31, 50, 92, 0.7);
}

.btn {
  border: none;
  border-radius: 18px;
  min-height: 56px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
  box-shadow: 0 12px 18px rgba(70, 90, 170, 0.14);
}

.btn:hover:not(:disabled),
.btn:focus-visible:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.02);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #7c6dff, #5f52e7);
  color: white;
}

.btn-secondary {
  background: linear-gradient(180deg, #ffb870, #ff9066);
  color: #fff;
}

.btn-check {
  background: linear-gradient(180deg, #34d399, #22a86b);
  color: white;
}

.btn-clear {
  background: linear-gradient(180deg, #ffd166, #f2b74c);
  color: #1d2d4f;
}

.btn-next {
  background: linear-gradient(180deg, #38ef7d, #11998e);
  color: white;
  box-shadow: 0 10px 24px rgba(17, 153, 142, 0.35);
  animation: pulseNext 1.8s infinite ease-in-out;
}

@keyframes pulseNext {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.04);
  }
}

.btn-skip {
  background: linear-gradient(180deg, #f3f6ff, #e2e8ff);
  color: #2b3a67;
  border: 2px solid rgba(108, 99, 255, 0.22);
}

.btn-chip-menu {
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid rgba(108, 99, 255, 0.22);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.88rem;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  white-space: nowrap;
}

.btn-chip-menu:hover {
  transform: translateY(-2px);
  background: #ffffff;
  box-shadow: 0 6px 14px rgba(108, 99, 255, 0.15);
}

#btn-start {
  width: 100%;
  font-size: 1.1rem;
}

.leaderboard-section {
  margin-top: 26px;
}

.leaderboard-card {
  display: flex;
  flex-direction: column;
  padding: 24px 20px;
}

.leaderboard-card h2 {
  font-size: 1.35rem;
  margin-bottom: 16px;
  color: var(--ink);
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.leaderboard-entry {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  gap: 12px;
  align-items: center;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 0.98rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

.leaderboard-entry.top-1 {
  background: linear-gradient(90deg, #fff8dc, #ffffff);
  border-left: 4px solid #ffd866;
}

.leaderboard-entry.top-2 {
  background: linear-gradient(90deg, #f2f5ff, #ffffff);
  border-left: 4px solid #b8c7ff;
}

.leaderboard-entry.top-3 {
  background: linear-gradient(90deg, #fff0eb, #ffffff);
  border-left: 4px solid #ffb899;
}

.leaderboard-entry .rank {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--primary-strong);
}

.leaderboard-entry .name {
  font-weight: 600;
  color: var(--ink);
}

.leaderboard-entry .score {
  font-weight: 800;
  color: var(--primary-strong);
}

.leaderboard-entry .date {
  font-size: 0.85rem;
  color: rgba(31, 50, 92, 0.5);
  font-weight: 500;
}

.leaderboard-empty {
  margin: 14px 0 0;
  color: rgba(31, 50, 92, 0.7);
  text-align: center;
}

.hidden {
  display: none !important;
}

#screen-game {
  max-width: 900px;
  margin: 0 auto;
}

.game-card {
  padding: 22px 18px 26px;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.progress-info {
  flex: 1;
}

.progress-info span {
  font-size: 0.95rem;
  color: rgba(31, 50, 92, 0.85);
  font-weight: 700;
}

.progress-bar {
  height: 10px;
  background: rgba(108, 99, 255, 0.12);
  border-radius: 99px;
  margin-top: 6px;
  overflow: hidden;
  max-width: 260px;
}

.progress-fill {
  height: 100%;
  width: 20%;
  background: linear-gradient(90deg, #ff8a5b, #6c63ff);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.mode-indicator {
  background: linear-gradient(180deg, #ffe8b8, #ffd07d);
  color: #473200;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: inset 0 -3px rgba(0, 0, 0, 0.08);
}

.score-badge {
  background: linear-gradient(180deg, #f5ebff, #ebd7ff);
  color: var(--ink);
  border-radius: 999px;
  font-weight: 700;
  padding: 8px 16px;
  white-space: nowrap;
}

.challenge-target {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  padding: 16px 18px;
  margin-bottom: 10px;
  font-weight: 700;
}

.challenge-target.top-target {
  margin-top: 4px;
  margin-bottom: 12px;
  padding: 14px 18px;
  border: 2px solid rgba(108, 99, 255, 0.18);
}

.target-label {
  font-size: 1.05rem;
}

.target-num-badge {
  background: var(--primary);
  color: white;
  font-size: 0.88rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.5px;
  box-shadow: 0 3px 8px rgba(108, 99, 255, 0.3);
}

.target-name {
  font-size: 1.05rem;
  color: var(--ink);
}

.target-color-preview {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 4px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.challenge-hint {
  margin: 0 0 18px;
  text-align: center;
  color: rgba(31, 50, 92, 0.75);
  font-size: 1rem;
}

.beaker-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 8px 0 18px;
}

.beaker {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

.beaker-vessel {
  position: relative;
  flex: 0 0 200px;
  width: 200px;
  height: 200px;
}

.beaker-glass {
  position: relative;
  width: 200px;
  height: 200px;
  border: 6px solid #3b4b73;
  border-top: none;
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
  background: rgba(255, 255, 255, 0.38);
  overflow: hidden;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.4);
}

.beaker-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  border-radius: 0 0 18px 18px;
  background: rgba(255, 255, 255, 0.5);
  transition: height 0.4s ease, background 0.35s ease;
  box-shadow: inset 0 10px 24px rgba(255, 255, 255, 0.25);
}

.beaker-glow {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
  filter: blur(16px);
}

.beaker-bubbles {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.85) 2px, transparent 3px);
  background-size: 18px 18px;
  opacity: 0.15;
}

.beaker-readout {
  display: flex;
  justify-content: center;
  gap: 16px;
  min-height: 24px;
  margin-top: 8px;
  color: var(--ink);
  font-weight: 700;
}

.current-color-info {
  display: flex;
  /* flex-direction: column; */
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 5px;
  min-height: 20px;
  text-align: center;
}

.color-hex {
  font-size: 1.15rem;
  font-weight: 700;
  color: rgba(31, 50, 92, 0.8);
}

.color-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: rgba(31, 50, 92, 0.8);
}

.ingredients-panel {
  background: rgba(255, 255, 255, 0.58);
  border-radius: 24px;
  padding: 14px 14px;
  margin-bottom: 18px;
}

.ingredients-panel h3 {
  font-size: 1.15rem;
  margin-bottom: 12px;
  text-align: center;
}

.ingredient-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ingredient-row.modifiers {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.ingredient-btn {
  position: relative;
  display: flex;
  /* flex-direction: column; */
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 90px;
  border: 3px solid rgba(255, 255, 255, 0.8);
  border-radius: 22px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
}

.ingredient-btn.primary {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(245, 248, 255, 0.92));
}

.ingredient-btn.modifier {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(243, 243, 255, 0.92));
}

.ingredient-btn[data-color="red"] {
  background: linear-gradient(180deg, #ffe2e7, #ffc7d2);
}

.ingredient-btn[data-color="blue"] {
  background: linear-gradient(180deg, #e2ebff, #cfe1ff);
}

.ingredient-btn[data-color="yellow"] {
  background: linear-gradient(180deg, #fff2bf, #ffe682);
}

.ingredient-btn[data-color="white"] {
  background: linear-gradient(180deg, #ffffff, #eef0f5);
}

.ingredient-btn[data-color="black"] {
  background: linear-gradient(180deg, #f0f3ff, #dfe6ff);
}

.ingredient-btn:hover:not(:disabled),
.ingredient-btn:focus-visible:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
}

.ingredient-btn.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-6px);
  }

  40% {
    transform: translateX(6px);
  }

  60% {
    transform: translateX(-4px);
  }

  80% {
    transform: translateX(4px);
  }
}

.ingredient-icon {
  font-size: 2rem;
}

.ingredient-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
}

.action-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.action-buttons .btn {
  min-width: 190px;
}

.feedback {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  padding: 12px;
  font-weight: 700;
  margin-bottom: 12px;
}

.feedback-perfect {
  background: rgba(46, 204, 113, 0.15);
  color: #0a804f;
}

.feedback-great {
  background: rgba(52, 152, 219, 0.15);
  color: #1e6ae9;
}

.feedback-good {
  background: rgba(241, 196, 15, 0.18);
  color: #af8200;
}

.feedback-try_again {
  background: rgba(255, 92, 107, 0.12);
  color: #b52a34;
}

.stars-container {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-height: 28px;
  margin-bottom: 4px;
}

.star {
  font-size: 1.7rem;
  opacity: 0.24;
  transform: scale(0.8);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.star.filled {
  opacity: 1;
  transform: scale(1);
  animation: pop 0.35s ease;
}

@keyframes pop {
  0% {
    transform: scale(0.7);
  }

  60% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

#screen-results {
  max-width: 620px;
  margin: 0 auto;
}

.results-card {
  text-align: center;
  padding: 22px 20px 28px;
}

.results-emoji {
  font-size: 4rem;
  margin-bottom: 10px;
}

.results-greeting {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 18px;
}

.results-comparison {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.color-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.color-swatch {
  width: 100px;
  height: 100px;
  border-radius: 20px;
  border: 4px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
}

.color-label {
  font-weight: 700;
  color: rgba(31, 50, 92, 0.8);
}

.results-score-box {
  background: rgba(108, 99, 255, 0.08);
  border: 2px dashed rgba(108, 99, 255, 0.25);
  border-radius: 20px;
  padding: 16px 20px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.results-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(31, 50, 92, 0.7);
}

.final-score {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--primary-strong);
  line-height: 1.1;
}

.results-max {
  font-size: 0.9rem;
  color: rgba(31, 50, 92, 0.6);
}

.results-stars-summary {
  font-size: 1.15rem;
  font-weight: 700;
  color: #b38200;
  margin: 0 0 10px;
}

.results-message {
  margin: 0 0 18px;
  font-size: 1.05rem;
  color: rgba(31, 50, 92, 0.85);
  font-weight: 600;
}

.results-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.save-confirmation {
  margin-top: 14px;
  color: var(--success);
  font-weight: 700;
}

.flying-drop {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

@media (max-width: 760px) {

  .mode-buttons,
  .action-buttons,
  .ingredient-row {
    grid-template-columns: 1fr;
  }

  .ingredient-row.modifiers {
    grid-template-columns: 1fr 1fr;
  }

  .game-header,
  .header-top,
  .results-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .challenge-target {
    flex-direction: column;
  }

  .beaker-glass {
    width: 180px;
    height: 220px;
  }

  .beaker-vessel {
    flex-basis: 180px;
    width: 180px;
    height: 220px;
  }

  .leaderboard-entry {
    grid-template-columns: 32px 1fr 1fr 54px;
  }

  .leaderboard-entry .date {
    display: none;
  }
}
