:root {
  --page-bg: linear-gradient(135deg, #fff4d6 0%, #d6f4ff 100%);
  --panel-bg: rgba(255, 255, 255, 0.8);
  --primary: #ff7a7a;
  --primary-dark: #eb5d5d;
  --accent: #67c7ff;
  --text: #27364d;
  --muted: #5f6c7a;
  --shadow: 0 18px 40px rgba(39, 54, 77, 0.14);
  --success: #40c98c;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  font-family: 'Nunito', sans-serif;
  background: var(--page-bg);
  color: var(--text);
}

button {
  font: inherit;
}

.game-shell {
  width: min(1100px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

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

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  box-shadow: var(--shadow);
  font-size: 1.6rem;
}

.title-wrap {
  text-align: center;
  flex: 1;
}

h1, h2 {
  margin: 0;
  font-family: 'Fredoka', sans-serif;
}

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  color: var(--primary-dark);
  line-height: 1;
}

.round-pill {
  min-width: 60px;
  text-align: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  font-weight: 800;
  box-shadow: var(--shadow);
}

.screen {
  display: block;
}

.screen.hidden {
  display: none;
}

.panel {
  background: var(--panel-bg);
  border: 3px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.level-panel {
  padding: 28px;
}

.level-panel h2 {
  text-align: center;
  margin-bottom: 22px;
  font-size: clamp(2rem, 3vw, 2.6rem);
  color: var(--text);
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
}

.level-button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 180px;
  padding: 18px 16px 14px;
  border: 3px solid rgba(255,255,255,0.8);
  border-radius: 26px;
  color: white;
  cursor: pointer;
  box-shadow: 0 12px 18px rgba(39, 54, 77, 0.12);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  font-weight: 800;
}

.level-button:hover,
.level-button:focus-visible {
  transform: translateY(-6px) scale(1.02);
  border-color: rgba(255,255,255,0.95);
}

.level-easy {
  background: linear-gradient(135deg, #7adf9d 0%, #3fcf8e 100%);
}

.level-medium {
  background: linear-gradient(135deg, #ffca5c 0%, #ff9a5b 100%);
}

.level-hard {
  background: linear-gradient(135deg, #ff7cab 0%, #b377ff 100%);
}

.difficulty-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  border: 2px solid rgba(255,255,255,0.3);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.level-name {
  font-size: 1.9rem;
  font-family: 'Fredoka', sans-serif;
  line-height: 1.1;
}

.level-desc {
  font-size: 1rem;
  opacity: 0.95;
}

.mini-progress {
  width: 82%;
  height: 12px;
  background: rgba(255,255,255,0.25);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}

.mini-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: rgba(255,255,255,0.8);
}

.level-easy .mini-progress span { width: 33%; }
.level-medium .mini-progress span { width: 66%; }
.level-hard .mini-progress span { width: 100%; }

.game-panel {
  display: flex;
  flex-direction: column;
  padding: 22px 18px 18px;
}

.hud-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 10px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #67c7ff 0%, #7fe0d1 100%);
  color: white;
  font-weight: 800;
}

.status-text {
  font-weight: 700;
  color: var(--muted);
  text-align: right;
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  border: none;
}

.object-area {
  margin-bottom: 18px;
}

.baskets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.basket {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  min-height: 180px;
  padding: 16px 12px 18px;
  border: 4px dashed rgba(116, 125, 147, 0.4);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.6);
  cursor: default;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.basket:hover,
.basket:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(39, 54, 77, 0.6);
}

.basket::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 18px;
  height: 95px;
  border-radius: 18px 18px 24px 24px;
  background: linear-gradient(180deg, var(--basket-color) 0%, color-mix(in srgb, var(--basket-color) 80%, #ffffff) 100%);
  box-shadow: inset 0 -8px 0 rgba(255,255,255,0.18);
}

.basket::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 96px;
  height: 18px;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.85), rgba(255,255,255,0.45));
}

.basket.correct {
  border-color: var(--success);
  box-shadow: 0 0 0 5px rgba(64, 201, 140, 0.2);
}

.basket.wrong {
  border-color: var(--danger);
  box-shadow: 0 0 0 5px rgba(255, 107, 107, 0.18);
}

.basket-label {
  position: relative;
  z-index: 1;
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.object-area {
  text-align: center;
}

.object-label {
  display: none;
}

.objects {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  min-height: 120px;
}

.object {
  width: 82px;
  height: 82px;
  border: none;
  border-radius: 22px;
  background: var(--object-color);
  color: white;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 18px rgba(0,0,0,0.12);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  user-select: none;
  touch-action: none;
}

.object:hover,
.object:focus-visible,
.object.selected {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 16px 24px rgba(0,0,0,0.18);
}

.object.dragging {
  cursor: grabbing;
  opacity: 0.98;
  box-shadow: 0 24px 30px rgba(0, 0, 0, 0.2);
}

.object.selected {
  outline: 4px solid rgba(255, 255, 255, 0.9);
  outline-offset: 2px;
}

.item-shape {
  display: inline-block;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(255,255,255,0.3);
  border: 3px solid rgba(255,255,255,0.7);
}

.item-shape.circle {
  border-radius: 50%;
}

.item-shape.triangle {
  width: 0;
  height: 0;
  border-left: 22px solid transparent;
  border-right: 22px solid transparent;
  border-bottom: 40px solid rgba(255,255,255,0.25);
  background: transparent;
  border-radius: 0;
}

.item-shape.star {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 92%, 50% 71%, 21% 92%, 32% 57%, 2% 35%, 39% 35%);
  background: rgba(255,255,255,0.25);
}

.celebration-panel {
  max-width: 600px;
  margin: 40px auto 0;
  padding: 32px 26px;
  text-align: center;
}

.celebration-badge {
  font-size: 4rem;
  margin-bottom: 12px;
}

.celebration-panel h2 {
  font-size: clamp(2.4rem, 3vw, 3rem);
  margin-bottom: 12px;
}

.celebration-panel p {
  display: none;
}

.celebration-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.action-button {
  border: none;
  width: 90px;
  height: 90px;
  border-radius: 28px;
  padding: 0;
  font-size: 2.2rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s ease;
}

.action-button:hover,
.action-button:focus-visible {
  transform: translateY(-2px);
}

.action-button.primary {
  background: linear-gradient(135deg, #ff7a7a, #ffab73);
  color: white;
}

.action-button.secondary {
  background: linear-gradient(135deg, #67c7ff, #7ce2d4);
  color: white;
}

@media (max-width: 700px) {
  .topbar {
    flex-wrap: wrap;
    justify-content: center;
  }

  .title-wrap {
    order: -1;
    width: 100%;
  }

  .baskets {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}
