:root {
  --bg: #f4f7fb;
  --ink: #152238;
  --line: #d4dfef;
  --panel: #ffffff;
  --accent: #0ea5e9;
  --ok: #0f9d58;
  --bad: #d93025;
  --miss: #ef6c00;
  --basket: #c97a2f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #dbeafe 0%, var(--bg) 52%);
  min-height: 100vh;
}

.app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
}

.topbar h1 {
  margin: 0;
  font-size: 32px;
}

.topbar-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mini-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
}

.top-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.mini-btn.active {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: #075985;
}

.subtitle {
  margin: 6px 0 12px;
  color: #334155;
}

.hud {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
}

.playfield-wrap {
  position: relative;
  margin-top: 14px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #f8fbff, #f1f5f9);
  overflow: hidden;
  padding-left: 56px;
}

.speed-panel {
  position: absolute;
  left: 8px;
  top: 8px;
  bottom: 8px;
  width: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-right: 1px dashed var(--line);
  padding: 10px 0;
}

.speed-title {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.3px;
}

.speed-bar {
  writing-mode: bt-lr;
  -webkit-appearance: slider-vertical;
  width: 26px;
  height: calc(100% - 48px);
  min-height: 300px;
  cursor: pointer;
}

.speed-track {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.speed-marks {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  padding: 2px 0;
}

.speed-marks span {
  width: 10px;
  height: 1px;
  background: #94a3b8;
  opacity: 0.9;
}

.speed-value {
  font-size: 11px;
  color: #334155;
  text-align: center;
  line-height: 1.2;
}

.playfield {
  position: relative;
  height: 430px;
  border-bottom: 2px dashed var(--line);
  background:
    linear-gradient(180deg, rgba(191, 219, 254, 0.75) 0%, rgba(240, 249, 255, 0.95) 18%, rgba(248, 251, 255, 1) 42%);
  overflow: hidden;
}

.playfield::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 14%, rgba(255, 255, 255, 0.95) 0 14px, rgba(255, 255, 255, 0) 16px),
    radial-gradient(circle at 26% 10%, rgba(255, 255, 255, 0.9) 0 20px, rgba(255, 255, 255, 0) 22px),
    radial-gradient(circle at 74% 12%, rgba(255, 255, 255, 0.92) 0 18px, rgba(255, 255, 255, 0) 20px),
    radial-gradient(circle at 82% 8%, rgba(255, 255, 255, 0.88) 0 14px, rgba(255, 255, 255, 0) 16px);
  opacity: 0.55;
}

.faller {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  touch-action: none;
  cursor: grab;
}

.faller.dragging {
  cursor: grabbing;
  transform: scale(1.06);
}

.baskets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.basket {
  border: 3px solid var(--basket);
  border-top-width: 8px;
  border-radius: 0 0 12px 12px;
  height: 150px;
  background: #fff7ee;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.basket[data-color="purple"] {
  border-color: #7c3aed;
  background: linear-gradient(180deg, #f3e8ff, #ede9fe);
}

.basket[data-color="orange"] {
  border-color: #ea580c;
  background: linear-gradient(180deg, #ffedd5, #fed7aa);
}

.basket[data-color="green"] {
  border-color: #16a34a;
  background: linear-gradient(180deg, #dcfce7, #bbf7d0);
}

.basket.active {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(201, 122, 47, 0.24);
  animation: basketPulse 0.45s ease-in-out infinite alternate;
}

.basket.locked {
  animation: basketPulse 0.5s ease-in-out infinite alternate;
}

@keyframes basketPulse {
  from {
    box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.25);
  }
  to {
    box-shadow: 0 0 0 6px rgba(14, 165, 233, 0.05), 0 12px 26px rgba(14, 165, 233, 0.25);
  }
}

.basket-grid {
  position: absolute;
  inset: 8px;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.65) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.65) 1px, transparent 1px);
  background-size: 20px 20px;
}

.basket[data-color="purple"] .basket-label {
  color: #6d28d9;
}

.basket[data-color="orange"] .basket-label {
  color: #c2410c;
}

.basket[data-color="green"] .basket-label {
  color: #15803d;
}

.basket-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 700;
  z-index: 2;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.controls {
  margin-top: 44px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: #ffffff;
}

.btn.ghost {
  background: #e2e8f0;
  color: #0f172a;
}

.log {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.log-title {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 4px;
}

.feedback-ok {
  color: var(--ok);
  font-weight: 700;
}

.feedback-bad {
  color: var(--bad);
  font-weight: 700;
}

.feedback-miss {
  color: var(--miss);
  font-weight: 700;
}

@media (max-width: 760px) {
  .topbar-head {
    flex-direction: column;
  }

  .topbar-tools {
    justify-content: flex-start;
  }

  .playfield-wrap {
    padding-left: 44px;
  }

  .speed-panel {
    width: 34px;
    left: 6px;
  }

  .speed-bar {
    min-height: 240px;
  }

  .playfield {
    height: 380px;
  }

  .faller {
    width: 42px;
    height: 42px;
  }

  .basket {
    height: 126px;
  }
}
