:root {
  --bg: #f0f1fc;
  --card: #ffffff;
  --line: #dcdff5;
  --indigo: #4c51bf;
  --indigo-dark: #353a96;
  --indigo-soft: #ebf0ff;
  --text: #1a202c;
  --muted: #5a6778;
  --good: #2f855a;
  --bad: #c53030;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}
body { display: flex; flex-direction: column; height: 100dvh; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

#topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
#topbar::-webkit-scrollbar { display: none; }
#brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; white-space: nowrap; }
#tabs { display: flex; gap: 6px; }
.tab { padding: 9px 14px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-weight: 800; font-size: 15px; white-space: nowrap; }
.tab.active { border-color: var(--indigo); background: var(--indigo-soft); color: var(--indigo-dark); }

#main { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px 30px; }
.page { max-width: 960px; margin: 0 auto; }
.page h1 { margin: 6px 0 2px; font-size: 26px; }
.lead { margin: 0 0 12px; color: var(--muted); font-size: 16px; }

.progress { display: flex; align-items: center; gap: 6px; justify-content: center; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #d4d8f0; }
.dot.done { background: var(--indigo); }
.dot.now { background: #fff; box-shadow: 0 0 0 3px var(--indigo); }
.progress .score { margin-left: 10px; font-weight: 800; color: #b7791f; }

/* sort */
.tray {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  min-height: 112px;
  padding: 12px;
  margin-bottom: 14px;
  border-radius: 18px;
  background: #fff;
  border: 2px dashed var(--line);
}
.obj {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 108px;
  min-height: 92px;
  padding: 6px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fff;
  transition: transform .1s;
}
.obj .e { font-size: 40px; line-height: 1.1; }
.obj .n { font-size: 13px; font-weight: 700; text-align: center; line-height: 1.2; }
.obj.sel { border-color: var(--indigo); background: var(--indigo-soft); transform: translateY(-4px) scale(1.04); box-shadow: 0 6px 14px rgba(76, 81, 191, .25); }
.obj.right { border-color: var(--good); background: #e6ffed; }
.obj.wrong { border-color: var(--bad); background: #fff0f0; }
.bins { display: grid; gap: 12px; }
.bins-2 { grid-template-columns: 1fr 1fr; }
.bins-3 { grid-template-columns: 1fr 1fr 1fr; }
.bin {
  min-height: 190px;
  padding: 10px;
  border-radius: 18px;
  background: #fff;
  border: 3px solid var(--line);
  transition: border-color .15s, background .15s;
}
.bin.ready { border-color: #a3bffa; background: #f7f9ff; cursor: pointer; }
.bin-label { font-weight: 800; font-size: 18px; text-align: center; margin-bottom: 8px; }
.bin-items { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.bin .obj { width: 96px; min-height: 80px; }
.bin .obj .e { font-size: 32px; }
.empty { color: var(--muted); font-size: 14px; font-weight: 600; align-self: center; }

.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.go, .ghost {
  height: 54px;
  padding: 0 22px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
}
.go { border: 0; background: var(--indigo); color: #fff; box-shadow: 0 3px 0 var(--indigo-dark); }
.go:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--indigo-dark); }
.go:disabled { background: #b4b8e3; box-shadow: none; cursor: default; }
.ghost { border: 2px solid var(--line); background: #fff; }

.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #fff;
  border: 3px solid var(--indigo);
  animation: pop .2s ease-out;
}
.feedback.soft { border-color: #ed8936; }
.feedback h3 { margin: 0 0 8px; font-size: 19px; }
.feedback ul { list-style: none; padding: 0; margin: 0 0 12px; }
.feedback li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); line-height: 1.4; }
.feedback li .e { font-size: 26px; }
.feedback .go { margin-top: 6px; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* made of */
.big-obj { display: flex; flex-direction: column; align-items: center; margin: 10px 0 16px; }
.big-obj .e { font-size: 110px; line-height: 1.1; }
.big-obj .n { font-size: 26px; font-weight: 800; }
.mats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fff;
  font-weight: 800;
  font-size: 15px;
}
.mat .e { font-size: 30px; }
.mat.right { border-color: var(--good); background: #e6ffed; }
.mat.wrong { border-color: var(--bad); background: #fff0f0; }
.mat:disabled:not(.right):not(.wrong) { opacity: .5; }

/* design */
.job {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  margin: 10px 0 14px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
}
.job .e { font-size: 64px; }
.job small { display: block; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-size: 12px; }
.job b { font-size: 22px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.option {
  min-height: 58px;
  padding: 10px 14px;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-size: 17px;
  font-weight: 800;
}
.option.right { border-color: var(--good); background: #e6ffed; }
.option.wrong { border-color: var(--bad); background: #fff0f0; }
.option:disabled:not(.right):not(.wrong) { opacity: .5; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  padding: 10px 14px;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 15px;
  font-weight: 700;
}
.chip.on { border-color: var(--indigo); background: var(--indigo-soft); }
.chip.good, .k.good { border-color: var(--good); background: #e6ffed; }
.chip.missed, .k.missed { border-style: dashed; border-color: var(--good); background: #fff; }
.chip.bad, .k.bad { border-color: var(--bad); background: #fff0f0; }
.chip.fine, .k.fine { border-color: #3182ce; background: #ebf8ff; }
.why { font-size: 16px; font-weight: 600; line-height: 1.45; }
.key { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }
.k { padding: 2px 8px; border: 2px solid; border-radius: 999px; font-weight: 700; }

.end { text-align: center; padding-top: 30px; }
.end .big { font-size: 72px; }
.end p { font-size: 18px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(26, 32, 44, .9);
  color: #fff;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
#toast.show { opacity: 1; }

@media (max-width: 820px) {
  #brand span { display: none; }
  .bins-3 { grid-template-columns: 1fr; }
  .mats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .bins-2, .options { grid-template-columns: 1fr; }
  .tab { font-size: 13px; padding: 8px 10px; }
}
