:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #eef3ff;
  --line: #dfe8f7;
  --text: #1d2736;
  --muted: #66758f;
  --primary: #4d7cff;
  --primary-soft: #ebf0ff;
  --success: #15a46d;
  --success-soft: #dff9ee;
  --danger: #e25d5d;
  --danger-soft: #ffe4e4;
  --shadow: 0 14px 32px rgba(20, 35, 61, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #f6f8fc 0%, #edf3ff 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
}

.start-screen {
  width: min(540px, calc(100% - 24px));
  display: grid;
  place-items: center;
  margin: auto;
}

.start-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(173, 188, 219, 0.75);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 36px 28px 30px;
  text-align: center;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.start-card .back-button {
  position: absolute;
  top: 18px;
  left: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #d8e3ff;
  text-decoration: none;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.start-card .back-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(77, 124, 255, 0.15);
}

.start-card::before,
.start-card::after {
  content: "";
  position: absolute;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(120, 157, 255, 0.2), rgba(120, 157, 255, 0));
  pointer-events: none;
}

.start-card::before {
  top: -64px;
  left: -48px;
}

.start-card::after {
  right: -52px;
  bottom: -60px;
}

.start-card .eyebrow {
  margin-bottom: 10px;
}

.start-card h2 {
  margin: 0 0 18px;
  font-size: clamp(2.1rem, 4vw, 3rem);
  letter-spacing: -0.04em;
}

#start-game-button {
  border: none;
  width: 88px;
  height: 88px;
  background: linear-gradient(180deg, #6f97ff 0%, #4d7cff 100%);
  color: #fff;
  font-weight: 800;
  font-size: 2.4rem;
  line-height: 1;
  padding: 0;
  border-radius: 28px;
  cursor: pointer;
  box-shadow: 0 16px 26px rgba(77, 124, 255, 0.22);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

#start-game-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 30px rgba(77, 124, 255, 0.24);
  filter: brightness(1.02);
}

.game-shell {
  width: min(980px, 100%);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(173, 188, 219, 0.75);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 24px 24px 18px;
  position: relative;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #d8e3ff;
  text-decoration: none;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.back-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(77, 124, 255, 0.15);
}

.eyebrow,
.panel-label,
.start-card h2,
.header-left h1,
.celebration-card h2,
.celebration-card p {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.header-mark {
  font-size: 2.2rem;
  line-height: 1;
}

.progress {
  min-width: 78px;
  text-align: center;
  background: var(--primary-soft);
  border: 1px solid #d7e2ff;
  color: var(--primary);
  font-weight: 800;
  border-radius: 999px;
  padding: 10px 14px;
}

.game-board {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
}

.panel-label {
  display: none;
}

.target-area {
  min-height: 220px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #f1f6ff 0%, #edf3ff 100%);
  border: 2px dashed #b4c7ff;
  border-radius: 24px;
  padding: 16px;
  transition: border-color 0.2s ease, transform 0.2s ease;
  touch-action: none;
}

.target-area.drag-over {
  border-color: var(--primary);
  transform: scale(1.01);
}

.target-area.spring-back {
  animation: spring-back 0.26s ease;
}

@keyframes spring-back {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.03);
  }
  60% {
    transform: scale(0.98);
  }
  100% {
    transform: scale(1);
  }
}

.target-card {
  width: min(160px, 100%);
  aspect-ratio: 1;
  border-radius: 22px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 10px 18px rgba(24, 39, 73, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  user-select: none;
}

.target-card.empty {
  font-size: 2.4rem;
  color: var(--muted);
}

.object-visual {
  font-size: clamp(2.7rem, 4vw, 4.3rem);
  line-height: 1;
}

.object-label {
  display: none;
}

.bucket {
  min-height: 220px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 14px;
  justify-content: center;
  padding: 8px;
}

.object-card {
  width: 116px;
  min-height: 108px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  cursor: grab;
  box-shadow: 0 8px 16px rgba(26, 42, 66, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  user-select: none;
  touch-action: none;
}

.touch-drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 116px;
  min-height: 108px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 24px rgba(26, 42, 66, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 1000;
}

.object-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 20px rgba(26, 42, 66, 0.1);
}

.object-card.dragging {
  opacity: 0.55;
  transform: scale(0.98);
}

.object-card:active {
  cursor: grabbing;
}

.object-card .object-label {
  margin-top: 8px;
  font-size: 0.78rem;
}

.feedback {
  min-height: 24px;
  margin-top: 16px;
  border-radius: 12px;
  text-align: center;
  font-weight: 700;
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 0;
}

.feedback.show {
  opacity: 1;
  transform: translateY(0);
}

.feedback.success {
  background: var(--success-soft);
  color: var(--success);
}

.feedback.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.celebration {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 30, 44, 0.38);
  backdrop-filter: blur(3px);
}

.celebration.hidden {
  display: none;
}

.celebration-card {
  position: relative;
  width: min(420px, calc(100% - 28px));
  background: linear-gradient(180deg, #ffffff 0%, #f2f7ff 100%);
  border: 1px solid rgba(174, 190, 227, 0.8);
  border-radius: 30px;
  box-shadow: 0 26px 44px rgba(52, 81, 134, 0.2);
  padding: 28px 22px 22px;
  text-align: center;
  overflow: hidden;
  animation: celebration-pop 0.35s ease;
}

.celebration-card::before,
.celebration-card::after {
  content: "";
  position: absolute;
  inset: 14px 18px auto;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.55), transparent);
  transform: rotate(-8deg);
  opacity: 0.8;
}

.celebration-card::after {
  inset: auto 20px 12px;
  transform: rotate(6deg);
}

.celebration-badges {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 2rem;
  margin-bottom: 10px;
  animation: badge-bounce 0.8s ease-in-out infinite alternate;
}

.celebration-badges span:nth-child(2) {
  animation-delay: 0.15s;
}

.celebration-badges span:nth-child(3) {
  animation-delay: 0.3s;
}

.celebration-card h2 {
  margin: 0 0 18px;
  font-size: 3rem;
  line-height: 1;
  color: var(--success);
  letter-spacing: -0.04em;
}

.celebration-card p {
  display: none;
}

#play-again {
  width: 88px;
  height: 88px;
  border: none;
  background: linear-gradient(180deg, #6f97ff 0%, #4d7cff 100%);
  color: white;
  font-weight: 800;
  font-size: 2.1rem;
  padding: 0;
  border-radius: 28px;
  cursor: pointer;
  box-shadow: 0 12px 18px rgba(77, 124, 255, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#play-again:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 22px rgba(77, 124, 255, 0.3);
}

@keyframes celebration-pop {
  0% {
    transform: scale(0.9) translateY(12px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes badge-bounce {
  0% {
    transform: translateY(0) scale(1);
  }
  100% {
    transform: translateY(-6px) scale(1.06);
  }
}

@media (max-width: 720px) {
  .game-shell {
    padding: 18px 14px 12px;
  }

  .game-board {
    grid-template-columns: 1fr;
  }

  .target-area {
    min-height: 180px;
  }
}
