body {
  text-align: center;
  font-family: Arial, sans-serif;
  margin: 24px;
  background: #ffffff;
  color: #000000;
}

.sticky-area {
  position: sticky;
  top: 0;
  z-index: 1000;
  max-width: 980px;
  margin: 0 auto 16px;
  background: #ffffff;
  padding-bottom: 8px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 980px;
  margin: 0 auto 10px;
  padding: 12px 14px;
  gap: 12px;
  border: 1px solid #d1d5db;
  border-radius: 14px;
  box-sizing: border-box;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.left {
  text-align: left;
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: bold;
}

.right {
  text-align: right;
  flex: 1;
  min-width: 0;
  font-size: 24px;
  font-weight: bold;
}

.top-center {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-shrink: 0;
}

.top-btn,
.action-btn {
  min-width: 84px;
  height: 40px;
  padding: 0 14px;
  border: none;
  border-radius: 10px;
  background: #e5e7eb;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: 0.15s;
}

.top-btn:hover,
.action-btn:hover {
  background: #d1d5db;
}

.nav-btn {
  min-width: 96px;
}

.need-box,
.section-box {
  width: 100%;
  max-width: 980px;
  margin: 0 auto 16px;
  padding: 16px 18px;
  border: 1px solid #d1d5db;
  border-radius: 16px;
  box-sizing: border-box;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.need-box {
  margin-bottom: 10px;
}

.section-title {
  font-size: 18px;
  font-weight: bold;
  text-align: left;
}

.need-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.need-left {
  font-size: 18px;
  font-weight: bold;
}

.need-right {
  flex-shrink: 0;
}

#needSelect {
  min-width: 180px;
  height: 40px;
  padding: 0 10px;
  font-size: 15px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  color: inherit;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.collapsible-header {
  cursor: pointer;
  user-select: none;
}

.collapse-icon {
  width: 18px;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  color: #6b7280;
}

#groupsContent.collapsed {
  display: none;
}

.groups-container {
  width: 100%;
  margin: 0 auto;
}

.group-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid #d1d5db;
}

.group-row:first-child {
  border-top: 1px solid #d1d5db;
}

.group-title {
  width: 96px;
  min-width: 96px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  padding-top: 20px;
  font-size: 16px;
}

.group-name {
  font-weight: bold;
}

.group-score {
  margin-top: 4px;
  font-size: 12px;
  color: #9ca3af;
}

.group-items {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  flex: 1;
}

.item {
  text-align: center;
}

.item-card {
  border: 1px solid #d1d5db;
  border-radius: 14px;
  padding: 10px;
  background: #ffffff;
  transition: 0.12s;
}

.item-card.selected {
  border-color: #ef4444;
  box-shadow: inset 0 0 0 1px #ef4444;
}

.empty-card {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.image-box {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.image-box img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: pointer;
  border-radius: 10px;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}

.image-box::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-sizing: border-box;
  border: 2px solid #d1d5db;
  border-radius: 10px;
}

.image-box.selected::after {
  border-color: #ef4444;
}

.label {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.3;
  word-break: keep-all;
  min-height: 36px;
  transition: 0.1s;
}

.selected-item .label {
  font-weight: bold;
  color: #dc2626;
}

.empty {
  width: 80px;
  height: 80px;
  margin: 0 auto;
}

.action-row {
  display: flex;
  justify-content: center;
  margin: 16px auto 0;
}

.reset-button {
  min-width: 120px;
}

.credit {
  position: fixed;
  right: 14px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1;
  color: #9ca3af;
  opacity: 0.85;
  pointer-events: none;
  z-index: 9999;
}

.credit-logo {
  width: 12px;
  height: 12px;
  object-fit: contain;
}

@media (hover: hover) and (pointer: fine) {
  .image-box:hover::after {
    border-color: #ff9999;
  }

  .dark body .image-box:hover::after {
    border-color: #f87171;
  }
}

.image-box:active::after {
  border-color: #ff9999;
}

.dark body .image-box:active::after {
  border-color: #f87171;
}

.dark body {
  background: #111827;
  color: #f9fafb;
}

.dark body .sticky-area {
  background: #111827;
}

.dark body .top-bar,
.dark body .need-box,
.dark body .section-box {
  background: #1f2937;
  border-color: #374151;
}

.dark body .group-row {
  border-bottom-color: #374151;
}

.dark body .group-row:first-child {
  border-top-color: #374151;
}

.dark body .group-score,
.dark body .collapse-icon,
.dark body .credit {
  color: #9ca3af;
}

.dark body .top-btn,
.dark body .action-btn {
  background: #374151;
  color: #f9fafb;
}

.dark body .top-btn:hover,
.dark body .action-btn:hover {
  background: #4b5563;
}

.dark body #needSelect {
  background: #111827;
  color: #f9fafb;
  border-color: #374151;
}

.dark body .item-card {
  background: #1f2937;
  border-color: #374151;
}

.dark body .item-card.selected {
  border-color: #ef4444;
}

.dark body .image-box {
  background: #111827;
}

.dark body .image-box::after {
  border-color: #374151;
}

.dark body .image-box.selected::after {
  border-color: #ef4444;
}

@media (max-width: 768px) {
  body {
    margin: 12px;
    padding-bottom: 36px;
  }

  .sticky-area {
    margin-bottom: 12px;
  }

  .top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .left,
  .right {
    text-align: center;
  }

  .top-center {
    flex-wrap: wrap;
  }
  .top-btn {
    width: 96px;     /* 다시 강제 고정 */
    flex: 0 0 auto;  /* 늘어나지 않게 */
  }

  .right {
    font-size: 20px;
  }

  .group-row {
    flex-direction: column;
    gap: 10px;
  }

  .group-title {
    width: 100%;
    min-width: 0;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    padding-top: 0;
  }

  .group-items {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .need-inner {
    flex-direction: column;
    gap: 10px;
  }

  .need-right,
  #needSelect {
    width: 100%;
    min-width: 0;
  }

  .group-items {
    grid-template-columns: repeat(2, 1fr);
  }

  .image-box,
  .empty {
    width: 72px;
    height: 72px;
  }

  .label {
    min-height: 32px;
    font-size: 12px;
  }
}